From: Guenter Roeck Date: Sun, 14 Apr 2013 15:11:30 +0000 (-0700) Subject: Fix reported use of unassigned variable X-Git-Tag: nct6775-v1.0~4 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9b02810326ad715ecc42ad142e1ba4325573d2f4;p=groeck-nct6775 Fix reported use of unassigned variable In some conditions, the compiler reports the use of address as returned from nct6775_find to be unassigned. Fix by returning it as return value together with the error. Signed-off-by: Guenter Roeck --- diff --git a/nct6775.c b/nct6775.c index af1d810..aa41a74 100644 --- a/nct6775.c +++ b/nct6775.c @@ -3656,11 +3656,11 @@ static const char *nct6775_sio_names[] __initconst = { }; /* nct6775_find() looks for a '627 in the Super-I/O config space */ -static int __init nct6775_find(int sioaddr, unsigned short *addr, - struct nct6775_sio_data *sio_data) +static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) { u16 val; int err; + int addr; err = superio_enter(sioaddr); if (err) @@ -3695,8 +3695,8 @@ static int __init nct6775_find(int sioaddr, unsigned short *addr, superio_select(sioaddr, NCT6775_LD_HWM); val = (superio_inb(sioaddr, SIO_REG_ADDR) << 8) | superio_inb(sioaddr, SIO_REG_ADDR + 1); - *addr = val & IOREGION_ALIGNMENT; - if (*addr == 0) { + addr = val & IOREGION_ALIGNMENT; + if (addr == 0) { pr_err("Refusing to enable a Super-I/O device with a base I/O port 0\n"); superio_exit(sioaddr); return -ENODEV; @@ -3711,10 +3711,10 @@ static int __init nct6775_find(int sioaddr, unsigned short *addr, superio_exit(sioaddr); pr_info("Found %s or compatible chip at %#x:%#x\n", - nct6775_sio_names[sio_data->kind], sioaddr, *addr); + nct6775_sio_names[sio_data->kind], sioaddr, addr); sio_data->sioreg = sioaddr; - return 0; + return addr; } /* @@ -3729,7 +3729,7 @@ static int __init sensors_nct6775_init(void) { int i, err; bool found = false; - unsigned short address; + int address; struct resource res; struct nct6775_sio_data sio_data; int sioaddr[2] = { 0x2e, 0x4e }; @@ -3746,7 +3746,8 @@ static int __init sensors_nct6775_init(void) * nct6775 hardware monitor, and call probe() */ for (i = 0; i < ARRAY_SIZE(pdev); i++) { - if (nct6775_find(sioaddr[i], &address, &sio_data)) + address = nct6775_find(sioaddr[i], &sio_data); + if (address <= 0) continue; found = true;