Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Ahmad Khalifa <ahmad@khalifa.ws>
To: Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>,
	linux-hwmon@vger.kernel.org
Cc: Ahmad Khalifa <ahmad@khalifa.ws>
Subject: [PATCH v2 2/2] it87: check device is valid before using force_id
Date: Sun,  2 Oct 2022 18:43:02 +0100	[thread overview]
Message-ID: <20221002174259.14609-3-ahmad@khalifa.ws> (raw)
In-Reply-To: <20221002174259.14609-1-ahmad@khalifa.ws>

Check if there is a valid device before using force_id parameter value
in order to avoid registering two devices.

Signed-off-by: Ahmad Khalifa <ahmad@khalifa.ws>
---
 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 ce579f5aebcf..6d71f6c481c8 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 so force_id doesn't register a second empty device */
+	if (chip_type == 0xffff)
+		goto exit;
+
+	if (force_id)
+		chip_type = force_id;
 
 	switch (chip_type) {
 	case IT8705F_DEVID:
-- 
2.30.2


  parent reply	other threads:[~2022-10-02 17:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-02 17:42 [PATCH v2 0/2] it87: Add param to ignore ACPI resource conflicts Ahmad Khalifa
2022-10-02 17:43 ` [PATCH v2 1/2] " Ahmad Khalifa
2022-10-03 18:10   ` Guenter Roeck
2022-10-03 20:30     ` Ahmad Khalifa
2022-10-03 20:50       ` Guenter Roeck
2022-10-04 16:24         ` Ahmad Khalifa
2022-10-04 16:36           ` Guenter Roeck
2022-10-02 17:43 ` Ahmad Khalifa [this message]
2022-10-03 18:01   ` [PATCH v2 2/2] it87: check device is valid before using force_id Guenter Roeck
2022-10-03 20:28     ` Ahmad Khalifa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221002174259.14609-3-ahmad@khalifa.ws \
    --to=ahmad@khalifa.ws \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox