Skip to contentSkip to conversation

hwmon: (nct6775) Do not accept force_id unless chip is found

PATCH In review Guenter Roeck 2 participants 3 messages Aug 4, 2016 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 1/1 hwmon: (nct6775) Do not accept force_id unless chip is found

Since commit 698a7c24a544 ("hwmon: (nct6775) Support two SuperIO chips in the same system"), the driver supports two Super-IO chips. This has the undesirable side effect that force_id always detects a second chip at address 0xfff8, even if no chip exists at that address.

nct6775: Found NCT6793D or compatible chip at 0x4e:0xfff8

If no chip at all is found at a given SIO address, it does not make sense to instantiate it. Limit force_id to only work if some chip is found, that is if the chip ID returns a value other than 0xffff.

---
 drivers/hwmon/nct6775.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/nct6775.c +4 -4
index d087a8e00cf5..7859a30ce31e 100644
@@ -4232,11 +4232,11 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data)
 	if (err)
 		return err;
 
-	if (force_id)
+	val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8) |
+		superio_inb(sioaddr, SIO_REG_DEVID + 1);
+	if (force_id && val != 0xffff)
 		val = force_id;
-	else
-		val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8)
-		    | superio_inb(sioaddr, SIO_REG_DEVID + 1);
+
 	switch (val & SIO_ID_MASK) {
 	case SIO_NCT6106_ID:
 		sio_data->kind = nct6106;
Signature · 1 line
2.5.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Guenter,

Quoted 10 lines · Guenter Roeck

Since commit 698a7c24a544 ("hwmon: (nct6775) Support two SuperIO chips in the same system"), the driver supports two Super-IO chips. This has the undesirable side effect that force_id always detects a second chip at address 0xfff8, even if no chip exists at that address.

nct6775: Found NCT6793D or compatible chip at 0x4e:0xfff8

If no chip at all is found at a given SIO address, it does not make sense to instantiate it. Limit force_id to only work if some chip is found, that is if the chip ID returns a value other than 0xffff.

Agreed, good catch.

Quoted 16 lines
---
 drivers/hwmon/nct6775.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/nct6775.c +1 -1
index d087a8e00cf5..7859a30ce31e 100644
@@ -4232,11 +4232,11 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data)
 	if (err)
 		return err;
 
-	if (force_id)
+	val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8) |

drivers/hwmon/nct6775.c static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) · line 4242

Quoted 10 lines
drivers/hwmon/nct6775.c +3 -3
+		superio_inb(sioaddr, SIO_REG_DEVID + 1);
+	if (force_id && val != 0xffff)
 		val = force_id;
-	else
-		val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8)
-		    | superio_inb(sioaddr, SIO_REG_DEVID + 1);
+
 	switch (val & SIO_ID_MASK) {
 	case SIO_NCT6106_ID:
 		sio_data->kind = nct6106;
Signature · 2 lines
Jean Delvare
SUSE L3 Support
author maintainer
#2 lore raw
Quoted 30 lines · Jean Delvare

Hi Guenter,

Quoted 10 lines · Guenter Roeck

Since commit 698a7c24a544 ("hwmon: (nct6775) Support two SuperIO chips in the same system"), the driver supports two Super-IO chips. This has the undesirable side effect that force_id always detects a second chip at address 0xfff8, even if no chip exists at that address.

nct6775: Found NCT6793D or compatible chip at 0x4e:0xfff8

If no chip at all is found at a given SIO address, it does not make sense to instantiate it. Limit force_id to only work if some chip is found, that is if the chip ID returns a value other than 0xffff.

Agreed, good catch.

Quoted 14 lines
---
  drivers/hwmon/nct6775.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/nct6775.c +0 -0
index d087a8e00cf5..7859a30ce31e 100644
@@ -4232,11 +4232,11 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data)
  	if (err)
  		return err;
 
Quoted 15 lines

drivers/hwmon/nct6775.c static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) · line 4242

Quoted 12 lines
drivers/hwmon/nct6775.c +4 -4
-	if (force_id)
+	val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8) |
+		superio_inb(sioaddr, SIO_REG_DEVID + 1);
+	if (force_id && val != 0xffff)
  		val = force_id;
-	else
-		val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8)
-		    | superio_inb(sioaddr, SIO_REG_DEVID + 1);
+
  	switch (val & SIO_ID_MASK) {
  	case SIO_NCT6106_ID:
  		sio_data->kind = nct6106;

Thanks!

Guenter