linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Tomer Barletz <barletz@gmail.com>, tj@kernel.org
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sata_sx4: Check return code from pdc20621_i2c_read()
Date: Mon, 3 Aug 2015 21:52:44 +0300	[thread overview]
Message-ID: <55BFB87C.1010405@cogentembedded.com> (raw)
In-Reply-To: <1438627595-17126-1-git-send-email-barletz@gmail.com>

On 08/03/2015 09:46 PM, Tomer Barletz wrote:

> The variable spd0 might be used uninitialized when pdc20621_i2c_read()
> fails.
> This also generates a compilation warning with gcc 5.1.

> Signed-off-by: Tomer Barletz <barletz@gmail.com>
> ---
>   drivers/ata/sata_sx4.c | 16 ++++++++++++----
>   1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
> index 3a18a8a..e1c1423 100644
> --- a/drivers/ata/sata_sx4.c
> +++ b/drivers/ata/sata_sx4.c
> @@ -1238,8 +1238,12 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host)
>   	readl(mmio + PDC_SDRAM_CONTROL);
>
>   	/* Turn on for ECC */
> -	pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
> -			  PDC_DIMM_SPD_TYPE, &spd0);
> +	if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
> +	                       PDC_DIMM_SPD_TYPE, &spd0)) {

    That won't do, you didn't fix the indentation here.

> +		printk(KERN_ERR "Failed in i2c read: device=%#x, subaddr=%#x\n",
> +		       PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);
> +		return 1;
> +	}
>   	if (spd0 == 0x02) {
>   		data |= (0x01 << 16);
>   		writel(data, mmio + PDC_SDRAM_CONTROL);
> @@ -1380,8 +1384,12 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host)
>
>   	/* ECC initiliazation. */
>
> -	pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
> -			  PDC_DIMM_SPD_TYPE, &spd0);
> +	if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
> +	                       PDC_DIMM_SPD_TYPE, &spd0)) {

    And here.

> +		printk(KERN_ERR "Failed in i2c read: device=%#x, subaddr=%#x\n",
> +		       PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);
> +		return 1;
> +	}
>   	if (spd0 == 0x02) {
>   		void *buf;
>   		VPRINTK("Start ECC initialization\n");

MBR, Sergei

  reply	other threads:[~2015-08-03 18:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-02 10:12 [PATCH] Check return code from pdc20621_i2c_read() Tomer Barletz
2015-08-02 11:09 ` Sergei Shtylyov
     [not found]   ` <CAO-S75CRyh=FPbeTJMZWiYTvpd_wn57f4eGQgOHW2p16+9ANhQ@mail.gmail.com>
2015-08-02 17:55     ` Tomer Barletz
2015-08-02 18:03       ` Joe Perches
2015-08-02 20:22       ` Joe Perches
2015-08-03 15:42       ` Sergei Shtylyov
2015-08-03 15:52         ` Sergei Shtylyov
2015-08-03 18:46           ` [PATCH] sata_sx4: " Tomer Barletz
2015-08-03 18:52             ` Sergei Shtylyov [this message]
2015-08-03 19:04               ` Tomer Barletz
2015-08-03 19:09                 ` Joe Perches
2015-08-03 19:19                 ` Sergei Shtylyov
2015-08-03 19:18               ` Tomer Barletz
2015-08-06 16:40                 ` Tejun Heo
2015-08-03  6:06     ` [PATCH] " Tomer Barletz
2015-08-03 15:40       ` Sergei Shtylyov

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=55BFB87C.1010405@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=barletz@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).