Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 lm-sensors (1:3.6.0-7.1watter3) unstable; urgency=medium
 .
   * One more attempt. Reworked driver to assign logical names which
     works out to onewire@<PIN>-<FN>-<DID> for our devices.
Author: Ben <bcollins@watter.com>

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2025-06-25

--- lm-sensors-3.6.0.orig/lib/access.c
+++ lm-sensors-3.6.0/lib/access.c
@@ -371,6 +371,8 @@ const char *sensors_get_adapter_name(con
 		return "MDIO adapter";
 	case SENSORS_BUS_TYPE_SCSI:
 		return "SCSI adapter";
+	case SENSORS_BUS_TYPE_W1:
+		return "Dallas 1-wire";
 	}
 
 	/* bus types with several instances */
--- lm-sensors-3.6.0.orig/lib/data.c
+++ lm-sensors-3.6.0/lib/data.c
@@ -127,6 +127,8 @@ int sensors_parse_chip_name(const char *
 		res->bus.type = SENSORS_BUS_TYPE_MDIO;
 	else if (!strncmp(name, "scsi", dash - name))
 		res->bus.type = SENSORS_BUS_TYPE_SCSI;
+	else if (!strncmp(name, "w1", dash - name))
+		res->bus.type = SENSORS_BUS_TYPE_W1;
 	else
 		goto ERROR;
 	name = dash + 1;
@@ -204,6 +206,9 @@ int sensors_snprintf_chip_name(char *str
 	case SENSORS_BUS_TYPE_SCSI:
 		return snprintf(str, size, "%s-scsi-%hd-%x", chip->prefix,
 				chip->bus.nr, chip->addr);
+	case SENSORS_BUS_TYPE_W1:
+		return snprintf(str, size, "%s-w1-%hd-%x", chip->prefix,
+				chip->bus.nr, chip->addr);
 	}
 
 	return -SENSORS_ERR_CHIP_NAME;
--- lm-sensors-3.6.0.orig/lib/sensors.h
+++ lm-sensors-3.6.0/lib/sensors.h
@@ -46,6 +46,7 @@
 #define SENSORS_BUS_TYPE_HID		6
 #define SENSORS_BUS_TYPE_MDIO		7
 #define SENSORS_BUS_TYPE_SCSI		8
+#define SENSORS_BUS_TYPE_W1		9
 #define SENSORS_BUS_NR_ANY		(-1)
 #define SENSORS_BUS_NR_IGNORE		(-2)
 
--- lm-sensors-3.6.0.orig/lib/sysfs.c
+++ lm-sensors-3.6.0/lib/sysfs.c
@@ -615,11 +615,13 @@ int sensors_init_sysfs(void)
 	return 1;
 }
 
-static int classify_device(const char *dev_name,
+static int classify_device(const char *dev_path,
+                           const char *dev_name,
                            const char *subsys,
                            sensors_chip_features *entry)
 {
 	int domain, bus, slot, fn, vendor, product, id;
+	unsigned long long slave_id;
 	char bus_path[NAME_MAX];
 	char *bus_attr;
 	int ret = 1;
@@ -660,6 +662,15 @@ static int classify_device(const char *d
 		entry->chip.bus.type = SENSORS_BUS_TYPE_PCI;
 		entry->chip.bus.nr = 0;
 	} else
+	if ((!subsys || !strcmp(subsys, "w1")) &&
+	    (bus_attr = sysfs_read_attr(dev_path, "name")) &&
+	    sscanf(bus_attr, "onewire@%x-%x-%llx", &bus, &fn, &slave_id) == 3) {
+                /* W1 */
+		entry->chip.bus.type = SENSORS_BUS_TYPE_W1;
+		entry->chip.addr = fn;
+                entry->chip.bus.nr = bus;
+		free(bus_attr);
+        } else
 	if ((!subsys || !strcmp(subsys, "platform") ||
 			!strcmp(subsys, "of_platform"))) {
 		/* must be new ISA (platform driver) */
@@ -736,7 +747,7 @@ static int find_bus_type(const char *dev
 			subsys_path[sub_len] = '\0';
 			subsys = strrchr(subsys_path, '/') + 1;
 		}
-		ret = classify_device(dev_name, subsys, entry);
+		ret = classify_device(dev_path, dev_name, subsys, entry);
 		if (!ret) {
 			snprintf(linkpath, NAME_MAX, "%s/device", my_dev_path);
 			free(my_dev_path);
