Commit bb44e154 authored by Tomer Barletz's avatar Tomer Barletz Committed by Tejun Heo

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.

tj: use pr_err()
Signed-off-by: default avatarTomer Barletz <barletz@gmail.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 74a80d67
...@@ -1238,8 +1238,12 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host) ...@@ -1238,8 +1238,12 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host)
readl(mmio + PDC_SDRAM_CONTROL); readl(mmio + PDC_SDRAM_CONTROL);
/* Turn on for ECC */ /* Turn on for ECC */
pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
PDC_DIMM_SPD_TYPE, &spd0); PDC_DIMM_SPD_TYPE, &spd0)) {
pr_err("Failed in i2c read: device=%#x, subaddr=%#x\n",
PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);
return 1;
}
if (spd0 == 0x02) { if (spd0 == 0x02) {
data |= (0x01 << 16); data |= (0x01 << 16);
writel(data, mmio + PDC_SDRAM_CONTROL); writel(data, mmio + PDC_SDRAM_CONTROL);
...@@ -1380,8 +1384,12 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host) ...@@ -1380,8 +1384,12 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host)
/* ECC initiliazation. */ /* ECC initiliazation. */
pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
PDC_DIMM_SPD_TYPE, &spd0); PDC_DIMM_SPD_TYPE, &spd0)) {
pr_err("Failed in i2c read: device=%#x, subaddr=%#x\n",
PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);
return 1;
}
if (spd0 == 0x02) { if (spd0 == 0x02) {
void *buf; void *buf;
VPRINTK("Start ECC initialization\n"); VPRINTK("Start ECC initialization\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment