aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2007-04-24 10:48:12 -0400
committerLen Brown <len.brown@intel.com>2007-04-25 02:00:27 -0400
commit54ae15014c306b3d7ad32c996fea9a5ac8560b60 (patch)
treebe9760b8447cf37a33395a8a9be688ccc4ed2171
parent99fba3f8177956170f3d86f83c2cf2f70747105f (diff)
ACPI: thinkpad-acpi: register with the device model
Register thinkpad-acpi platform driver and platform device for the device model. Also register the platform device with the hwmon class. Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--Documentation/thinkpad-acpi.txt40
-rw-r--r--drivers/misc/Kconfig1
-rw-r--r--drivers/misc/thinkpad_acpi.c54
-rw-r--r--drivers/misc/thinkpad_acpi.h8
4 files changed, 97 insertions, 6 deletions
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index 1a42b77e2ece..0e4e053cface 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -1,7 +1,7 @@
1 ThinkPad ACPI Extras Driver 1 ThinkPad ACPI Extras Driver
2 2
3 Version 0.14 3 Version 0.14
4 March 26th, 2007 4 April 21st, 2007
5 5
6 Borislav Deianov <borislav@users.sf.net> 6 Borislav Deianov <borislav@users.sf.net>
7 Henrique de Moraes Holschuh <hmh@hmh.eng.br> 7 Henrique de Moraes Holschuh <hmh@hmh.eng.br>
@@ -67,11 +67,39 @@ thinkpad-specific bay functionality.
67Features 67Features
68-------- 68--------
69 69
70The driver creates the /proc/acpi/ibm directory. There is a file under 70The driver exports two different interfaces to userspace, which can be
71that directory for each feature described below. Note that while the 71used to access the features it provides. One is a legacy procfs-based
72driver is still in the alpha stage, the exact proc file format and 72interface, which will be removed at some time in the distant future.
73commands supported by the various features is guaranteed to change 73The other is a new sysfs-based interface which is not complete yet.
74frequently. 74
75The procfs interface creates the /proc/acpi/ibm directory. There is a
76file under that directory for each feature it supports. The procfs
77interface is mostly frozen, and will change very little if at all: it
78will not be extended to add any new functionality in the driver, instead
79all new functionality will be implemented on the sysfs interface.
80
81The sysfs interface tries to blend in the generic Linux sysfs subsystems
82and classes as much as possible. Since some of these subsystems are not
83yet ready or stabilized, it is expected that this interface will change,
84and any and all userspace programs must deal with it.
85
86
87Notes about the sysfs interface:
88
89Unlike what was done with the procfs interface, correctness when talking
90to the sysfs interfaces will be enforced, as will correctness in the
91thinkpad-acpi's implementation of sysfs interfaces.
92
93Also, any bugs in the thinkpad-acpi sysfs driver code or in the
94thinkpad-acpi's implementation of the sysfs interfaces will be fixed for
95maximum correctness, even if that means changing an interface in
96non-compatible ways. As these interfaces mature both in the kernel and
97in thinkpad-acpi, such changes should become quite rare.
98
99Applications interfacing to the thinkpad-acpi sysfs interfaces must
100follow all sysfs guidelines and correctly process all errors (the sysfs
101interface makes extensive use of errors). File descriptors and open /
102close operations to the sysfs inodes must also be properly implemented.
75 103
76Driver version -- /proc/acpi/ibm/driver 104Driver version -- /proc/acpi/ibm/driver
77--------------------------------------- 105---------------------------------------
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 44e4c8fb7a74..445c4b10c41e 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -126,6 +126,7 @@ config THINKPAD_ACPI
126 tristate "ThinkPad ACPI Laptop Extras" 126 tristate "ThinkPad ACPI Laptop Extras"
127 depends on X86 && ACPI 127 depends on X86 && ACPI
128 select BACKLIGHT_CLASS_DEVICE 128 select BACKLIGHT_CLASS_DEVICE
129 select HWMON
129 ---help--- 130 ---help---
130 This is a driver for the IBM and Lenovo ThinkPad laptops. It adds 131 This is a driver for the IBM and Lenovo ThinkPad laptops. It adds
131 support for Fn-Fx key combinations, Bluetooth control, video 132 support for Fn-Fx key combinations, Bluetooth control, video
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 9b4eea4c8ff7..e47eaf72763d 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -477,6 +477,25 @@ static char *next_cmd(char **cmds)
477/**************************************************************************** 477/****************************************************************************
478 **************************************************************************** 478 ****************************************************************************
479 * 479 *
480 * Device model: hwmon and platform
481 *
482 ****************************************************************************
483 ****************************************************************************/
484
485static struct platform_device *tpacpi_pdev = NULL;
486static struct class_device *tpacpi_hwmon = NULL;
487
488static struct platform_driver tpacpi_pdriver = {
489 .driver = {
490 .name = IBM_DRVR_NAME,
491 .owner = THIS_MODULE,
492 },
493};
494
495
496/****************************************************************************
497 ****************************************************************************
498 *
480 * Subdrivers 499 * Subdrivers
481 * 500 *
482 **************************************************************************** 501 ****************************************************************************
@@ -3225,10 +3244,12 @@ static int __init thinkpad_acpi_module_init(void)
3225{ 3244{
3226 int ret, i; 3245 int ret, i;
3227 3246
3247 /* Driver-level probe */
3228 ret = probe_for_thinkpad(); 3248 ret = probe_for_thinkpad();
3229 if (ret) 3249 if (ret)
3230 return ret; 3250 return ret;
3231 3251
3252 /* Driver initialization */
3232 ibm_thinkpad_ec_found = check_dmi_for_ec(); 3253 ibm_thinkpad_ec_found = check_dmi_for_ec();
3233 IBM_ACPIHANDLE_INIT(ecrd); 3254 IBM_ACPIHANDLE_INIT(ecrd);
3234 IBM_ACPIHANDLE_INIT(ecwr); 3255 IBM_ACPIHANDLE_INIT(ecwr);
@@ -3241,6 +3262,31 @@ static int __init thinkpad_acpi_module_init(void)
3241 } 3262 }
3242 proc_dir->owner = THIS_MODULE; 3263 proc_dir->owner = THIS_MODULE;
3243 3264
3265 ret = platform_driver_register(&tpacpi_pdriver);
3266 if (ret) {
3267 printk(IBM_ERR "unable to register platform driver\n");
3268 thinkpad_acpi_module_exit();
3269 return ret;
3270 }
3271
3272 /* Device initialization */
3273 tpacpi_pdev = platform_device_register_simple(IBM_DRVR_NAME, -1,
3274 NULL, 0);
3275 if (IS_ERR(tpacpi_pdev)) {
3276 ret = PTR_ERR(tpacpi_pdev);
3277 tpacpi_pdev = NULL;
3278 printk(IBM_ERR "unable to register platform device\n");
3279 thinkpad_acpi_module_exit();
3280 return ret;
3281 }
3282 tpacpi_hwmon = hwmon_device_register(&tpacpi_pdev->dev);
3283 if (IS_ERR(tpacpi_hwmon)) {
3284 ret = PTR_ERR(tpacpi_hwmon);
3285 tpacpi_hwmon = NULL;
3286 printk(IBM_ERR "unable to register hwmon device\n");
3287 thinkpad_acpi_module_exit();
3288 return ret;
3289 }
3244 for (i = 0; i < ARRAY_SIZE(ibms_init); i++) { 3290 for (i = 0; i < ARRAY_SIZE(ibms_init); i++) {
3245 ret = ibm_init(&ibms_init[i]); 3291 ret = ibm_init(&ibms_init[i]);
3246 if (ret >= 0 && *ibms_init[i].param) 3292 if (ret >= 0 && *ibms_init[i].param)
@@ -3266,6 +3312,14 @@ static void thinkpad_acpi_module_exit(void)
3266 3312
3267 dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n"); 3313 dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n");
3268 3314
3315 if (tpacpi_hwmon)
3316 hwmon_device_unregister(tpacpi_hwmon);
3317
3318 if (tpacpi_pdev)
3319 platform_device_unregister(tpacpi_pdev);
3320
3321 platform_driver_unregister(&tpacpi_pdriver);
3322
3269 if (proc_dir) 3323 if (proc_dir)
3270 remove_proc_entry(IBM_PROC_DIR, acpi_root_dir); 3324 remove_proc_entry(IBM_PROC_DIR, acpi_root_dir);
3271 3325
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 6432b28339af..fea580999e94 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -34,6 +34,8 @@
34#include <linux/proc_fs.h> 34#include <linux/proc_fs.h>
35#include <linux/backlight.h> 35#include <linux/backlight.h>
36#include <linux/fb.h> 36#include <linux/fb.h>
37#include <linux/platform_device.h>
38#include <linux/hwmon.h>
37#include <asm/uaccess.h> 39#include <asm/uaccess.h>
38 40
39#include <linux/dmi.h> 41#include <linux/dmi.h>
@@ -56,6 +58,7 @@
56 58
57#define IBM_PROC_DIR "ibm" 59#define IBM_PROC_DIR "ibm"
58#define IBM_ACPI_EVENT_PREFIX "ibm" 60#define IBM_ACPI_EVENT_PREFIX "ibm"
61#define IBM_DRVR_NAME IBM_FILE
59 62
60#define IBM_LOG IBM_FILE ": " 63#define IBM_LOG IBM_FILE ": "
61#define IBM_ERR KERN_ERR IBM_LOG 64#define IBM_ERR KERN_ERR IBM_LOG
@@ -130,6 +133,11 @@ static int dispatch_procfs_write(struct file *file,
130 unsigned long count, void *data); 133 unsigned long count, void *data);
131static char *next_cmd(char **cmds); 134static char *next_cmd(char **cmds);
132 135
136/* Device model */
137static struct platform_device *tpacpi_pdev;
138static struct class_device *tpacpi_hwmon;
139static struct platform_driver tpacpi_pdriver;
140
133/* Module */ 141/* Module */
134static int experimental; 142static int experimental;
135static u32 dbg_level; 143static u32 dbg_level;