2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-30 22:05:11 +00:00

libsensors: Add support for SENSORS_BUS_TYPE_SCSI

Upcoming kernel drivers may add SCSI bus based sensors.
Add support for it to libsensors.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Guenter Roeck
2018-08-11 11:59:14 -07:00
parent fde815c4fb
commit 09a60b9065
6 changed files with 19 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ SVN HEAD
pwmconfig: replaced deprecated sub shell syntax
fancontrol: replaced deprecated sub shell syntax
fancontrol.8: replaced deprecated sub shell syntax
libsensors: Add support for SENSORS_BUS_TYPE_SCSI
3.4.0 (2015-06-25)
documentation: Update the note about libsensors license

View File

@@ -12,6 +12,8 @@ given new feature.
enum sensors_subfeature_type SENSORS_SUBFEATURE_POWER_LCRIT
enum sensors_subfeature_type SENSORS_SUBFEATURE_POWER_MIN_ALARM
enum sensors_subfeature_type SENSORS_SUBFEATURE_POWER_LCRIT_ALARM
* Added bus type "scsi":
#define SENSORS_BUS_TYPE_SCSI
0x440 lm-sensors 3.4.0
* Defined SENSORS_FEATURE_MAX

View File

@@ -369,6 +369,8 @@ const char *sensors_get_adapter_name(const sensors_bus_id *bus)
return "HID adapter";
case SENSORS_BUS_TYPE_MDIO:
return "MDIO adapter";
case SENSORS_BUS_TYPE_SCSI:
return "SCSI adapter";
}
/* bus types with several instances */

View File

@@ -125,6 +125,8 @@ int sensors_parse_chip_name(const char *name, sensors_chip_name *res)
res->bus.type = SENSORS_BUS_TYPE_HID;
else if (!strncmp(name, "mdio", dash - name))
res->bus.type = SENSORS_BUS_TYPE_MDIO;
else if (!strncmp(name, "scsi", dash - name))
res->bus.type = SENSORS_BUS_TYPE_SCSI;
else
goto ERROR;
name = dash + 1;
@@ -136,6 +138,7 @@ int sensors_parse_chip_name(const char *name, sensors_chip_name *res)
case SENSORS_BUS_TYPE_I2C:
case SENSORS_BUS_TYPE_SPI:
case SENSORS_BUS_TYPE_HID:
case SENSORS_BUS_TYPE_SCSI:
if (!strncmp(name, "*-", 2)) {
res->bus.nr = SENSORS_BUS_NR_ANY;
name += 2;
@@ -198,6 +201,9 @@ int sensors_snprintf_chip_name(char *str, size_t size,
case SENSORS_BUS_TYPE_MDIO:
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 -SENSORS_ERR_CHIP_NAME;

View File

@@ -45,6 +45,7 @@
#define SENSORS_BUS_TYPE_ACPI 5
#define SENSORS_BUS_TYPE_HID 6
#define SENSORS_BUS_TYPE_MDIO 7
#define SENSORS_BUS_TYPE_SCSI 8
#define SENSORS_BUS_NR_ANY (-1)
#define SENSORS_BUS_NR_IGNORE (-2)

View File

@@ -727,6 +727,13 @@ static int sensors_read_one_sysfs_chip(const char *dev_path,
entry.chip.addr = 0;
entry.chip.bus.type = SENSORS_BUS_TYPE_MDIO;
entry.chip.bus.nr = 0;
} else
if (subsys && !strcmp(subsys, "scsi") &&
sscanf(dev_name, "%d:%d:%d:%x", &domain, &bus, &slot, &fn) == 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;
} else {
/* Ignore unknown device */
err = 0;