aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--include/linux/pmu.h12
-rw-r--r--sound/oss/dmasound/dmasound_awacs.c5
6 files changed, 24 insertions, 88 deletions
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index f729eebf771f..adfea3c7c62a 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 c5e4d43f97fc..cdb0bead9917 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 179af10105d9..ed8423f4605d 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 b6073bdb50c3..ca3c4aba5a22 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);
diff --git a/include/linux/pmu.h b/include/linux/pmu.h
index 783177387ac6..b0952e532ed5 100644
--- a/include/linux/pmu.h
+++ b/include/linux/pmu.h
@@ -168,24 +168,16 @@ extern int pmu_get_model(void);
168 168
169struct pmu_sleep_notifier 169struct pmu_sleep_notifier
170{ 170{
171 int (*notifier_call)(struct pmu_sleep_notifier *self, int when); 171 void (*notifier_call)(struct pmu_sleep_notifier *self, int when);
172 int priority; 172 int priority;
173 struct list_head list; 173 struct list_head list;
174}; 174};
175 175
176/* Code values for calling sleep/wakeup handlers 176/* Code values for calling sleep/wakeup handlers
177 *
178 * Note: If a sleep request got cancelled, all drivers will get
179 * the PBOOK_SLEEP_REJECT, even those who didn't get the PBOOK_SLEEP_REQUEST.
180 */ 177 */
181#define PBOOK_SLEEP_REQUEST 1 178#define PBOOK_SLEEP_REQUEST 1
182#define PBOOK_SLEEP_NOW 2 179#define PBOOK_SLEEP_NOW 2
183#define PBOOK_SLEEP_REJECT 3 180#define PBOOK_WAKE 3
184#define PBOOK_WAKE 4
185
186/* Result codes returned by the notifiers */
187#define PBOOK_SLEEP_OK 0
188#define PBOOK_SLEEP_REFUSE -1
189 181
190/* priority levels in notifiers */ 182/* priority levels in notifiers */
191#define SLEEP_LEVEL_VIDEO 100 /* Video driver (first wake) */ 183#define SLEEP_LEVEL_VIDEO 100 /* Video driver (first wake) */
diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c
index 37773b1deea5..f8a49bd17a13 100644
--- a/sound/oss/dmasound/dmasound_awacs.c
+++ b/sound/oss/dmasound/dmasound_awacs.c
@@ -257,7 +257,7 @@ static volatile struct dbdma_cmd *emergency_dbdma_cmd;
257/* 257/*
258 * Stuff for restoring after a sleep. 258 * Stuff for restoring after a sleep.
259 */ 259 */
260static int awacs_sleep_notify(struct pmu_sleep_notifier *self, int when); 260static void awacs_sleep_notify(struct pmu_sleep_notifier *self, int when);
261struct pmu_sleep_notifier awacs_sleep_notifier = { 261struct pmu_sleep_notifier awacs_sleep_notifier = {
262 awacs_sleep_notify, SLEEP_LEVEL_SOUND, 262 awacs_sleep_notify, SLEEP_LEVEL_SOUND,
263}; 263};
@@ -1419,7 +1419,7 @@ load_awacs(void)
1419 * Save state when going to sleep, restore it afterwards. 1419 * Save state when going to sleep, restore it afterwards.
1420 */ 1420 */
1421/* FIXME: sort out disabling/re-enabling of read stuff as well */ 1421/* FIXME: sort out disabling/re-enabling of read stuff as well */
1422static int awacs_sleep_notify(struct pmu_sleep_notifier *self, int when) 1422static void awacs_sleep_notify(struct pmu_sleep_notifier *self, int when)
1423{ 1423{
1424 unsigned long flags; 1424 unsigned long flags;
1425 1425
@@ -1548,7 +1548,6 @@ static int awacs_sleep_notify(struct pmu_sleep_notifier *self, int when)
1548 spin_unlock_irqrestore(&dmasound.lock, flags); 1548 spin_unlock_irqrestore(&dmasound.lock, flags);
1549 UNLOCK(); 1549 UNLOCK();
1550 } 1550 }
1551 return PBOOK_SLEEP_OK;
1552} 1551}
1553#endif /* CONFIG_PM */ 1552#endif /* CONFIG_PM */
1554 1553