aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/ams/ams-core.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/drivers/hwmon/ams/ams-core.c b/drivers/hwmon/ams/ams-core.c
index 9b4a0e7a564f..6c9ace1b76f6 100644
--- a/drivers/hwmon/ams/ams-core.c
+++ b/drivers/hwmon/ams/ams-core.c
@@ -99,39 +99,31 @@ static struct pmf_irq_client ams_shock_client = {
99 */ 99 */
100static void ams_worker(struct work_struct *work) 100static void ams_worker(struct work_struct *work)
101{ 101{
102 mutex_lock(&ams_info.lock); 102 unsigned long flags;
103 103 u8 irqs_to_clear;
104 if (ams_info.has_device) {
105 unsigned long flags;
106 104
107 spin_lock_irqsave(&ams_info.irq_lock, flags); 105 mutex_lock(&ams_info.lock);
108 106
109 if (ams_info.worker_irqs & AMS_IRQ_FREEFALL) { 107 spin_lock_irqsave(&ams_info.irq_lock, flags);
110 if (verbose) 108 irqs_to_clear = ams_info.worker_irqs;
111 printk(KERN_INFO "ams: freefall detected!\n");
112 109
113 ams_info.worker_irqs &= ~AMS_IRQ_FREEFALL; 110 if (ams_info.worker_irqs & AMS_IRQ_FREEFALL) {
111 if (verbose)
112 printk(KERN_INFO "ams: freefall detected!\n");
114 113
115 /* we must call this with interrupts enabled */ 114 ams_info.worker_irqs &= ~AMS_IRQ_FREEFALL;
116 spin_unlock_irqrestore(&ams_info.irq_lock, flags); 115 }
117 ams_info.clear_irq(AMS_IRQ_FREEFALL);
118 spin_lock_irqsave(&ams_info.irq_lock, flags);
119 }
120 116
121 if (ams_info.worker_irqs & AMS_IRQ_SHOCK) { 117 if (ams_info.worker_irqs & AMS_IRQ_SHOCK) {
122 if (verbose) 118 if (verbose)
123 printk(KERN_INFO "ams: shock detected!\n"); 119 printk(KERN_INFO "ams: shock detected!\n");
124 120
125 ams_info.worker_irqs &= ~AMS_IRQ_SHOCK; 121 ams_info.worker_irqs &= ~AMS_IRQ_SHOCK;
122 }
126 123
127 /* we must call this with interrupts enabled */ 124 spin_unlock_irqrestore(&ams_info.irq_lock, flags);
128 spin_unlock_irqrestore(&ams_info.irq_lock, flags);
129 ams_info.clear_irq(AMS_IRQ_SHOCK);
130 spin_lock_irqsave(&ams_info.irq_lock, flags);
131 }
132 125
133 spin_unlock_irqrestore(&ams_info.irq_lock, flags); 126 ams_info.clear_irq(irqs_to_clear);
134 }
135 127
136 mutex_unlock(&ams_info.lock); 128 mutex_unlock(&ams_info.lock);
137} 129}