aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-03-19 06:53:55 -0400
committerPaul Mackerras <paulus@samba.org>2007-03-25 22:35:17 -0400
commit70b52b3869a31aab85241a1f998f9943a3905637 (patch)
tree3c6944c5545c206cc43b8c20f1b9fe150b7ac0e9 /drivers/macintosh
parent17e638bc28f2fdc9c0d3eebfb80fce43827b8d12 (diff)
[POWERPC] powermac: disallow pmu sleep notifiers from aborting sleep
Tracing through the code, no current PMU sleep notifier can abort sleep. Since no new PMU sleep notifiers should be added, this patch simplifies the code and removes the ability to abort sleep. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: 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.c42
-rw-r--r--drivers/macintosh/apm_emu.c13
-rw-r--r--drivers/macintosh/via-pmu-led.c4
-rw-r--r--drivers/macintosh/via-pmu.c36
4 files changed, 20 insertions, 75 deletions
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index f729eebf771..adfea3c7c62 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -90,7 +90,7 @@ static int autopoll_devs;
90int __adb_probe_sync; 90int __adb_probe_sync;
91 91
92#ifdef CONFIG_PM 92#ifdef CONFIG_PM
93static int adb_notify_sleep(struct pmu_sleep_notifier *self, int when); 93static void adb_notify_sleep(struct pmu_sleep_notifier *self, int when);
94static struct pmu_sleep_notifier adb_sleep_notifier = { 94static struct pmu_sleep_notifier adb_sleep_notifier = {
95 adb_notify_sleep, 95 adb_notify_sleep,
96 SLEEP_LEVEL_ADB, 96 SLEEP_LEVEL_ADB,
@@ -340,11 +340,9 @@ __initcall(adb_init);
340/* 340/*
341 * notify clients before sleep and reset bus afterwards 341 * notify clients before sleep and reset bus afterwards
342 */ 342 */
343int 343void
344adb_notify_sleep(struct pmu_sleep_notifier *self, int when) 344adb_notify_sleep(struct pmu_sleep_notifier *self, int when)
345{ 345{
346 int ret;
347
348 switch (when) { 346 switch (when) {
349 case PBOOK_SLEEP_REQUEST: 347 case PBOOK_SLEEP_REQUEST:
350 adb_got_sleep = 1; 348 adb_got_sleep = 1;
@@ -353,22 +351,8 @@ adb_notify_sleep(struct pmu_sleep_notifier *self, int when)
353 /* Stop autopoll */ 351 /* Stop autopoll */
354 if (adb_controller->autopoll) 352 if (adb_controller->autopoll)
355 adb_controller->autopoll(0); 353 adb_controller->autopoll(0);
356 ret = blocking_notifier_call_chain(&adb_client_list, 354 blocking_notifier_call_chain(&adb_client_list,
357 ADB_MSG_POWERDOWN, NULL); 355 ADB_MSG_POWERDOWN, NULL);
358 if (ret & NOTIFY_STOP_MASK) {
359 up(&adb_probe_mutex);
360 return PBOOK_SLEEP_REFUSE;
361 }
362 break;
363 case PBOOK_SLEEP_REJECT:
364 if (adb_got_sleep) {
365 adb_got_sleep = 0;
366 up(&adb_probe_mutex);
367 adb_reset_bus();
368 }
369 break;
370
371 case PBOOK_SLEEP_NOW:
372 break; 356 break;
373 case PBOOK_WAKE: 357 case PBOOK_WAKE:
374 adb_got_sleep = 0; 358 adb_got_sleep = 0;
@@ -376,14 +360,13 @@ adb_notify_sleep(struct pmu_sleep_notifier *self, int when)
376 adb_reset_bus(); 360 adb_reset_bus();
377 break; 361 break;
378 } 362 }
379 return PBOOK_SLEEP_OK;
380} 363}
381#endif /* CONFIG_PM */ 364#endif /* CONFIG_PM */
382 365
383static int 366static int
384do_adb_reset_bus(void) 367do_adb_reset_bus(void)
385{ 368{
386 int ret, nret; 369 int ret;
387 370
388 if (adb_controller == NULL) 371 if (adb_controller == NULL)
389 return -ENXIO; 372 return -ENXIO;
@@ -391,13 +374,8 @@ do_adb_reset_bus(void)
391 if (adb_controller->autopoll) 374 if (adb_controller->autopoll)
392 adb_controller->autopoll(0); 375 adb_controller->autopoll(0);
393 376
394 nret = blocking_notifier_call_chain(&adb_client_list, 377 blocking_notifier_call_chain(&adb_client_list,
395 ADB_MSG_PRE_RESET, NULL); 378 ADB_MSG_PRE_RESET, NULL);
396 if (nret & NOTIFY_STOP_MASK) {
397 if (adb_controller->autopoll)
398 adb_controller->autopoll(autopoll_devs);
399 return -EBUSY;
400 }
401 379
402 if (sleepy_trackpad) { 380 if (sleepy_trackpad) {
403 /* Let the trackpad settle down */ 381 /* Let the trackpad settle down */
@@ -427,10 +405,8 @@ do_adb_reset_bus(void)
427 } 405 }
428 up(&adb_handler_sem); 406 up(&adb_handler_sem);
429 407
430 nret = blocking_notifier_call_chain(&adb_client_list, 408 blocking_notifier_call_chain(&adb_client_list,
431 ADB_MSG_POST_RESET, NULL); 409 ADB_MSG_POST_RESET, NULL);
432 if (nret & NOTIFY_STOP_MASK)
433 return -EBUSY;
434 410
435 return ret; 411 return ret;
436} 412}
diff --git a/drivers/macintosh/apm_emu.c b/drivers/macintosh/apm_emu.c
index c5e4d43f97f..cdb0bead991 100644
--- a/drivers/macintosh/apm_emu.c
+++ b/drivers/macintosh/apm_emu.c
@@ -96,7 +96,7 @@ static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
96static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue); 96static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
97static struct apm_user * user_list; 97static struct apm_user * user_list;
98 98
99static int apm_notify_sleep(struct pmu_sleep_notifier *self, int when); 99static void apm_notify_sleep(struct pmu_sleep_notifier *self, int when);
100static struct pmu_sleep_notifier apm_sleep_notifier = { 100static struct pmu_sleep_notifier apm_sleep_notifier = {
101 apm_notify_sleep, 101 apm_notify_sleep,
102 SLEEP_LEVEL_USERLAND, 102 SLEEP_LEVEL_USERLAND,
@@ -352,7 +352,7 @@ static int do_open(struct inode * inode, struct file * filp)
352 * doesn't provide a way to NAK, but this could be added 352 * doesn't provide a way to NAK, but this could be added
353 * here. 353 * here.
354 */ 354 */
355static int wait_all_suspend(void) 355static void wait_all_suspend(void)
356{ 356{
357 DECLARE_WAITQUEUE(wait, current); 357 DECLARE_WAITQUEUE(wait, current);
358 358
@@ -366,24 +366,19 @@ static int wait_all_suspend(void)
366 remove_wait_queue(&apm_suspend_waitqueue, &wait); 366 remove_wait_queue(&apm_suspend_waitqueue, &wait);
367 367
368 DBG("apm_emu: wait_all_suspend() - complete !\n"); 368 DBG("apm_emu: wait_all_suspend() - complete !\n");
369
370 return 1;
371} 369}
372 370
373static int apm_notify_sleep(struct pmu_sleep_notifier *self, int when) 371static void apm_notify_sleep(struct pmu_sleep_notifier *self, int when)
374{ 372{
375 switch(when) { 373 switch(when) {
376 case PBOOK_SLEEP_REQUEST: 374 case PBOOK_SLEEP_REQUEST:
377 queue_event(APM_SYS_SUSPEND, NULL); 375 queue_event(APM_SYS_SUSPEND, NULL);
378 if (!wait_all_suspend()) 376 wait_all_suspend();
379 return PBOOK_SLEEP_REFUSE;
380 break; 377 break;
381 case PBOOK_SLEEP_REJECT:
382 case PBOOK_WAKE: 378 case PBOOK_WAKE:
383 queue_event(APM_NORMAL_RESUME, NULL); 379 queue_event(APM_NORMAL_RESUME, NULL);
384 break; 380 break;
385 } 381 }
386 return PBOOK_SLEEP_OK;
387} 382}
388 383
389#define APM_CRITICAL 10 384#define APM_CRITICAL 10
diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c
index 179af10105d..ed8423f4605 100644
--- a/drivers/macintosh/via-pmu-led.c
+++ b/drivers/macintosh/via-pmu-led.c
@@ -81,7 +81,7 @@ static struct led_classdev pmu_led = {
81}; 81};
82 82
83#ifdef CONFIG_PM 83#ifdef CONFIG_PM
84static int pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when) 84static void pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when)
85{ 85{
86 unsigned long flags; 86 unsigned long flags;
87 87
@@ -99,8 +99,6 @@ static int pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when)
99 break; 99 break;
100 } 100 }
101 spin_unlock_irqrestore(&pmu_blink_lock, flags); 101 spin_unlock_irqrestore(&pmu_blink_lock, flags);
102
103 return PBOOK_SLEEP_OK;
104} 102}
105 103
106static struct pmu_sleep_notifier via_pmu_led_sleep_notif = { 104static struct pmu_sleep_notifier via_pmu_led_sleep_notif = {
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index b6073bdb50c..ca3c4aba5a2 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -1769,35 +1769,21 @@ EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
1769#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 1769#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
1770 1770
1771/* Sleep is broadcast last-to-first */ 1771/* Sleep is broadcast last-to-first */
1772static int 1772static void broadcast_sleep(int when)
1773broadcast_sleep(int when, int fallback)
1774{ 1773{
1775 int ret = PBOOK_SLEEP_OK;
1776 struct list_head *list; 1774 struct list_head *list;
1777 struct pmu_sleep_notifier *notifier; 1775 struct pmu_sleep_notifier *notifier;
1778 1776
1779 for (list = sleep_notifiers.prev; list != &sleep_notifiers; 1777 for (list = sleep_notifiers.prev; list != &sleep_notifiers;
1780 list = list->prev) { 1778 list = list->prev) {
1781 notifier = list_entry(list, struct pmu_sleep_notifier, list); 1779 notifier = list_entry(list, struct pmu_sleep_notifier, list);
1782 ret = notifier->notifier_call(notifier, when); 1780 notifier->notifier_call(notifier, when);
1783 if (ret != PBOOK_SLEEP_OK) {
1784 printk(KERN_DEBUG "sleep %d rejected by %p (%p)\n",
1785 when, notifier, notifier->notifier_call);
1786 for (; list != &sleep_notifiers; list = list->next) {
1787 notifier = list_entry(list, struct pmu_sleep_notifier, list);
1788 notifier->notifier_call(notifier, fallback);
1789 }
1790 return ret;
1791 }
1792 } 1781 }
1793 return ret;
1794} 1782}
1795 1783
1796/* Wake is broadcast first-to-last */ 1784/* Wake is broadcast first-to-last */
1797static int 1785static void broadcast_wake(void)
1798broadcast_wake(void)
1799{ 1786{
1800 int ret = PBOOK_SLEEP_OK;
1801 struct list_head *list; 1787 struct list_head *list;
1802 struct pmu_sleep_notifier *notifier; 1788 struct pmu_sleep_notifier *notifier;
1803 1789
@@ -1806,7 +1792,6 @@ broadcast_wake(void)
1806 notifier = list_entry(list, struct pmu_sleep_notifier, list); 1792 notifier = list_entry(list, struct pmu_sleep_notifier, list);
1807 notifier->notifier_call(notifier, PBOOK_WAKE); 1793 notifier->notifier_call(notifier, PBOOK_WAKE);
1808 } 1794 }
1809 return ret;
1810} 1795}
1811 1796
1812/* 1797/*
@@ -2013,12 +1998,8 @@ pmac_suspend_devices(void)
2013 1998
2014 pm_prepare_console(); 1999 pm_prepare_console();
2015 2000
2016 /* Notify old-style device drivers & userland */ 2001 /* Notify old-style device drivers */
2017 ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT); 2002 broadcast_sleep(PBOOK_SLEEP_REQUEST);
2018 if (ret != PBOOK_SLEEP_OK) {
2019 printk(KERN_ERR "Sleep rejected by drivers\n");
2020 return -EBUSY;
2021 }
2022 2003
2023 /* Sync the disks. */ 2004 /* Sync the disks. */
2024 /* XXX It would be nice to have some way to ensure that 2005 /* XXX It would be nice to have some way to ensure that
@@ -2028,12 +2009,7 @@ pmac_suspend_devices(void)
2028 */ 2009 */
2029 sys_sync(); 2010 sys_sync();
2030 2011
2031 /* Sleep can fail now. May not be very robust but useful for debugging */ 2012 broadcast_sleep(PBOOK_SLEEP_NOW);
2032 ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
2033 if (ret != PBOOK_SLEEP_OK) {
2034 printk(KERN_ERR "Driver sleep failed\n");
2035 return -EBUSY;
2036 }
2037 2013
2038 /* Send suspend call to devices, hold the device core's dpm_sem */ 2014 /* Send suspend call to devices, hold the device core's dpm_sem */
2039 ret = device_suspend(PMSG_SUSPEND); 2015 ret = device_suspend(PMSG_SUSPEND);