public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] filling in ACPI files in sysfs
@ 2004-04-06 15:56 Alex Williamson
  0 siblings, 0 replies; 13+ messages in thread
From: Alex Williamson @ 2004-04-06 15:56 UTC (permalink / raw)
  To: linux-kernel, acpi-devel


   Seems like it's about time the ACPI sysfs namespace started doing
more than looking pretty.  Here's a stab at adding in some basic
functionality.  I'd like to get some feedback before I start filling in
the more complicated features.  This has been lightly tested on a
sampling of HP ia64 boxes.  Does this seem like a reasonable start? 
Comments and reports from other platforms welcome.  Thanks,

	Alex

-- 
Alex Williamson                             HP Linux & Open Source Lab

===== drivers/acpi/scan.c 1.22 vs edited =====
--- 1.22/drivers/acpi/scan.c	Tue Feb  3 22:29:19 2004
+++ edited/drivers/acpi/scan.c	Tue Apr  6 09:15:29 2004
@@ -7,6 +7,7 @@
 
 #include <acpi/acpi_drivers.h>
 #include <acpi/acinterp.h>	/* for acpi_ex_eisa_id_to_string() */
+#include <acpi/actypes.h>
 
 
 #define _COMPONENT		ACPI_BUS_COMPONENT
@@ -22,9 +23,184 @@
 #define ACPI_BUS_DRIVER_NAME		"ACPI Bus Driver"
 #define ACPI_BUS_DEVICE_NAME		"System Bus"
 
+#define METHOD_NAME__DDN		"_DDN"
+#define METHOD_NAME__SUN		"_SUN"
+#define METHOD_NAME__STR		"_STR"
+
 static LIST_HEAD(acpi_device_list);
 static spinlock_t acpi_device_lock = SPIN_LOCK_UNLOCKED;
 
+struct acpi_handle_attribute {
+	struct attribute attr;
+	ssize_t (*show)(struct acpi_device *, char *, char *);
+	ssize_t (*store)(struct acpi_device *, char *, const char *, size_t);
+};
+
+#define EISA_ID_TYPE (1<<0)
+#define UNICODE_TYPE (1<<1)
+
+static ssize_t
+parse_integer(char *buf, u32 value, unsigned int flags) {
+	if (flags & EISA_ID_TYPE) {
+		acpi_ex_eisa_id_to_string(value, buf);
+		buf[8] = '\n';
+		return 9;
+	}
+	return sprintf(buf, "%08x\n", value);
+}
+
+static ssize_t
+parse_string(char *buf, u32 length, char *pointer, unsigned int flags) {
+	snprintf(buf, length, "%s", pointer);
+	buf[length] = '\n';
+	return length + 1;
+}
+
+static ssize_t
+parse_buffer(char *buf, u32 length, u8 *pointer, unsigned int flags) {
+	ssize_t offset = 0;
+
+	if (flags & UNICODE_TYPE) {
+		for (; length > 0 ; length -= 2) {
+			sprintf(buf + offset, "%c", *pointer);
+			offset++;
+			pointer += 2;
+		}
+	} else {
+		for (; length > 0 ; length--) {
+			sprintf(buf + offset, "%02x", *pointer);
+			offset += 2;
+			pointer++;
+		}
+	}
+	sprintf(buf + offset++, "\n");
+	return offset;
+}
+
+static ssize_t parse_package(char *, union acpi_object *, unsigned int);
+
+static ssize_t
+parse_element(
+	char			*buf,
+	union acpi_object	*element,
+	unsigned int		flags)
+{
+
+	switch (element->type) {
+		case ACPI_TYPE_INTEGER:
+			return parse_integer(buf, element->integer.value, flags);
+		case ACPI_TYPE_STRING:
+			return parse_string(buf, element->string.length,
+			                    element->string.pointer, flags);
+		case ACPI_TYPE_BUFFER:
+			return parse_buffer(buf, element->buffer.length,
+			                   element->buffer.pointer, flags);
+		case ACPI_TYPE_PACKAGE:
+			return parse_package(buf, element, flags);
+		default:
+			return sprintf(buf, "Unknown Type: %d\n", element->type);
+	}
+}
+
+static ssize_t
+parse_package(char *buf, union acpi_object *element, unsigned int flags) {
+	int count = element->package.count;
+	ssize_t tmp, retval = 0;
+
+	element = element->package.elements;
+
+	for (; count > 0 ; count--, element++) {
+		tmp = parse_element(buf, element, flags);
+		buf += tmp;
+		retval += tmp;
+	}
+	return retval;
+}
+
+static ssize_t
+acpi_device_read_file (
+	struct acpi_device	*device,
+	char			*method,
+	char			*buf)
+{
+	acpi_status status;
+	union acpi_object *element;
+	struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	ssize_t retval = 0;
+	unsigned int flags = 0;
+
+	status = acpi_evaluate_object(device->handle, method, NULL, &buffer);
+	if (ACPI_FAILURE(status))
+		return -ENODEV;
+	
+	if (!strcmp(method, METHOD_NAME__HID)
+	    || !strcmp(method, METHOD_NAME__CID))
+		flags |= EISA_ID_TYPE;
+
+	if (!strcmp(method, METHOD_NAME__STR))
+		flags |= UNICODE_TYPE;
+
+	element = (union acpi_object *) buffer.pointer;
+	retval = parse_element(buf, element, flags);
+	acpi_os_free(element);
+	return retval;
+}
+
+#define acpi_handle_attr(method, show_func, store_func) \
+static struct acpi_handle_attribute acpi_handle_attr##method = { \
+	.attr = {.name = METHOD_NAME_##method, .mode = S_IFREG | S_IRUGO}, \
+	.show = show_func, \
+	.store = store_func, \
+};
+
+acpi_handle_attr(_ADR, acpi_device_read_file, NULL)
+acpi_handle_attr(_BBN, acpi_device_read_file, NULL)
+acpi_handle_attr(_CID, acpi_device_read_file, NULL)
+acpi_handle_attr(_DDN, acpi_device_read_file, NULL)
+acpi_handle_attr(_HID, acpi_device_read_file, NULL)
+acpi_handle_attr(_SEG, acpi_device_read_file, NULL)
+acpi_handle_attr(_STA, acpi_device_read_file, NULL)
+acpi_handle_attr(_STR, acpi_device_read_file, NULL)
+acpi_handle_attr(_SUN, acpi_device_read_file, NULL)
+acpi_handle_attr(_UID, acpi_device_read_file, NULL)
+
+typedef void acpi_device_sysfs_files(struct kobject *,
+                                     const struct attribute *);
+
+static void
+setup_sys_fs_files (
+	struct acpi_device *dev,
+	acpi_device_sysfs_files *func)
+{
+	acpi_handle tmp = NULL;
+
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__ADR, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_ADR.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__BBN, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_BBN.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__CID, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_CID.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__DDN, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_DDN.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__HID, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_HID.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__SEG, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_SEG.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__STA, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_STA.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__STR, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_STR.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__SUN, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_SUN.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__UID, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_UID.attr);
+}
+
+#define create_sysfs_files(dev) \
+	setup_sys_fs_files(dev, (acpi_device_sysfs_files *)&sysfs_create_file)
+#define remove_sysfs_files(dev) \
+	setup_sys_fs_files(dev, &sysfs_remove_file)
+
 static void acpi_device_release(struct kobject * kobj)
 {
 	struct acpi_device * dev = container_of(kobj,struct acpi_device,kobj);
@@ -33,7 +209,32 @@
 	kfree(dev);
 }
 
