mfd: tps6591x: Natively register pm_power_off
Dan Willemsen [Thu, 1 Dec 2011 23:08:12 +0000 (15:08 -0800)]
Instead of forcing the board files to register this themselves, just add
a bool to the platform data to let the board files opt into this.

Change-Id: Ide3d6cbc49584c3ed993f30b1396c8ae56d87b3b
Signed-off-by: Dan Willemsen <dwillemsen@nvidia.com>
Reviewed-on: http://git-master/r/83594
Reviewed-by: Varun Wadekar <vwadekar@nvidia.com>

drivers/mfd/tps6591x.c
include/linux/mfd/tps6591x.h

index 8ce4424..b475e06 100644 (file)
@@ -283,25 +283,19 @@ out:
 EXPORT_SYMBOL_GPL(tps6591x_update);
 
 static struct i2c_client *tps6591x_i2c_client;
-int tps6591x_power_off(void)
+static void tps6591x_power_off(void)
 {
        struct device *dev = NULL;
-       int ret;
 
        if (!tps6591x_i2c_client)
-               return -EINVAL;
+               return;
 
        dev = &tps6591x_i2c_client->dev;
 
-       ret = tps6591x_set_bits(dev, TPS6591X_DEVCTRL, DEVCTRL_PWR_OFF_SEQ);
-       if (ret < 0)
-               return ret;
-
-       ret = tps6591x_clr_bits(dev, TPS6591X_DEVCTRL, DEVCTRL_DEV_ON);
-       if (ret < 0)
-               return ret;
+       if (tps6591x_set_bits(dev, TPS6591X_DEVCTRL, DEVCTRL_PWR_OFF_SEQ) < 0)
+               return;
 
-       return 0;
+       tps6591x_clr_bits(dev, TPS6591X_DEVCTRL, DEVCTRL_DEV_ON);
 }
 
 static int tps6591x_gpio_get(struct gpio_chip *gc, unsigned offset)
@@ -841,6 +835,9 @@ static int __devinit tps6591x_i2c_probe(struct i2c_client *client,
 
        tps6591x_sleepinit(tps6591x, pdata);
 
+       if (pdata->use_power_off && !pm_power_off)
+               pm_power_off = tps6591x_power_off;
+
        tps6591x_i2c_client = client;
 
        return 0;
index 525a861..d0d829f 100644 (file)
@@ -104,6 +104,8 @@ struct tps6591x_platform_data {
 
        struct tps6591x_gpio_init_data *gpio_init_data;
        int num_gpioinit_data;
+
+       bool use_power_off;
 };
 
 /*
@@ -118,6 +120,5 @@ extern int tps6591x_set_bits(struct device *dev, int reg, uint8_t bit_mask);
 extern int tps6591x_clr_bits(struct device *dev, int reg, uint8_t bit_mask);
 extern int tps6591x_update(struct device *dev, int reg, uint8_t val,
                           uint8_t mask);
-extern int tps6591x_power_off(void);
 
 #endif /*__LINUX_MFD_TPS6591X_H */