summaryrefslogtreecommitdiffstats
path: root/drivers/power/jz4740-battery.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power/jz4740-battery.c')
-rw-r--r--drivers/power/jz4740-battery.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/drivers/power/jz4740-battery.c b/drivers/power/jz4740-battery.c
index 0444434e1927..abdfc21ec13f 100644
--- a/drivers/power/jz4740-battery.c
+++ b/drivers/power/jz4740-battery.c
@@ -46,7 +46,8 @@ struct jz_battery {
struct completion read_completion;
- struct power_supply battery;
+ struct power_supply *battery;
+ struct power_supply_desc battery_desc;
struct delayed_work work;
struct mutex lock;
@@ -54,7 +55,7 @@ struct jz_battery {
static inline struct jz_battery *psy_to_jz_battery(struct power_supply *psy)
{
- return container_of(psy, struct jz_battery, battery);
+ return power_supply_get_drvdata(psy);
}
static irqreturn_t jz_battery_irq_handler(int irq, void *devid)
@@ -213,7 +214,7 @@ static void jz_battery_update(struct jz_battery *jz_battery)
}
if (has_changed)
- power_supply_changed(&jz_battery->battery);
+ power_supply_changed(jz_battery->battery);
}
static enum power_supply_property jz_battery_properties[] = {
@@ -242,8 +243,9 @@ static int jz_battery_probe(struct platform_device *pdev)
{
int ret = 0;
struct jz_battery_platform_data *pdata = pdev->dev.parent->platform_data;
+ struct power_supply_config psy_cfg = {};
struct jz_battery *jz_battery;
- struct power_supply *battery;
+ struct power_supply_desc *battery_desc;
struct resource *mem;
if (!pdata) {
@@ -271,14 +273,17 @@ static int jz_battery_probe(struct platform_device *pdev)
if (IS_ERR(jz_battery->base))
return PTR_ERR(jz_battery->base);
- battery = &jz_battery->battery;
- battery->name = pdata->info.name;
- battery->type = POWER_SUPPLY_TYPE_BATTERY;
- battery->properties = jz_battery_properties;
- battery->num_properties = ARRAY_SIZE(jz_battery_properties);
- battery->get_property = jz_battery_get_property;
- battery->external_power_changed = jz_battery_external_power_changed;
- battery->use_for_apm = 1;
+ battery_desc = &jz_battery->battery_desc;
+ battery_desc->name = pdata->info.name;
+ battery_desc->type = POWER_SUPPLY_TYPE_BATTERY;
+ battery_desc->properties = jz_battery_properties;
+ battery_desc->num_properties = ARRAY_SIZE(jz_battery_properties);
+ battery_desc->get_property = jz_battery_get_property;
+ battery_desc->external_power_changed =
+ jz_battery_external_power_changed;
+ battery_desc->use_for_apm = 1;
+
+ psy_cfg.drv_data = jz_battery;
jz_battery->pdata = pdata;
jz_battery->pdev = pdev;
@@ -330,9 +335,11 @@ static int jz_battery_probe(struct platform_device *pdev)
else
jz4740_adc_set_config(pdev->dev.parent, JZ_ADC_CONFIG_BAT_MB, 0);
- ret = power_supply_register(&pdev->dev, &jz_battery->battery, NULL);
- if (ret) {
+ jz_battery->battery = power_supply_register(&pdev->dev, battery_desc,
+ &psy_cfg);
+ if (IS_ERR(jz_battery->battery)) {
dev_err(&pdev->dev, "power supply battery register failed.\n");
+ ret = PTR_ERR(jz_battery->battery);
goto err_free_charge_irq;
}
@@ -364,7 +371,7 @@ static int jz_battery_remove(struct platform_device *pdev)
gpio_free(jz_battery->pdata->gpio_charge);
}
- power_supply_unregister(&jz_battery->battery);
+ power_supply_unregister(jz_battery->battery);
free_irq(jz_battery->irq, jz_battery);