diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2008-10-17 11:51:13 -0400 |
---|---|---|
committer | Jean Delvare <khali@mahadeva.delvare> | 2008-10-17 11:51:13 -0400 |
commit | dbee356262bb1c84cfa585530e33e7003534052a (patch) | |
tree | 63210fdf2058ac09b3d501171184aa88bdae59d7 /drivers/hwmon/ams | |
parent | ee4cd32ee8a68e22081f698602e4315fb4272853 (diff) |
hwmon: (ams) Simplify IRQ handling routine
Simplify the IRQ handling routine of ams driver.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/ams')
-rw-r--r-- | drivers/hwmon/ams/ams-core.c | 42 |
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 | */ |
100 | static void ams_worker(struct work_struct *work) | 100 | static 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 | } |