lkml.org 
[lkml]   [2019]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] leds: an30259a: add a check for devm_regmap_init_i2c
From
Date
Chuhong

On 10/16/19 7:54 AM, Chuhong Yuan wrote:
> 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 <hslester96@gmail.com>
> ---
> Changes in v2:
> - Use goto exit instead of return to destroy the mutex when failed.
>
> drivers/leds/leds-an30259a.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/leds/leds-an30259a.c b/drivers/leds/leds-an30259a.c
> index 250dc9d6f635..82350a28a564 100644
> --- a/drivers/leds/leds-an30259a.c
> +++ b/drivers/leds/leds-an30259a.c
> @@ -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;
> + }
> +

Reviewed-by: Dan Murphy <dmurphy@ti.com>


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

\
 
 \ /
  Last update: 2019-10-16 16:35    [W:0.057 / U:20.720 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site