[POWERPC] powermac: disallow pmu sleep notifiers from aborting sleep
[powerpc.git] / drivers / macintosh / via-pmu.c
index eb6653f..ca3c4ab 100644 (file)
@@ -141,13 +141,13 @@ static volatile int adb_int_pending;
 static volatile int disable_poll;
 static struct device_node *vias;
 static int pmu_kind = PMU_UNKNOWN;
-static int pmu_fully_inited = 0;
+static int pmu_fully_inited;
 static int pmu_has_adb;
 static struct device_node *gpio_node;
-static unsigned char __iomem *gpio_reg = NULL;
+static unsigned char __iomem *gpio_reg;
 static int gpio_irq = NO_IRQ;
 static int gpio_irq_enabled = -1;
-static volatile int pmu_suspended = 0;
+static volatile int pmu_suspended;
 static spinlock_t pmu_lock;
 static u8 pmu_intr_mask;
 static int pmu_version;
@@ -169,7 +169,7 @@ static int option_server_mode;
 
 int pmu_battery_count;
 int pmu_cur_battery;
-unsigned int pmu_power_flags;
+unsigned int pmu_power_flags = PMU_PWR_AC_PRESENT;
 struct pmu_battery_info pmu_batteries[PMU_MAX_BATTERIES];
 static int query_batt_timer = BATTERY_POLLING_COUNT;
 static struct adb_request batt_req;
@@ -180,7 +180,7 @@ int asleep;
 BLOCKING_NOTIFIER_HEAD(sleep_notifier_list);
 
 #ifdef CONFIG_ADB
-static int adb_dev_map = 0;
+static int adb_dev_map;
 static int pmu_adb_flags;
 
 static int pmu_probe(void);
@@ -1769,35 +1769,21 @@ EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
 #if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 
 /* Sleep is broadcast last-to-first */
-static int
-broadcast_sleep(int when, int fallback)
+static void broadcast_sleep(int when)
 {
-       int ret = PBOOK_SLEEP_OK;
        struct list_head *list;
        struct pmu_sleep_notifier *notifier;
 
        for (list = sleep_notifiers.prev; list != &sleep_notifiers;
             list = list->prev) {
                notifier = list_entry(list, struct pmu_sleep_notifier, list);
-               ret = notifier->notifier_call(notifier, when);
-               if (ret != PBOOK_SLEEP_OK) {
-                       printk(KERN_DEBUG "sleep %d rejected by %p (%p)\n",
-                              when, notifier, notifier->notifier_call);
-                       for (; list != &sleep_notifiers; list = list->next) {
-                               notifier = list_entry(list, struct pmu_sleep_notifier, list);
-                               notifier->notifier_call(notifier, fallback);
-                       }
-                       return ret;
-               }
+               notifier->notifier_call(notifier, when);
        }
-       return ret;
 }
 
 /* Wake is broadcast first-to-last */
-static int
-broadcast_wake(void)
+static void broadcast_wake(void)
 {
-       int ret = PBOOK_SLEEP_OK;
        struct list_head *list;
        struct pmu_sleep_notifier *notifier;
 
@@ -1806,7 +1792,6 @@ broadcast_wake(void)
                notifier = list_entry(list, struct pmu_sleep_notifier, list);
                notifier->notifier_call(notifier, PBOOK_WAKE);
        }
-       return ret;
 }
 
 /*
@@ -2013,12 +1998,8 @@ pmac_suspend_devices(void)
 
        pm_prepare_console();
        
-       /* Notify old-style device drivers & userland */
-       ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT);
-       if (ret != PBOOK_SLEEP_OK) {
-               printk(KERN_ERR "Sleep rejected by drivers\n");
-               return -EBUSY;
-       }
+       /* Notify old-style device drivers */
+       broadcast_sleep(PBOOK_SLEEP_REQUEST);
 
        /* Sync the disks. */
        /* XXX It would be nice to have some way to ensure that
@@ -2028,12 +2009,7 @@ pmac_suspend_devices(void)
         */
        sys_sync();
 
-       /* Sleep can fail now. May not be very robust but useful for debugging */
-       ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
-       if (ret != PBOOK_SLEEP_OK) {
-               printk(KERN_ERR "Driver sleep failed\n");
-               return -EBUSY;
-       }
+       broadcast_sleep(PBOOK_SLEEP_NOW);
 
        /* Send suspend call to devices, hold the device core's dpm_sem */
        ret = device_suspend(PMSG_SUSPEND);
@@ -2672,7 +2648,7 @@ pmu_ioctl(struct inode * inode, struct file *filp,
        return error;
 }
 
-static struct file_operations pmu_device_fops = {
+static const struct file_operations pmu_device_fops = {
        .read           = pmu_read,
        .write          = pmu_write,
        .poll           = pmu_fpoll,
@@ -2776,7 +2752,7 @@ pmu_polled_request(struct adb_request *req)
 
 #if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 
-static int pmu_sys_suspended = 0;
+static int pmu_sys_suspended;
 
 static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state)
 {
@@ -2816,7 +2792,6 @@ static struct sysdev_class pmu_sysclass = {
 };
 
 static struct sys_device device_pmu = {
-       .id             = 0,
        .cls            = &pmu_sysclass,
 };