lp5521_write(client, LP5521_REG_RESET, 0xff);
}
+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;
usleep_range(10000, 20000);
ret = lp5521_detect(client);
- if (ret)
+ if (ret) {
dev_err(&client->dev, "Chip not found\n");
+ goto err;
+ }
+
+ ret = lp5521_configure(client);
+ if (ret < 0) {
+ dev_err(&client->dev, "error configuring chip\n");
+ goto err_config;
+ }
+ return 0;
+
+err_config:
+ lp5521_deinit_device(chip);
+err:
return ret;
}
ret = lp5521_init_device(chip);
if (ret)
- goto fail1;
+ goto err_init;
dev_info(&client->dev, "%s programmable led chip found\n", id->name);
- ret = lp5521_configure(client);
- if (ret < 0) {
- dev_err(&client->dev, "error configuring chip\n");
- goto fail1;
- }
-
ret = lp5521_register_leds(chip);
if (ret)
goto fail2;
return ret;
fail2:
lp5521_unregister_leds(chip);
-fail1:
lp5521_deinit_device(chip);
+err_init:
return ret;
}
lp5523_write(client, LP5523_REG_RESET, 0xff);
}
+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;
* Exact value is not available. 10 - 20ms
* appears to be enough for reset.
*/
- return lp5523_detect(client);
+ ret = lp5523_detect(client);
+ if (ret)
+ goto err;
+
+ ret = lp5523_configure(client);
+ if (ret < 0) {
+ dev_err(&client->dev, "error configuring chip\n");
+ goto err_config;
+ }
+
+ return 0;
+
+err_config:
+ lp5523_deinit_device(chip);
+err:
+ return ret;
}
static void lp5523_deinit_device(struct lp5523_chip *chip)
ret = lp5523_init_device(chip);
if (ret)
- goto fail1;
+ goto err_init;
dev_info(&client->dev, "%s Programmable led chip found\n", id->name);
goto fail1;
}
}
- ret = lp5523_configure(client);
- if (ret < 0) {
- dev_err(&client->dev, "error configuring chip\n");
- goto fail1;
- }
ret = lp5523_register_leds(chip, id->name);
if (ret)
lp5523_unregister_leds(chip);
fail1:
lp5523_deinit_device(chip);
+err_init:
return ret;
}