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 /drivers/misc/thinkpad_acpi.c | |
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>
Diffstat (limited to 'drivers/misc/thinkpad_acpi.c')
-rw-r--r-- | drivers/misc/thinkpad_acpi.c | 54 |
1 files changed, 54 insertions, 0 deletions
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 | ||