linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: lm75: Use zero lm75_type for lm75
@ 2021-01-30 10:10 Matwey V. Kornilov
  2021-01-30 15:31 ` Guenter Roeck
  2021-02-02 14:21 ` [PATCH v2] hwmon: lm75: Handle broken device nodes gracefully Matwey V. Kornilov
  0 siblings, 2 replies; 8+ messages in thread
From: Matwey V. Kornilov @ 2021-01-30 10:10 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, Javier Martinez Canillas,
	open list:HARDWARE MONITORING, open list
  Cc: matwey.kornilov, Matwey V. Kornilov,
	open list:HARDWARE MONITORING, open list

There is a logical flaw in lm75_probe() function introduced in

    e97a45f1b460 ("hwmon: (lm75) Add OF device ID table")

Note, that of_device_get_match_data() returns NULL when no match
found. This is the case when OF node exists but has unknown
compatible line, while the module is still loaded via i2c
detection.

arch/powerpc/boot/dts/fsl/p2041rdb.dts:

    lm75b@48 {
    	compatible = "nxp,lm75a";
    	reg = <0x48>;
    };

In this case, the sensor is mistakenly considered as ADT75 variant.
The simplest way to handle this issue is to make the LM75 code
zero.

Fixes: e97a45f1b460 ("hwmon: (lm75) Add OF device ID table")
Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
---
 drivers/hwmon/lm75.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index e447febd121a..3aa7f9454f57 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -25,12 +25,12 @@
  */
 
 enum lm75_type {		/* keep sorted in alphabetical order */
+	lm75 = 0,		/* except of lm75 which is default fallback */
 	adt75,
 	ds1775,
 	ds75,
 	ds7505,
 	g751,
-	lm75,
 	lm75a,
 	lm75b,
 	max6625,
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-02-02 20:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-30 10:10 [PATCH] hwmon: lm75: Use zero lm75_type for lm75 Matwey V. Kornilov
2021-01-30 15:31 ` Guenter Roeck
     [not found]   ` <CAJs94EY=hDwNun_kzNQdMHmC27KEZV6urxcKm9xbHriJ_1m3UQ@mail.gmail.com>
2021-01-30 16:00     ` Guenter Roeck
2021-02-02 14:21 ` [PATCH v2] hwmon: lm75: Handle broken device nodes gracefully Matwey V. Kornilov
2021-02-02 15:08   ` Guenter Roeck
2021-02-02 18:37   ` [PATCH v3] " Matwey V. Kornilov
2021-02-02 19:29     ` Guenter Roeck
     [not found]       ` <CAJs94Ea--d7tW6ZYOjMhHsaXAJZjtivazw+0CAopFmNbYsgAgQ@mail.gmail.com>
2021-02-02 20:54         ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).