Skip to contentSkip to conversation

Check return code from pdc20621_i2c_read()

PATCH In review Tomer Barletz 4 participants 16 messages Aug 2, 2015 – Aug 6, 2015 1 message not in the archive libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Check return code from pdc20621_i2c_read()

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

---
 drivers/ata/sata_sx4.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/ata/sata_sx4.c +10 -4
index 3a18a8a..bed311b 100644
@@ -1238,8 +1238,11 @@ 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)) {
+		printk(KERN_ERR "Failed in i2c read: device=0x%d, subaddr=0x%d\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 +1383,11 @@ 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)) {
+		printk(KERN_ERR "Failed in i2c read: device=0x%d, subaddr=0x%d\n", PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);
+		return 1;
+	}
 	if (spd0 == 0x02) {
 		void *buf;
 		VPRINTK("Start ECC initialization\n");
Signature · 1 line
2.4.3
#1 lore raw

Hello.

Quoted 14 lines · Tomer Barletz

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

---
  drivers/ata/sata_sx4.c | 14 ++++++++++----
  1 file changed, 10 insertions(+), 4 deletions(-)
drivers/ata/sata_sx4.c +0 -0
index 3a18a8a..bed311b 100644

drivers/ata/sata_sx4.c static unsigned int pdc20621_prog_dimm_global(struct ata_host *host) · line 1243

Quoted 8 lines
drivers/ata/sata_sx4.c +3 -2
@@ -1238,8 +1238,11 @@ 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)) {
+		printk(KERN_ERR "Failed in i2c read: device=0x%d, subaddr=0x%d\n", PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);

Please use pr_err() instead. And "0x%d" makes no sense at all, please use
"%#x" instead.

[...]

drivers/ata/sata_sx4.c static unsigned int pdc20621_dimm_init(struct ata_host *host) · line 1388

Quoted 9 lines
drivers/ata/sata_sx4.c +3 -2
@@ -1380,8 +1383,11 @@ 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)) {
+		printk(KERN_ERR "Failed in i2c read: device=0x%d, subaddr=0x%d\n", PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);

Likewise.

MNR, Sergei

A message that is not in the archive (sent off-list or not yet received): CAO-S75CRyh=FPbeTJMZWiYTvpd_wn57f4eGQgOHW2p16+9ANhQ@mail.gmail.com

#3 lore raw

Re-sending in plain-text.

Quoted 2 lines · Sergei Shtylyov

Please use pr_err() instead. And "0x%d" makes no sense at all, please use "%#x" instead.

Yeah, not sure what I was drinking before writing this 0x%d thing...

Regarding the pr_err() - it is not used at all in this file, and printk() is used instead. Wouldn't it be better to leave it with printk for this change, then have another change that replaces printk()s with pr_err()s?

--Tomer

Quoted 16 lines · Tomer Barletz
Quoted 3 lines · Sergei Shtylyov

Please use pr_err() instead. And "0x%d" makes no sense at all, please
use "%#x" instead.

Yeah, not sure what I was drinking before writing this 0x%d thing...

Regarding the pr_err() - it is not used at all in this file, and printk() is used instead. Wouldn't it be better to leave it with printk for this change, then have another change that replaces printk()s with pr_err()s?

--Tomer

#4 lore raw
Quoted 9 lines · Tomer Barletz

Re-sending in plain-text.

Quoted 3 lines · Sergei Shtylyov

Please use pr_err() instead. And "0x%d" makes no sense at all,
please use "%#x" instead.

Quoted 6 lines

Yeah, not sure what I was drinking before writing this 0x%d thing...

Regarding the pr_err() - it is not used at all in this file, and printk() is used instead. Wouldn't it be better to leave it with printk for this change, then have another change that replaces printk()s with pr_err()s?

Where possible, it'd be better to use ata_dev_<level>

#5 lore raw
In reply to Tomer Barletz
Quoted 8 lines · Tomer Barletz
Quoted 3 lines · Sergei Shtylyov

Please use pr_err() instead. And "0x%d" makes no sense at all,
please use "%#x" instead.

Yeah, not sure what I was drinking before writing this 0x%d thing...

btw: you and a few others ([dui]: debugging under the influence?):

$ git grep -n -E "0x[\*\d\.]*%[dui]"
drivers/block/DAC960.c:2957:            DAC960_Error("IO port 0x%d busy for Controller at\n",
drivers/block/DAC960.c:2993:            DAC960_Error("IO port 0x%d busy for Controller at\n",
drivers/block/cciss.c:3857:     dev_dbg(&h->pdev->dev, "   Max outstanding commands = 0x%d\n",
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c:523:    mfc_debug(2, "stream buf addr: 0x%08lx, size: 0x%d\n",
drivers/misc/sgi-gru/grumain.c:286:     gru_dbg(grudev, "gid %d, gts %p, gms %p, ctxnum 0x%d, asidmap 0x%lx\n",
sound/soc/atmel/atmel_ssc_dai.c:293:    pr_debug("atmel_ssc_startup: SSC_SR=0x%u\n",

I'll send a few patches...

#6 lore raw
In reply to Tomer Barletz
Quoted 6 lines · Tomer Barletz
Quoted 1 line
    Please use pr_err() instead. And "0x%d" makes no sense at all, please use "%#x" instead.

Yeah, not sure what I was drinking before writing this 0x%d thing...

Regarding the pr_err() - it is not used at all in this file, and printk() is used instead.

The problem is these printk() calls cause complaints from
scripts/checkpatch.pl.

Quoted 3 lines

Wouldn't it be better to leave it with
printk for this change, then have another change that replaces printk()s with pr_err()s?

Probably yes...

Quoted 1 line

--Tomer

MBR, Sergei

#7 lore raw
Quoted 7 lines · Sergei Shtylyov
Quoted 7 lines
Quoted 2 lines
    Please use pr_err() instead. And "0x%d" makes no sense at all, please

use "%#x" instead.

Yeah, not sure what I was drinking before writing this 0x%d thing...

Regarding the pr_err() - it is not used at all in this file, and printk() is used instead.

Didn't notice before: the patch subject should start with the driver name
and a colon, "sats_sx4: ".

Quoted 1 line
Quoted 1 line

--Tomer

MBR, Sergei

#8 lore raw

PATCH 1/1 sata_sx4: Check return code from pdc20621_i2c_read()

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

---
 drivers/ata/sata_sx4.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/ata/sata_sx4.c +12 -4
index 3a18a8a..e1c1423 100644
@@ -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)) {
+		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)) {
+		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");
Signature · 1 line
2.4.3
#9 lore raw

Re: [PATCH] sata_sx4: Check return code from pdc20621_i2c_read()

Quoted 14 lines · Tomer Barletz

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

---
  drivers/ata/sata_sx4.c | 16 ++++++++++++----
  1 file changed, 12 insertions(+), 4 deletions(-)
drivers/ata/sata_sx4.c +0 -0
index 3a18a8a..e1c1423 100644

drivers/ata/sata_sx4.c static unsigned int pdc20621_prog_dimm_global(struct ata_host *host) · line 1242

Quoted 7 lines
drivers/ata/sata_sx4.c +2 -2
@@ -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.

Quoted 8 lines
drivers/ata/sata_sx4.c +4 -0
+		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);

drivers/ata/sata_sx4.c static unsigned int pdc20621_dimm_init(struct ata_host *host) · line 1388

Quoted 7 lines
drivers/ata/sata_sx4.c +2 -2
@@ -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.

drivers/ata/sata_sx4.c static unsigned int pdc20621_dimm_init(struct ata_host *host) · line 1395

Quoted 7 lines
drivers/ata/sata_sx4.c +4 -0
+		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

#10 lore raw

Re: [PATCH] sata_sx4: Check return code from pdc20621_i2c_read()

I see how it makes sense to add a tab to align with the previous line of code, as it will always look similar in all editors, no matter how their tab character is set up to be.
However, adding more tabs will just mess up editors that are not set up with 8-space width tabs.

Is this a bug in checkpatch.pl, or are we saying everyone should have their editor set to 8-spaces width tabs?

--Tomer

Quoted 62 lines · Sergei Shtylyov
Quoted 15 lines · Tomer Barletz

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

---
  drivers/ata/sata_sx4.c | 16 ++++++++++++----
  1 file changed, 12 insertions(+), 4 deletions(-)
drivers/ata/sata_sx4.c +0 -0
index 3a18a8a..e1c1423 100644

drivers/ata/sata_sx4.c static unsigned int · line 1243

Quoted 8 lines
drivers/ata/sata_sx4.c +2 -2
@@ -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.

Quoted 9 lines
drivers/ata/sata_sx4.c +4 -0
+               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);

drivers/ata/sata_sx4.c static unsigned int pdc20621_dimm_init(struct · line 1389

Quoted 8 lines
drivers/ata/sata_sx4.c +2 -2
@@ -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.

Quoted 8 lines
drivers/ata/sata_sx4.c +4 -0
+               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

#11 lore raw

Re: [PATCH] sata_sx4: Check return code from pdc20621_i2c_read()

Quoted 8 lines · Tomer Barletz

I see how it makes sense to add a tab to align with the previous line of code, as it will always look similar in all editors, no matter how their tab character is set up to be.
However, adding more tabs will just mess up editors that are not set up with 8-space width tabs.

Is this a bug in checkpatch.pl, or are we saying everyone should have their editor set to 8-spaces width tabs?

from Documentation/CodingStyle:

Chapter 1: Indentation

Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3.

Rationale: The whole idea behind indentation is to clearly define where a block of control starts and ends. Especially when you've been looking at your screen for 20 straight hours, you'll find it a lot easier to see how the indentation works if you have large indentations.

Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.

In short, 8-char indents make things easier to read, and have the added benefit of warning you when you're nesting your functions too deep. Heed that warning.

#12 lore raw

Re: [PATCH] sata_sx4: Check return code from pdc20621_i2c_read()

In reply to Tomer Barletz

On 08/03/2015 10:04 PM, Tomer Barletz wrote:

Please don't top-post.

Quoted 8 lines

I see how it makes sense to add a tab to align with the previous line of code, as it will always look similar in all editors, no matter how their tab character is set up to be.
However, adding more tabs will just mess up editors that are not set up with 8-space width tabs.

Is this a bug in checkpatch.pl, or are we saying everyone should have their editor set to 8-spaces width tabs?

The latter. :-)

MBR, Sergei

#13 lore raw

PATCH 1/1 sata_sx4: Check return code from pdc20621_i2c_read()

In reply to Sergei Shtylyov

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

---
 drivers/ata/sata_sx4.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/ata/sata_sx4.c +12 -4
index 3a18a8a..b482c25 100644
@@ -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)) {
+		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)) {
+		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");
Signature · 1 line
2.4.3
Applied
#14 lore raw

Re: [PATCH] sata_sx4: Check return code from pdc20621_i2c_read()

Quoted 5 lines · Tomer Barletz

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

Applied to libata/for-4.2-fixes with minor edits.

Thanks.

Signature · 1 line
tejun
#15 lore raw

PATCH 1/1 Check return code from pdc20621_i2c_read()

In reply to a message not in the archive

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

---
 drivers/ata/sata_sx4.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/ata/sata_sx4.c +10 -4
index 3a18a8a..070b272 100644
@@ -1238,8 +1238,11 @@ 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)) {
+		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 +1383,11 @@ 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)) {
+		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");
Signature · 1 line
2.4.3
#16 lore raw

Hello.

Quoted 31 lines · Tomer Barletz

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

---
  drivers/ata/sata_sx4.c | 14 ++++++++++----
  1 file changed, 10 insertions(+), 4 deletions(-)
drivers/ata/sata_sx4.c +5 -2
index 3a18a8a..070b272 100644
@@ -1238,8 +1238,11 @@ 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)) {
+		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 +1383,11 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host)
 
  	/* ECC initiliazation. */
 

