Subject: acpi sensor name change (was Re: envstat -s sensor -d device)
To: None <tech-kern@netbsd.org>
From: Iain Hibbert <plunky@rya-online.net>
List: tech-kern
Date: 10/25/2007 13:50:53
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--0-85717757-1193259065=:21788
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-ID: <Pine.NEB.4.64.0710251325331.360@localhost.>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

This didn't get any response on tech-userlevel so I repost here.

I would like to change the sensor names for acpi devices.

Currently, the ACPI sensor name includes the name of the device, but its
redundant because the envstat/sysmon/envsys (?) interface requires you to
know that separately in any case.

so
	device "acpiacad0" sensor "acpiacad0 connected" value "ON"

becomes
	device "acpiacad0" sensor "connected" value "ON"

sensors attached to other devices do not contain the device name, so this
would bring the ACPI sensors into line with the convention.

patch to do this is attached.

For compatibility, the API is changed in any case so users of the new API
will deal with the new names. I can additionally modify the GTREINFO ioctl
handler as follows:

- --- /usr/src/sys/dev/sysmon/sysmon_envsys.c	2007-10-24 20:19:10.000000000 +0100
+++ sysmon_envsys.c	2007-10-24 21:48:13.000000000 +0100
@@ -430,8 +430,17 @@

 		if (binfo->sensor < sme->sme_nsensors) {
 			binfo->units = edata->units;
- -			(void)strlcpy(binfo->desc, edata->desc,
- -			    sizeof(binfo->desc));
+
+			/*
+			 * previously, the ACPI sensor names included the
+			 * device name. Include that in compatibility code.
+			 */
+			if (strncmp(sme->sme_name, "acpi", 4) == 0)
+				(void)snprintf(binfo->desc, sizeof(binfo->desc),
+				    "%s %s", sme->sme_name, edata->desc);
+			else
+				(void)strlcpy(binfo->desc, edata->desc,
+				    sizeof(binfo->desc));
 		}

 		DPRINTFOBJ(("%s: binfo->units=%d binfo->validflags=%d\n",

to allow callers to the old API to get the same results.

any comments and/or objections?

iain
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (NetBSD)

iQEVAwUBRyCRLfFJxoMWDXVDAQL8Agf+PH1LGRQtTubPByS9XphOMT4xz1fjBN8f
iMKPvrLh4TtSWjO18bQc6i8NkWNHO0ZXAMOx4lbGsauWEluZMjIaX8NmwnChkyJl
TY6CPht3b1HCSbtOkqcSen2EjS6Wc0NxvYbifigQhIyEY26FHaqfHHRkkF/3tIMS
UAJg5pyQjH+l6oYiPuVu32XQQbW4Mf8auHQWGUmuGIxoYhrr2o7iP0jsFb6TmteP
PgC8avISMs6CktJxqpzcQDsbI7yLq8mRC2KHTzVQjez15xwFJPwuv1RFqUbNdX54
xg3ICucpHbdcNDkh9iiXGz8D28e8wcAkmOQeCSUbMyA7EtxEPDxynQ==
=D5+U
-----END PGP SIGNATURE-----
--0-85717757-1193259065=:21788
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME=acpi.diff
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.NEB.4.64.0710242151050.21788@localhost.>
Content-Description: remove ACPI device names from sensor name
Content-Disposition: ATTACHMENT; FILENAME=acpi.diff

LS0tIC91c3Ivc3JjL3N5cy9kZXYvYWNwaS9hY3BpX2FjYWQuYwkyMDA3LTEw
LTI0IDIwOjE3OjQ0LjAwMDAwMDAwMCArMDEwMA0KKysrIHNyYy9zeXMvZGV2
L2FjcGkvYWNwaV9hY2FkLmMJMjAwNy0xMC0yNCAyMTowMjo0My4wMDAwMDAw
MDAgKzAxMDANCkBAIC0yNzUsOCArMjc1LDcgQEANCiAJc2MtPnNjX2RhdGFb
MF0uc2Vuc29yID0gMDsNCiAJc2MtPnNjX2RhdGFbMF0uc3RhdGUgPSBFTlZT
WVNfU1ZBTElEOw0KIAlzYy0+c2NfZGF0YVswXS51bml0cyA9IEVOVlNZU19J
TkRJQ0FUT1I7DQotCXNucHJpbnRmKHNjLT5zY19kYXRhWzBdLmRlc2MsIHNp
emVvZihzYy0+c2NfZGF0YS0+ZGVzYyksDQotCSAgICAiJXMgJXMiLCBkZXZp
Y2VfeG5hbWUoZHYpLCAiY29ubmVjdGVkIik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