+#define to_acpi_device(n) container_of(n, struct acpi_device, kobj)
+#define to_handle_attr(n) container_of(n, struct acpi_handle_attribute, attr);
+
+static ssize_t acpi_device_attr_show(struct kobject *kobj,
+                struct attribute *attr, char *buf)
+{
+	struct acpi_device *device = to_acpi_device(kobj);
+	struct acpi_handle_attribute *attribute = to_handle_attr(attr);
+	return attribute->show ? attribute->show(device, attribute->attr.name, buf) : 0;
+}
+
+static ssize_t acpi_device_attr_store(struct kobject *kobj,
+                struct attribute *attr, const char *buf, size_t len)
+{
+	struct acpi_device *device = to_acpi_device(kobj);
+	struct acpi_handle_attribute *attribute = to_handle_attr(attr);
+	return attribute->store ? attribute->store(device, attribute->attr.name, buf, len) : 0;
+}
+
+static struct sysfs_ops acpi_device_sysfs_ops = {
+	.show = acpi_device_attr_show,
+	.store = acpi_device_attr_store,
+};
+
 static struct kobj_type ktype_acpi_ns = {
+	.sysfs_ops	= &acpi_device_sysfs_ops,
 	.release	= acpi_device_release,
 };
 
@@ -72,6 +273,7 @@
 	device->kobj.ktype = &ktype_acpi_ns;
 	device->kobj.kset = &acpi_namespace_kset;
 	kobject_add(&device->kobj);
+	create_sysfs_files(device);
 }
 
 static int
@@ -79,6 +281,7 @@
 	struct acpi_device	*device, 
 	int			type)
 {
+	remove_sysfs_files(device);
 	kobject_unregister(&device->kobj);
 	return 0;
 }
	

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC] filling in ACPI files in sysfs
@ 2004-04-07 21:36 Paul Ionescu
       [not found] ` <1081373781.23176.30.camel-LjAuIDrFwz0@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Paul Ionescu @ 2004-04-07 21:36 UTC (permalink / raw)
  To: acpi, alex.williamson-VXdhtT5mjnY

Hi Alex,

I patch-ed a 2.6.5 kernel, and boot-ed an IBM T30 Thinkpad Laptop.
It looks nice at first sight, and now I want _Qxx methods in /EC to play
with :)

What I found strange is the following behaviour:
If I boot with my second battery inserted, I have the corresponding
entries for BAT1 in /proc/acpi/battery and /sys/.../EC/BAT1
If I boot without my second battery inserted, and I insert it later on,
I don't have the corresponding BAT1 directory for it in /proc/acpi and
/sys/.../EC/.
And this is true for other acpi devices too.
I think that the problem is that it does not (yet) update the list of
active devices in real time, but uses the list with devices detected at
boot time.

Anyway, this is a good start, and I am waiting for more patches to test.

Thanks,
Paul


>   Seems like it's about time the ACPI sysfs namespace started >doing
>more than looking pretty.  Here's a stab at adding in some basic
>functionality.  I'd like to get some feedback before I start filling in
>the more complicated features.  This has been lightly tested on a
>sampling of HP ia64 boxes.  Does this seem like a reasonable start? 
>Comments and reports from other platforms welcome.  Thanks,




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC] filling in ACPI files in sysfs
       [not found] ` <1081373781.23176.30.camel-LjAuIDrFwz0@public.gmane.org>
@ 2004-04-07 22:13   ` Alex Williamson
       [not found]     ` <1081376023.2748.15.camel-Wmjt7DDUnIVxnVILBQAtiA@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Alex Williamson @ 2004-04-07 22:13 UTC (permalink / raw)
  To: Paul Ionescu; +Cc: acpi

On Wed, 2004-04-07 at 15:36, Paul Ionescu wrote:
> Hi Alex,
> 
> I patch-ed a 2.6.5 kernel, and boot-ed an IBM T30 Thinkpad Laptop.
> It looks nice at first sight, and now I want _Qxx methods in /EC to play
> with :)
> 
> What I found strange is the following behaviour:
> If I boot with my second battery inserted, I have the corresponding
> entries for BAT1 in /proc/acpi/battery and /sys/.../EC/BAT1
> If I boot without my second battery inserted, and I insert it later on,
> I don't have the corresponding BAT1 directory for it in /proc/acpi and
> /sys/.../EC/.
> And this is true for other acpi devices too.
> I think that the problem is that it does not (yet) update the list of
> active devices in real time, but uses the list with devices detected at
> boot time.

   Yeah, we were only filling in devices that the _STA method claimed
were present at boot.  I've fixed that now.

> Anyway, this is a good start, and I am waiting for more patches to test.

   Here you go, a second iteration.  I haven't looked at the _Qxx
methods yet, but we're up to over 30 methods exported now.  I've added
several writable methods so you can do more than query status.  I've
been able to undock my omnibook 500 laptop (electromechanical eject) and
switch between a CRT and LCD using only the sysfs interface.  I thought
about parsing some of the more complicated data structures, but that
turned into way too much code too quickly.  So you'll find there are
several entries that return a binary dump of the data structures.  these
include _CRS, _PRS, _PRT, and _MAT.  Some of the methods look like they
should work, but I don't have a box w/ firmware that exports them, so
let me know if the output is broken.  Thanks,

	Alex

-- 
Alex Williamson                             HP Linux & Open Source Lab

===== drivers/acpi/scan.c 1.22 vs edited =====
--- 1.22/drivers/acpi/scan.c	Tue Feb  3 22:29:19 2004
+++ edited/drivers/acpi/scan.c	Wed Apr  7 15:55:17 2004
@@ -7,6 +7,7 @@
 
 #include <acpi/acpi_drivers.h>
 #include <acpi/acinterp.h>	/* for acpi_ex_eisa_id_to_string() */
+#include <acpi/actypes.h>
 
 
 #define _COMPONENT		ACPI_BUS_COMPONENT
@@ -22,9 +23,326 @@
 #define ACPI_BUS_DRIVER_NAME		"ACPI Bus Driver"
 #define ACPI_BUS_DEVICE_NAME		"System Bus"
 
+#define METHOD_NAME__BCL		"_BCL"
+#define METHOD_NAME__BCM		"_BCM"
+#define METHOD_NAME__DCK		"_DCK"
+#define METHOD_NAME__DCS		"_DCS"
+#define METHOD_NAME__DGS		"_DGS"
+#define METHOD_NAME__DDN		"_DDN"
+#define METHOD_NAME__DSS		"_DSS"
+#define METHOD_NAME__DOS		"_DOS"
+#define METHOD_NAME__DOD		"_DOD"
+#define METHOD_NAME__EDL		"_EDL"
+#define METHOD_NAME__EJ0		"_EJ0"
+#define METHOD_NAME__EJD		"_EJD"
+#define METHOD_NAME__FIX		"_FIX"
+#define METHOD_NAME__HPP		"_HPP"
+#define METHOD_NAME__LCK		"_LCK"
+#define METHOD_NAME__LID		"_LID"
+#define METHOD_NAME__MAT		"_MAT"
+#define METHOD_NAME__PXM		"_PXM"
+#define METHOD_NAME__RMV		"_RMV"
+#define METHOD_NAME__STR		"_STR"
+#define METHOD_NAME__SUN		"_SUN"
+
 static LIST_HEAD(acpi_device_list);
 static spinlock_t acpi_device_lock = SPIN_LOCK_UNLOCKED;
 
+struct acpi_handle_attribute {
+	struct attribute attr;
+	ssize_t (*show)(struct acpi_device *, char *, char *);
+	ssize_t (*store)(struct acpi_device *, char *, const char *, size_t);
+};
+
+#define EISA_ID_TYPE (1<<0)
+#define UNICODE_TYPE (1<<1)
+
+static ssize_t
+parse_integer(char *buf, u32 value, unsigned int flags) {
+	if (flags & EISA_ID_TYPE) {
+		acpi_ex_eisa_id_to_string(value, buf);
+		buf[8] = '\n';
+		return 9;
+	}
+	return sprintf(buf, "%08x\n", value);
+}
+
+static ssize_t
+parse_string(char *buf, u32 length, char *pointer, unsigned int flags) {
+	snprintf(buf, length, "%s", pointer);
+	buf[length++] = '\n';
+	return length;
+}
+
+static ssize_t
+parse_buffer(char *buf, u32 length, u8 *pointer, unsigned int flags) {
+	ssize_t offset = 0;
+
+	if (flags & UNICODE_TYPE) {
+		for (; length > 0 ; length -= 2) {
+			buf[offset++] = *pointer;
+			pointer += 2;
+		}
+	} else {
+		for (; length > 0 ; length--) {
+			sprintf(buf + offset, "%02x", *pointer);
+			offset += 2;
+			pointer++;
+		}
+	}
+	buf[offset++] = '\n';
+	return offset;
+}
+
+static ssize_t parse_package(char *, union acpi_object *, unsigned int);
+
+static ssize_t
+parse_element(
+	char			*buf,
+	union acpi_object	*element,
+	unsigned int		flags)
+{
+
+	switch (element->type) {
+		case ACPI_TYPE_INTEGER:
+			return parse_integer(buf, element->integer.value, flags);
+		case ACPI_TYPE_STRING:
+			return parse_string(buf, element->string.length,
+			                    element->string.pointer, flags);
+		case ACPI_TYPE_BUFFER:
+			return parse_buffer(buf, element->buffer.length,
+			                   element->buffer.pointer, flags);
+		case ACPI_TYPE_PACKAGE:
+			return parse_package(buf, element, flags);
+		default:
+			return sprintf(buf, "Unknown Type: %d\n", element->type);
+	}
+}
+
+static ssize_t
+parse_package(char *buf, union acpi_object *element, unsigned int flags) {
+	int count = element->package.count;
+	ssize_t tmp, retval = 0;
+
+	element = element->package.elements;
+
+	for (; count > 0 ; count--, element++) {
+		tmp = parse_element(buf, element, flags);
+		buf += tmp;
+		retval += tmp;
+	}
+	return retval;
+}
+
+static ssize_t
+acpi_device_read_file (
+	struct acpi_device	*device,
+	char			*method,
+	char			*buf)
+{
+	acpi_status status;
+	union acpi_object *element;
+	struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	ssize_t retval = 0;
+	unsigned int flags = 0;
+
+	if (!strcmp(method, METHOD_NAME__CRS)) {
+		status = acpi_get_current_resources(device->handle, &buffer);
+		if (ACPI_FAILURE(status))
+			return -ENODEV;
+
+		memcpy(buf, buffer.pointer, buffer.length);
+		retval = buffer.length;
+		acpi_os_free(buffer.pointer);
+	} else if (!strcmp(method, METHOD_NAME__PRS)) {
+		status = acpi_get_possible_resources(device->handle, &buffer);
+		if (ACPI_FAILURE(status))
+			return -ENODEV;
+
+		memcpy(buf, buffer.pointer, buffer.length);
+		retval = buffer.length;
+		acpi_os_free(buffer.pointer);
+	} else if (!strcmp(method, METHOD_NAME__PRT)) {
+		status = acpi_get_irq_routing_table(device->handle, &buffer);
+		if (ACPI_FAILURE(status))
+			return -ENODEV;
+
+		memcpy(buf, buffer.pointer, buffer.length);
+		retval = buffer.length;
+		acpi_os_free(buffer.pointer);
+	} else if (!strcmp(method, METHOD_NAME__MAT)) {
+		status = acpi_evaluate_object(device->handle, method,
+		                              NULL, &buffer);
+		if (ACPI_FAILURE(status))
+			return -ENODEV;
+
+		memcpy(buf, buffer.pointer, buffer.length);
+		retval = buffer.length;
+		acpi_os_free(buffer.pointer);
+	} else {
+		status = acpi_evaluate_object(device->handle, method,
+		                              NULL, &buffer);
+		if (ACPI_FAILURE(status))
+			return -ENODEV;
+	
+		if (!strcmp(method, METHOD_NAME__HID)
+		    || !strcmp(method, METHOD_NAME__CID)
+		    || !strcmp(method, METHOD_NAME__FIX))
+			flags |= EISA_ID_TYPE;
+
+		if (!strcmp(method, METHOD_NAME__STR))
+			flags |= UNICODE_TYPE;
+
+		element = (union acpi_object *) buffer.pointer;
+		retval = parse_element(buf, element, flags);
+		acpi_os_free(buffer.pointer);
+	}
+	return retval;
+}
+
+static ssize_t
+acpi_device_write_integer (
+	struct acpi_device	*device,
+	char			*method,
+	const char		*buf,
+	size_t			length)
+{
+	struct acpi_object_list arg_list;
+	union acpi_object arg;
+	int value;
+
+
+	value = simple_strtol(buf, NULL, 0);
+
+	arg_list.count = 1;
+	arg_list.pointer = &arg;
+	arg.type = ACPI_TYPE_INTEGER;
+	arg.integer.value = value;
+
+	if (ACPI_FAILURE(acpi_evaluate_object(device->handle, method, &arg_list, NULL)))
+		return -ENODEV;
+	
+	return length;
+}
+
+#define acpi_handle_attr(method, show_func, store_func) \
+static struct acpi_handle_attribute acpi_handle_attr##method = { \
+	.attr = {.name = METHOD_NAME_##method, .mode = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP}, \
+	.show = show_func, \
+	.store = store_func, \
+};
+
+acpi_handle_attr(_ADR, acpi_device_read_file, NULL)
+acpi_handle_attr(_BBN, acpi_device_read_file, NULL)
+acpi_handle_attr(_BCL, acpi_device_read_file, NULL)
+acpi_handle_attr(_BCM, NULL, acpi_device_write_integer)
+acpi_handle_attr(_CID, acpi_device_read_file, NULL)
+acpi_handle_attr(_CRS, acpi_device_read_file, NULL)
+acpi_handle_attr(_DCK, NULL, acpi_device_write_integer)
+acpi_handle_attr(_DCS, acpi_device_read_file, NULL)
+acpi_handle_attr(_DGS, acpi_device_read_file, NULL)
+acpi_handle_attr(_DDN, acpi_device_read_file, NULL)
+acpi_handle_attr(_DSS, NULL, acpi_device_write_integer)
+acpi_handle_attr(_DOS, NULL, acpi_device_write_integer)
+acpi_handle_attr(_DOD, acpi_device_read_file, NULL)
+acpi_handle_attr(_EDL, acpi_device_read_file, NULL)
+acpi_handle_attr(_EJ0, NULL, acpi_device_write_integer)
+acpi_handle_attr(_EJD, acpi_device_read_file, NULL)
+acpi_handle_attr(_FIX, acpi_device_read_file, NULL)
+acpi_handle_attr(_HID, acpi_device_read_file, NULL)
+acpi_handle_attr(_HPP, acpi_device_read_file, NULL)
+acpi_handle_attr(_LCK, NULL, acpi_device_write_integer)
+acpi_handle_attr(_LID, acpi_device_read_file, NULL)
+acpi_handle_attr(_MAT, acpi_device_read_file, NULL)
+acpi_handle_attr(_PRS, acpi_device_read_file, NULL)
+acpi_handle_attr(_PRT, acpi_device_read_file, NULL)
+acpi_handle_attr(_PXM, acpi_device_read_file, NULL)
+acpi_handle_attr(_RMV, acpi_device_read_file, NULL)
+acpi_handle_attr(_SEG, acpi_device_read_file, NULL)
+acpi_handle_attr(_STA, acpi_device_read_file, NULL)
+acpi_handle_attr(_STR, acpi_device_read_file, NULL)
+acpi_handle_attr(_SUN, acpi_device_read_file, NULL)
+acpi_handle_attr(_UID, acpi_device_read_file, NULL)
+
+typedef void acpi_device_sysfs_files(struct kobject *,
+                                     const struct attribute *);
+
+static void
+setup_sys_fs_files (
+	struct acpi_device *dev,
+	acpi_device_sysfs_files *func)
+{
+	acpi_handle tmp = NULL;
+
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__ADR, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_ADR.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__BBN, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_BBN.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__BCL, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_BCL.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__BCM, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_BCM.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__CID, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_CID.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__CRS, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_CRS.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__DCK, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_DCK.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__DCS, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_DCS.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__DGS, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_DGS.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__DDN, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_DDN.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__DSS, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_DSS.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__DOS, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_DOS.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__DOD, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_DOD.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__EDL, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_EDL.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__EJ0, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_EJ0.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__EJD, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_EJD.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__FIX, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_FIX.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__HID, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_HID.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__HPP, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_HPP.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__LCK, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_LCK.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__LID, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_LID.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__MAT, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_MAT.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__PRS, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_PRS.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__PRT, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_PRT.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__PXM, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_PXM.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__RMV, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_RMV.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__SEG, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_SEG.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__STA, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_STA.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__STR, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_STR.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__SUN, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_SUN.attr);
+	if (ACPI_SUCCESS(acpi_get_handle(dev->handle, METHOD_NAME__UID, &tmp)))
+		(*(func))(&dev->kobj, &acpi_handle_attr_UID.attr);
+}
+
+#define create_sysfs_files(dev) \
+	setup_sys_fs_files(dev, (acpi_device_sysfs_files *)&sysfs_create_file)
+#define remove_sysfs_files(dev) \
+	setup_sys_fs_files(dev, &sysfs_remove_file)
+
 static void acpi_device_release(struct kobject * kobj)
 {
 	struct acpi_device * dev = container_of(kobj,struct acpi_device,kobj);
@@ -33,7 +351,32 @@
 	kfree(dev);
 }
 
