Linux-ide Archive on lore.kernel.org
 help / color / Atom feed
From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-hwmon@vger.kernel.org, Jean Delvare <jdelvare@suse.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bart Van Assche <bvanassche@acm.org>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org,
	Chris Healy <cphealy@gmail.com>
Subject: Re: [PATCH v2] hwmon: Driver for temperature sensors on SATA drives
Date: Tue, 07 Jan 2020 20:29:40 -0500
Message-ID: <yq1o8ve20sb.fsf@oracle.com> (raw)
In-Reply-To: <d42990af-78e4-e6c4-37ae-8043d27e565a@roeck-us.net> (Guenter Roeck's message of "Tue, 7 Jan 2020 05:00:39 -0800")


Guenter,

> "scsi-8-140" is created by libsensors, so any change in that would
> have to be made there, not in the kernel driver.

Yes. Something like the patch below which will produce actual SCSI
device instance names:

	drivetemp-scsi-7:0:29:0
	drivetemp-scsi-8:0:30:0
	drivetemp-scsi-8:0:15:0
	drivetemp-scsi-7:0:24:0

Instead of the current:

	drivetemp-scsi-7-1d0
	drivetemp-scsi-8-1e0
	drivetemp-scsi-8-f0
	drivetemp-scsi-7-180

Other question: Does hwmon have any notion of sensor topology? As I
mentioned earlier, SCSI installations typically rely on SAF-TE or SES
instead of the physical drive sensors. SES also includes monitoring of
fans, power supplies, etc. And more importantly, it provides a
representation of the location of a given component. E.g.: Tray number
#4, disk drive bay #5.

So it would be helpful if libsensors had a way to represent sensors in a
way that mimics the physical device layout reported by SES.

-- 
Martin K. Petersen	Oracle Linux Engineering


diff --git a/lib/data.c b/lib/data.c
index c5aea42967a6..06cfa86f353b 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -202,8 +202,9 @@ int sensors_snprintf_chip_name(char *str, size_t size,
 		return snprintf(str, size, "%s-mdio-%x", chip->prefix,
 				chip->addr);
 	case SENSORS_BUS_TYPE_SCSI:
-		return snprintf(str, size, "%s-scsi-%hd-%x", chip->prefix,
-				chip->bus.nr, chip->addr);
+		return snprintf(str, size, "%s-scsi-%u:%u:%u:%lu", chip->prefix,
+				chip->bus.nr, chip->addr, chip->sub_addr,
+				chip->sub_sub_addr);
 	}
 
 	return -SENSORS_ERR_CHIP_NAME;
diff --git a/lib/sensors.h b/lib/sensors.h
index 94f6f23051d2..f468cccabc72 100644
--- a/lib/sensors.h
+++ b/lib/sensors.h
@@ -65,6 +65,8 @@ typedef struct sensors_chip_name {
 	char *prefix;
 	sensors_bus_id bus;
 	int addr;
+	unsigned int sub_addr;
+	unsigned long sub_sub_addr;
 	char *path;
 } sensors_chip_name;
 
diff --git a/lib/sysfs.c b/lib/sysfs.c
index e63688b72aba..f76b4a99aa7d 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -620,6 +620,7 @@ static int classify_device(const char *dev_name,
                            sensors_chip_features *entry)
 {
 	int domain, bus, slot, fn, vendor, product, id;
+	unsigned long lun;
 	char bus_path[NAME_MAX];
 	char *bus_attr;
 	int ret = 1;
@@ -687,11 +688,13 @@ static int classify_device(const char *dev_name,
 		entry->chip.bus.nr = 0;
 	} else
 	if (subsys && !strcmp(subsys, "scsi") &&
-	    sscanf(dev_name, "%d:%d:%d:%x", &domain, &bus, &slot, &fn) == 4) {
+	    sscanf(dev_name, "%u:%u:%u:%lu", &domain, &bus, &id, &lun) == 4) {
 		/* adapter(host), channel(bus), id(target), lun */
-		entry->chip.addr = (bus << 8) + (slot << 4) + fn;
-		entry->chip.bus.type = SENSORS_BUS_TYPE_SCSI;
 		entry->chip.bus.nr = domain;
+		entry->chip.addr = bus;
+		entry->chip.sub_addr = id;
+		entry->chip.sub_sub_addr = lun;
+		entry->chip.bus.type = SENSORS_BUS_TYPE_SCSI;
 	} else {
 		/* Unknown device */
 		ret = 0;

  reply index

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-15 17:45 [PATCH v2 0/1] Summary: hwmon driver " Guenter Roeck
2019-12-15 17:45 ` [PATCH v2] hwmon: Driver " Guenter Roeck
2019-12-19  0:15   ` Martin K. Petersen
2019-12-19  0:32     ` Guenter Roeck
2020-01-07  4:10       ` Martin K. Petersen
2020-01-07 13:00         ` Guenter Roeck
2020-01-08  1:29           ` Martin K. Petersen [this message]
2020-01-08 15:32             ` Guenter Roeck
2019-12-19  7:37     ` Guenter Roeck
2020-01-01 17:46     ` Guenter Roeck
2020-01-03  3:06       ` Martin K. Petersen
2020-01-08  1:12       ` Martin K. Petersen
2020-01-08 15:33         ` Guenter Roeck
2020-01-11 20:22           ` Guenter Roeck
2020-01-12 11:17             ` Gabriel C
2020-01-12 11:21               ` Linus Walleij
2020-01-12 12:02                 ` Gabriel C
2020-01-12 12:07                   ` Linus Walleij
2020-01-12 13:07                     ` Guenter Roeck
2020-01-12 13:45                       ` Gabriel C
2020-01-12 15:26                         ` Guenter Roeck
2020-01-12 18:37                           ` Gabriel C
2020-01-12 20:08                             ` Guenter Roeck
2020-01-12 22:26                               ` Gabriel C
2020-01-14  3:03             ` Martin K. Petersen
2020-01-14  5:20               ` Guenter Roeck
2020-01-16  4:12                 ` Martin K. Petersen
2020-01-16  5:09                   ` Guenter Roeck
2020-01-16 17:47                   ` Guenter Roeck
2020-01-17  1:43                     ` Martin K. Petersen
2020-01-17  3:53                       ` Guenter Roeck

Reply instructions:

You may reply publically 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=yq1o8ve20sb.fsf@oracle.com \
    --to=martin.petersen@oracle.com \
    --cc=bvanassche@acm.org \
    --cc=cphealy@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@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

Linux-ide Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-ide/0 linux-ide/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-ide linux-ide/ https://lore.kernel.org/linux-ide \
		linux-ide@vger.kernel.org
	public-inbox-index linux-ide

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-ide


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git