]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
leds-lp55xx: use lp55xx common init function - platform data
authorMilo(Woogyom) Kim <milo.kim@ti.com>
Tue, 5 Feb 2013 09:07:20 +0000 (18:07 +0900)
committerBryan Wu <cooloney@gmail.com>
Wed, 6 Feb 2013 23:59:27 +0000 (15:59 -0800)
 LP5521/5523 platform data functions are moved to lp55xx common driver.
 New init function, lp55xx_init_device() is created.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
drivers/leds/leds-lp5521.c
drivers/leds/leds-lp5523.c
drivers/leds/leds-lp55xx-common.c
drivers/leds/leds-lp55xx-common.h

index 341a41030fd859aa3b7ce797dfad91f3c3f277e5..124ce80fa115db51342d6f17c3d98dbcdc3253ac 100644 (file)
@@ -719,23 +719,9 @@ static void lp5521_reset_device(struct lp5521_chip *chip)
 static void lp5521_deinit_device(struct lp5521_chip *chip);
 static int lp5521_init_device(struct lp5521_chip *chip)
 {
-       struct lp5521_platform_data *pdata = chip->pdata;
        struct i2c_client *client = chip->client;
        int ret;
 
-       if (pdata->setup_resources) {
-               ret = pdata->setup_resources();
-               if (ret < 0)
-                       return ret;
-       }
-
-       if (pdata->enable) {
-               pdata->enable(0);
-               usleep_range(1000, 2000); /* Keep enable down at least 1ms */
-               pdata->enable(1);
-               usleep_range(1000, 2000); /* 500us abs min. */
-       }
-
        lp5521_reset_device(chip);
 
        usleep_range(10000, 20000); /*
index 2ca41c5af7191dc1946567717351fca9b5b412e0..8e602047ce35665f6ddfb80e8a8b5e1fe4b19cc7 100644 (file)
@@ -910,23 +910,9 @@ static void lp5523_reset_device(struct lp5523_chip *chip)
 static void lp5523_deinit_device(struct lp5523_chip *chip);
 static int lp5523_init_device(struct lp5523_chip *chip)
 {
-       struct lp5523_platform_data *pdata = chip->pdata;
        struct i2c_client *client = chip->client;
        int ret;
 
-       if (pdata->setup_resources) {
-               ret = pdata->setup_resources();
-               if (ret < 0)
-                       return ret;
-       }
-
-       if (pdata->enable) {
-               pdata->enable(0);
-               usleep_range(1000, 2000); /* Keep enable down at least 1ms */
-               pdata->enable(1);
-               usleep_range(1000, 2000); /* 500us abs min. */
-       }
-
        lp5523_reset_device(chip);
 
        usleep_range(10000, 20000); /*
index 1c716ecfa817bdd73dedf3503a9027dc34caafed..05a854c0d9b2abee655d93cab63e97b4e7e80305 100644 (file)
@@ -12,6 +12,7 @@
  * Derived from leds-lp5521.c, leds-lp5523.c
  */
 
+#include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/leds.h>
 #include <linux/module.h>
@@ -54,6 +55,39 @@ int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg, u8 mask, u8 val)
 }
 EXPORT_SYMBOL_GPL(lp55xx_update_bits);
 
+int lp55xx_init_device(struct lp55xx_chip *chip)
+{
+       struct lp55xx_platform_data *pdata;
+       struct device *dev = &chip->cl->dev;
+       int ret = 0;
+
+       WARN_ON(!chip);
+
+       pdata = chip->pdata;
+
+       if (!pdata)
+               return -EINVAL;
+
+       if (pdata->setup_resources) {
+               ret = pdata->setup_resources();
+               if (ret < 0) {
+                       dev_err(dev, "setup resoure err: %d\n", ret);
+                       goto err;
+               }
+       }
+
+       if (pdata->enable) {
+               pdata->enable(0);
+               usleep_range(1000, 2000); /* Keep enable down at least 1ms */
+               pdata->enable(1);
+               usleep_range(1000, 2000); /* 500us abs min. */
+       }
+
+err:
+       return ret;
+}
+EXPORT_SYMBOL_GPL(lp55xx_init_device);
+
 MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>");
 MODULE_DESCRIPTION("LP55xx Common Driver");
 MODULE_LICENSE("GPL");
index 369cb9c91f171cafc040cbd4c728612976b4f236..09d1882ce58e81ee8dc26072b739b346e262bb0e 100644 (file)
@@ -58,4 +58,7 @@ extern int lp55xx_read(struct lp55xx_chip *chip, u8 reg, u8 *val);
 extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg,
                        u8 mask, u8 val);
 
+/* common device init functions */
+extern int lp55xx_init_device(struct lp55xx_chip *chip);
+
 #endif /* _LEDS_LP55XX_COMMON_H */