public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>
To: Raghavendra D Prabhu <rprabhu@wnohang.net>
Cc: Richard Purdie <rpurdie@rpsys.net>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] FIX: engine_state is uninitialized
Date: Mon, 18 Apr 2011 13:21:25 +0200	[thread overview]
Message-ID: <20110418112124.GB1100@debian.debian> (raw)
In-Reply-To: <20110416084313.GA27564@Xye>

On Sat, Apr 16, 2011 at 02:13:13PM +0530, Raghavendra D Prabhu wrote:
> In case lp5521_read() returns EIO, engine_state is in an uninitialized state. This
> adds checks to fix that.
>
> Signed-off-by: Raghavendra D Prabhu <rprabhu@wnohang.net>
> ---
>  drivers/leds/leds-lp5521.c |   10 ++++++----
>  1 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
> index c0cff64..6c5eac0 100644
> --- a/drivers/leds/leds-lp5521.c
> +++ b/drivers/leds/leds-lp5521.c
> @@ -176,11 +176,13 @@ static int lp5521_set_engine_mode(struct lp5521_engine *engine, u8 mode)
>  	ret = lp5521_read(client, LP5521_REG_OP_MODE, &engine_state);
> +	if (ret == 0){
>  	/* set mode only for this engine */
> -	engine_state &= ~(engine->engine_mask);
> -	mode &= engine->engine_mask;
> -	engine_state |= mode;
> -	ret |= lp5521_write(client, LP5521_REG_OP_MODE, engine_state);
> +		engine_state &= ~(engine->engine_mask);
> +		mode &= engine->engine_mask;
> +		engine_state |= mode;
> +		ret |= lp5521_write(client, LP5521_REG_OP_MODE, engine_state);
> +	}
>  	return ret;
>  }
> --
> 1.7.4.4

Usually something like

	if (ret < 0)
		goto out;

	/* some code here */

out:
	return ret;

is preferred to avoid unnecessary nesting/indentation. Anyway, thanks for the
patch (although I'm not the maintainer, but just commenting).

Thanks,
	Jonathan Neuschäfer

  reply	other threads:[~2011-04-18 11:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-16  8:37 [PATCH] Fix for unintialized variables Raghavendra D Prabhu
2011-04-16  8:43 ` [PATCH 1/2] FIX: engine_state is uninitialized Raghavendra D Prabhu
2011-04-18 11:21   ` Jonathan Neuschäfer [this message]
2011-04-16  8:44 ` [PATCH 2/2] FIX: Check the return value before proceeding Raghavendra D Prabhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110418112124.GB1100@debian.debian \
    --to=j.neuschaefer@gmx.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rprabhu@wnohang.net \
    --cc=rpurdie@rpsys.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox