diff options
-rw-r--r-- | Documentation/thinkpad-acpi.txt | 42 | ||||
-rw-r--r-- | drivers/misc/thinkpad_acpi.c | 90 | ||||
-rw-r--r-- | drivers/misc/thinkpad_acpi.h | 3 |
3 files changed, 133 insertions, 2 deletions
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt index 0e4e053cface..cc079afaf66b 100644 --- a/Documentation/thinkpad-acpi.txt +++ b/Documentation/thinkpad-acpi.txt | |||
@@ -101,11 +101,39 @@ follow all sysfs guidelines and correctly process all errors (the sysfs | |||
101 | interface makes extensive use of errors). File descriptors and open / | 101 | interface makes extensive use of errors). File descriptors and open / |
102 | close operations to the sysfs inodes must also be properly implemented. | 102 | close operations to the sysfs inodes must also be properly implemented. |
103 | 103 | ||
104 | Driver version -- /proc/acpi/ibm/driver | 104 | The version of thinkpad-acpi's sysfs interface is exported by the driver |
105 | --------------------------------------- | 105 | as a driver attribute (see below). |
106 | |||
107 | Sysfs driver attributes are on the driver's sysfs attribute space, | ||
108 | for 2.6.20 this is /sys/bus/platform/drivers/thinkpad-acpi/. | ||
109 | |||
110 | Sysfs device attributes are on the driver's sysfs attribute space, | ||
111 | for 2.6.20 this is /sys/devices/platform/thinkpad-acpi/. | ||
112 | |||
113 | Driver version | ||
114 | -------------- | ||
115 | |||
116 | procfs: /proc/acpi/ibm/driver | ||
117 | sysfs driver attribute: version | ||
106 | 118 | ||
107 | The driver name and version. No commands can be written to this file. | 119 | The driver name and version. No commands can be written to this file. |
108 | 120 | ||
121 | Sysfs interface version | ||
122 | ----------------------- | ||
123 | |||
124 | sysfs driver attribute: interface_version | ||
125 | |||
126 | Version of the thinkpad-acpi sysfs interface, as an unsigned long | ||
127 | (output in hex format: 0xAAAABBCC), where: | ||
128 | AAAA - major revision | ||
129 | BB - minor revision | ||
130 | CC - bugfix revision | ||
131 | |||
132 | The sysfs interface version changelog for the driver can be found at the | ||
133 | end of this document. Changes to the sysfs interface done by the kernel | ||
134 | subsystems are not documented here, nor are they tracked by this | ||
135 | attribute. | ||
136 | |||
109 | Hot keys -- /proc/acpi/ibm/hotkey | 137 | Hot keys -- /proc/acpi/ibm/hotkey |
110 | --------------------------------- | 138 | --------------------------------- |
111 | 139 | ||
@@ -745,9 +773,19 @@ to enable more than one output class, just add their values. | |||
745 | There is also a kernel build option to enable more debugging | 773 | There is also a kernel build option to enable more debugging |
746 | information, which may be necessary to debug driver problems. | 774 | information, which may be necessary to debug driver problems. |
747 | 775 | ||
776 | The level of debugging information output by the driver can be changed | ||
777 | at runtime through sysfs, using the driver attribute debug_level. The | ||
778 | attribute takes the same bitmask as the debug module parameter above. | ||
779 | |||
748 | Force loading of module | 780 | Force loading of module |
749 | ----------------------- | 781 | ----------------------- |
750 | 782 | ||
751 | If thinkpad-acpi refuses to detect your ThinkPad, you can try to specify | 783 | If thinkpad-acpi refuses to detect your ThinkPad, you can try to specify |
752 | the module parameter force_load=1. Regardless of whether this works or | 784 | the module parameter force_load=1. Regardless of whether this works or |
753 | not, please contact ibm-acpi-devel@lists.sourceforge.net with a report. | 785 | not, please contact ibm-acpi-devel@lists.sourceforge.net with a report. |
786 | |||
787 | |||
788 | Sysfs interface changelog: | ||
789 | |||
790 | 0x000100: Initial sysfs support, as a single platform driver and | ||
791 | device. | ||
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index e47eaf72763d..a31d00d570cb 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c | |||
@@ -22,6 +22,7 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | #define IBM_VERSION "0.14" | 24 | #define IBM_VERSION "0.14" |
25 | #define TPACPI_SYSFS_VERSION 0x000100 | ||
25 | 26 | ||
26 | /* | 27 | /* |
27 | * Changelog: | 28 | * Changelog: |
@@ -493,6 +494,87 @@ static struct platform_driver tpacpi_pdriver = { | |||
493 | }; | 494 | }; |
494 | 495 | ||
495 | 496 | ||
497 | /************************************************************************* | ||
498 | * thinkpad-acpi driver attributes | ||
499 | */ | ||
500 | |||
501 | /* interface_version --------------------------------------------------- */ | ||
502 | static ssize_t tpacpi_driver_interface_version_show( | ||
503 | struct device_driver *drv, | ||
504 | char *buf) | ||
505 | { | ||
506 | return snprintf(buf, PAGE_SIZE, "0x%08x\n", TPACPI_SYSFS_VERSION); | ||
507 | } | ||
508 | |||
509 | static DRIVER_ATTR(interface_version, S_IRUGO, | ||
510 | tpacpi_driver_interface_version_show, NULL); | ||
511 | |||
512 | /* debug_level --------------------------------------------------------- */ | ||
513 | static ssize_t tpacpi_driver_debug_show(struct device_driver *drv, | ||
514 | char *buf) | ||
515 | { | ||
516 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", dbg_level); | ||
517 | } | ||
518 | |||
519 | static ssize_t tpacpi_driver_debug_store(struct device_driver *drv, | ||
520 | const char *buf, size_t count) | ||
521 | { | ||
522 | unsigned long t; | ||
523 | char *endp; | ||
524 | |||
525 | t = simple_strtoul(buf, &endp, 0); | ||
526 | while (*endp && isspace(*endp)) | ||
527 | endp++; | ||
528 | if (*endp) | ||
529 | return -EINVAL; | ||
530 | |||
531 | dbg_level = t; | ||
532 | |||
533 | return count; | ||
534 | } | ||
535 | |||
536 | static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, | ||
537 | tpacpi_driver_debug_show, tpacpi_driver_debug_store); | ||
538 | |||
539 | /* version ------------------------------------------------------------- */ | ||
540 | static ssize_t tpacpi_driver_version_show(struct device_driver *drv, | ||
541 | char *buf) | ||
542 | { | ||
543 | return snprintf(buf, PAGE_SIZE, "%s v%s\n", IBM_DESC, IBM_VERSION); | ||
544 | } | ||
545 | |||
546 | static DRIVER_ATTR(version, S_IRUGO, | ||
547 | tpacpi_driver_version_show, NULL); | ||
548 | |||
549 | /* --------------------------------------------------------------------- */ | ||
550 | |||
551 | static struct driver_attribute* tpacpi_driver_attributes[] = { | ||
552 | &driver_attr_debug_level, &driver_attr_version, | ||
553 | &driver_attr_interface_version, | ||
554 | }; | ||
555 | |||
556 | static int __init tpacpi_create_driver_attributes(struct device_driver *drv) | ||
557 | { | ||
558 | int i, res; | ||
559 | |||
560 | i = 0; | ||
561 | res = 0; | ||
562 | while (!res && i < ARRAY_SIZE(tpacpi_driver_attributes)) { | ||
563 | res = driver_create_file(drv, tpacpi_driver_attributes[i]); | ||
564 | i++; | ||
565 | } | ||
566 | |||
567 | return res; | ||
568 | } | ||
569 | |||
570 | static void tpacpi_remove_driver_attributes(struct device_driver *drv) | ||
571 | { | ||
572 | int i; | ||
573 | |||
574 | for(i = 0; i < ARRAY_SIZE(tpacpi_driver_attributes); i++) | ||
575 | driver_remove_file(drv, tpacpi_driver_attributes[i]); | ||
576 | } | ||
577 | |||
496 | /**************************************************************************** | 578 | /**************************************************************************** |
497 | **************************************************************************** | 579 | **************************************************************************** |
498 | * | 580 | * |
@@ -3268,6 +3350,13 @@ static int __init thinkpad_acpi_module_init(void) | |||
3268 | thinkpad_acpi_module_exit(); | 3350 | thinkpad_acpi_module_exit(); |
3269 | return ret; | 3351 | return ret; |
3270 | } | 3352 | } |
3353 | ret = tpacpi_create_driver_attributes(&tpacpi_pdriver.driver); | ||
3354 | if (ret) { | ||
3355 | printk(IBM_ERR "unable to create sysfs driver attributes\n"); | ||
3356 | thinkpad_acpi_module_exit(); | ||
3357 | return ret; | ||
3358 | } | ||
3359 | |||
3271 | 3360 | ||
3272 | /* Device initialization */ | 3361 | /* Device initialization */ |
3273 | tpacpi_pdev = platform_device_register_simple(IBM_DRVR_NAME, -1, | 3362 | tpacpi_pdev = platform_device_register_simple(IBM_DRVR_NAME, -1, |
@@ -3318,6 +3407,7 @@ static void thinkpad_acpi_module_exit(void) | |||
3318 | if (tpacpi_pdev) | 3407 | if (tpacpi_pdev) |
3319 | platform_device_unregister(tpacpi_pdev); | 3408 | platform_device_unregister(tpacpi_pdev); |
3320 | 3409 | ||
3410 | tpacpi_remove_driver_attributes(&tpacpi_pdriver.driver); | ||
3321 | platform_driver_unregister(&tpacpi_pdriver); | 3411 | platform_driver_unregister(&tpacpi_pdriver); |
3322 | 3412 | ||
3323 | if (proc_dir) | 3413 | if (proc_dir) |
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h index fea580999e94..37860582956f 100644 --- a/drivers/misc/thinkpad_acpi.h +++ b/drivers/misc/thinkpad_acpi.h | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/list.h> | 32 | #include <linux/list.h> |
33 | 33 | ||
34 | #include <linux/proc_fs.h> | 34 | #include <linux/proc_fs.h> |
35 | #include <linux/sysfs.h> | ||
35 | #include <linux/backlight.h> | 36 | #include <linux/backlight.h> |
36 | #include <linux/fb.h> | 37 | #include <linux/fb.h> |
37 | #include <linux/platform_device.h> | 38 | #include <linux/platform_device.h> |
@@ -137,6 +138,8 @@ static char *next_cmd(char **cmds); | |||
137 | static struct platform_device *tpacpi_pdev; | 138 | static struct platform_device *tpacpi_pdev; |
138 | static struct class_device *tpacpi_hwmon; | 139 | static struct class_device *tpacpi_hwmon; |
139 | static struct platform_driver tpacpi_pdriver; | 140 | static struct platform_driver tpacpi_pdriver; |
141 | static int tpacpi_create_driver_attributes(struct device_driver *drv); | ||
142 | static void tpacpi_remove_driver_attributes(struct device_driver *drv); | ||
140 | 143 | ||
141 | /* Module */ | 144 | /* Module */ |
142 | static int experimental; | 145 | static int experimental; |