diff options
author | Milo(Woogyom) Kim <milo.kim@ti.com> | 2013-02-05 04:07:20 -0500 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2013-02-06 18:59:27 -0500 |
commit | a85908dd7799e4fa242812ce27a8f774c721d1fb (patch) | |
tree | 673164ea62b7041480a88bda3d8724d2cdb9bf88 /drivers/leds | |
parent | 632418bf65503405df3f9a6a1616f5a95f91db85 (diff) |
leds-lp55xx: use lp55xx common init function - platform data
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>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/leds-lp5521.c | 14 | ||||
-rw-r--r-- | drivers/leds/leds-lp5523.c | 14 | ||||
-rw-r--r-- | drivers/leds/leds-lp55xx-common.c | 34 | ||||
-rw-r--r-- | drivers/leds/leds-lp55xx-common.h | 3 |
4 files changed, 37 insertions, 28 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 341a41030fd8..124ce80fa115 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
@@ -719,23 +719,9 @@ static void lp5521_reset_device(struct lp5521_chip *chip) | |||
719 | static void lp5521_deinit_device(struct lp5521_chip *chip); | 719 | static void lp5521_deinit_device(struct lp5521_chip *chip); |
720 | static int lp5521_init_device(struct lp5521_chip *chip) | 720 | static int lp5521_init_device(struct lp5521_chip *chip) |
721 | { | 721 | { |
722 | struct lp5521_platform_data *pdata = chip->pdata; | ||
723 | struct i2c_client *client = chip->client; | 722 | struct i2c_client *client = chip->client; |
724 | int ret; | 723 | int ret; |
725 | 724 | ||
726 | if (pdata->setup_resources) { | ||
727 | ret = pdata->setup_resources(); | ||
728 | if (ret < 0) | ||
729 | return ret; | ||
730 | } | ||
731 | |||
732 | if (pdata->enable) { | ||
733 | pdata->enable(0); | ||
734 | usleep_range(1000, 2000); /* Keep enable down at least 1ms */ | ||
735 | pdata->enable(1); | ||
736 | usleep_range(1000, 2000); /* 500us abs min. */ | ||
737 | } | ||
738 | |||
739 | lp5521_reset_device(chip); | 725 | lp5521_reset_device(chip); |
740 | 726 | ||
741 | usleep_range(10000, 20000); /* | 727 | usleep_range(10000, 20000); /* |
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index 2ca41c5af719..8e602047ce35 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c | |||
@@ -910,23 +910,9 @@ static void lp5523_reset_device(struct lp5523_chip *chip) | |||
910 | static void lp5523_deinit_device(struct lp5523_chip *chip); | 910 | static void lp5523_deinit_device(struct lp5523_chip *chip); |
911 | static int lp5523_init_device(struct lp5523_chip *chip) | 911 | static int lp5523_init_device(struct lp5523_chip *chip) |
912 | { | 912 | { |
913 | struct lp5523_platform_data *pdata = chip->pdata; | ||
914 | struct i2c_client *client = chip->client; | 913 | struct i2c_client *client = chip->client; |
915 | int ret; | 914 | int ret; |
916 | 915 | ||
917 | if (pdata->setup_resources) { | ||
918 | ret = pdata->setup_resources(); | ||
919 | if (ret < 0) | ||
920 | return ret; | ||
921 | } | ||
922 | |||
923 | if (pdata->enable) { | ||
924 | pdata->enable(0); | ||
925 | usleep_range(1000, 2000); /* Keep enable down at least 1ms */ | ||
926 | pdata->enable(1); | ||
927 | usleep_range(1000, 2000); /* 500us abs min. */ | ||
928 | } | ||
929 | |||
930 | lp5523_reset_device(chip); | 916 | lp5523_reset_device(chip); |
931 | 917 | ||
932 | usleep_range(10000, 20000); /* | 918 | usleep_range(10000, 20000); /* |
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 1c716ecfa817..05a854c0d9b2 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c | |||
@@ -12,6 +12,7 @@ | |||
12 | * Derived from leds-lp5521.c, leds-lp5523.c | 12 | * Derived from leds-lp5521.c, leds-lp5523.c |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/delay.h> | ||
15 | #include <linux/i2c.h> | 16 | #include <linux/i2c.h> |
16 | #include <linux/leds.h> | 17 | #include <linux/leds.h> |
17 | #include <linux/module.h> | 18 | #include <linux/module.h> |
@@ -54,6 +55,39 @@ int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg, u8 mask, u8 val) | |||
54 | } | 55 | } |
55 | EXPORT_SYMBOL_GPL(lp55xx_update_bits); | 56 | EXPORT_SYMBOL_GPL(lp55xx_update_bits); |
56 | 57 | ||
58 | int lp55xx_init_device(struct lp55xx_chip *chip) | ||
59 | { | ||
60 | struct lp55xx_platform_data *pdata; | ||
61 | struct device *dev = &chip->cl->dev; | ||
62 | int ret = 0; | ||
63 | |||
64 | WARN_ON(!chip); | ||
65 | |||
66 | pdata = chip->pdata; | ||
67 | |||
68 | if (!pdata) | ||
69 | return -EINVAL; | ||
70 | |||
71 | if (pdata->setup_resources) { | ||
72 | ret = pdata->setup_resources(); | ||
73 | if (ret < 0) { | ||
74 | dev_err(dev, "setup resoure err: %d\n", ret); | ||
75 | goto err; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | if (pdata->enable) { | ||
80 | pdata->enable(0); | ||
81 | usleep_range(1000, 2000); /* Keep enable down at least 1ms */ | ||
82 | pdata->enable(1); | ||
83 | usleep_range(1000, 2000); /* 500us abs min. */ | ||
84 | } | ||
85 | |||
86 | err: | ||
87 | return ret; | ||
88 | } | ||
89 | EXPORT_SYMBOL_GPL(lp55xx_init_device); | ||
90 | |||
57 | MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>"); | 91 | MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>"); |
58 | MODULE_DESCRIPTION("LP55xx Common Driver"); | 92 | MODULE_DESCRIPTION("LP55xx Common Driver"); |
59 | MODULE_LICENSE("GPL"); | 93 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/leds/leds-lp55xx-common.h b/drivers/leds/leds-lp55xx-common.h index 369cb9c91f17..09d1882ce58e 100644 --- a/drivers/leds/leds-lp55xx-common.h +++ b/drivers/leds/leds-lp55xx-common.h | |||
@@ -58,4 +58,7 @@ extern int lp55xx_read(struct lp55xx_chip *chip, u8 reg, u8 *val); | |||
58 | extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg, | 58 | extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg, |
59 | u8 mask, u8 val); | 59 | u8 mask, u8 val); |
60 | 60 | ||
61 | /* common device init functions */ | ||
62 | extern int lp55xx_init_device(struct lp55xx_chip *chip); | ||
63 | |||
61 | #endif /* _LEDS_LP55XX_COMMON_H */ | 64 | #endif /* _LEDS_LP55XX_COMMON_H */ |