[PATCH] ppc: fix a bunch of warnings
[deliverable/linux.git] / drivers / macintosh / via-pmu.c
index b941ee220997adbc96b50b48862d0e47c687afda..7ebbc0f534201ab6f21985c8f628e20a4836c555 100644 (file)
 #include <asm/backlight.h>
 #endif
 
+#ifdef CONFIG_PPC32
+#include <asm/open_pic.h>
+#endif
+
 /* Some compile options */
 #undef SUSPEND_USES_PMU
 #define DEBUG_SLEEP
@@ -151,10 +155,10 @@ static spinlock_t pmu_lock;
 static u8 pmu_intr_mask;
 static int pmu_version;
 static int drop_interrupts;
-#ifdef CONFIG_PMAC_PBOOK
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 static int option_lid_wakeup = 1;
 static int sleep_in_progress;
-#endif /* CONFIG_PMAC_PBOOK */
+#endif /* CONFIG_PM && CONFIG_PPC32 */
 static unsigned long async_req_locks;
 static unsigned int pmu_irq_stats[11];
 
@@ -164,7 +168,6 @@ static struct proc_dir_entry *proc_pmu_irqstats;
 static struct proc_dir_entry *proc_pmu_options;
 static int option_server_mode;
 
-#ifdef CONFIG_PMAC_PBOOK
 int pmu_battery_count;
 int pmu_cur_battery;
 unsigned int pmu_power_flags;
@@ -172,7 +175,6 @@ struct pmu_battery_info pmu_batteries[PMU_MAX_BATTERIES];
 static int query_batt_timer = BATTERY_POLLING_COUNT;
 static struct adb_request batt_req;
 static struct proc_dir_entry *proc_pmu_batt[PMU_MAX_BATTERIES];
-#endif /* CONFIG_PMAC_PBOOK */
 
 #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
 extern int disable_kernel_backlight;
