aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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 /drivers
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/Kconfig1
-rw-r--r--drivers/misc/thinkpad_acpi.c54
-rw-r--r--drivers/misc/thinkpad_acpi.h8
3 files changed, 63 insertions, 0 deletions
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;