S3C-fb: PM fix
[safe/jmp/linux-2.6] / drivers / parisc / led.c
index 453e682..9581d36 100644 (file)
@@ -3,7 +3,7 @@
  *
  *      (c) Copyright 2000 Red Hat Software
  *      (c) Copyright 2000 Helge Deller <hdeller@redhat.com>
- *      (c) Copyright 2001-2005 Helge Deller <deller@gmx.de>
+ *      (c) Copyright 2001-2009 Helge Deller <deller@gmx.de>
  *      (c) Copyright 2001 Randolph Chung <tausq@debian.org>
  *
  *      This program is free software; you can redistribute it and/or modify
@@ -195,12 +195,6 @@ static int led_proc_write(struct file *file, const char *buf,
 
        cur = lbuf;
 
-       /* skip initial spaces */
-       while (*cur && isspace(*cur))
-       {
-               cur++;
-       }
-
        switch ((long)data)
        {
        case LED_NOLCD:
@@ -249,13 +243,11 @@ static int __init led_create_procfs(void)
 
        proc_pdc_root = proc_mkdir("pdc", 0);
        if (!proc_pdc_root) return -1;
-       proc_pdc_root->owner = THIS_MODULE;
        ent = create_proc_entry("led", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root);
        if (!ent) return -1;
        ent->data = (void *)LED_NOLCD; /* LED */
        ent->read_proc = led_proc_read;
        ent->write_proc = led_proc_write;
-       ent->owner = THIS_MODULE;
 
        if (led_type == LED_HASLCD)
        {
@@ -264,7 +256,6 @@ static int __init led_create_procfs(void)
                ent->data = (void *)LED_HASLCD; /* LCD */
                ent->read_proc = led_proc_read;
                ent->write_proc = led_proc_write;
-               ent->owner = THIS_MODULE;
        }
 
        return 0;
@@ -365,16 +356,14 @@ static __inline__ int led_get_net_activity(void)
         * for reading should be OK */
        read_lock(&dev_base_lock);
        rcu_read_lock();
-       for (dev = dev_base; dev; dev = dev->next) {
-           struct net_device_stats *stats;
+       for_each_netdev(&init_net, dev) {
+           const struct net_device_stats *stats;
            struct in_device *in_dev = __in_dev_get_rcu(dev);
            if (!in_dev || !in_dev->ifa_list)
                continue;
-           if (LOOPBACK(in_dev->ifa_list->ifa_local))
-               continue;
-           stats = dev->get_stats(dev);
-           if (!stats)
+           if (ipv4_is_loopback(in_dev->ifa_list->ifa_local))
                continue;
+           stats = dev_get_stats(dev);
            rx_total += stats->rx_packets;
            tx_total += stats->tx_packets;
        }
@@ -471,9 +460,20 @@ static void led_work_func (struct work_struct *unused)
        if (likely(led_lanrxtx))  currentleds |= led_get_net_activity();
        if (likely(led_diskio))   currentleds |= led_get_diskio_activity();
 
-       /* blink all LEDs twice a second if we got an Oops (HPMC) */
-       if (unlikely(oops_in_progress)) 
-               currentleds = (count_HZ<=(HZ/2)) ? 0 : 0xff;
+       /* blink LEDs if we got an Oops (HPMC) */
+       if (unlikely(oops_in_progress)) {
+               if (boot_cpu_data.cpu_type >= pcxl2) {
+                       /* newer machines don't have loadavg. LEDs, so we
+                        * let all LEDs blink twice per second instead */
+                       currentleds = (count_HZ <= (HZ/2)) ? 0 : 0xff;
+               } else {
+                       /* old machines: blink loadavg. LEDs twice per second */
+                       if (count_HZ <= (HZ/2))
+                               currentleds &= ~(LED4|LED5|LED6|LED7);
+                       else
+                               currentleds |= (LED4|LED5|LED6|LED7);
+               }
+       }
 
        if (currentleds != lastleds)
        {
@@ -519,7 +519,7 @@ static int led_halt(struct notifier_block *nb, unsigned long event, void *buf)
        
        /* Cancel the work item and delete the queue */
        if (led_wq) {
-               cancel_rearming_delayed_workqueue(led_wq, &led_task);
+               cancel_delayed_work_sync(&led_task);
                destroy_workqueue(led_wq);
                led_wq = NULL;
        }
@@ -577,7 +577,7 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d
 
        default:
                printk(KERN_ERR "%s: Wrong LCD/LED model %d !\n",
-                      __FUNCTION__, lcd_info.model);
+                      __func__, lcd_info.model);
                return 1;
        }
        
@@ -638,7 +638,7 @@ int lcd_print( const char *str )
        
        /* temporarily disable the led work task */
        if (led_wq)
-               cancel_rearming_delayed_workqueue(led_wq, &led_task);
+               cancel_delayed_work_sync(&led_task);
 
        /* copy display string to buffer for procfs */
        strlcpy(lcd_text, str, sizeof(lcd_text));