[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK5ve-Li0O5b7WL6R+RL6+=4FAV=NSLfMt99rG+k7ruTEPNVEg@mail.gmail.com>
Date: Mon, 3 Dec 2012 11:18:52 -0800
From: Bryan Wu <cooloney@...il.com>
To: Dan Carpenter <dan.carpenter@...cle.com>
Cc: Richard Purdie <rpurdie@...ys.net>, linux-leds@...r.kernel.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [patch] leds: leds-lp5521: return an error code on error in probe()
On Sun, Dec 2, 2012 at 9:29 AM, Dan Carpenter <dan.carpenter@...cle.com> wrote:
> If "buf" wasn't equal to LP5521_REG_R_CURR_DEFAULT the probe fails but
> we still return zero. I've changed it to print an error message and
> return -EINVAL.
>
Looks fine with me, I applied it to my for-next branch.
-Bryan
> Reported-by: Ben Hutchings <ben@...adent.org.uk>
> Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
>
> diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
> index 2bee6b9..cb8a522 100644
> --- a/drivers/leds/leds-lp5521.c
> +++ b/drivers/leds/leds-lp5521.c
> @@ -788,10 +788,17 @@ static int lp5521_probe(struct i2c_client *client,
> * LP5521_REG_ENABLE register will not have any effect - strange!
> */
> ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf);
> - if (ret || buf != LP5521_REG_R_CURR_DEFAULT) {
> + if (ret) {
> dev_err(&client->dev, "error in resetting chip\n");
> goto fail2;
> }
> + if (buf != LP5521_REG_R_CURR_DEFAULT) {
> + dev_err(&client->dev,
> + "unexpected data in register (expected 0x%x got 0x%x)\n",
> + LP5521_REG_R_CURR_DEFAULT, buf);
> + ret = -EINVAL;
> + goto fail2;
> + }
> usleep_range(10000, 20000);
>
> ret = lp5521_detect(client);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists