summaryrefslogtreecommitdiff
path: root/drivers/power/wm97xx_battery.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power/wm97xx_battery.c')
-rw-r--r--drivers/power/wm97xx_battery.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/wm97xx_battery.c
index a8e6203673ad..c2f09ed35050 100644
--- a/drivers/power/wm97xx_battery.c
+++ b/drivers/power/wm97xx_battery.c
@@ -32,20 +32,20 @@ static enum power_supply_property *prop;
static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
{
- struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+ struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data;
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_div;
}
static unsigned long wm97xx_read_temp(struct power_supply *bat_ps)
{
- struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+ struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data;
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_div;
}
@@ -54,7 +54,7 @@ static int wm97xx_bat_get_property(struct power_supply *bat_ps,
enum power_supply_property psp,
union power_supply_propval *val)
{
- struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+ struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data;
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
switch (psp) {
@@ -105,7 +105,7 @@ static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps)
static void wm97xx_bat_update(struct power_supply *bat_ps)
{
int old_status = bat_status;
- struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+ struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data;
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
mutex_lock(&work_lock);
@@ -117,7 +117,7 @@ static void wm97xx_bat_update(struct power_supply *bat_ps)
POWER_SUPPLY_STATUS_UNKNOWN;
if (old_status != bat_status) {
- pr_debug("%s: %i -> %i\n", bat_ps->name, old_status,
+ pr_debug("%s: %i -> %i\n", bat_ps->desc->name, old_status,
bat_status);
power_supply_changed(bat_ps);
}
@@ -125,7 +125,8 @@ static void wm97xx_bat_update(struct power_supply *bat_ps)
mutex_unlock(&work_lock);
}
-static struct power_supply bat_ps = {
+static struct power_supply *bat_psy;
+static struct power_supply_desc bat_psy_desc = {
.type = POWER_SUPPLY_TYPE_BATTERY,
.get_property = wm97xx_bat_get_property,
.external_power_changed = wm97xx_bat_external_power_changed,
@@ -134,7 +135,7 @@ static struct power_supply bat_ps = {
static void wm97xx_bat_work(struct work_struct *work)
{
- wm97xx_bat_update(&bat_ps);
+ wm97xx_bat_update(bat_psy);
}
static irqreturn_t wm97xx_chrg_irq(int irq, void *data)
@@ -237,18 +238,20 @@ static int wm97xx_bat_probe(struct platform_device *dev)
dev_info(&dev->dev, "Please consider setting proper battery "
"name in platform definition file, falling "
"back to name \"wm97xx-batt\"\n");
- bat_ps.name = "wm97xx-batt";
+ bat_psy_desc.name = "wm97xx-batt";
} else
- bat_ps.name = pdata->batt_name;
+ bat_psy_desc.name = pdata->batt_name;
- bat_ps.properties = prop;
- bat_ps.num_properties = props;
+ bat_psy_desc.properties = prop;
+ bat_psy_desc.num_properties = props;
- ret = power_supply_register(&dev->dev, &bat_ps);
- if (!ret)
+ bat_psy = power_supply_register(&dev->dev, &bat_psy_desc, NULL);
+ if (!IS_ERR(bat_psy)) {
schedule_work(&bat_work);
- else
+ } else {
+ ret = PTR_ERR(bat_psy);
goto err4;
+ }
return 0;
err4:
@@ -273,7 +276,7 @@ static int wm97xx_bat_remove(struct platform_device *dev)
gpio_free(pdata->charge_gpio);
}
cancel_work_sync(&bat_work);
- power_supply_unregister(&bat_ps);
+ power_supply_unregister(bat_psy);
kfree(prop);
return 0;
}