summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorSergiy Kibrik <sakib@darkstar.site>2018-03-21 23:10:49 +0300
committerSebastian Reichel <sebastian.reichel@collabora.co.uk>2018-04-26 01:12:11 +0300
commit2490640b2764ee570eef83528a8fd888f3b6103c (patch)
treecc6b4306df79cfe13049e96641810003405ebaf9 /drivers/power
parent111242d6e1aa0cbdf1dd91fff6f210ae0d4d01bc (diff)
downloadlinux-2490640b2764ee570eef83528a8fd888f3b6103c.tar.xz
power: supply: s3c-adc-battery: fix driver data initialization
For power_supply_get_drvdata() routine to work correctly the driver data has to be provided when registering power supply, otherwise driver gives up immediately with these errors: power_supply main-battery: no battery infos ?! power_supply main-battery: driver failed to report `status' property: -22 Signed-off-by: Sergiy Kibrik <sakib@darkstar.site> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/s3c_adc_battery.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/power/supply/s3c_adc_battery.c b/drivers/power/supply/s3c_adc_battery.c
index 0ffe5cd3abf6..3d00b35cafc9 100644
--- a/drivers/power/supply/s3c_adc_battery.c
+++ b/drivers/power/supply/s3c_adc_battery.c
@@ -293,6 +293,7 @@ static int s3c_adc_bat_probe(struct platform_device *pdev)
{
struct s3c_adc_client *client;
struct s3c_adc_bat_pdata *pdata = pdev->dev.platform_data;
+ struct power_supply_config psy_cfg = {};
int ret;
client = s3c_adc_register(pdev, NULL, NULL, 0);
@@ -309,14 +310,15 @@ static int s3c_adc_bat_probe(struct platform_device *pdev)
main_bat.cur_value = -1;
main_bat.cable_plugged = 0;
main_bat.status = POWER_SUPPLY_STATUS_DISCHARGING;
+ psy_cfg.drv_data = &main_bat;
- main_bat.psy = power_supply_register(&pdev->dev, &main_bat_desc, NULL);
+ main_bat.psy = power_supply_register(&pdev->dev, &main_bat_desc, &psy_cfg);
if (IS_ERR(main_bat.psy)) {
ret = PTR_ERR(main_bat.psy);
goto err_reg_main;
}
if (pdata->backup_volt_mult) {
- const struct power_supply_config psy_cfg
+ const struct power_supply_config backup_psy_cfg
= { .drv_data = &backup_bat, };
backup_bat.client = client;
@@ -324,7 +326,7 @@ static int s3c_adc_bat_probe(struct platform_device *pdev)
backup_bat.volt_value = -1;
backup_bat.psy = power_supply_register(&pdev->dev,
&backup_bat_desc,
- &psy_cfg);
+ &backup_psy_cfg);
if (IS_ERR(backup_bat.psy)) {
ret = PTR_ERR(backup_bat.psy);
goto err_reg_backup;