diff mbox series

[v3,2/2] hwmon: (it87) Check for a valid chip before using force_id

Message ID 20221004210100.540120-3-ahmad@khalifa.ws (mailing list archive)
State Accepted
Headers show
Series hwmon: (it87) Add param to ignore ACPI resource | expand

Commit Message

Ahmad Khalifa Oct. 4, 2022, 9:01 p.m. UTC
Check there is a chip before using force_id parameter as there
is no value in registering a non-existent chip

Signed-off-by: Ahmad Khalifa <ahmad@khalifa.ws>
---
 drivers/hwmon/it87.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Guenter Roeck Oct. 5, 2022, 6:32 p.m. UTC | #1
On Tue, Oct 04, 2022 at 10:01:03PM +0100, Ahmad Khalifa wrote:
> Check there is a chip before using force_id parameter as there
> is no value in registering a non-existent chip
> 
> Signed-off-by: Ahmad Khalifa <ahmad@khalifa.ws>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  drivers/hwmon/it87.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
> index c4f5500dcf3c..bb9870c79ffe 100644
> --- a/drivers/hwmon/it87.c
> +++ b/drivers/hwmon/it87.c
> @@ -2401,7 +2401,13 @@ static int __init it87_find(int sioaddr, unsigned short *address,
>  		return err;
>  
>  	err = -ENODEV;
> -	chip_type = force_id ? force_id : superio_inw(sioaddr, DEVID);
> +	chip_type = superio_inw(sioaddr, DEVID);
> +	/* check first for a valid chip before forcing chip id */
> +	if (chip_type == 0xffff)
> +		goto exit;
> +
> +	if (force_id)
> +		chip_type = force_id;
>  
>  	switch (chip_type) {
>  	case IT8705F_DEVID:
diff mbox series

Patch

diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index c4f5500dcf3c..bb9870c79ffe 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -2401,7 +2401,13 @@  static int __init it87_find(int sioaddr, unsigned short *address,
 		return err;
 
 	err = -ENODEV;
-	chip_type = force_id ? force_id : superio_inw(sioaddr, DEVID);
+	chip_type = superio_inw(sioaddr, DEVID);
+	/* check first for a valid chip before forcing chip id */
+	if (chip_type == 0xffff)
+		goto exit;
+
+	if (force_id)
+		chip_type = force_id;
 
 	switch (chip_type) {
 	case IT8705F_DEVID: