ab8500_bm: Always send platform specific battery information via pdata
authorLee Jones <lee.jones@linaro.org>
Thu, 29 Nov 2012 15:08:41 +0000 (15:08 +0000)
committerLee Jones <lee.jones@linaro.org>
Tue, 11 Dec 2012 08:43:54 +0000 (08:43 +0000)
Currently the AB8500 battery management subsystem receives platform
specific information via two different means depending on how the
platform is booted. If DT is not enabled, a reference to a *_bm_data
data structure containing each platform specific attribute is passed
though platform_data. However, if DT is enabled, then platform_data
is empty and the reference is gained though a DT specific probe
function. There are two issues here 1) the same reference is
being collected each time and 2) the DT way doesn't allow any
provisions to select different platform specific attributes, which
kind of defeats the object.

Cc: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/ab8500-core.c
drivers/power/ab8500_bmdata.c
drivers/power/ab8500_btemp.c
drivers/power/ab8500_charger.c
drivers/power/ab8500_fg.c
drivers/power/abx500_chargalg.c
include/linux/mfd/abx500.h

index 5ec70f26b9d5631e6d720af53b8e467ebb845cb5..bbd49d7969029741a39523fde2d89df066d2d5aa 100644 (file)
@@ -1044,40 +1044,32 @@ static struct mfd_cell __devinitdata ab8500_bm_devs[] = {
                .of_compatible = "stericsson,ab8500-charger",
                .num_resources = ARRAY_SIZE(ab8500_charger_resources),
                .resources = ab8500_charger_resources,
-#ifndef CONFIG_OF
                .platform_data = &ab8500_bm_data,
                .pdata_size = sizeof(ab8500_bm_data),
-#endif
        },
        {
                .name = "ab8500-btemp",
                .of_compatible = "stericsson,ab8500-btemp",
                .num_resources = ARRAY_SIZE(ab8500_btemp_resources),
                .resources = ab8500_btemp_resources,
-#ifndef CONFIG_OF
                .platform_data = &ab8500_bm_data,
                .pdata_size = sizeof(ab8500_bm_data),
-#endif
        },
        {
                .name = "ab8500-fg",
                .of_compatible = "stericsson,ab8500-fg",
                .num_resources = ARRAY_SIZE(ab8500_fg_resources),
                .resources = ab8500_fg_resources,
-#ifndef CONFIG_OF
                .platform_data = &ab8500_bm_data,
                .pdata_size = sizeof(ab8500_bm_data),
-#endif
        },
        {
                .name = "ab8500-chargalg",
                .of_compatible = "stericsson,ab8500-chargalg",
                .num_resources = ARRAY_SIZE(ab8500_chargalg_resources),
                .resources = ab8500_chargalg_resources,
-#ifndef CONFIG_OF
                .platform_data = &ab8500_bm_data,
                .pdata_size = sizeof(ab8500_bm_data),
-#endif
        },
 };
 
