Merge branch 'next-s3c-hwmon' into next-s3c
[safe/jmp/linux-2.6] / drivers / hwmon / ams / ams-core.c
index dbe6a32..6c9ace1 100644 (file)
@@ -23,9 +23,8 @@
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/init.h>
-#include <linux/module.h>
+#include <linux/of_platform.h>
 #include <asm/pmac_pfunc.h>
-#include <asm/of_platform.h>
 
 #include "ams.h"
 
@@ -100,39 +99,31 @@ static struct pmf_irq_client ams_shock_client = {
  */
 static void ams_worker(struct work_struct *work)
 {
-       mutex_lock(&ams_info.lock);
-
-       if (ams_info.has_device) {
-               unsigned long flags;
+       unsigned long flags;
+       u8 irqs_to_clear;
 
-               spin_lock_irqsave(&ams_info.irq_lock, flags);
+       mutex_lock(&ams_info.lock);
 
-               if (ams_info.worker_irqs & AMS_IRQ_FREEFALL) {
-                       if (verbose)
-                               printk(KERN_INFO "ams: freefall detected!\n");
+       spin_lock_irqsave(&ams_info.irq_lock, flags);
+       irqs_to_clear = ams_info.worker_irqs;
 
-                       ams_info.worker_irqs &= ~AMS_IRQ_FREEFALL;
+       if (ams_info.worker_irqs & AMS_IRQ_FREEFALL) {
+               if (verbose)
+                       printk(KERN_INFO "ams: freefall detected!\n");
 
-                       /* we must call this with interrupts enabled */
-                       spin_unlock_irqrestore(&ams_info.irq_lock, flags);
-                       ams_info.clear_irq(AMS_IRQ_FREEFALL);
-                       spin_lock_irqsave(&ams_info.irq_lock, flags);
-               }
+               ams_info.worker_irqs &= ~AMS_IRQ_FREEFALL;
+       }
 
-               if (ams_info.worker_irqs & AMS_IRQ_SHOCK) {
-                       if (verbose)
-                               printk(KERN_INFO "ams: shock detected!\n");
+       if (ams_info.worker_irqs & AMS_IRQ_SHOCK) {
+               if (verbose)
+                       printk(KERN_INFO "ams: shock detected!\n");
 
-                       ams_info.worker_irqs &= ~AMS_IRQ_SHOCK;
+               ams_info.worker_irqs &= ~AMS_IRQ_SHOCK;
+       }
 
-                       /* we must call this with interrupts enabled */
-                       spin_unlock_irqrestore(&ams_info.irq_lock, flags);
-                       ams_info.clear_irq(AMS_IRQ_SHOCK);
-                       spin_lock_irqsave(&ams_info.irq_lock, flags);
-               }
+       spin_unlock_irqrestore(&ams_info.irq_lock, flags);
 
-               spin_unlock_irqrestore(&ams_info.irq_lock, flags);
-       }
+       ams_info.clear_irq(irqs_to_clear);
 
        mutex_unlock(&ams_info.lock);
 }
@@ -219,42 +210,33 @@ int __init ams_init(void)
                /* Found PMU motion sensor */
                return ams_pmu_init(np);
 #endif
-
-       printk(KERN_ERR "ams: No motion sensor found.\n");
-
        return -ENODEV;
 }
 
 void ams_exit(void)
 {
-       mutex_lock(&ams_info.lock);
-
-       if (ams_info.has_device) {
-               /* Remove input device */
-               ams_input_exit();
-
-               /* Shut down implementation */
-               ams_info.exit();
+       /* Remove input device */
+       ams_input_exit();
 
-               /* Flush interrupt worker
-                *
-                * We do this after ams_info.exit(), because an interrupt might
-                * have arrived before disabling them.
-                */
-               flush_scheduled_work();
+       /* Remove attributes */
+       device_remove_file(&ams_info.of_dev->dev, &dev_attr_current);
 
-               /* Remove attributes */
-               device_remove_file(&ams_info.of_dev->dev, &dev_attr_current);
+       /* Shut down implementation */
+       ams_info.exit();
 
-               /* Remove device */
-               of_device_unregister(ams_info.of_dev);
+       /* Flush interrupt worker
+        *
+        * We do this after ams_info.exit(), because an interrupt might
+        * have arrived before disabling them.
+        */
+       flush_scheduled_work();
 
-               /* Remove handler */
-               pmf_unregister_irq_client(&ams_shock_client);
-               pmf_unregister_irq_client(&ams_freefall_client);
-       }
+       /* Remove device */
+       of_device_unregister(ams_info.of_dev);
 
-       mutex_unlock(&ams_info.lock);
+       /* Remove handler */
+       pmf_unregister_irq_client(&ams_shock_client);
+       pmf_unregister_irq_client(&ams_freefall_client);
 }
 
 MODULE_AUTHOR("Stelian Pop, Michael Hanselmann");