From 2490640b2764ee570eef83528a8fd888f3b6103c Mon Sep 17 00:00:00 2001 From: Sergiy Kibrik Date: Wed, 21 Mar 2018 22:10:49 +0200 Subject: [PATCH] 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 Signed-off-by: Sebastian Reichel --- drivers/power/supply/s3c_adc_battery.c | 8 +++++--- 1 file 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;