+#define to_acpi_device(n) container_of(n, struct acpi_device, kobj)
+#define to_handle_attr(n) container_of(n, struct acpi_handle_attribute, attr);
+
+static ssize_t acpi_device_attr_show(struct kobject *kobj,
+                struct attribute *attr, char *buf)
+{
+	struct acpi_device *device = to_acpi_device(kobj);
+	struct acpi_handle_attribute *attribute = to_handle_attr(attr);
+	return attribute->show ? attribute->show(device, attribute->attr.name, buf) : 0;
+}
+
+static ssize_t acpi_device_attr_store(struct kobject *kobj,
+                struct attribute *attr, const char *buf, size_t len)
+{
+	struct acpi_device *device = to_acpi_device(kobj);
+	struct acpi_handle_attribute *attribute = to_handle_attr(attr);
+	return attribute->store ? attribute->store(device, attribute->attr.name, buf, len) : len;
+}
+
+static struct sysfs_ops acpi_device_sysfs_ops = {
+	.show = acpi_device_attr_show,
+	.store = acpi_device_attr_store,
+};
+
 static struct kobj_type ktype_acpi_ns = {
+	.sysfs_ops	= &acpi_device_sysfs_ops,
 	.release	= acpi_device_release,
 };
 
@@ -72,6 +415,7 @@
 	device->kobj.ktype = &ktype_acpi_ns;
 	device->kobj.kset = &acpi_namespace_kset;
 	kobject_add(&device->kobj);
+	create_sysfs_files(device);
 }
 
 static int
@@ -79,6 +423,7 @@
 	struct acpi_device	*device, 
 	int			type)
 {
+	remove_sysfs_files(device);
 	kobject_unregister(&device->kobj);
 	return 0;
 }
@@ -706,7 +1051,7 @@
 	switch (type) {
 	case ACPI_BUS_TYPE_DEVICE:
 		result = acpi_bus_get_status(device);
-		if (ACPI_FAILURE(result) || !device->status.present) {
+		if (ACPI_FAILURE(result)) {
 			result = -ENOENT;
 			goto end;
 		}




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC] filling in ACPI files in sysfs
       [not found]     ` <1081376023.2748.15.camel-Wmjt7DDUnIVxnVILBQAtiA@public.gmane.org>
@ 2004-04-08  5:56       ` Paul Ionescu
  2004-04-08 15:46       ` Paul Ionescu
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: Paul Ionescu @ 2004-04-08  5:56 UTC (permalink / raw)
  To: Alex Williamson; +Cc: acpi

Hi Alex,

Boy, you are fast.
I compiled the second patch in kernel 2.6.5 and booted the laptop.
The first thing I've noticed is that now we have all devices in
/sys/firmware/acpi/... even if they are initialized or not (present or
not) which IMHO is good. So, your fix works.
I still don't have /proc/acpi/battery/BAT1 if I hot plug the second
battery after loading the kernel. I don't really know if is because of
your patch or this is how new kernel behave (I have to test it with
vanilla 2.6.5 later)

I will get back with more details after more testing/playing.

Thanks,
Paul

On Thu, 2004-04-08 at 01:13, Alex Williamson wrote:
> On Wed, 2004-04-07 at 15:36, Paul Ionescu wrote:
> > Hi Alex,
> > 
> > I patch-ed a 2.6.5 kernel, and boot-ed an IBM T30 Thinkpad Laptop.
> > It looks nice at first sight, and now I want _Qxx methods in /EC to play
> > with :)
> > 
> > What I found strange is the following behaviour:
> > If I boot with my second battery inserted, I have the corresponding
> > entries for BAT1 in /proc/acpi/battery and /sys/.../EC/BAT1
> > If I boot without my second battery inserted, and I insert it later on,
> > I don't have the corresponding BAT1 directory for it in /proc/acpi and
> > /sys/.../EC/.
> > And this is true for other acpi devices too.
> > I think that the problem is that it does not (yet) update the list of
> > active devices in real time, but uses the list with devices detected at
> > boot time.
> 
>    Yeah, we were only filling in devices that the _STA method claimed
> were present at boot.  I've fixed that now.
> 
> > Anyway, this is a good start, and I am waiting for more patches to test.
> 
>    Here you go, a second iteration.  I haven't looked at the _Qxx
> methods yet, but we're up to over 30 methods exported now.  I've added
> several writable methods so you can do more than query status.  I've
> been able to undock my omnibook 500 laptop (electromechanical eject) and
> switch between a CRT and LCD using only the sysfs interface.  I thought
> about parsing some of the more complicated data structures, but that
> turned into way too much code too quickly.  So you'll find there are
> several entries that return a binary dump of the data structures.  these
> include _CRS, _PRS, _PRT, and _MAT.  Some of the methods look like they
> should work, but I don't have a box w/ firmware that exports them, so
> let me know if the output is broken.  Thanks,
> 
> 	Alex



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC] filling in ACPI files in sysfs
@ 2004-04-08  8:14 Paul Ionescu
       [not found] ` <20040408081455.52935.qmail-BuYeCebq3BaA/QwVtaZbd3CJp6faPEW9@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Paul Ionescu @ 2004-04-08  8:14 UTC (permalink / raw)
  To: alex.williamson-VXdhtT5mjnY; +Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 1424 bytes --]

Hi Alex,

I attached a file containing what I have in
/sys/firmware/acpi with your second patch.
I also tried the docking station with:
echo 1  >
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/DOCK/_DCK

and 

echo 0 >
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/DOCK/_DCK

with this commands I semi turned on/off the doking
station. I say ´semi´ because is not fully on/off.
When I turn it on (echo 1 > _DCK), the docking station
fan starts, and the LED indicating the usage of
docking station turns on, but I don´t see the new
devices from the docking station (2 new usb, 2 new
cardbus, 1 new ide, 1 new pci etc). I suspect this is
not your patch fault, but the way ACPI handles this
event. It should add the new description tables of
ACPI devices on the fly not only at boot time. When it
boots without docking station ACPI has no way to know
what will be in my docking station, so it has to add
new devices after inserting and activating the
docking.
Now, when I turn it off (with echo 0 > _DCK), the fan
stops, but the ACTIVE led is still on, and the
electromechanical eject was not activated.

Is this the way I was supposed to test docking ?

I´ll get back with more testing feedback.
If you want me to do specific tests, just let me know,
I´ll be happy to help.







__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/

[-- Attachment #2: acpi --]
[-- Type: application/octet-stream, Size: 12264 bytes --]

/sys/firmware/acpi/namespace/ACPI/
/sys/firmware/acpi/namespace/ACPI/THM0
/sys/firmware/acpi/namespace/ACPI/_SB
/sys/firmware/acpi/namespace/ACPI/_SB/SWAP
/sys/firmware/acpi/namespace/ACPI/_SB/SWAP/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/SWAP/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/NEST
/sys/firmware/acpi/namespace/ACPI/_SB/NEST/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/NEST/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/NEST/_EJ0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AC97
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AC97/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB2
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB2/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB1
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB1/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB0/URTH
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB0/URTH/UNST
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB0/URTH/UNST/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB0/URTH/UNST/_EJD
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB0/URTH/UNST/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB0/URTH/UPDK
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB0/URTH/UPDK/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB0/URTH/UPDK/_EJD
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB0/URTH/UPDK/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB0/URTH/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/USB0/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/IDE0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/IDE0/SCND
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/IDE0/SCND/MSTR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/IDE0/SCND/MSTR/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/IDE0/SCND/MSTR/_EJ0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/IDE0/SCND/MSTR/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/IDE0/SCND/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/IDE0/PRIM
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/IDE0/PRIM/MSTR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/IDE0/PRIM/MSTR/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/IDE0/PRIM/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/IDE0/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/DOCK
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/DOCK/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/DOCK/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/DOCK/_PRT
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/DOCK/_EJ0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/DOCK/_DCK
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/DOCK/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/CBS1
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/CBS1/_SUN
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/CBS1/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/CBS0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/CBS0/_SUN
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/CBS0/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/_PRT
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/DVI0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/DVI0/_DSS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/DVI0/_DGS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/DVI0/_DCS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/DVI0/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/TV0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/TV0/_DSS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/TV0/_DGS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/TV0/_DCS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/TV0/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/CRT0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/CRT0/_DSS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/CRT0/_DGS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/CRT0/_DCS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/CRT0/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/LCD0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/LCD0/_DSS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/LCD0/_DGS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/LCD0/_DCS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/LCD0/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/_DOD
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/_DOS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/VID/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/_PRT
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/AGP/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/HKEY
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/HKEY/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/HKEY/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/AC
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/AC/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/AC/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/AC/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/BAT1
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/BAT1/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/BAT1/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/BAT1/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/BAT1/_EJ0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/BAT0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/BAT0/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/BAT0/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/BAT0/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/PUBS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/PUBS/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/EC/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FIR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FIR/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FIR/_PRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FIR/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FIR/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FIR/_CID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/ECP
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/ECP/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/ECP/_PRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/ECP/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/ECP/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/LPT
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/LPT/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/LPT/_PRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/LPT/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/LPT/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/UART
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/UART/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/UART/_PRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/UART/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/UART/_EJD
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/UART/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FDC
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FDC/FDD0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FDC/FDD0/_EJD
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FDC/FDD0/_EJ0
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FDC/FDD0/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FDC/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FDC/_PRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FDC/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FDC/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/MOU
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/MOU/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/MOU/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/MOU/_CID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/KBD
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/KBD/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/KBD/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/RTC
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/RTC/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/RTC/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FPU
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FPU/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/FPU/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/SPKR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/SPKR/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/SPKR/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/DMAC
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/DMAC/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/DMAC/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/TIMR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/TIMR/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/TIMR/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/PIC
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/PIC/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/PIC/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/SIO
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/SIO/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/SIO/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/SIO/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/LPC/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/_PRT
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/_BBN
/sys/firmware/acpi/namespace/ACPI/_SB/PCI0/_ADR
/sys/firmware/acpi/namespace/ACPI/_SB/SLPB
/sys/firmware/acpi/namespace/ACPI/_SB/SLPB/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/LID
/sys/firmware/acpi/namespace/ACPI/_SB/LID/_LID
/sys/firmware/acpi/namespace/ACPI/_SB/LID/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/MEM
/sys/firmware/acpi/namespace/ACPI/_SB/MEM/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/MEM/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKH
/sys/firmware/acpi/namespace/ACPI/_SB/LNKH/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKH/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/LNKH/_PRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKH/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKH/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKG
/sys/firmware/acpi/namespace/ACPI/_SB/LNKG/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKG/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/LNKG/_PRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKG/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKG/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKF
/sys/firmware/acpi/namespace/ACPI/_SB/LNKF/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKF/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/LNKF/_PRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKF/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKF/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKE
/sys/firmware/acpi/namespace/ACPI/_SB/LNKE/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKE/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/LNKE/_PRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKE/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKE/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKD
/sys/firmware/acpi/namespace/ACPI/_SB/LNKD/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKD/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/LNKD/_PRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKD/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKD/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKC
/sys/firmware/acpi/namespace/ACPI/_SB/LNKC/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKC/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/LNKC/_PRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKC/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKC/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKB
/sys/firmware/acpi/namespace/ACPI/_SB/LNKB/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKB/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/LNKB/_PRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKB/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKB/_CRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKA
/sys/firmware/acpi/namespace/ACPI/_SB/LNKA/_UID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKA/_STA
/sys/firmware/acpi/namespace/ACPI/_SB/LNKA/_PRS
/sys/firmware/acpi/namespace/ACPI/_SB/LNKA/_HID
/sys/firmware/acpi/namespace/ACPI/_SB/LNKA/_CRS
/sys/firmware/acpi/namespace/ACPI/CPU
/sys/firmware/acpi/namespace/ACPI/PWRF

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC] filling in ACPI files in sysfs
       [not found] ` <20040408081455.52935.qmail-BuYeCebq3BaA/QwVtaZbd3CJp6faPEW9@public.gmane.org>
@ 2004-04-08 14:36   ` Alex Williamson
  0 siblings, 0 replies; 13+ messages in thread
From: Alex Williamson @ 2004-04-08 14:36 UTC (permalink / raw)
  To: Paul Ionescu; +Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Thu, 2004-04-08 at 02:14, Paul Ionescu wrote:
> Hi Alex,
> 
> I attached a file containing what I have in
> /sys/firmware/acpi with your second patch.

   Thanks, looks like your namespace is more complete than on my old
omnibook.

> I also tried the docking station with:
> echo 1  >
> /sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/DOCK/_DCK
> 
> and 
> 
> echo 0 >
> /sys/firmware/acpi/namespace/ACPI/_SB/PCI0/PCI1/DOCK/_DCK
> 
> with this commands I semi turned on/off the doking
> station. I say semi because is not fully on/off.
> When I turn it on (echo 1 > _DCK), the docking station
> fan starts, and the LED indicating the usage of
> docking station turns on, but I dont see the new
> devices from the docking station (2 new usb, 2 new
> cardbus, 1 new ide, 1 new pci etc). I suspect this is
> not your patch fault, but the way ACPI handles this
> event. It should add the new description tables of
> ACPI devices on the fly not only at boot time. When it
> boots without docking station ACPI has no way to know
> what will be in my docking station, so it has to add
> new devices after inserting and activating the
> docking.

   Yes, as far as I'm aware, we don't try to re-parse acpi namespace
after such events.  I'm not trying to solve that problem though.  This
is also just a raw interface to the acpi methods, so undocking w/o
handling the things that will get removed may be unsafe.  I envision it
being an interface by which hotplug could evaluate, via the _EJD
methods, what devices will go away and do smart things prior to the
actual eject.  On my docking station, there's no obvious effect of
calling the _DCK method, but calling _EJ0 pops it out.  Also, I see all
3 possible batteries under /proc/acpi/battery (even though only 1 is
plugged in), so I doubt this patch is changing that behavior at all.

> Now, when I turn it off (with echo 0 > _DCK), the fan
> stops, but the ACTIVE led is still on, and the
> electromechanical eject was not activated.
> 
> Is this the way I was supposed to test docking ?


   Try the _EJ0 method.  Assuming all device that you'll lose are
quiesced and removed (probably everything that lists _SB.PCI0.PCI1.DOCK
in their _EJD method), I believe you need to do the following sequence:

echo 0 > _DCK
echo 1 > _EJ0 

And after you re-dock, you should probably echo 1 > _DCK.  Thanks,

	Alex

-- 
Alex Williamson                             HP Linux & Open Source Lab



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC] filling in ACPI files in sysfs
       [not found]     ` <1081376023.2748.15.camel-Wmjt7DDUnIVxnVILBQAtiA@public.gmane.org>
  2004-04-08  5:56       ` Paul Ionescu
@ 2004-04-08 15:46       ` Paul Ionescu
       [not found]         ` <1081439217.23176.70.camel-LjAuIDrFwz0@public.gmane.org>
  2004-04-08 16:53       ` Paul Ionescu
  2004-04-08 17:25       ` Matthew Wilcox
  3 siblings, 1 reply; 13+ messages in thread
From: Paul Ionescu @ 2004-04-08 15:46 UTC (permalink / raw)
  To: Alex Williamson; +Cc: acpi

Hi Alex,

I think I found a little bug:

cat _SB/PCI0/LCP/UART/_EJD
gives me: _SB.PCI0.PCI1.DOC
and it should give _SB.PCI0.PCI1.DOCK (I searched in the DSDT)

So I think that _EJD function is eating the last byte.

I tried some more _EJDs and the same result; missing last byte.

Thanks,
Paul



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC] filling in ACPI files in sysfs
       [not found]         ` <1081439217.23176.70.camel-LjAuIDrFwz0@public.gmane.org>
@ 2004-04-08 16:41           ` Alex Williamson
  0 siblings, 0 replies; 13+ messages in thread
From: Alex Williamson @ 2004-04-08 16:41 UTC (permalink / raw)
  To: Paul Ionescu; +Cc: acpi

On Thu, 2004-04-08 at 09:46, Paul Ionescu wrote:
> Hi Alex,
> 
> I think I found a little bug:
> 
> cat _SB/PCI0/LCP/UART/_EJD
> gives me: _SB.PCI0.PCI1.DOC
> and it should give _SB.PCI0.PCI1.DOCK (I searched in the DSDT)
> 
> So I think that _EJD function is eating the last byte.

   Yep, I wasn't accounting for the '\0' snprintf wants to put at the
end.  If you make drivers/acpi/scan.c:parse_string() look like this it
should work:

static ssize_t
parse_string(char *buf, u32 length, char *pointer, unsigned int flags) {
	length += 2;
	return snprintf(buf, length, "%s\n", pointer);
}

I could probably just use an sprintf, but I was being paranoid that
firmware might not terminate the string.  I'll fix it in the next
version.  Thanks,

	Alex

-- 
Alex Williamson                             HP Linux & Open Source Lab



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC] filling in ACPI files in sysfs
       [not found]     ` <1081376023.2748.15.camel-Wmjt7DDUnIVxnVILBQAtiA@public.gmane.org>
  2004-04-08  5:56       ` Paul Ionescu
  2004-04-08 15:46       ` Paul Ionescu
@ 2004-04-08 16:53       ` Paul Ionescu
  2004-04-08 17:25       ` Matthew Wilcox
  3 siblings, 0 replies; 13+ messages in thread
From: Paul Ionescu @ 2004-04-08 16:53 UTC (permalink / raw)
  To: Alex Williamson; +Cc: acpi

Hi Alex,

I was browsing my DSDT when I found out that I really have in it
description for DOCK.IDE1.MSTR, DOCK.CBS2 and DOCK.CBS3, but they don't
appear in my /sys/firmware/... unless I booted in docking station.
Is this normal ? I thought that it should be like the battery thing, if
is in DSDT, then we should have it, even if it is not present at the
boot time.

Thanks,
Paul




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC] filling in ACPI files in sysfs
       [not found]     ` <1081376023.2748.15.camel-Wmjt7DDUnIVxnVILBQAtiA@public.gmane.org>
                         ` (2 preceding siblings ...)
  2004-04-08 16:53       ` Paul Ionescu
@ 2004-04-08 17:25       ` Matthew Wilcox
       [not found]         ` <20040408172548.GH18329-+pPCBgu9SkPzIGdyhVEDUDl5KyyQGfY2kSSpQ9I8OhVaa/9Udqfwiw@public.gmane.org>
  3 siblings, 1 reply; 13+ messages in thread
From: Matthew Wilcox @ 2004-04-08 17:25 UTC (permalink / raw)
  To: Alex Williamson; +Cc: Paul Ionescu, acpi

On Wed, Apr 07, 2004 at 04:13:43PM -0600, Alex Williamson wrote:
>    Here you go, a second iteration.  I haven't looked at the _Qxx
> methods yet, but we're up to over 30 methods exported now.  I've added
> several writable methods so you can do more than query status.  I've
> been able to undock my omnibook 500 laptop (electromechanical eject) and
> switch between a CRT and LCD using only the sysfs interface.  I thought
> about parsing some of the more complicated data structures, but that
> turned into way too much code too quickly.  So you'll find there are
> several entries that return a binary dump of the data structures.  these
> include _CRS, _PRS, _PRT, and _MAT.  Some of the methods look like they
> should work, but I don't have a box w/ firmware that exports them, so
> let me know if the output is broken.  Thanks,

Ii'm not a big fan of overloading acpi_device_read_file ... how about
splitting it up like this?

diff -u edited/drivers/acpi/scan.c b/drivers/acpi/scan.c
--- edited/drivers/acpi/scan.c	Wed Apr  7 15:55:17 2004
+++ b/drivers/acpi/scan.c	8 Apr 2004 15:49:40 -0000
@@ -146,61 +146,86 @@
 	ssize_t retval = 0;
 	unsigned int flags = 0;
 
-	if (!strcmp(method, METHOD_NAME__CRS)) {
-		status = acpi_get_current_resources(device->handle, &buffer);
-		if (ACPI_FAILURE(status))
-			return -ENODEV;
-
-		memcpy(buf, buffer.pointer, buffer.length);
-		retval = buffer.length;
-		acpi_os_free(buffer.pointer);
-	} else if (!strcmp(method, METHOD_NAME__PRS)) {
-		status = acpi_get_possible_resources(device->handle, &buffer);
-		if (ACPI_FAILURE(status))
-			return -ENODEV;
-
-		memcpy(buf, buffer.pointer, buffer.length);
-		retval = buffer.length;
-		acpi_os_free(buffer.pointer);
-	} else if (!strcmp(method, METHOD_NAME__PRT)) {
-		status = acpi_get_irq_routing_table(device->handle, &buffer);
-		if (ACPI_FAILURE(status))
-			return -ENODEV;
-
-		memcpy(buf, buffer.pointer, buffer.length);
-		retval = buffer.length;
-		acpi_os_free(buffer.pointer);
-	} else if (!strcmp(method, METHOD_NAME__MAT)) {
-		status = acpi_evaluate_object(device->handle, method,
-		                              NULL, &buffer);
-		if (ACPI_FAILURE(status))
-			return -ENODEV;
-
-		memcpy(buf, buffer.pointer, buffer.length);
-		retval = buffer.length;
-		acpi_os_free(buffer.pointer);
-	} else {
-		status = acpi_evaluate_object(device->handle, method,
-		                              NULL, &buffer);
-		if (ACPI_FAILURE(status))
-			return -ENODEV;
-	
-		if (!strcmp(method, METHOD_NAME__HID)
-		    || !strcmp(method, METHOD_NAME__CID)
-		    || !strcmp(method, METHOD_NAME__FIX))
-			flags |= EISA_ID_TYPE;
-
-		if (!strcmp(method, METHOD_NAME__STR))
-			flags |= UNICODE_TYPE;
-
-		element = (union acpi_object *) buffer.pointer;
-		retval = parse_element(buf, element, flags);
-		acpi_os_free(buffer.pointer);
-	}
+	status = acpi_evaluate_object(device->handle, method, NULL, &buffer);
+	if (ACPI_FAILURE(status))
+		return -ENODEV;
+
+	if (!strcmp(method, METHOD_NAME__HID)
+	    || !strcmp(method, METHOD_NAME__CID)
+	    || !strcmp(method, METHOD_NAME__FIX))
+		flags = EISA_ID_TYPE;
+
+	if (!strcmp(method, METHOD_NAME__STR))
+		flags = UNICODE_TYPE;
+
+	element = (union acpi_object *) buffer.pointer;
+	retval = parse_element(buf, element, flags);
+	acpi_os_free(buffer.pointer);
+
 	return retval;
 }
 
 static ssize_t
+acpi_device_read_raw(struct acpi_device *device, char *method, char *buf)
+{
+	acpi_status status;
+	struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+
+	status = acpi_evaluate_object(device->handle, method, NULL, &buffer);
+	if (ACPI_FAILURE(status))
+		return -ENODEV;
+
+	memcpy(buf, buffer.pointer, buffer.length);
+	acpi_os_free(buffer.pointer);
+	return buffer.length;
+}
+
+static ssize_t
+acpi_device_read_crs(struct acpi_device *device, char *method, char *buf)
+{
+	acpi_status status;
+	struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+
+	status = acpi_get_current_resources(device->handle, &buffer);
+	if (ACPI_FAILURE(status))
+		return -ENODEV;
+
+	memcpy(buf, buffer.pointer, buffer.length);
+	acpi_os_free(buffer.pointer);
+	return buffer.length;
+}
+
+static ssize_t
+acpi_device_read_prs(struct acpi_device *device, char *method, char *buf)
+{
+	acpi_status status;
+	struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+
+	status = acpi_get_possible_resources(device->handle, &buffer);
+	if (ACPI_FAILURE(status))
+		return -ENODEV;
+
+	memcpy(buf, buffer.pointer, buffer.length);
+	acpi_os_free(buffer.pointer);
+	return buffer.length;
+}
+
+static ssize_t
+acpi_device_read_prt(struct acpi_device *device, char *method, char *buf)
+{
+	acpi_status status;
+	struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+
+	status = acpi_get_irq_routing_table(device->handle, &buffer);
+	if (ACPI_FAILURE(status))
+		return -ENODEV;
+
+	memcpy(buf, buffer.pointer, buffer.length);
+	acpi_os_free(buffer.pointer);
+	return buffer.length;
+}
+
+static ssize_t
 acpi_device_write_integer (
 	struct acpi_device	*device,
 	char			*method,
@@ -237,7 +262,7 @@
 acpi_handle_attr(_BCL, acpi_device_read_file, NULL)
 acpi_handle_attr(_BCM, NULL, acpi_device_write_integer)
 acpi_handle_attr(_CID, acpi_device_read_file, NULL)
-acpi_handle_attr(_CRS, acpi_device_read_file, NULL)
+acpi_handle_attr(_CRS, acpi_device_read_crs, NULL)
 acpi_handle_attr(_DCK, NULL, acpi_device_write_integer)
 acpi_handle_attr(_DCS, acpi_device_read_file, NULL)
 acpi_handle_attr(_DGS, acpi_device_read_file, NULL)
@@ -253,9 +278,9 @@
 acpi_handle_attr(_HPP, acpi_device_read_file, NULL)
 acpi_handle_attr(_LCK, NULL, acpi_device_write_integer)
 acpi_handle_attr(_LID, acpi_device_read_file, NULL)
-acpi_handle_attr(_MAT, acpi_device_read_file, NULL)
-acpi_handle_attr(_PRS, acpi_device_read_file, NULL)
-acpi_handle_attr(_PRT, acpi_device_read_file, NULL)
+acpi_handle_attr(_MAT, acpi_device_read_raw, NULL)
+acpi_handle_attr(_PRS, acpi_device_read_prs, NULL)
+acpi_handle_attr(_PRT, acpi_device_read_prt, NULL)
 acpi_handle_attr(_PXM, acpi_device_read_file, NULL)
 acpi_handle_attr(_RMV, acpi_device_read_file, NULL)
 acpi_handle_attr(_SEG, acpi_device_read_file, NULL)

-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC] filling in ACPI files in sysfs
       [not found]         ` <20040408172548.GH18329-+pPCBgu9SkPzIGdyhVEDUDl5KyyQGfY2kSSpQ9I8OhVaa/9Udqfwiw@public.gmane.org>
@ 2004-04-08 17:33           ` Alex Williamson
       [not found]             ` <1081536801.26073.120.camel@t40>
       [not found]             ` <1081536489.23178.113.camel@t40>
  0 siblings, 2 replies; 13+ messages in thread
