Skip to content

Commit

Permalink
leds: an30259a: add a check for devm_regmap_init_i2c
Browse files Browse the repository at this point in the history
an30259a_probe misses a check for devm_regmap_init_i2c and may cause
problems.
Add a check and print errors like other leds drivers.

Signed-off-by: Chuhong Yuan <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
  • Loading branch information
WillLester authored and pavelmachek committed Nov 3, 2019
1 parent 7c6082b commit fc7b502
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/leds/leds-an30259a.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,13 @@ static int an30259a_probe(struct i2c_client *client)

chip->regmap = devm_regmap_init_i2c(client, &an30259a_regmap_config);

if (IS_ERR(chip->regmap)) {
err = PTR_ERR(chip->regmap);
dev_err(&client->dev, "Failed to allocate register map: %d\n",
err);
goto exit;
}

for (i = 0; i < chip->num_leds; i++) {
struct led_init_data init_data = {};

Expand Down

0 comments on commit fc7b502

Please sign in to comment.