From owner-acpi-jp@jp.FreeBSD.org Thu Jan  1 08:44:41 2004
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) id hBVNifl58599;
	Thu, 1 Jan 2004 08:44:41 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.46])
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) with ESMTP/inet id hBVNifC58564
	for <acpi-jp@jp.FreeBSD.org>; Thu, 1 Jan 2004 08:44:41 +0900 (JST)
	(envelope-from DrZiplok@mac.com)
Received: from mac.com (smtpin07-en2 [10.13.10.152])
	by smtpout.mac.com (8.12.6/MantshX 2.0) with ESMTP id hBVNidJR015725
	for <acpi-jp@jp.FreeBSD.org>; Wed, 31 Dec 2003 15:44:39 -0800 (PST)
Received: from [192.168.0.100] (c-24-7-66-113.client.comcast.net [24.7.66.113])
	(authenticated bits=0)
	by mac.com (Xserve/smtpin07/MantshX 3.0) with ESMTP id hBVNidOR020429
	for <acpi-jp@jp.FreeBSD.org>; Wed, 31 Dec 2003 15:44:39 -0800 (PST)
Mime-Version: 1.0 (Apple Message framework v609)
In-Reply-To: <20031231145342.P2857@root.org>
References: <20031212114100.GC659@hermes.nixsys.be> <20031212171121.M54374@root.org> <20031215073539.GB685@hermes.nixsys.be> <20031231113238.A2478@root.org> <20031231195702.GF751@hermes.home.paeps.cx> <9FDA83CC-3BDF-11D8-AE15-000393C72BD6@mac.com> <20031231145342.P2857@root.org>
Content-Type: text/plain; charset=US-ASCII; format=flowed
Message-Id: <4B0D15D1-3BEB-11D8-AE15-000393C72BD6@mac.com>
Content-Transfer-Encoding: 7bit
From: Michael Smith <DrZiplok@mac.com>
To: acpi-jp@jp.FreeBSD.org
X-Mailer: Apple Mail (2.609)
Reply-To: acpi-jp@jp.FreeBSD.org
Precedence: list
Date: Wed, 31 Dec 2003 15:44:36 -0800
X-Sequence: acpi-jp 2959
Subject: [acpi-jp 2959] Re: [patch] Thermal ioctls?
Sender: owner-acpi-jp@jp.FreeBSD.org
X-Originator: DrZiplok@mac.com
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+031216


On Dec 31, 2003, at 2:55 PM, Nate Lawson wrote:

> So are you against adding the thermal ioctls?  It would be nice to
> simplify the means of exporting temp data to user applications.  Isn't
> there already an API for this that ACPI can provide information to?  I
> find it hard to believe FreeBSD has had no thermal information API for 
> the
> past 3 years.

I'm opposed to the use of ioctls for this, yes.

Sysctl is typically simpler to use, too:


#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <machine/acpi_thermal.h>

	int fd;
	struct acpi_thermal_req req;

	if ((fd = open("/dev/acpi_thermal", O_RDONLY)) < 0)
		err(1, "/dev/acpi_thermal");
	req.thermal_zone = zone_number;
	if (ioctl(fd, 't', ACPI_THERMAL_GET_TEMPERATURE, req) < 0)
		err(1, "ioctl(ACPI_THERMAL_GET_TEMPERATURE));
	close(fd);
	temperature = req.value;

vs.

#include <sys/sysctl.h>

	char *path;
	size_t valsize;

	path = asprintf("hw.acpi.thermal.%d.temperature", zone_number);
	valsize = sizeof(temperature);
	if (sysctlbyname(path, &temperature, &valsize, NULL, 0) || (valsize != 
sizeof(temperature)))
		err(1, "sysctlbyname(%s)", path);
	free(path);
	

... I won't bother to detail the kernel-side differences, but suffice 
it to say that adding
a sysctl node is a lot easier than adding an entire new device to back 
the ioctls.

  = Mike

