All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: emc1812: reject channel index 0 in device tree config
@ 2026-07-16  0:25 Ivy Lopez
  2026-07-16  0:34 ` Guenter Roeck
  2026-07-16  0:37 ` sashiko-bot
  0 siblings, 2 replies; 3+ messages in thread
From: Ivy Lopez @ 2026-07-16  0:25 UTC (permalink / raw)
  To: marius.cristea, linux; +Cc: linux-hwmon, linux-kernel, Ivy Lopez

Channel index 0 is reserved for the internal diode and is set
unconditionally before parsing child nodes. If a child node specifies
reg = 0, it silently overwrites the internal diode label

Reject reg = 0 in child nodes and improve the error message to
include the invalid index value.

Signed-off-by: Ivy Lopez <skunkolee@gmail.com>
---
 drivers/hwmon/emc1812.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/emc1812.c b/drivers/hwmon/emc1812.c
index 68575c27d090..143c3c07dbaa 100644
--- a/drivers/hwmon/emc1812.c
+++ b/drivers/hwmon/emc1812.c
@@ -809,9 +809,10 @@ static int emc1812_parse_fw_config(struct emc1812_data *data, struct device *dev
 
 	device_for_each_child_node_scoped(dev, child) {
 		ret = fwnode_property_read_u32(child, "reg", &reg_nr);
-		if (ret || reg_nr >= data->chip->phys_channels)
+		if (ret || reg_nr == 0 || reg_nr >= data->chip->phys_channels)
 			return dev_err_probe(dev, -EINVAL,
-					     "The index is higher then the chip supports\n");
+					"Invalid channel index %u\n",
+					reg_nr);
 		/* Mark channel as active */
 		set_bit(reg_nr, &data->active_ch_mask);
 
-- 
2.55.0


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

end of thread, other threads:[~2026-07-16  0:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16  0:25 [PATCH] hwmon: emc1812: reject channel index 0 in device tree config Ivy Lopez
2026-07-16  0:34 ` Guenter Roeck
2026-07-16  0:37 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.