drivers/ata/sata_sx4.c static unsigned int pdc20621_dimm_init(struct ata_host *host) · line 1393

Quoted 10 lines
drivers/ata/sata_sx4.c +5 -2
-	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)) {
+		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");
$ scripts/checkpatch.pl ~/patches/Check-return-code-from-pdc20621_i2c_read.patch
ERROR: code indent should use tabs where possible
#23: FILE: drivers/ata/sata_sx4.c:1242:
+^I                       PDC_DIMM_SPD_TYPE, &spd0)) {$

WARNING: line over 80 characters
#24: FILE: drivers/ata/sata_sx4.c:1243:
+ printk(KERN_ERR "Failed in i2c read: device=%#x, subaddr=%#x\n", PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);

WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(... to printk(KERN_ERR ... #24: FILE: drivers/ata/sata_sx4.c:1243:
+ printk(KERN_ERR "Failed in i2c read: device=%#x, subaddr=%#x\n", PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);

ERROR: code indent should use tabs where possible
#37: FILE: drivers/ata/sata_sx4.c:1387:
+^I PDC_DIMM_SPD_TYPE, &spd0)) {$

WARNING: line over 80 characters
#38: FILE: drivers/ata/sata_sx4.c:1388:
+ printk(KERN_ERR "Failed in i2c read: device=%#x, subaddr=%#x\n", PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);

WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(... to printk(KERN_ERR ... #38: FILE: drivers/ata/sata_sx4.c:1388:
+ printk(KERN_ERR "Failed in i2c read: device=%#x, subaddr=%#x\n", PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);

total: 2 errors, 4 warnings, 26 lines checked

NOTE: Whitespace errors detected.
You may wish to use scripts/cleanpatch or scripts/cleanfile

/home/headless/patches/Check-return-code-from-pdc20621_i2c_read.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

MBR, Sergei