Commit 6ce61762 authored by Milo(Woogyom) Kim's avatar Milo(Woogyom) Kim Committed by Bryan Wu

leds-lp55xx: use lp55xx common deinit function

 Two separate de-init functions are merged into one common function.
 And it is used in err_post_init of lp55xx_init_device().
Signed-off-by: default avatarMilo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: default avatarBryan Wu <cooloney@gmail.com>
parent 22ebeb48
...@@ -689,16 +689,6 @@ static void lp5521_unregister_sysfs(struct i2c_client *client) ...@@ -689,16 +689,6 @@ static void lp5521_unregister_sysfs(struct i2c_client *client)
&lp5521_led_attribute_group); &lp5521_led_attribute_group);
} }
static void lp5521_deinit_device(struct lp5521_chip *chip)
{
struct lp5521_platform_data *pdata = chip->pdata;
if (pdata->enable)
pdata->enable(0);
if (pdata->release_resources)
pdata->release_resources();
}
static int lp5521_init_led(struct lp5521_led *led, static int lp5521_init_led(struct lp5521_led *led,
struct i2c_client *client, struct i2c_client *client,
int chan, struct lp5521_platform_data *pdata) int chan, struct lp5521_platform_data *pdata)
...@@ -858,7 +848,7 @@ static int lp5521_probe(struct i2c_client *client, ...@@ -858,7 +848,7 @@ static int lp5521_probe(struct i2c_client *client,
return ret; return ret;
fail2: fail2:
lp5521_unregister_leds(old_chip); lp5521_unregister_leds(old_chip);
lp5521_deinit_device(old_chip); lp55xx_deinit_device(chip);
err_init: err_init:
return ret; return ret;
} }
...@@ -866,13 +856,15 @@ static int lp5521_probe(struct i2c_client *client, ...@@ -866,13 +856,15 @@ static int lp5521_probe(struct i2c_client *client,
static int lp5521_remove(struct i2c_client *client) static int lp5521_remove(struct i2c_client *client)
{ {
struct lp5521_chip *old_chip = i2c_get_clientdata(client); struct lp5521_chip *old_chip = i2c_get_clientdata(client);
struct lp55xx_led *led = i2c_get_clientdata(client);
struct lp55xx_chip *chip = led->chip;
lp5521_run_led_pattern(PATTERN_OFF, old_chip); lp5521_run_led_pattern(PATTERN_OFF, old_chip);
lp5521_unregister_sysfs(client); lp5521_unregister_sysfs(client);
lp5521_unregister_leds(old_chip); lp5521_unregister_leds(old_chip);
lp55xx_deinit_device(chip);
lp5521_deinit_device(old_chip);
return 0; return 0;
} }
......
...@@ -872,16 +872,6 @@ static void lp5523_unregister_leds(struct lp5523_chip *chip) ...@@ -872,16 +872,6 @@ static void lp5523_unregister_leds(struct lp5523_chip *chip)
} }
} }
static void lp5523_deinit_device(struct lp5523_chip *chip)
{
struct lp5523_platform_data *pdata = chip->pdata;
if (pdata->enable)
pdata->enable(0);
if (pdata->release_resources)
pdata->release_resources();
}
/* Chip specific configurations */ /* Chip specific configurations */
static struct lp55xx_device_config lp5523_cfg = { static struct lp55xx_device_config lp5523_cfg = {
.reset = { .reset = {
...@@ -944,7 +934,7 @@ static int lp5523_probe(struct i2c_client *client, ...@@ -944,7 +934,7 @@ static int lp5523_probe(struct i2c_client *client,
return ret; return ret;
fail2: fail2:
lp5523_unregister_leds(old_chip); lp5523_unregister_leds(old_chip);
lp5523_deinit_device(old_chip); lp55xx_deinit_device(chip);
err_init: err_init:
return ret; return ret;
} }
...@@ -952,6 +942,8 @@ static int lp5523_probe(struct i2c_client *client, ...@@ -952,6 +942,8 @@ static int lp5523_probe(struct i2c_client *client,
static int lp5523_remove(struct i2c_client *client) static int lp5523_remove(struct i2c_client *client)
{ {
struct lp5523_chip *old_chip = i2c_get_clientdata(client); struct lp5523_chip *old_chip = i2c_get_clientdata(client);
struct lp55xx_led *led = i2c_get_clientdata(client);
struct lp55xx_chip *chip = led->chip;
/* Disable engine mode */ /* Disable engine mode */
lp5523_write(client, LP5523_REG_OP_MODE, LP5523_CMD_DISABLED); lp5523_write(client, LP5523_REG_OP_MODE, LP5523_CMD_DISABLED);
...@@ -959,8 +951,8 @@ static int lp5523_remove(struct i2c_client *client) ...@@ -959,8 +951,8 @@ static int lp5523_remove(struct i2c_client *client)
lp5523_unregister_sysfs(client); lp5523_unregister_sysfs(client);
lp5523_unregister_leds(old_chip); lp5523_unregister_leds(old_chip);
lp55xx_deinit_device(chip);
lp5523_deinit_device(old_chip);
return 0; return 0;
} }
......
...@@ -152,14 +152,23 @@ int lp55xx_init_device(struct lp55xx_chip *chip) ...@@ -152,14 +152,23 @@ int lp55xx_init_device(struct lp55xx_chip *chip)
return 0; return 0;
err_post_init: err_post_init:
lp55xx_deinit_device(chip);
err:
return ret;
}
EXPORT_SYMBOL_GPL(lp55xx_init_device);
void lp55xx_deinit_device(struct lp55xx_chip *chip)
{
struct lp55xx_platform_data *pdata = chip->pdata;
if (pdata->enable) if (pdata->enable)
pdata->enable(0); pdata->enable(0);
if (pdata->release_resources) if (pdata->release_resources)
pdata->release_resources(); pdata->release_resources();
err:
return ret;
} }
EXPORT_SYMBOL_GPL(lp55xx_init_device); EXPORT_SYMBOL_GPL(lp55xx_deinit_device);
MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>"); MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>");
MODULE_DESCRIPTION("LP55xx Common Driver"); MODULE_DESCRIPTION("LP55xx Common Driver");
......
...@@ -84,7 +84,8 @@ extern int lp55xx_read(struct lp55xx_chip *chip, u8 reg, u8 *val); ...@@ -84,7 +84,8 @@ extern int lp55xx_read(struct lp55xx_chip *chip, u8 reg, u8 *val);
extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg, extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg,
u8 mask, u8 val); u8 mask, u8 val);
/* common device init functions */ /* common device init/deinit functions */
extern int lp55xx_init_device(struct lp55xx_chip *chip); extern int lp55xx_init_device(struct lp55xx_chip *chip);
extern void lp55xx_deinit_device(struct lp55xx_chip *chip);
#endif /* _LEDS_LP55XX_COMMON_H */ #endif /* _LEDS_LP55XX_COMMON_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment