]> err.no Git - linux-2.6/blobdiff - drivers/macintosh/via-pmu.c
[POWERPC] Cleanup pseries smp initialisation code
[linux-2.6] / drivers / macintosh / via-pmu.c
index dda03985dcf5b804cdf7c6724561012523660942..b6073bdb50c36a73b73e6851ebe6ba2f414801fb 100644 (file)
@@ -42,8 +42,9 @@
 #include <linux/interrupt.h>
 #include <linux/device.h>
 #include <linux/sysdev.h>
-#include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/syscalls.h>
+#include <linux/suspend.h>
 #include <linux/cpu.h>
 #include <asm/prom.h>
 #include <asm/machdep.h>
@@ -140,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;
@@ -168,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;
@@ -179,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);
@@ -191,8 +192,8 @@ static int pmu_adb_reset_bus(void);
 
 static int init_pmu(void);
 static void pmu_start(void);
-static irqreturn_t via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs);
-static irqreturn_t gpio1_interrupt(int irq, void *arg, struct pt_regs *regs);
+static irqreturn_t via_pmu_interrupt(int irq, void *arg);
+static irqreturn_t gpio1_interrupt(int irq, void *arg);
 static int proc_get_info(char *page, char **start, off_t off,
                          int count, int *eof, void *data);
 static int proc_get_irqstats(char *page, char **start, off_t off,
@@ -336,8 +337,10 @@ int __init find_via_pmu(void)
                        if (gaddr != OF_BAD_ADDR)
                                gpio_reg = ioremap(gaddr, 0x10);
                }
-               if (gpio_reg == NULL)
+               if (gpio_reg == NULL) {
                        printk(KERN_ERR "via-pmu: Can't find GPIO reg !\n");
+                       goto fail_gpio;
+               }
        } else
                pmu_kind = PMU_UNKNOWN;
 
@@ -365,6 +368,9 @@ int __init find_via_pmu(void)
        return 1;
  fail:
        of_node_put(vias);
+       iounmap(gpio_reg);
+       gpio_reg = NULL;
+ fail_gpio:
        vias = NULL;
        return 0;
 }
@@ -510,7 +516,6 @@ static int __init via_pmu_dev_init(void)
                                        proc_get_irqstats, NULL);
                proc_pmu_options = create_proc_entry("options", 0600, proc_pmu_root);
                if (proc_pmu_options) {
-                       proc_pmu_options->nlink = 1;
                        proc_pmu_options->read_proc = proc_read_options;
                        proc_pmu_options->write_proc = proc_write_options;
                }
@@ -550,7 +555,7 @@ init_pmu(void)
                }
                if (pmu_state == idle)
                        adb_int_pending = 1;
-               via_pmu_interrupt(0, NULL, NULL);
+               via_pmu_interrupt(0, NULL);
                udelay(10);
        }
 
@@ -1210,7 +1215,7 @@ pmu_poll(void)
                return;
        if (disable_poll)
                return;
-       via_pmu_interrupt(0, NULL, NULL);
+       via_pmu_interrupt(0, NULL);
 }
 
 void
@@ -1223,7 +1228,7 @@ pmu_poll_adb(void)
        /* Kicks ADB read when PMU is suspended */
        adb_int_pending = 1;
        do {
-               via_pmu_interrupt(0, NULL, NULL);
+               via_pmu_interrupt(0, NULL);
        } while (pmu_suspended && (adb_int_pending || pmu_state != idle
                || req_awaiting_reply));
 }
@@ -1234,7 +1239,7 @@ pmu_wait_complete(struct adb_request *req)
        if (!via)
                return;
        while((pmu_state != idle && pmu_state != locked) || !req->complete)
-               via_pmu_interrupt(0, NULL, NULL);
+               via_pmu_interrupt(0, NULL);
 }
 
 /* This function loops until the PMU is idle and prevents it from
@@ -1263,7 +1268,7 @@ pmu_suspend(void)
                spin_unlock_irqrestore(&pmu_lock, flags);
                if (req_awaiting_reply)
                        adb_int_pending = 1;
-               via_pmu_interrupt(0, NULL, NULL);
+               via_pmu_interrupt(0, NULL);
                spin_lock_irqsave(&pmu_lock, flags);
                if (!adb_int_pending && pmu_state == idle && !req_awaiting_reply) {
 #ifdef SUSPEND_USES_PMU
@@ -1313,7 +1318,7 @@ pmu_resume(void)
 
 /* Interrupt data could be the result data from an ADB cmd */
 static void
-pmu_handle_data(unsigned char *data, int len, struct pt_regs *regs)
+pmu_handle_data(unsigned char *data, int len)
 {
        unsigned char ints, pirq;
        int i = 0;
@@ -1388,7 +1393,7 @@ next:
                        if (!(pmu_kind == PMU_OHARE_BASED && len == 4
                              && data[1] == 0x2c && data[3] == 0xff
                              && (data[2] & ~1) == 0xf4))
-                               adb_input(data+1, len-1, regs, 1);
+                               adb_input(data+1, len-1, 1);
 #endif /* CONFIG_ADB */                
                }
        }
@@ -1426,7 +1431,7 @@ next:
 }
 
 static struct adb_request*
-pmu_sr_intr(struct pt_regs *regs)
+pmu_sr_intr(void)
 {
        struct adb_request *req;
        int bite = 0;
@@ -1532,7 +1537,7 @@ pmu_sr_intr(struct pt_regs *regs)
 }
 
 static irqreturn_t
-via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs)
+via_pmu_interrupt(int irq, void *arg)
 {
        unsigned long flags;
        int intr;
@@ -1562,7 +1567,7 @@ via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs)
                        pmu_irq_stats[0]++;
                }
                if (intr & SR_INT) {
-                       req = pmu_sr_intr(regs);
+                       req = pmu_sr_intr();
                        if (req)
                                break;
                }
@@ -1608,7 +1613,7 @@ no_free_slot:
                
        /* Deal with interrupt datas outside of the lock */
        if (int_data >= 0) {
-               pmu_handle_data(interrupt_data[int_data], interrupt_data_len[int_data], regs);
+               pmu_handle_data(interrupt_data[int_data], interrupt_data_len[int_data]);
                spin_lock_irqsave(&pmu_lock, flags);
                ++disable_poll;
                int_data_state[int_data] = int_data_empty;
@@ -1633,7 +1638,7 @@ pmu_unlock(void)
 
 
 static irqreturn_t
-gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
+gpio1_interrupt(int irq, void *arg)
 {
        unsigned long flags;
 
@@ -1646,7 +1651,7 @@ gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
                pmu_irq_stats[1]++;
                adb_int_pending = 1;
                spin_unlock_irqrestore(&pmu_lock, flags);
-               via_pmu_interrupt(0, NULL, NULL);
+               via_pmu_interrupt(0, NULL);
                return IRQ_HANDLED;
        }
        return IRQ_NONE;
@@ -1827,7 +1832,7 @@ pbook_alloc_pci_save(void)
        struct pci_dev *pd = NULL;
 
        npci = 0;
-       while ((pd = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
+       while ((pd = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
                ++npci;
        }
        if (npci == 0)
@@ -1857,9 +1862,11 @@ pbook_pci_save(void)
        if (ps == NULL)
                return;
 
-       while ((pd = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
-               if (npci-- == 0)
+       while ((pd = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
+               if (npci-- == 0) {
+                       pci_dev_put(pd);
                        return;
+               }
 #ifndef HACKED_PCI_SAVE
                pci_read_config_word(pd, PCI_COMMAND, &ps->command);
                pci_read_config_word(pd, PCI_CACHE_LINE_SIZE, &ps->cache_lat);
@@ -1887,11 +1894,13 @@ pbook_pci_restore(void)
        int npci = pbook_npci_saves;
        int j;
 
-       while ((pd = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
+       while ((pd = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
 #ifdef HACKED_PCI_SAVE
                int i;
-               if (npci-- == 0)
+               if (npci-- == 0) {
+                       pci_dev_put(pd);
                        return;
+               }
                ps++;
                for (i=2;i<16;i++)
                        pci_write_config_dword(pd, i<<4, ps->config[i]);
@@ -2107,7 +2116,7 @@ pmac_wakeup_devices(void)
 
        /* Force a poll of ADB interrupts */
        adb_int_pending = 1;
-       via_pmu_interrupt(0, NULL, NULL);
+       via_pmu_interrupt(0, NULL);
 
        /* Restart jiffies & scheduling */
        wakeup_decrementer();
@@ -2663,7 +2672,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,
@@ -2767,7 +2776,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)
 {
@@ -2807,7 +2816,6 @@ static struct sysdev_class pmu_sysclass = {
 };
 
 static struct sys_device device_pmu = {
-       .id             = 0,
        .cls            = &pmu_sysclass,
 };