Commit 6480af49 authored by Robert Jarzmik's avatar Robert Jarzmik Committed by Sebastian Reichel

power_supply: wm97xx_battery: use power_supply_get_drvdata

As the power supply framework provides a way to store and retrieve
private supply data, use it.

In the process, change the platform data for wm97xx_battery from a
container of a single struct wm97xx_batt_pdata to the direct point to wm97xx_batt_pdata.
Signed-off-by: default avatarRobert Jarzmik <robert.jarzmik@free.fr>
Acked-by: default avatarCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 8d4124cb
...@@ -682,7 +682,7 @@ static int wm97xx_probe(struct device *dev) ...@@ -682,7 +682,7 @@ static int wm97xx_probe(struct device *dev)
} }
platform_set_drvdata(wm->battery_dev, wm); platform_set_drvdata(wm->battery_dev, wm);
wm->battery_dev->dev.parent = dev; wm->battery_dev->dev.parent = dev;
wm->battery_dev->dev.platform_data = pdata; wm->battery_dev->dev.platform_data = pdata->batt_pdata;
ret = platform_device_add(wm->battery_dev); ret = platform_device_add(wm->battery_dev);
if (ret < 0) if (ret < 0)
goto batt_reg_err; goto batt_reg_err;
......
...@@ -30,8 +30,7 @@ static enum power_supply_property *prop; ...@@ -30,8 +30,7 @@ static enum power_supply_property *prop;
static unsigned long wm97xx_read_bat(struct power_supply *bat_ps) static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
{ {
struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data; struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps);
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
return wm97xx_read_aux_adc(dev_get_drvdata(bat_ps->dev.parent), return wm97xx_read_aux_adc(dev_get_drvdata(bat_ps->dev.parent),
pdata->batt_aux) * pdata->batt_mult / pdata->batt_aux) * pdata->batt_mult /
...@@ -40,8 +39,7 @@ static unsigned long wm97xx_read_bat(struct power_supply *bat_ps) ...@@ -40,8 +39,7 @@ static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
static unsigned long wm97xx_read_temp(struct power_supply *bat_ps) static unsigned long wm97xx_read_temp(struct power_supply *bat_ps)
{ {
struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data; struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps);
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
return wm97xx_read_aux_adc(dev_get_drvdata(bat_ps->dev.parent), return wm97xx_read_aux_adc(dev_get_drvdata(bat_ps->dev.parent),
pdata->temp_aux) * pdata->temp_mult / pdata->temp_aux) * pdata->temp_mult /
...@@ -52,8 +50,7 @@ static int wm97xx_bat_get_property(struct power_supply *bat_ps, ...@@ -52,8 +50,7 @@ static int wm97xx_bat_get_property(struct power_supply *bat_ps,
enum power_supply_property psp, enum power_supply_property psp,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data; struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps);
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_STATUS: case POWER_SUPPLY_PROP_STATUS:
...@@ -103,8 +100,7 @@ static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps) ...@@ -103,8 +100,7 @@ static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps)
static void wm97xx_bat_update(struct power_supply *bat_ps) static void wm97xx_bat_update(struct power_supply *bat_ps)
{ {
int old_status = bat_status; int old_status = bat_status;
struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data; struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps);
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
mutex_lock(&work_lock); mutex_lock(&work_lock);
...@@ -166,15 +162,15 @@ static int wm97xx_bat_probe(struct platform_device *dev) ...@@ -166,15 +162,15 @@ static int wm97xx_bat_probe(struct platform_device *dev)
int ret = 0; int ret = 0;
int props = 1; /* POWER_SUPPLY_PROP_PRESENT */ int props = 1; /* POWER_SUPPLY_PROP_PRESENT */
int i = 0; int i = 0;
struct wm97xx_pdata *wmdata = dev->dev.platform_data; struct wm97xx_batt_pdata *pdata = dev->dev.platform_data;
struct wm97xx_batt_pdata *pdata; struct power_supply_config cfg = {};
if (!wmdata) { if (!pdata) {
dev_err(&dev->dev, "No platform data supplied\n"); dev_err(&dev->dev, "No platform data supplied\n");
return -EINVAL; return -EINVAL;
} }
pdata = wmdata->batt_pdata; cfg.drv_data = pdata;
if (dev->id != -1) if (dev->id != -1)
return -EINVAL; return -EINVAL;
...@@ -243,7 +239,7 @@ static int wm97xx_bat_probe(struct platform_device *dev) ...@@ -243,7 +239,7 @@ static int wm97xx_bat_probe(struct platform_device *dev)
bat_psy_desc.properties = prop; bat_psy_desc.properties = prop;
bat_psy_desc.num_properties = props; bat_psy_desc.num_properties = props;
bat_psy = power_supply_register(&dev->dev, &bat_psy_desc, NULL); bat_psy = power_supply_register(&dev->dev, &bat_psy_desc, &cfg);
if (!IS_ERR(bat_psy)) { if (!IS_ERR(bat_psy)) {
schedule_work(&bat_work); schedule_work(&bat_work);
} else { } else {
...@@ -266,8 +262,7 @@ static int wm97xx_bat_probe(struct platform_device *dev) ...@@ -266,8 +262,7 @@ static int wm97xx_bat_probe(struct platform_device *dev)
static int wm97xx_bat_remove(struct platform_device *dev) static int wm97xx_bat_remove(struct platform_device *dev)
{ {
struct wm97xx_pdata *wmdata = dev->dev.platform_data; struct wm97xx_batt_pdata *pdata = dev->dev.platform_data;
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
if (pdata && gpio_is_valid(pdata->charge_gpio)) { if (pdata && gpio_is_valid(pdata->charge_gpio)) {
free_irq(gpio_to_irq(pdata->charge_gpio), dev); free_irq(gpio_to_irq(pdata->charge_gpio), dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment