From ac122bb64b0d51f0512185d3522a75f3f3a80bc9 Mon Sep 17 00:00:00 2001 From: "Ilya A. Volynets-Evenbakh" Date: Mon, 19 Feb 2007 15:19:31 -0800 Subject: ACPI: dock: add access to ACPI docking station UID It is useful to know whether your laptop is docked or not, but it is even more useful to know which docking station it's docked to. Attached patch adds "uid" file to sysfs. Tested on Dell Latitude D600 with D/Dock. Patch is against official 2.6.20 release. Signed-off-by: Len Brown --- drivers/acpi/dock.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'drivers') diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 54a697f9aa1..811b1aac65d 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -667,6 +667,23 @@ static ssize_t write_undock(struct device *dev, struct device_attribute *attr, } DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock); +/* + * show_dock_uid - read method for "uid" file in sysfs + */ +static ssize_t show_dock_uid(struct device *dev, + struct device_attribute *attr, char *buf) +{ + unsigned long lbuf; + acpi_status status = acpi_evaluate_integer(dock_station->handle, "_UID", 0, &lbuf); + if(ACPI_FAILURE(status)) { + return 0; + } + return snprintf(buf, PAGE_SIZE, "%lx\n", lbuf); +} +DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL); + + + /** * dock_add - add a new dock station * @handle: the dock station handle @@ -715,6 +732,13 @@ static int dock_add(acpi_handle handle) kfree(dock_station); return ret; } + ret = device_create_file(&dock_device.dev, &dev_attr_uid); + if (ret) { + printk("Error %d adding sysfs file\n", ret); + platform_device_unregister(&dock_device); + kfree(dock_station); + return ret; + } /* Find dependent devices */ acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, -- cgit v1.2.3 From 62a6d7fd9bc1d85f9aae734c46234e88fa839db0 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 26 Mar 2007 21:38:49 -0800 Subject: ACPI: dock: use NULL for pointer Use NULL instead of 0 for pointers: drivers/acpi/dock.c:677:75: warning: Using plain integer as NULL pointer Signed-off-by: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/dock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 811b1aac65d..4546bf873ae 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -674,7 +675,7 @@ static ssize_t show_dock_uid(struct device *dev, struct device_attribute *attr, char *buf) { unsigned long lbuf; - acpi_status status = acpi_evaluate_integer(dock_station->handle, "_UID", 0, &lbuf); + acpi_status status = acpi_evaluate_integer(dock_station->handle, "_UID", NULL, &lbuf); if(ACPI_FAILURE(status)) { return 0; } -- cgit v1.2.3