power: tps80031: battery-gauge: register as mfd sub device
Laxman Dewangan [Wed, 1 Aug 2012 11:04:12 +0000 (16:04 +0530)]
Register battery gauge driver of TPS80031 as mfd
sub driver in place of adding it as a sub devices.
This is inline with the mfd driver policy.

Change-Id: I15765be19fc138695de2d813e5fa025400747c86
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/121134
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>

arch/arm/mach-tegra/board-enterprise-power.c
drivers/mfd/tps80031.c
drivers/power/tps80031_battery_gauge.c
include/linux/mfd/tps80031.h

index 4bf7f03..b908edb 100644 (file)
@@ -338,11 +338,6 @@ static struct tps80031_bg_platform_data battery_gauge_data = {
                .name   = "tps80031-charger",           \
                .platform_data = &bcharger_pdata,       \
        }
-#define TPS_BATTERY_GAUGE()                            \
-       {                                               \
-               .name   = "tps80031-battery-gauge",     \
-               .platform_data = &battery_gauge_data,   \
-       }
 #define TPS_GPADC()                                    \
        {                                               \
                .name   = "tps80031-gpadc",             \
@@ -350,13 +345,11 @@ static struct tps80031_bg_platform_data battery_gauge_data = {
 
 #define TPS80031_DEVS_COMMON           \
        TPS_BATTERY(),                  \
-       TPS_BATTERY_GAUGE(),            \
        TPS_GPADC()
 
 
 static struct tps80031_subdev_info tps80031_devs[] = {
        TPS_BATTERY(),
-       TPS_BATTERY_GAUGE(),
        TPS_GPADC()
 };
 
@@ -443,6 +436,7 @@ static struct tps80031_platform_data tps_platform = {
        .clk32k_init_data_size  = ARRAY_SIZE(clk32k_idata),
        .use_power_off  = true,
        .rtc_pdata = &rtc_data,
+       .bg_pdata = &battery_gauge_data,
 };
 
 static struct i2c_board_info __initdata enterprise_regulators[] = {
index a1b6237..f9f3f09 100644 (file)
@@ -305,6 +305,9 @@ static struct mfd_cell tps80031_cell[] = {
        {
                .name = "tps80031-rtc",
        },
+       {
+               .name = "tps80031-battery-gauge",
+       },
 };
 
 
index 9ccfaad..69bad9c 100644 (file)
@@ -453,7 +453,20 @@ static int tps80031_battery_probe(struct platform_device *pdev)
        uint8_t retval;
        struct device *dev = &pdev->dev;
        struct tps80031_device_info *di;
-       struct tps80031_bg_platform_data *pdata = pdev->dev.platform_data;
+       struct tps80031_platform_data *tps80031_pdata;
+       struct tps80031_bg_platform_data *pdata;
+
+       tps80031_pdata = dev_get_platdata(pdev->dev.parent);
+       if (!tps80031_pdata) {
+               dev_err(&pdev->dev, "no tps80031 platform_data specified\n");
+               return -EINVAL;
+       }
+
+       pdata = tps80031_pdata->bg_pdata;
+       if (!pdata) {
+               dev_err(&pdev->dev, "no battery_gauge platform data\n");
+               return -EINVAL;
+       }
 
        di = devm_kzalloc(&pdev->dev, sizeof *di, GFP_KERNEL);
        if (!di) {
index d0cef73..d3371a7 100644 (file)
@@ -184,6 +184,11 @@ struct tps80031_pupd_init_data {
        int setting;
 };
 
+struct tps80031_bg_platform_data {
+       int irq_base;
+       int battery_present;
+};
+
 struct tps80031_platform_data {
        int num_subdevs;
        struct tps80031_subdev_info *subdevs;
@@ -200,12 +205,9 @@ struct tps80031_platform_data {
        struct tps80031_regulator_platform_data **regulator_pdata;
        int num_regulator_pdata;
        struct tps80031_rtc_platform_data *rtc_pdata;
+       struct tps80031_bg_platform_data *bg_pdata;
 };
 
-struct tps80031_bg_platform_data {
-       int irq_base;
-       int battery_present;
-};
 
 /*
  * NOTE: the functions below are not intended for use outside