mfd: tps80031: Natively register pm_power_off
Dan Willemsen [Thu, 1 Dec 2011 22:56:47 +0000 (14:56 -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: Ia545f23b95f9727932aaf3f3b64a109dae0f2448
Signed-off-by: Dan Willemsen <dwillemsen@nvidia.com>
Reviewed-on: http://git-master/r/83592
Reviewed-by: Varun Wadekar <vwadekar@nvidia.com>

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

index e6bfd47..fb6ff3b 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/slab.h>
 #include <linux/gpio.h>
 #include <linux/i2c.h>
+#include <linux/pm.h>
 
 #include <linux/mfd/core.h>
 #include <linux/mfd/tps80031.h>
@@ -498,14 +499,14 @@ int tps80031_get_pmu_version(struct device *dev)
 EXPORT_SYMBOL_GPL(tps80031_get_pmu_version);
 
 static struct tps80031 *tps80031_dev;
-int tps80031_power_off(void)
+static void tps80031_power_off(void)
 {
        struct tps80031_client *tps = &tps80031_dev->tps_clients[SLAVE_ID1];
 
        if (!tps->client)
-               return -EINVAL;
+               return;
        dev_info(&tps->client->dev, "switching off PMU\n");
-       return __tps80031_write(tps->client, TPS80031_PHOENIX_DEV_ON, DEVOFF);
+       __tps80031_write(tps->client, TPS80031_PHOENIX_DEV_ON, DEVOFF);
 }
 
 static void tps80031_init_ext_control(struct tps80031 *tps80031,
@@ -1210,6 +1211,9 @@ static int __devinit tps80031_i2c_probe(struct i2c_client *client,
 
        tps80031_debuginit(tps80031);
 
+       if (pdata->use_power_off && !pm_power_off)
+               pm_power_off = tps80031_power_off;
+
        tps80031_dev = tps80031;
 
        return 0;
index c6aa7ea..1802dfe 100644 (file)
@@ -164,6 +164,7 @@ struct tps80031_platform_data {
        int gpio_init_data_size;
        struct tps80031_clk32k_init_data *clk32k_init_data;
        int clk32k_init_data_size;
+       bool use_power_off;
 };
 
 struct tps80031_bg_platform_data {
@@ -193,8 +194,6 @@ extern int tps80031_ext_power_req_config(struct device *dev,
                unsigned long ext_ctrl_flag, int preq_bit,
                int state_reg_add, int trans_reg_add);
 
-extern int tps80031_power_off(void);
-
 extern unsigned long tps80031_get_chip_info(struct device *dev);
 
 extern int tps80031_gpadc_conversion(int channle_no);