@@ -206,11 +208,9 @@ static int proc_get_irqstats(char *page, char **start, off_t off,
 static int pmu_set_backlight_level(int level, void* data);
 static int pmu_set_backlight_enable(int on, int level, void* data);
 #endif /* CONFIG_PMAC_BACKLIGHT */
-#ifdef CONFIG_PMAC_PBOOK
 static void pmu_pass_intr(unsigned char *data, int len);
 static int proc_get_batt(char *page, char **start, off_t off,
                        int count, int *eof, void *data);
-#endif /* CONFIG_PMAC_PBOOK */
 static int proc_read_options(char *page, char **start, off_t off,
                        int count, int *eof, void *data);
 static int proc_write_options(struct file *file, const char __user *buffer,
@@ -244,7 +244,7 @@ int pmu_wink(struct adb_request *req);
  * - the number of response bytes which the PMU will return, or
  *   -1 if it will send a length byte.
  */
-static const s8 pmu_data_len[256][2] __openfirmwaredata = {
+static const s8 pmu_data_len[256][2] = {
 /*        0       1       2       3       4       5       6       7  */
 /*00*/ {-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},
 /*08*/ {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
@@ -295,7 +295,7 @@ static struct backlight_controller pmu_backlight_controller = {
 };
 #endif /* CONFIG_PMAC_BACKLIGHT */
 
-int __openfirmware
+int
 find_via_pmu(void)
 {
        if (via != 0)
@@ -374,7 +374,7 @@ find_via_pmu(void)
 }
 
 #ifdef CONFIG_ADB
-static int __openfirmware
+static int
 pmu_probe(void)
 {
        return vias == NULL? -ENODEV: 0;
@@ -403,8 +403,12 @@ static int __init via_pmu_start(void)
 
        bright_req_1.complete = 1;
        bright_req_2.complete = 1;
-#ifdef CONFIG_PMAC_PBOOK
        batt_req.complete = 1;
+
+#if defined(CONFIG_PPC32) && !defined(CONFIG_PPC_MERGE)
+       if (pmu_kind == PMU_KEYLARGO_BASED)
+               openpic_set_irq_priority(vias->intrs[0].line,
+                                        OPENPIC_PRIORITY_DEFAULT + 1);
 #endif
 
        if (request_irq(vias->intrs[0].line, via_pmu_interrupt, 0, "VIA-PMU",
@@ -458,7 +462,7 @@ static int __init via_pmu_dev_init(void)
        register_backlight_controller(&pmu_backlight_controller, NULL, "pmu");
 #endif /* CONFIG_PMAC_BACKLIGHT */
 
-#ifdef CONFIG_PMAC_PBOOK
+#ifdef CONFIG_PPC32
        if (machine_is_compatible("AAPL,3400/2400") ||
                machine_is_compatible("AAPL,3500")) {
                int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO,
@@ -486,20 +490,19 @@ static int __init via_pmu_dev_init(void)
                                pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART;
                }
        }
-#endif /* CONFIG_PMAC_PBOOK */
+#endif /* CONFIG_PPC32 */
+
        /* Create /proc/pmu */
        proc_pmu_root = proc_mkdir("pmu", NULL);
        if (proc_pmu_root) {
-#ifdef CONFIG_PMAC_PBOOK
-               int i;
+               long i;
 
                for (i=0; i<pmu_battery_count; i++) {
                        char title[16];
-                       sprintf(title, "battery_%d", i);
+                       sprintf(title, "battery_%ld", i);
                        proc_pmu_batt[i] = create_proc_read_entry(title, 0, proc_pmu_root,
                                                proc_get_batt, (void *)i);
                }
-#endif /* CONFIG_PMAC_PBOOK */
 
                proc_pmu_info = create_proc_read_entry("info", 0, proc_pmu_root,
                                        proc_get_info, NULL);
@@ -517,7 +520,7 @@ static int __init via_pmu_dev_init(void)
 
 device_initcall(via_pmu_dev_init);
 
-static int __openfirmware
+static int
 init_pmu(void)
 {
        int timeout;
@@ -585,17 +588,6 @@ pmu_get_model(void)
        return pmu_kind;
 }
 
-#ifndef CONFIG_PPC64
-static inline void wakeup_decrementer(void)
-{
-       set_dec(tb_ticks_per_jiffy);
-       /* No currently-supported powerbook has a 601,
-        * so use get_tbl, not native
-        */
-       last_jiffy_stamp(0) = tb_last_stamp = get_tbl();
-}
-#endif
-
 static void pmu_set_server_mode(int server_mode)
 {
        struct adb_request req;
@@ -619,12 +611,10 @@ static void pmu_set_server_mode(int server_mode)
        pmu_wait_complete(&req);
 }
 
-#ifdef CONFIG_PMAC_PBOOK
-
 /* This new version of the code for 2400/3400/3500 powerbooks
  * is inspired from the implementation in gkrellm-pmu
  */
-static void __pmac
+static void
 done_battery_state_ohare(struct adb_request* req)
 {
        /* format:
@@ -712,7 +702,7 @@ done_battery_state_ohare(struct adb_request* req)
        clear_bit(0, &async_req_locks);
 }
 
-static void __pmac
+static void
 done_battery_state_smart(struct adb_request* req)
 {
        /* format:
@@ -790,7 +780,7 @@ done_battery_state_smart(struct adb_request* req)
        clear_bit(0, &async_req_locks);
 }
 
-static void __pmac
+static void
 query_battery_state(void)
 {
        if (test_and_set_bit(0, &async_req_locks))
@@ -803,9 +793,7 @@ query_battery_state(void)
                        2, PMU_SMART_BATTERY_STATE, pmu_cur_battery+1);
 }
 
-#endif /* CONFIG_PMAC_PBOOK */
-
-static int __pmac
+static int
 proc_get_info(char *page, char **start, off_t off,
                int count, int *eof, void *data)
 {
@@ -813,16 +801,14 @@ proc_get_info(char *page, char **start, off_t off,
 
        p += sprintf(p, "PMU driver version     : %d\n", PMU_DRIVER_VERSION);
        p += sprintf(p, "PMU firmware version   : %02x\n", pmu_version);
-#ifdef CONFIG_PMAC_PBOOK
        p += sprintf(p, "AC Power               : %d\n",
                ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0));
        p += sprintf(p, "Battery count          : %d\n", pmu_battery_count);
-#endif /* CONFIG_PMAC_PBOOK */
 
        return p - page;
 }
 
-static int __pmac
+static int
 proc_get_irqstats(char *page, char **start, off_t off,
                  int count, int *eof, void *data)
 {
@@ -849,12 +835,11 @@ proc_get_irqstats(char *page, char **start, off_t off,
        return p - page;
 }
 
-#ifdef CONFIG_PMAC_PBOOK
-static int __pmac
+static int
 proc_get_batt(char *page, char **start, off_t off,
                int count, int *eof, void *data)
 {
-       int batnum = (int)data;
+       long batnum = (long)data;
        char *p = page;
        
        p += sprintf(p, "\n");
@@ -873,26 +858,25 @@ proc_get_batt(char *page, char **start, off_t off,
 
        return p - page;
 }
-#endif /* CONFIG_PMAC_PBOOK */
 
-static int __pmac
+static int
 proc_read_options(char *page, char **start, off_t off,
                        int count, int *eof, void *data)
 {
        char *p = page;
 
-#ifdef CONFIG_PMAC_PBOOK
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
        if (pmu_kind == PMU_KEYLARGO_BASED &&
            pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0)
                p += sprintf(p, "lid_wakeup=%d\n", option_lid_wakeup);
-#endif /* CONFIG_PMAC_PBOOK */
+#endif
        if (pmu_kind == PMU_KEYLARGO_BASED)
                p += sprintf(p, "server_mode=%d\n", option_server_mode);
 
        return p - page;
 }
                        
-static int __pmac
+static int
 proc_write_options(struct file *file, const char __user *buffer,
                        unsigned long count, void *data)
 {
@@ -922,12 +906,12 @@ proc_write_options(struct file *file, const char __user *buffer,
        *(val++) = 0;
        while(*val == ' ')
                val++;
-#ifdef CONFIG_PMAC_PBOOK
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
        if (pmu_kind == PMU_KEYLARGO_BASED &&
            pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0)
                if (!strcmp(label, "lid_wakeup"))
                        option_lid_wakeup = ((*val) == '1');
-#endif /* CONFIG_PMAC_PBOOK */
+#endif
        if (pmu_kind == PMU_KEYLARGO_BASED && !strcmp(label, "server_mode")) {
                int new_value;
                new_value = ((*val) == '1');
@@ -939,7 +923,7 @@ proc_write_options(struct file *file, const char __user *buffer,
 
 #ifdef CONFIG_ADB
 /* Send an ADB command */
-static int __pmac
+static int
 pmu_send_request(struct adb_request *req, int sync)
 {
        int i, ret;
@@ -1019,7 +1003,7 @@ pmu_send_request(struct adb_request *req, int sync)
 }
 
 /* Enable/disable autopolling */
-static int __pmac
+static int
 pmu_adb_autopoll(int devs)
 {
        struct adb_request req;
@@ -1042,7 +1026,7 @@ pmu_adb_autopoll(int devs)
 }
 
 /* Reset the ADB bus */
-static int __pmac
+static int
 pmu_adb_reset_bus(void)
 {
        struct adb_request req;
@@ -1077,7 +1061,7 @@ pmu_adb_reset_bus(void)
 #endif /* CONFIG_ADB */
 
 /* Construct and send a pmu request */
-int __openfirmware
+int
 pmu_request(struct adb_request *req, void (*done)(struct adb_request *),
            int nbytes, ...)
 {
@@ -1103,7 +1087,7 @@ pmu_request(struct adb_request *req, void (*done)(struct adb_request *),
        return pmu_queue_request(req);
 }
 
-int __pmac
+int
 pmu_queue_request(struct adb_request *req)
 {
        unsigned long flags;
@@ -1195,7 +1179,7 @@ pmu_done(struct adb_request *req)
                (*done)(req);
 }
 
-static void __pmac
+static void
 pmu_start(void)
 {
        struct adb_request *req;
@@ -1219,7 +1203,7 @@ pmu_start(void)
        send_byte(req->data[0]);
 }
 
-void __openfirmware
+void
 pmu_poll(void)
 {
        if (!via)
@@ -1229,7 +1213,7 @@ pmu_poll(void)
        via_pmu_interrupt(0, NULL, NULL);
 }
 
-void __openfirmware
+void
 pmu_poll_adb(void)
 {
        if (!via)
@@ -1244,7 +1228,7 @@ pmu_poll_adb(void)
                || req_awaiting_reply));
 }
 
-void __openfirmware
+void
 pmu_wait_complete(struct adb_request *req)
 {
        if (!via)
@@ -1258,7 +1242,7 @@ pmu_wait_complete(struct adb_request *req)
  * This is done to avoid spurrious shutdowns when we know we'll have
  * interrupts switched off for a long time
  */
-void __openfirmware
+void
 pmu_suspend(void)
 {
        unsigned long flags;
@@ -1298,7 +1282,7 @@ pmu_suspend(void)
        } while (1);
 }
 
-void __openfirmware
+void
 pmu_resume(void)
 {
        unsigned long flags;
@@ -1328,7 +1312,7 @@ pmu_resume(void)
 }
 
 /* Interrupt data could be the result data from an ADB cmd */
-static void __pmac
+static void
 pmu_handle_data(unsigned char *data, int len, struct pt_regs *regs)
 {
        unsigned char ints, pirq;
@@ -1422,7 +1406,6 @@ next:
        }
        /* Tick interrupt */
        else if ((1 << pirq) & PMU_INT_TICK) {
-#ifdef CONFIG_PMAC_PBOOK
                /* Environement or tick interrupt, query batteries */
                if (pmu_battery_count) {
                        if ((--query_batt_timer) == 0) {
@@ -1437,12 +1420,11 @@ next:
                pmu_pass_intr(data, len);
        } else {
               pmu_pass_intr(data, len);
-#endif /* CONFIG_PMAC_PBOOK */
        }
        goto next;
 }
 
-static struct adb_request* __pmac
+static struct adb_request*
 pmu_sr_intr(struct pt_regs *regs)
 {
        struct adb_request *req;
@@ -1548,7 +1530,7 @@ pmu_sr_intr(struct pt_regs *regs)
        return NULL;
 }
 
-static irqreturn_t __pmac
+static irqreturn_t
 via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs)
 {
        unsigned long flags;
@@ -1636,7 +1618,7 @@ no_free_slot:
        return IRQ_RETVAL(handled);
 }
 
-void __pmac
+void
 pmu_unlock(void)
 {
        unsigned long flags;
@@ -1649,7 +1631,7 @@ pmu_unlock(void)
 }
 
 
-static irqreturn_t __pmac
+static irqreturn_t
 gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
 {
        unsigned long flags;
@@ -1670,12 +1652,12 @@ gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
 }
 
 #ifdef CONFIG_PMAC_BACKLIGHT
-static int backlight_to_bright[] __pmacdata = {
+static int backlight_to_bright[] = {
        0x7f, 0x46, 0x42, 0x3e, 0x3a, 0x36, 0x32, 0x2e,
        0x2a, 0x26, 0x22, 0x1e, 0x1a, 0x16, 0x12, 0x0e
 };
  
-static int __openfirmware
+static int
 pmu_set_backlight_enable(int on, int level, void* data)
 {
        struct adb_request req;
@@ -1695,7 +1677,7 @@ pmu_set_backlight_enable(int on, int level, void* data)
        return 0;
 }
 
-static void __openfirmware
+static void
 pmu_bright_complete(struct adb_request *req)
 {
        if (req == &bright_req_1)
@@ -1704,7 +1686,7 @@ pmu_bright_complete(struct adb_request *req)
                clear_bit(2, &async_req_locks);
 }
 
-static int __openfirmware
+static int
 pmu_set_backlight_level(int level, void* data)
 {
        if (vias == NULL)
@@ -1724,7 +1706,7 @@ pmu_set_backlight_level(int level, void* data)
 }
 #endif /* CONFIG_PMAC_BACKLIGHT */
 
-void __pmac
+void
 pmu_enable_irled(int on)
 {
        struct adb_request req;
@@ -1739,7 +1721,7 @@ pmu_enable_irled(int on)
        pmu_wait_complete(&req);
 }
 
-void __pmac
+void
 pmu_restart(void)
 {
        struct adb_request req;
@@ -1764,7 +1746,7 @@ pmu_restart(void)
                ;
 }
 
-void __pmac
+void
 pmu_shutdown(void)
 {
        struct adb_request req;
@@ -2052,7 +2034,7 @@ pmu_i2c_simple_write(int bus, int addr,  u8* data, int len)
        return -1;
 }
 
-#ifdef CONFIG_PMAC_PBOOK
+#ifdef CONFIG_PM
 
 static LIST_HEAD(sleep_notifiers);
 
@@ -2081,9 +2063,12 @@ pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* n)
        n->list.next = NULL;
        return 0;
 }
+#endif /* CONFIG_PM */
+
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 
 /* Sleep is broadcast last-to-first */
-static int __pmac
+static int
 broadcast_sleep(int when, int fallback)
 {
        int ret = PBOOK_SLEEP_OK;
@@ -2108,7 +2093,7 @@ broadcast_sleep(int when, int fallback)
 }
 
 /* Wake is broadcast first-to-last */
-static int __pmac
+static int
 broadcast_wake(void)
 {
        int ret = PBOOK_SLEEP_OK;
@@ -2139,7 +2124,7 @@ static struct pci_save {
 } *pbook_pci_saves;
 static int pbook_npci_saves;
 
-static void __pmac
+static void
 pbook_alloc_pci_save(void)
 {
        int npci;
@@ -2156,7 +2141,7 @@ pbook_alloc_pci_save(void)
        pbook_npci_saves = npci;
 }
 
-static void __pmac
+static void
 pbook_free_pci_save(void)
 {
        if (pbook_pci_saves == NULL)
@@ -2166,7 +2151,7 @@ pbook_free_pci_save(void)
        pbook_npci_saves = 0;
 }
 
-static void __pmac
+static void
 pbook_pci_save(void)
 {
        struct pci_save *ps = pbook_pci_saves;
@@ -2197,7 +2182,7 @@ pbook_pci_save(void)
  * during boot, it will be in the pci dev list. If it's disabled at this point
  * (and it will probably be), then you can't access it's config space.
  */
-static void __pmac
+static void
 pbook_pci_restore(void)
 {
        u16 cmd;
@@ -2245,7 +2230,7 @@ pbook_pci_restore(void)
 
 #ifdef DEBUG_SLEEP
 /* N.B. This doesn't work on the 3400 */
-void  __pmac
+void 
 pmu_blink(int n)
 {
        struct adb_request req;
@@ -2284,9 +2269,9 @@ pmu_blink(int n)
  * Put the powerbook to sleep.
  */
  
-static u32 save_via[8] __pmacdata;
+static u32 save_via[8];
 
-static void __pmac
+static void
 save_via_state(void)
 {
        save_via[0] = in_8(&via[ANH]);
@@ -2298,7 +2283,7 @@ save_via_state(void)
        save_via[6] = in_8(&via[T1CL]);
        save_via[7] = in_8(&via[T1CH]);
 }
-static void __pmac
+static void
 restore_via_state(void)
 {
        out_8(&via[ANH], save_via[0]);
@@ -2314,7 +2299,7 @@ restore_via_state(void)
        out_8(&via[IER], IER_SET | SR_INT | CB1_INT);
 }
 
-static int __pmac
+static int
 pmac_suspend_devices(void)
 {
        int ret;
@@ -2404,7 +2389,7 @@ pmac_suspend_devices(void)
        return 0;
 }
 
-static int __pmac
+static int
 pmac_wakeup_devices(void)
 {
        mdelay(100);
@@ -2443,7 +2428,7 @@ pmac_wakeup_devices(void)
 #define        GRACKLE_NAP     (1<<4)
 #define        GRACKLE_SLEEP   (1<<3)
 
-int __pmac
+int
 powerbook_sleep_grackle(void)
 {
        unsigned long save_l2cr;
@@ -2527,7 +2512,7 @@ powerbook_sleep_grackle(void)
        return 0;
 }
 
-static int __pmac
+static int
 powerbook_sleep_Core99(void)
 {
        unsigned long save_l2cr;
@@ -2627,7 +2612,7 @@ powerbook_sleep_Core99(void)
 #define PB3400_MEM_CTRL                0xf8000000
 #define PB3400_MEM_CTRL_SLEEP  0x70
 
-static int __pmac
+static int
 powerbook_sleep_3400(void)
 {
        int ret, i, x;
@@ -2682,10 +2667,10 @@ powerbook_sleep_3400(void)
        asleep = 1;
 
        /* Put the CPU into sleep mode */
-       asm volatile("mfspr %0,1008" : "=r" (hid0) :);
+       hid0 = mfspr(SPRN_HID0);
        hid0 = (hid0 & ~(HID0_NAP | HID0_DOZE)) | HID0_SLEEP;
-       asm volatile("mtspr 1008,%0" : : "r" (hid0));
-       _nmask_and_or_msr(0, MSR_POW | MSR_EE);
+       mtspr(SPRN_HID0, hid0);
+       mtmsr(mfmsr() | MSR_POW | MSR_EE);
        udelay(10);
 
        /* OK, we're awake again, start restoring things */
@@ -2705,6 +2690,8 @@ powerbook_sleep_3400(void)
        return 0;
 }
 
+#endif /* CONFIG_PM && CONFIG_PPC32 */
+
 /*
  * Support for /dev/pmu device
  */
@@ -2725,9 +2712,9 @@ struct pmu_private {
 };
 
 static LIST_HEAD(all_pmu_pvt);
-static DEFINE_SPINLOCK(all_pvt_lock __pmacdata);
+static DEFINE_SPINLOCK(all_pvt_lock);
 
-static void __pmac
+static void
 pmu_pass_intr(unsigned char *data, int len)
 {
        struct pmu_private *pp;
@@ -2756,7 +2743,7 @@ pmu_pass_intr(unsigned char *data, int len)
        spin_unlock_irqrestore(&all_pvt_lock, flags);
 }
 
-static int __pmac
+static int
 pmu_open(struct inode *inode, struct file *file)
 {
        struct pmu_private *pp;
@@ -2778,7 +2765,7 @@ pmu_open(struct inode *inode, struct file *file)
        return 0;
 }
 
-static ssize_t  __pmac
+static ssize_t 
 pmu_read(struct file *file, char __user *buf,
                        size_t count, loff_t *ppos)
 {
@@ -2830,14 +2817,14 @@ pmu_read(struct file *file, char __user *buf,
        return ret;
 }
 
-static ssize_t __pmac
+static ssize_t
 pmu_write(struct file *file, const char __user *buf,
                         size_t count, loff_t *ppos)
 {
        return 0;
 }
 
-static unsigned int __pmac
+static unsigned int
 pmu_fpoll(struct file *filp, poll_table *wait)
 {
        struct pmu_private *pp = filp->private_data;
@@ -2854,7 +2841,7 @@ pmu_fpoll(struct file *filp, poll_table *wait)
        return mask;
 }
 
-static int __pmac
+static int
 pmu_release(struct inode *inode, struct file *file)
 {
        struct pmu_private *pp = file->private_data;
@@ -2879,16 +2866,15 @@ pmu_release(struct inode *inode, struct file *file)
        return 0;
 }
 
-/* Note: removed __openfirmware here since it causes link errors */
-static int __pmac
+static int
 pmu_ioctl(struct inode * inode, struct file *filp,
                     u_int cmd, u_long arg)
 {
-       struct pmu_private *pp = filp->private_data;
        __u32 __user *argp = (__u32 __user *)arg;
-       int error;
+       int error = -EINVAL;
 
        switch (cmd) {
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
        case PMU_IOC_SLEEP:
                if (!capable(CAP_SYS_ADMIN))
                        return -EACCES;
@@ -2910,12 +2896,13 @@ pmu_ioctl(struct inode * inode, struct file *filp,
                        error = -ENOSYS;
                }
                sleep_in_progress = 0;
-               return error;
+               break;
        case PMU_IOC_CAN_SLEEP:
                if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) < 0)
                        return put_user(0, argp);
                else
                        return put_user(1, argp);
+#endif /* CONFIG_PM && CONFIG_PPC32 */
 
 #ifdef CONFIG_PMAC_BACKLIGHT
        /* Backlight should have its own device or go via
@@ -2936,11 +2923,13 @@ pmu_ioctl(struct inode * inode, struct file *filp,
                error = get_user(value, argp);
                if (!error)
                        error = set_backlight_level(value);
-               return error;
+               break;
        }
 #ifdef CONFIG_INPUT_ADBHID
        case PMU_IOC_GRAB_BACKLIGHT: {
+               struct pmu_private *pp = filp->private_data;
                unsigned long flags;
+
                if (pp->backlight_locker)
                        return 0;
                pp->backlight_locker = 1;
@@ -2956,10 +2945,10 @@ pmu_ioctl(struct inode * inode, struct file *filp,
        case PMU_IOC_HAS_ADB:
                return put_user(pmu_has_adb, argp);
        }
-       return -EINVAL;
+       return error;
 }
 
-static struct file_operations pmu_device_fops __pmacdata = {
+static struct file_operations pmu_device_fops = {
        .read           = pmu_read,
        .write          = pmu_write,
        .poll           = pmu_fpoll,
@@ -2968,21 +2957,23 @@ static struct file_operations pmu_device_fops __pmacdata = {
        .release        = pmu_release,
 };
 
-static struct miscdevice pmu_device __pmacdata = {
+static struct miscdevice pmu_device = {
        PMU_MINOR, "pmu", &pmu_device_fops
 };
 
-void pmu_device_init(void)
+static int pmu_device_init(void)
 {
        if (!via)
-               return;
+               return 0;
        if (misc_register(&pmu_device) < 0)
                printk(KERN_ERR "via-pmu: cannot register misc device.\n");
+       return 0;
 }
-#endif /* CONFIG_PMAC_PBOOK */
+device_initcall(pmu_device_init);
+
 
 #ifdef DEBUG_SLEEP
-static inline void  __pmac
+static inline void 
 polled_handshake(volatile unsigned char __iomem *via)
 {
        via[B] &= ~TREQ; eieio();
@@ -2993,7 +2984,7 @@ polled_handshake(volatile unsigned char __iomem *via)
                ;
 }
 
-static inline void  __pmac
+static inline void 
 polled_send_byte(volatile unsigned char __iomem *via, int x)
 {
        via[ACR] |= SR_OUT | SR_EXT; eieio();
@@ -3001,7 +2992,7 @@ polled_send_byte(volatile unsigned char __iomem *via, int x)
        polled_handshake(via);
 }
 
-static inline int __pmac
+static inline int
 polled_recv_byte(volatile unsigned char __iomem *via)
 {
        int x;
@@ -3013,7 +3004,7 @@ polled_recv_byte(volatile unsigned char __iomem *via)
        return x;
 }
 
-int __pmac
+int
 pmu_polled_request(struct adb_request *req)
 {
        unsigned long flags;
@@ -3059,13 +3050,13 @@ pmu_polled_request(struct adb_request *req)
  * to do suspend-to-disk.
  */
 
-#ifdef CONFIG_PM
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 
 static int pmu_sys_suspended = 0;
 
 static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state)
 {
-       if (state != PM_SUSPEND_DISK || pmu_sys_suspended)
+       if (state.event != PM_EVENT_SUSPEND || pmu_sys_suspended)
                return 0;
 
        /* Suspend PMU event interrupts */
@@ -3094,7 +3085,7 @@ static int pmu_sys_resume(struct sys_device *sysdev)
        return 0;
 }
 
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM && CONFIG_PPC32 */
 
 static struct sysdev_class pmu_sysclass = {
        set_kset_name("pmu"),
@@ -3106,10 +3097,10 @@ static struct sys_device device_pmu = {
 };
 
 static struct sysdev_driver driver_pmu = {
-#ifdef CONFIG_PM
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
        .suspend        = &pmu_sys_suspend,
        .resume         = &pmu_sys_resume,
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM && CONFIG_PPC32 */
 };
 
 static int __init init_pmu_sysfs(void)
@@ -3147,12 +3138,12 @@ EXPORT_SYMBOL(pmu_i2c_combined_read);
 EXPORT_SYMBOL(pmu_i2c_stdsub_write);
 EXPORT_SYMBOL(pmu_i2c_simple_read);
 EXPORT_SYMBOL(pmu_i2c_simple_write);
-#ifdef CONFIG_PMAC_PBOOK
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 EXPORT_SYMBOL(pmu_register_sleep_notifier);
 EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
 EXPORT_SYMBOL(pmu_enable_irled);
 EXPORT_SYMBOL(pmu_battery_count);
 EXPORT_SYMBOL(pmu_batteries);
 EXPORT_SYMBOL(pmu_power_flags);
-#endif /* CONFIG_PMAC_PBOOK */
+#endif /* CONFIG_PM && CONFIG_PPC32 */
 
This page took 0.046028 seconds and 5 git commands to generate.