diff options
author | Henrique de Moraes Holschuh <hmh@hmh.eng.br> | 2007-04-24 10:48:12 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-04-25 02:00:27 -0400 |
commit | 54ae15014c306b3d7ad32c996fea9a5ac8560b60 (patch) | |
tree | be9760b8447cf37a33395a8a9be688ccc4ed2171 | |
parent | 99fba3f8177956170f3d86f83c2cf2f70747105f (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.txt | 40 | ||||
-rw-r--r-- | drivers/misc/Kconfig | 1 | ||||
-rw-r--r-- | drivers/misc/thinkpad_acpi.c | 54 | ||||
-rw-r--r-- | drivers/misc/thinkpad_acpi.h | 8 |
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. | |||
67 | Features | 67 | Features |
68 | -------- | 68 | -------- |
69 | 69 | ||
70 | The driver creates the /proc/acpi/ibm directory. There is a file under | 70 | The driver exports two different interfaces to userspace, which can be |
71 | that directory for each feature described below. Note that while the | 71 | used to access the features it provides. One is a legacy procfs-based |
72 | driver is still in the alpha stage, the exact proc file format and | 72 | interface, which will be removed at some time in the distant future. |
73 | commands supported by the various features is guaranteed to change | 73 | The other is a new sysfs-based interface which is not complete yet. |
74 | frequently. | 74 | |
75 | The procfs interface creates the /proc/acpi/ibm directory. There is a | ||
76 | file under that directory for each feature it supports. The procfs | ||
77 | interface is mostly frozen, and will change very little if at all: it | ||
78 | will not be extended to add any new functionality in the driver, instead | ||
79 | all new functionality will be implemented on the sysfs interface. | ||
80 | |||
81 | The sysfs interface tries to blend in the generic Linux sysfs subsystems | ||
82 | and classes as much as possible. Since some of these subsystems are not | ||
83 | yet ready or stabilized, it is expected that this interface will change, | ||
84 | and any and all userspace programs must deal with it. | ||
85 | |||
86 | |||
87 | Notes about the sysfs interface: | ||
88 | |||
89 | Unlike what was done with the procfs interface, correctness when talking | ||
90 | to the sysfs interfaces will be enforced, as will correctness in the | ||
91 | thinkpad-acpi's implementation of sysfs interfaces. | ||
92 | |||
93 | Also, any bugs in the thinkpad-acpi sysfs driver code or in the | ||
94 | thinkpad-acpi's implementation of the sysfs interfaces will be fixed for | ||
95 | maximum correctness, even if that means changing an interface in | ||
96 | non-compatible ways. As these interfaces mature both in the kernel and | ||
97 | in thinkpad-acpi, such changes should become quite rare. | ||
98 | |||
99 | Applications interfacing to the thinkpad-acpi sysfs interfaces must | ||
100 | follow all sysfs guidelines and correctly process all errors (the sysfs | ||
101 | interface makes extensive use of errors). File descriptors and open / | ||
102 | close operations to the sysfs inodes must also be properly implemented. | ||
75 | 103 | ||
76 | Driver version -- /proc/acpi/ibm/driver | 104 | Driver 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 | |||
485 | static struct platform_device *tpacpi_pdev = NULL; | ||
486 | static struct class_device *tpacpi_hwmon = NULL; | ||
487 | |||
488 | static 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); |
131 | static char *next_cmd(char **cmds); | 134 | static char *next_cmd(char **cmds); |
132 | 135 | ||
136 | /* Device model */ | ||
137 | static struct platform_device *tpacpi_pdev; | ||
138 | static struct class_device *tpacpi_hwmon; | ||
139 | static struct platform_driver tpacpi_pdriver; | ||
140 | |||
133 | /* Module */ | 141 | /* Module */ |
134 | static int experimental; | 142 | static int experimental; |
135 | static u32 dbg_level; | 143 | static u32 dbg_level; |