power: battery-charger: pass driver data part of charger/gauge registration
Laxman Dewangan [Tue, 2 Jul 2013 06:58:29 +0000 (11:58 +0530)]
Pass the driver specific data as part of battery charger and battery gauge
driver registration.

This will simplify the registration and avoid the call of set_drvdata()
explicitly.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/244172
(cherry picked from commit f43d8265b5da40b3b3392c6a883e29061251b492)

Change-Id: Ie3936a2c05d411bc8a302d5dd999390d16eb9fdf
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/253366
Reviewed-by: Automatic_Commit_Validation_User

drivers/power/battery-charger-gauge-comm.c
drivers/power/bq2419x-charger.c
drivers/power/max17042_battery.c
drivers/power/max17048_battery.c
drivers/power/max77660-charger-extcon.c
drivers/power/max77665-charger.c
drivers/power/palmas-charger.c
drivers/power/palmas_battery.c
drivers/power/sbs-battery.c
drivers/power/tps65090-charger.c
include/linux/power/battery-charger-gauge-comm.h

index 17ec815..bb0d8f7 100644 (file)
@@ -227,7 +227,7 @@ int battery_charger_thermal_stop_monitoring(
 EXPORT_SYMBOL_GPL(battery_charger_thermal_stop_monitoring);
 
 struct battery_charger_dev *battery_charger_register(struct device *dev,
-       struct battery_charger_info *bci)
+       struct battery_charger_info *bci, void *drv_data)
 {
        struct battery_charger_dev *bc_dev;
 
@@ -250,6 +250,7 @@ struct battery_charger_dev *battery_charger_register(struct device *dev,
        bc_dev->cell_id = bci->cell_id;
        bc_dev->ops = bci->bc_ops;
        bc_dev->parent_dev = dev;
+       bc_dev->drv_data = drv_data;
        list_add(&bc_dev->list, &charger_list);
 
        INIT_DELAYED_WORK(&bc_dev->restart_charging_wq,
@@ -311,7 +312,7 @@ int battery_gauge_get_battery_temperature(struct battery_gauge_dev *bg_dev,
 EXPORT_SYMBOL_GPL(battery_gauge_get_battery_temperature);
 
 struct battery_gauge_dev *battery_gauge_register(struct device *dev,
-       struct battery_gauge_info *bgi)
+       struct battery_gauge_info *bgi, void *drv_data)
 {
        struct battery_gauge_dev *bg_dev;
 
@@ -334,6 +335,7 @@ struct battery_gauge_dev *battery_gauge_register(struct device *dev,
        bg_dev->cell_id = bgi->cell_id;
        bg_dev->ops = bgi->bg_ops;
        bg_dev->parent_dev = dev;
+       bg_dev->drv_data = drv_data;
        strcpy(bg_dev->tz_name, bgi->tz_name ? : "");
        bg_dev->battery_tz = thermal_zone_device_find_by_name(bg_dev->tz_name);
        if (!bg_dev->battery_tz)
index 96b0759..3163ae9 100644 (file)
@@ -858,14 +858,13 @@ static int bq2419x_probe(struct i2c_client *client,
        }
 
        bq2419x->bc_dev = battery_charger_register(bq2419x->dev,
-                       &bq2419x_charger_bci);
+                       &bq2419x_charger_bci, bq2419x);
        if (IS_ERR(bq2419x->bc_dev)) {
                ret = PTR_ERR(bq2419x->bc_dev);
                dev_err(bq2419x->dev, "battery charger register failed: %d\n",
                        ret);
                goto scrub_chg_reg;
        }
-       battery_charger_set_drvdata(bq2419x->bc_dev, bq2419x);
 
        ret = bq2419x_init_vbus_regulator(bq2419x, pdata);
        if (ret < 0) {
index 3ce85d9..1acc1fc 100644 (file)
@@ -857,14 +857,14 @@ static int max17042_probe(struct i2c_client *client,
                return ret;
        }
 
-       chip->bg_dev = battery_gauge_register(&client->dev, &max17042_bgi);
+       chip->bg_dev = battery_gauge_register(&client->dev, &max17042_bgi,
+                                       chip);
        if (IS_ERR(chip->bg_dev)) {
                ret = PTR_ERR(chip->bg_dev);
                dev_err(&client->dev, "battery gauge register failed: %d\n",
                        ret);
                goto bg_err;
        }
-       battery_gauge_set_drvdata(chip->bg_dev, chip);
 
        INIT_DEFERRABLE_WORK(&chip->work, max17042_init_worker);
        schedule_delayed_work(&chip->work, 0);
index 111c4de..8b80683 100644 (file)
@@ -676,14 +676,14 @@ static int max17048_probe(struct i2c_client *client,
                goto error;
        }
 
-       chip->bg_dev = battery_gauge_register(&client->dev, &max17048_bgi);
+       chip->bg_dev = battery_gauge_register(&client->dev, &max17048_bgi,
+                               chip);
        if (IS_ERR(chip->bg_dev)) {
                ret = PTR_ERR(chip->bg_dev);
                dev_err(&client->dev, "battery gauge register failed: %d\n",
                        ret);
                goto bg_err;
        }
-       battery_gauge_set_drvdata(chip->bg_dev, chip);
 
        INIT_DEFERRABLE_WORK(&chip->work, max17048_work);
        schedule_delayed_work(&chip->work, 0);
index 452e8bf..de9b9d6 100644 (file)
@@ -1012,14 +1012,13 @@ static int max77660_chg_extcon_probe(struct platform_device *pdev)
        }
 
        chg_extcon->bc_dev = battery_charger_register(&pdev->dev,
-                                               &max77660_charger_bci);
+                                       &max77660_charger_bci, chg_extcon);
        if (IS_ERR(chg_extcon->bc_dev)) {
                ret = PTR_ERR(chg_extcon->bc_dev);
                dev_err(&pdev->dev, "battery charger register failed: %d\n",
                        ret);
                goto chg_reg_err;
        }
-       battery_charger_set_drvdata(chg_extcon->bc_dev, chg_extcon);
 
        max77660_charger_thermal_info.polling_time_sec =
                        bcharger_pdata->temperature_poll_period_secs;
index ba72929..182f57b 100644 (file)
@@ -849,14 +849,13 @@ static int max77665_battery_probe(struct platform_device *pdev)
                                max77665_set_ideal_input_current_work);
 
        charger->bc_dev = battery_charger_register(&pdev->dev,
-                                       &max77665_charger_bci);
+                                       &max77665_charger_bci, charger);
        if (IS_ERR(charger->bc_dev)) {
                ret = PTR_ERR(charger->bc_dev);
                dev_err(&pdev->dev, "battery charger register failed: %d\n",
                        ret);
                goto free_lock;
        }
-       battery_charger_set_drvdata(charger->bc_dev, charger);
 
        /* modify OTP setting of input current limit to 100ma */
        ret = max77665_set_max_input_current(charger, 100);
index f9be656..3ccc37d 100644 (file)
@@ -998,14 +998,13 @@ static int palmas_probe(struct platform_device *pdev)
        }
 
        palmas_chip->bc_dev = battery_charger_register(&pdev->dev,
-                                       &palmas_charger_bci);
+                                       &palmas_charger_bci, palmas_chip);
        if (IS_ERR(palmas_chip->bc_dev)) {
                ret = PTR_ERR(palmas_chip->bc_dev);
                dev_err(&pdev->dev, "battery charger register failed: %d\n",
                        ret);
                goto scrub_bcharger_init;
        }