From: Alex Williamson @ 2004-04-08 17:33 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Paul Ionescu, acpi

On Thu, 2004-04-08 at 11:25, Matthew Wilcox wrote:
> 
> Ii'm not a big fan of overloading acpi_device_read_file ... how about
> splitting it up like this?
> 

   Looks good to me, I'll incorporate the changes.  Thanks,

	Alex

-- 
Alex Williamson                             HP Linux & Open Source Lab



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC] filling in ACPI files in sysfs
       [not found]                 ` <1081537175.2694.11.camel-Wmjt7DDUnIVxnVILBQAtiA@public.gmane.org>
@ 2004-04-10 10:03                   ` Paul Ionescu
  0 siblings, 0 replies; 13+ messages in thread
From: Paul Ionescu @ 2004-04-10 10:03 UTC (permalink / raw)
  To: Alex Williamson, acpi

Hi Alex,

You are right, I have:
/sys/bus/pci/slots/4294967295 # find .
.
./test
./cur_bus_speed
./max_bus_speed
./address
./adapter
./latch
./attention
./power

When I boot in dock, the value of power and adapter is 1, when I boot
normaly, I have 0 in those files.
Now, I booted in DOCK, and I did an echo 0 > power, and surprise, it did
an electromechanicaly eject of dock !!!.
Anyway, echo-ing 1 again, does nothing for me. I expected to power the
pci slot again and find the coresponding device in there.
So, thanks for the tips, now I get back to playing with apci.

Paul


On Fri, 2004-04-09 at 21:59, Alex Williamson wrote:
> On Fri, 2004-04-09 at 12:53, Paul Ionescu wrote:
> > I also have an ACPI hotplug PCI slot in the laptop, because when I
> > insert acpiphp.ko module, it sais that it found and registered a slot.
> > Now, where do I find some info about that slot, or how can I play with
> > it ? I suppose it is the PCI slot from my dock.
> > I could not find any info about it in /proc or /sys.
> > Is there a standard name I should look for ?
> 
> 
>    PCI hotplug slots registered via the ACPI hotplug driver show up
> under /sys/bus/pci/slots.  There are a few things you can do w/ it via
> that interface.
> 
> 	Alex



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC] filling in ACPI files in sysfs
       [not found]                 ` <1081537087.2694.8.camel-Wmjt7DDUnIVxnVILBQAtiA@public.gmane.org>
@ 2004-04-10 11:36                   ` Paul Ionescu
  0 siblings, 0 replies; 13+ messages in thread
From: Paul Ionescu @ 2004-04-10 11:36 UTC (permalink / raw)
  To: Alex Williamson, acpi

Hi Alex,

I found this in scan.c:
/*
 * If the device is present, enabled, and functioning then
 * parse its scope (depth-first).  Note that we need to
 * represent absent devices to facilitate PnP notifications
 * -- but only the subtree head (not all of its children,
 * which will be enumerated when the parent is inserted).
 *
 * TBD: Need notifications and other detection mechanisms
 *      in place before we can fully implement this.
 */

This can be the reason I don't see the subdevices in DOCK but only the
DOCK, when the dock is not active. So till someone does the TBD, this is
the normal behaviour, ie subdevices don't show up unless the parent is
active at scan time.

What do you think ?



On Fri, 2004-04-09 at 21:58, Alex Williamson wrote:
> On Fri, 2004-04-09 at 12:48, Paul Ionescu wrote:
> > Hi Alex,
> > 
> > Do you have any ideea why I don't have IDE1, CBS2 and CBS3 in the tree
> > even if they are present in the DSDT ?
> > They appear only when I boot in the dock.
> 
>    No, I don't.  You can try adding chunks of code like this in the scan
> file:
> 
> {
>         char pathname[ACPI_PATHNAME_MAX] = {0};
>         struct acpi_buffer buffer = {0, NULL};
>         buffer.length = sizeof(pathname);
>         buffer.pointer = pathname;
>         acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
>         printk("%s() - [%s]\n", __FUNCTION__, pathname);
> }
> 
> *Fix the handle pointer to be appropriate, everything else should be
> self contained
> 
> I'd start with adding it inside the while loop at the top of 
> drivers/acpi/scan.c:acpi_bus_scan().  It's possible it's in the DSDT,
> but not activated for some reason.  I'll be interested to hear why it's
> not showing up.  Thanks,
> 
> 	Alex



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-04-10 11:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-08  8:14 [RFC] filling in ACPI files in sysfs Paul Ionescu
     [not found] ` <20040408081455.52935.qmail-BuYeCebq3BaA/QwVtaZbd3CJp6faPEW9@public.gmane.org>
2004-04-08 14:36   ` Alex Williamson
  -- strict thread matches above, loose matches on Subject: below --
2004-04-07 21:36 Paul Ionescu
     [not found] ` <1081373781.23176.30.camel-LjAuIDrFwz0@public.gmane.org>
2004-04-07 22:13   ` Alex Williamson
     [not found]     ` <1081376023.2748.15.camel-Wmjt7DDUnIVxnVILBQAtiA@public.gmane.org>
2004-04-08  5:56       ` Paul Ionescu
2004-04-08 15:46       ` Paul Ionescu
     [not found]         ` <1081439217.23176.70.camel-LjAuIDrFwz0@public.gmane.org>
2004-04-08 16:41           ` Alex Williamson
2004-04-08 16:53       ` Paul Ionescu
2004-04-08 17:25       ` Matthew Wilcox
     [not found]         ` <20040408172548.GH18329-+pPCBgu9SkPzIGdyhVEDUDl5KyyQGfY2kSSpQ9I8OhVaa/9Udqfwiw@public.gmane.org>
2004-04-08 17:33           ` Alex Williamson
     [not found]             ` <1081536801.26073.120.camel@t40>
     [not found]               ` <1081537175.2694.11.camel@patsy.fc.hp.com>
     [not found]                 ` <1081537175.2694.11.camel-Wmjt7DDUnIVxnVILBQAtiA@public.gmane.org>
2004-04-10 10:03                   ` Paul Ionescu
     [not found]             ` <1081536489.23178.113.camel@t40>
     [not found]               ` <1081537087.2694.8.camel@patsy.fc.hp.com>
     [not found]                 ` <1081537087.2694.8.camel-Wmjt7DDUnIVxnVILBQAtiA@public.gmane.org>
2004-04-10 11:36                   ` Paul Ionescu
2004-04-06 15:56 Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox