diff options
author | Henrique de Moraes Holschuh <hmh@hmh.eng.br> | 2007-04-24 14:48:12 (GMT) |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-04-25 06:00:27 (GMT) |
commit | 54ae15014c306b3d7ad32c996fea9a5ac8560b60 (patch) | |
tree | be9760b8447cf37a33395a8a9be688ccc4ed2171 /drivers/misc | |
parent | 99fba3f8177956170f3d86f83c2cf2f70747105f (diff) | |
download | linux-54ae15014c306b3d7ad32c996fea9a5ac8560b60.tar.xz |
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/misc')
-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 |
3 files changed, 63 insertions, 0 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 44e4c8f..445c4b1 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -126,6 +126,7 @@ config THINKPAD_ACPI tristate "ThinkPad ACPI Laptop Extras" depends on X86 && ACPI select BACKLIGHT_CLASS_DEVICE + select HWMON ---help--- This is a driver for the IBM and Lenovo ThinkPad laptops. It adds support for Fn-Fx key combinations, Bluetooth control, video diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 9b4eea4..e47eaf7 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c @@ -477,6 +477,25 @@ static char *next_cmd(char **cmds) /**************************************************************************** **************************************************************************** * + * Device model: hwmon and platform + * + **************************************************************************** + ****************************************************************************/ + +static struct platform_device *tpacpi_pdev = NULL; +static struct class_device *tpacpi_hwmon = NULL; + +static struct platform_driver tpacpi_pdriver = { + .driver = { + .name = IBM_DRVR_NAME, + .owner = THIS_MODULE, + }, +}; + + +/**************************************************************************** + **************************************************************************** + * * Subdrivers * **************************************************************************** @@ -3225,10 +3244,12 @@ static int __init thinkpad_acpi_module_init(void) { int ret, i; + /* Driver-level probe */ ret = probe_for_thinkpad(); if (ret) return ret; + /* Driver initialization */ ibm_thinkpad_ec_found = check_dmi_for_ec(); IBM_ACPIHANDLE_INIT(ecrd); IBM_ACPIHANDLE_INIT(ecwr); @@ -3241,6 +3262,31 @@ static int __init thinkpad_acpi_module_init(void) } proc_dir->owner = THIS_MODULE; + ret = platform_driver_register(&tpacpi_pdriver); + if (ret) { + printk(IBM_ERR "unable to register platform driver\n"); + thinkpad_acpi_module_exit(); + return ret; + } + + /* Device initialization */ + tpacpi_pdev = platform_device_register_simple(IBM_DRVR_NAME, -1, + NULL, 0); + if (IS_ERR(tpacpi_pdev)) { + ret = PTR_ERR(tpacpi_pdev); + tpacpi_pdev = NULL; + printk(IBM_ERR "unable to register platform device\n"); + thinkpad_acpi_module_exit(); + return ret; + } + tpacpi_hwmon = hwmon_device_register(&tpacpi_pdev->dev); + if (IS_ERR(tpacpi_hwmon)) { + ret = PTR_ERR(tpacpi_hwmon); + tpacpi_hwmon = NULL; + printk(IBM_ERR "unable to register hwmon device\n"); + thinkpad_acpi_module_exit(); + return ret; + } for (i = 0; i < ARRAY_SIZE(ibms_init); i++) { ret = ibm_init(&ibms_init[i]); if (ret >= 0 && *ibms_init[i].param) @@ -3266,6 +3312,14 @@ static void thinkpad_acpi_module_exit(void) dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n"); + if (tpacpi_hwmon) + hwmon_device_unregister(tpacpi_hwmon); + + if (tpacpi_pdev) + platform_device_unregister(tpacpi_pdev); + + platform_driver_unregister(&tpacpi_pdriver); + if (proc_dir) remove_proc_entry(IBM_PROC_DIR, acpi_root_dir); diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h index 6432b28..fea58099 100644 --- a/drivers/misc/thinkpad_acpi.h +++ b/drivers/misc/thinkpad_acpi.h @@ -34,6 +34,8 @@ #include <linux/proc_fs.h> #include <linux/backlight.h> #include <linux/fb.h> +#include <linux/platform_device.h> +#include <linux/hwmon.h> #include <asm/uaccess.h> #include <linux/dmi.h> @@ -56,6 +58,7 @@ #define IBM_PROC_DIR "ibm" #define IBM_ACPI_EVENT_PREFIX "ibm" +#define IBM_DRVR_NAME IBM_FILE #define IBM_LOG IBM_FILE ": " #define IBM_ERR KERN_ERR IBM_LOG @@ -130,6 +133,11 @@ static int dispatch_procfs_write(struct file *file, unsigned long count, void *data); static char *next_cmd(char **cmds); +/* Device model */ +static struct platform_device *tpacpi_pdev; +static struct class_device *tpacpi_hwmon; +static struct platform_driver tpacpi_pdriver; + /* Module */ static int experimental; static u32 dbg_level; |