Subject: Re: acpi sensor name change (was Re: envstat -s sensor -d device)
To: Iain Hibbert <plunky@rya-online.net>
From: Juan RP <juan@xtrarom.org>
List: tech-kern
Date: 10/25/2007 21:12:48
On Thu, 25 Oct 2007 13:50:53 +0100 (BST)
Iain Hibbert <plunky@rya-online.net> wrote:

> -----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?

It's ok for me.

-- 
Juan Romero Pardines 	- The NetBSD Project
http://plog.xtrarom.org 	- NetBSD/pkgsrc news in Spanish