index c2fb2c554019840f8c3b4281d59809a0a0ce8b59..6b772e5f515fc9918aaa90999d748fa22b08e858 100644 (file)
@@ -454,16 +454,13 @@ struct abx500_bm_data ab8500_bm_data = {
 
 int __devinit ab8500_bm_of_probe(struct device *dev,
                                 struct device_node *np,
-                                struct abx500_bm_data **battery)
+                                struct abx500_bm_data *bm)
 {
        struct batres_vs_temp *tmp_batres_tbl;
        struct device_node *np_bat_supply;
-       struct abx500_bm_data *bat;
        const char *btech;
        int i;
 
-       *battery = &ab8500_bm_data;
-
        /* get phandle to 'battery-info' node */
        np_bat_supply = of_parse_phandle(np, "battery", 0);
        if (!np_bat_supply) {
@@ -477,16 +474,14 @@ int __devinit ab8500_bm_of_probe(struct device *dev,
                return -EINVAL;
        }
 
-       bat = *battery;
-
        if (strncmp(btech, "LION", 4) == 0) {
-               bat->no_maintenance  = true;
-               bat->chg_unknown_bat = true;
-               bat->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600;
-               bat->bat_type[BATTERY_UNKNOWN].termination_vol    = 4150;
-               bat->bat_type[BATTERY_UNKNOWN].recharge_vol       = 4130;
-               bat->bat_type[BATTERY_UNKNOWN].normal_cur_lvl     = 520;
-               bat->bat_type[BATTERY_UNKNOWN].normal_vol_lvl     = 4200;
+               bm->no_maintenance  = true;
+               bm->chg_unknown_bat = true;
+               bm->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600;
+               bm->bat_type[BATTERY_UNKNOWN].termination_vol    = 4150;
+               bm->bat_type[BATTERY_UNKNOWN].recharge_vol       = 4130;
+               bm->bat_type[BATTERY_UNKNOWN].normal_cur_lvl     = 520;
+               bm->bat_type[BATTERY_UNKNOWN].normal_vol_lvl     = 4200;
        }
 
        if (of_property_read_bool(np_bat_supply, "thermistor-on-batctrl")) {
@@ -495,15 +490,15 @@ int __devinit ab8500_bm_of_probe(struct device *dev,
                else
                        tmp_batres_tbl = temp_to_batres_tbl_thermistor;
        } else {
-               bat->n_btypes   = 4;
-               bat->bat_type   = bat_type_ext_thermistor;
-               bat->adc_therm  = ABx500_ADC_THERM_BATTEMP;
-               tmp_batres_tbl  = temp_to_batres_tbl_ext_thermistor;
+               bm->n_btypes   = 4;
+               bm->bat_type   = bat_type_ext_thermistor;
+               bm->adc_therm  = ABx500_ADC_THERM_BATTEMP;
+               tmp_batres_tbl = temp_to_batres_tbl_ext_thermistor;
        }
 
        /* select the battery resolution table */
-       for (i = 0; i < bat->n_btypes; ++i)
-               bat->bat_type[i]->batres_tbl = tmp_batres_tbl;
+       for (i = 0; i < bm->n_btypes; ++i)
+               bm->bat_type[i].batres_tbl = tmp_batres_tbl;
 
        of_node_put(np_bat_supply);
 
index 33ed0fccbd0e0c7ab6620f6d681058441a06e4b3..c0f7dcceae45d7ddfe70e62d9d0c387e3096ec0d 100644 (file)
@@ -988,7 +988,7 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev)
        di->bm = pdev->mfd_cell->platform_data;
        if (!di->bm) {
                if (np) {
-                       ret = ab8500_bm_of_probe(&pdev->dev, np, &di->bm);
+                       ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm);
                        if (ret) {
                                dev_err(&pdev->dev,
                                        "failed to get battery information\n");
index 21dc8422778de407700668106b40bcdcd3dabb27..c1077df26783316a7eb0e308fe61cf21822b27db 100644 (file)
@@ -2647,7 +2647,7 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
        di->bm = pdev->mfd_cell->platform_data;
        if (!di->bm) {
                if (np) {
-                       ret = ab8500_bm_of_probe(&pdev->dev, np, &di->bm);
+                       ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm);
                        if (ret) {
                                dev_err(&pdev->dev,
                                        "failed to get battery information\n");
index 4cf231375de3e681a2ae51865231c340674cff5b..8bb9df92627dce1ed0dcee53f36f941dc63d191e 100644 (file)
@@ -2460,7 +2460,7 @@ static int __devinit ab8500_fg_probe(struct platform_device *pdev)
        di->bm = pdev->mfd_cell->platform_data;
        if (!di->bm) {
                if (np) {
-                       ret = ab8500_bm_of_probe(&pdev->dev, np, &di->bm);
+                       ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm);
                        if (ret) {
                                dev_err(&pdev->dev,
                                        "failed to get battery information\n");
index ea2e2eb652ef7c72e6ee36207f7faa1ef8838454..22a511c2a719e81aaf9cdd51c93a0e048b37a531 100644 (file)
@@ -1817,7 +1817,7 @@ static int __devinit abx500_chargalg_probe(struct platform_device *pdev)
        di->bm = pdev->mfd_cell->platform_data;
        if (!di->bm) {
                if (np) {
-                       ret = ab8500_bm_of_probe(&pdev->dev, np, &di->bm);
+                       ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm);
                        if (ret) {
                                dev_err(&pdev->dev,
                                        "failed to get battery information\n");
index 6ce749a0e9d4337fda476deefd4b4f194fdb1e99..4906b1842d2f8591b28d4e90bc09831c0ba63e25 100644 (file)
@@ -281,7 +281,7 @@ enum {
 
 int ab8500_bm_of_probe(struct device *dev,
                       struct device_node *np,
-                      struct abx500_bm_data **battery);
+                      struct abx500_bm_data *bm);
 
 int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg,
        u8 value);