diff options
| author | Johannes Berg <johannes@sipsolutions.net> | 2007-12-11 09:21:25 -0500 |
|---|---|---|
| committer | Paul Mackerras <paulus@samba.org> | 2007-12-18 23:00:29 -0500 |
| commit | c9f6d3d5c6d4f4cd3a53549a69c92951180e2a76 (patch) | |
| tree | 91efe11af8b64b830819f7f4fabda6a28d6b5a2b /drivers/macintosh | |
| parent | 9fb1e350e16164d56990dde036ae9c0a2fd3f634 (diff) | |
[POWERPC] adb: Replace sleep notifier with platform driver suspend/resume hooks
This replaces the pmu sleep notifier that adb had with suspend/resume
hooks in a new platform driver/device.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'drivers/macintosh')
| -rw-r--r-- | drivers/macintosh/adb.c | 96 |
1 files changed, 57 insertions, 39 deletions
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index 5c742a52608..7b892f4a8e8 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c | |||
| @@ -89,14 +89,6 @@ static int sleepy_trackpad; | |||
| 89 | static int autopoll_devs; | 89 | static int autopoll_devs; |
| 90 | int __adb_probe_sync; | 90 | int __adb_probe_sync; |
| 91 | 91 | ||
| 92 | #ifdef CONFIG_PM_SLEEP | ||
| 93 | static void adb_notify_sleep(struct pmu_sleep_notifier *self, int when); | ||
| 94 | static struct pmu_sleep_notifier adb_sleep_notifier = { | ||
| 95 | adb_notify_sleep, | ||
| 96 | SLEEP_LEVEL_ADB, | ||
| 97 | }; | ||
| 98 | #endif | ||
| 99 | |||
| 100 | static int adb_scan_bus(void); | 92 | static int adb_scan_bus(void); |
| 101 | static int do_adb_reset_bus(void); | 93 | static int do_adb_reset_bus(void); |
| 102 | static void adbdev_init(void); | 94 | static void adbdev_init(void); |
| @@ -281,6 +273,36 @@ adb_reset_bus(void) | |||
| 281 | return 0; | 273 | return 0; |
| 282 | } | 274 | } |
| 283 | 275 | ||
| 276 | #ifdef CONFIG_PM | ||
| 277 | /* | ||
| 278 | * notify clients before sleep | ||
| 279 | */ | ||
| 280 | static int adb_suspend(struct platform_device *dev, pm_message_t state) | ||
| 281 | { | ||
| 282 | adb_got_sleep = 1; | ||
| 283 | /* We need to get a lock on the probe thread */ | ||
| 284 | down(&adb_probe_mutex); | ||
| 285 | /* Stop autopoll */ | ||
| 286 | if (adb_controller->autopoll) | ||
| 287 | adb_controller->autopoll(0); | ||
| 288 | blocking_notifier_call_chain(&adb_client_list, ADB_MSG_POWERDOWN, NULL); | ||
| 289 | |||
| 290 | return 0; | ||
| 291 | } | ||
| 292 | |||
| 293 | /* | ||
| 294 | * reset bus after sleep | ||
| 295 | */ | ||
| 296 | static int adb_resume(struct platform_device *dev) | ||
| 297 | { | ||
| 298 | adb_got_sleep = 0; | ||
| 299 | up(&adb_probe_mutex); | ||
| 300 | adb_reset_bus(); | ||
| 301 | |||
| 302 | return 0; | ||
| 303 | } | ||
| 304 | #endif /* CONFIG_PM */ | ||
| 305 | |||
| 284 | int __init adb_init(void) | 306 | int __init adb_init(void) |
| 285 | { | 307 | { |
| 286 | struct adb_driver *driver; | 308 | struct adb_driver *driver; |
| @@ -313,14 +335,12 @@ int __init adb_init(void) | |||
| 313 | printk(KERN_WARNING "Warning: no ADB interface detected\n"); | 335 | printk(KERN_WARNING "Warning: no ADB interface detected\n"); |
| 314 | adb_controller = NULL; | 336 | adb_controller = NULL; |
| 315 | } else { | 337 | } else { |
| 316 | #ifdef CONFIG_PM_SLEEP | ||
| 317 | pmu_register_sleep_notifier(&adb_sleep_notifier); | ||
| 318 | #endif /* CONFIG_PM */ | ||
| 319 | #ifdef CONFIG_PPC | 338 | #ifdef CONFIG_PPC |
| 320 | if (machine_is_compatible("AAPL,PowerBook1998") || | 339 | if (machine_is_compatible("AAPL,PowerBook1998") || |
| 321 | machine_is_compatible("PowerBook1,1")) | 340 | machine_is_compatible("PowerBook1,1")) |
| 322 | sleepy_trackpad = 1; | 341 | sleepy_trackpad = 1; |
| 323 | #endif /* CONFIG_PPC */ | 342 | #endif /* CONFIG_PPC */ |
| 343 | |||
| 324 | init_completion(&adb_probe_task_comp); | 344 | init_completion(&adb_probe_task_comp); |
| 325 | adbdev_init(); | 345 | adbdev_init(); |
| 326 | adb_reset_bus(); | 346 | adb_reset_bus(); |
| @@ -330,33 +350,6 @@ int __init adb_init(void) | |||
| 330 | 350 | ||
| 331 | __initcall(adb_init); | 351 | __initcall(adb_init); |
| 332 | 352 | ||
| 333 | #ifdef CONFIG_PM | ||
| 334 | /* | ||
| 335 | * notify clients before sleep and reset bus afterwards | ||
| 336 | */ | ||
| 337 | void | ||
| 338 | adb_notify_sleep(struct pmu_sleep_notifier *self, int when) | ||
| 339 | { | ||
| 340 | switch (when) { | ||
| 341 | case PBOOK_SLEEP_REQUEST: | ||
| 342 | adb_got_sleep = 1; | ||
| 343 | /* We need to get a lock on the probe thread */ | ||
| 344 | down(&adb_probe_mutex); | ||
| 345 | /* Stop autopoll */ | ||
| 346 | if (adb_controller->autopoll) | ||
| 347 | adb_controller->autopoll(0); | ||
| 348 | blocking_notifier_call_chain(&adb_client_list, | ||
| 349 | ADB_MSG_POWERDOWN, NULL); | ||
| 350 | break; | ||
| 351 | case PBOOK_WAKE: | ||
| 352 | adb_got_sleep = 0; | ||
| 353 | up(&adb_probe_mutex); | ||
| 354 | adb_reset_bus(); | ||
| 355 | break; | ||
| 356 | } | ||
| 357 | } | ||
| 358 | #endif /* CONFIG_PM */ | ||
| 359 | |||
| 360 | static int | 353 | static int |
| 361 | do_adb_reset_bus(void) | 354 | do_adb_reset_bus(void) |
| 362 | { | 355 | { |
| @@ -864,7 +857,29 @@ static const struct file_operations adb_fops = { | |||
| 864 | .release = adb_release, | 857 | .release = adb_release, |
| 865 | }; | 858 | }; |
| 866 | 859 | ||
| 867 | static void | 860 | static struct platform_driver adb_pfdrv = { |
| 861 | .driver = { | ||
| 862 | .name = "adb", | ||
| 863 | }, | ||
| 864 | #ifdef CONFIG_PM | ||
| 865 | .suspend = adb_suspend, | ||
| 866 | .resume = adb_resume, | ||
| 867 | #endif | ||
| 868 | }; | ||
| 869 | |||
| 870 | static struct platform_device adb_pfdev = { | ||
| 871 | .name = "adb", | ||
| 872 | }; | ||
| 873 | |||
| 874 | static int __init | ||
| 875 | adb_dummy_probe(struct platform_device *dev) | ||
| 876 | { | ||
| 877 | if (dev == &adb_pfdev) | ||
| 878 | return 0; | ||
| 879 | return -ENODEV; | ||
| 880 | } | ||
| 881 | |||
| 882 | static void __init | ||
| 868 | adbdev_init(void) | 883 | adbdev_init(void) |
| 869 | { | 884 | { |
| 870 | if (register_chrdev(ADB_MAJOR, "adb", &adb_fops)) { | 885 | if (register_chrdev(ADB_MAJOR, "adb", &adb_fops)) { |
| @@ -876,4 +891,7 @@ adbdev_init(void) | |||
| 876 | if (IS_ERR(adb_dev_class)) | 891 | if (IS_ERR(adb_dev_class)) |
| 877 | return; | 892 | return; |
| 878 | class_device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb"); | 893 | class_device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb"); |
| 894 | |||
| 895 | platform_device_register(&adb_pfdev); | ||
| 896 | platform_driver_probe(&adb_pfdrv, adb_dummy_probe); | ||
| 879 | } | 897 | } |
