diff options
author | Milo(Woogyom) Kim <milo.kim@ti.com> | 2013-02-05 04:09:56 -0500 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2013-02-06 18:59:27 -0500 |
commit | e3a700d8aae190e09fb06abe0ddd2e172a682508 (patch) | |
tree | 3cc952ab61cfb1219f2a43a5e0e738dd2fd7ae10 /drivers/leds/leds-lp5521.c | |
parent | 48068d5de16c23c256c085b2cd3ff03bec393900 (diff) |
leds-lp55xx: use lp55xx common init function - detect
LP5521/5523 chip detection functions are replaced with lp55xx common function,
lp55xx_detect_device().
Chip dependent address and values are configurable in each driver.
In init function, chip detection is executed.
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds/leds-lp5521.c')
-rw-r--r-- | drivers/leds/leds-lp5521.c | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index e1f1dfcd1547..0e27f7eb5d09 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
@@ -328,26 +328,6 @@ static void lp5521_led_brightness_work(struct work_struct *work) | |||
328 | mutex_unlock(&chip->lock); | 328 | mutex_unlock(&chip->lock); |
329 | } | 329 | } |
330 | 330 | ||
331 | /* Detect the chip by setting its ENABLE register and reading it back. */ | ||
332 | static int lp5521_detect(struct i2c_client *client) | ||
333 | { | ||
334 | int ret; | ||
335 | u8 buf; | ||
336 | |||
337 | ret = lp5521_write(client, LP5521_REG_ENABLE, LP5521_ENABLE_DEFAULT); | ||
338 | if (ret) | ||
339 | return ret; | ||
340 | /* enable takes 500us. 1 - 2 ms leaves some margin */ | ||
341 | usleep_range(1000, 2000); | ||
342 | ret = lp5521_read(client, LP5521_REG_ENABLE, &buf); | ||
343 | if (ret) | ||
344 | return ret; | ||
345 | if (buf != LP5521_ENABLE_DEFAULT) | ||
346 | return -ENODEV; | ||
347 | |||
348 | return 0; | ||
349 | } | ||
350 | |||
351 | /* Set engine mode and create appropriate sysfs attributes, if required. */ | 331 | /* Set engine mode and create appropriate sysfs attributes, if required. */ |
352 | static int lp5521_set_mode(struct lp5521_engine *engine, u8 mode) | 332 | static int lp5521_set_mode(struct lp5521_engine *engine, u8 mode) |
353 | { | 333 | { |
@@ -718,12 +698,6 @@ static int lp5521_init_device(struct lp5521_chip *chip) | |||
718 | struct i2c_client *client = chip->client; | 698 | struct i2c_client *client = chip->client; |
719 | int ret; | 699 | int ret; |
720 | 700 | ||
721 | ret = lp5521_detect(client); | ||
722 | if (ret) { | ||
723 | dev_err(&client->dev, "Chip not found\n"); | ||
724 | goto err; | ||
725 | } | ||
726 | |||
727 | ret = lp5521_configure(client); | 701 | ret = lp5521_configure(client); |
728 | if (ret < 0) { | 702 | if (ret < 0) { |
729 | dev_err(&client->dev, "error configuring chip\n"); | 703 | dev_err(&client->dev, "error configuring chip\n"); |
@@ -734,7 +708,6 @@ static int lp5521_init_device(struct lp5521_chip *chip) | |||
734 | 708 | ||
735 | err_config: | 709 | err_config: |
736 | lp5521_deinit_device(chip); | 710 | lp5521_deinit_device(chip); |
737 | err: | ||
738 | return ret; | 711 | return ret; |
739 | } | 712 | } |
740 | 713 | ||
@@ -851,6 +824,10 @@ static struct lp55xx_device_config lp5521_cfg = { | |||
851 | .addr = LP5521_REG_RESET, | 824 | .addr = LP5521_REG_RESET, |
852 | .val = LP5521_RESET, | 825 | .val = LP5521_RESET, |
853 | }, | 826 | }, |
827 | .enable = { | ||
828 | .addr = LP5521_REG_ENABLE, | ||
829 | .val = LP5521_ENABLE_DEFAULT, | ||
830 | }, | ||
854 | }; | 831 | }; |
855 | 832 | ||
856 | static int lp5521_probe(struct i2c_client *client, | 833 | static int lp5521_probe(struct i2c_client *client, |