leds-lp55xx: clean up init_device() in lp5521/5523

To make _probe() simple, device initialization code is moved to
 _init_device() at each driver.
 This patch is a preceding step for lp55xx common driver architecture.

 leds-lp5521:
 When 'lp5521_init_device()' gets failed, error handling should be 'fail1'
 rather than 'fail2'.
   fail1: releasing platform resource and return code
   fail2: releasing allocated LED devices with handling 'fail1'
 The 'lp5521_init_device()' is called before creating LED devices.
 Thus, 'goto fail1' is proper error handler of this function.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
这个提交包含在:
Milo(Woogyom) Kim
2013-02-05 17:49:46 +09:00
提交者 Bryan Wu
父节点 8a4529a38d
当前提交 944f7b1ded
修改 2 个文件,包含 84 行新增65 行删除

查看文件

@@ -896,6 +896,33 @@ static int lp5523_init_led(struct lp5523_led *led, struct device *dev,
return 0;
}
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_write(client, LP5523_REG_RESET, 0xff);
usleep_range(10000, 20000); /*
* Exact value is not available. 10 - 20ms
* appears to be enough for reset.
*/
return lp5523_detect(client);
}
static int lp5523_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -921,25 +948,7 @@ static int lp5523_probe(struct i2c_client *client,
chip->pdata = pdata;
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_write(client, LP5523_REG_RESET, 0xff);
usleep_range(10000, 20000); /*
* Exact value is not available. 10 - 20ms
* appears to be enough for reset.
*/
ret = lp5523_detect(client);
ret = lp5523_init_device(chip);
if (ret)
goto fail1;