-       battery_charger_set_drvdata(palmas_chip->bc_dev, palmas_chip);
 
        palams_charger_thermal_info.polling_time_sec =
                        pdata->bcharger_pdata->temperature_poll_period_secs;
index 1abe411..4faea9e 100644 (file)
@@ -1615,13 +1615,13 @@ static int palmas_battery_probe(struct platform_device *pdev)
        }
 
        palmas_battery_gauge_info.tz_name = pdata->therm_zone_name;
-       di->bg_dev = battery_gauge_register(di->dev, &palmas_battery_gauge_info);
+       di->bg_dev = battery_gauge_register(di->dev, &palmas_battery_gauge_info,
+                                       di);
        if (IS_ERR(di->bg_dev)) {
                ret = PTR_ERR(di->bg_dev);
                dev_err(di->dev, "battery gauge register failed: %d\n", ret);
                goto bg_err;
        }
-       battery_gauge_set_drvdata(di->bg_dev, di);
        return 0;
 
 bg_err:
index 2f1c4a9..45a0170 100644 (file)
@@ -826,14 +826,13 @@ skip_gpio:
                goto exit_psupply;
        }
 
-       chip->bg_dev = battery_gauge_register(&client->dev, &sbs_bgi);
+       chip->bg_dev = battery_gauge_register(&client->dev, &sbs_bgi, chip);
        if (IS_ERR(chip->bg_dev)) {
                rc = PTR_ERR(chip->bg_dev);
                dev_err(&client->dev, "battery gauge register failed: %d\n",
                        rc);
                goto bg_err;
        }
-       battery_gauge_set_drvdata(chip->bg_dev, chip);
 
        dev_info(&client->dev,
                "%s: battery gas gauge device registered\n", client->name);
index ed04080..d280716 100644 (file)
@@ -248,14 +248,13 @@ static int tps65090_charger_probe(struct platform_device *pdev)
        }
 
        charger_data->bc_dev = battery_charger_register(&pdev->dev,
-                               &tps65090_charger_bci);
+                               &tps65090_charger_bci, charger_data);
        if (IS_ERR(charger_data->bc_dev)) {
                ret = PTR_ERR(charger_data->bc_dev);
                dev_err(&pdev->dev, "battery charger register failed: %d\n",
                        ret);
                goto chg_reg_err;
        }
-       battery_charger_set_drvdata(charger_data->bc_dev, charger_data);
 
        ret = tps65090_config_charger(charger_data);
        if (ret < 0) {
index 481b5ca..641314f 100644 (file)
@@ -69,7 +69,7 @@ struct battery_gauge_info {
 };
 
 struct battery_charger_dev *battery_charger_register(struct device *dev,
-               struct battery_charger_info *bci);
+               struct battery_charger_info *bci, void *drv_data);
 void battery_charger_unregister(struct battery_charger_dev *bc_dev);
 int battery_charging_status_update(struct battery_charger_dev *bc_dev,
                enum battery_charger_status status);
@@ -88,7 +88,7 @@ int battery_charger_thermal_stop_monitoring(
 int battery_gauge_get_battery_temperature(struct battery_gauge_dev *bg_dev,
        int *temp);
 struct battery_gauge_dev *battery_gauge_register(struct device *dev,
-               struct battery_gauge_info *bgi);
+               struct battery_gauge_info *bgi, void *drv_data);
 void battery_gauge_unregister(struct battery_gauge_dev *bg_dev);
 
 void *battery_charger_get_drvdata(struct battery_charger_dev *bc_dev);