[PATCH] revert incorrect mutex conversion in hdaps driver

This reverts the mutex conversion that was recently done to the hdaps
driver; this coversion was buggy because the hdaps driver started using
this semaphore in IRQ context, which mutexes do not allow. Easiest
solution for now is to just revert the patch (the patch was part of a
bigger GIT commit, 9a61bf6300533d3b64d7ff29adfec00e596de67d but this
only reverts this one file)

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Arjan van de Ven and committed by Linus Torvalds 597a7679 7f344f0a

+18 -19
+18 -19
drivers/hwmon/hdaps.c
··· 33 33 #include <linux/module.h> 34 34 #include <linux/timer.h> 35 35 #include <linux/dmi.h> 36 - #include <linux/mutex.h> 37 36 #include <asm/io.h> 38 37 39 38 #define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */ ··· 70 71 static int rest_x; 71 72 static int rest_y; 72 73 73 - static DEFINE_MUTEX(hdaps_mutex); 74 + static DECLARE_MUTEX(hdaps_sem); 74 75 75 76 /* 76 - * __get_latch - Get the value from a given port. Callers must hold hdaps_mutex. 77 + * __get_latch - Get the value from a given port. Callers must hold hdaps_sem. 77 78 */ 78 79 static inline u8 __get_latch(u16 port) 79 80 { ··· 82 83 83 84 /* 84 85 * __check_latch - Check a port latch for a given value. Returns zero if the 85 - * port contains the given value. Callers must hold hdaps_mutex. 86 + * port contains the given value. Callers must hold hdaps_sem. 86 87 */ 87 88 static inline int __check_latch(u16 port, u8 val) 88 89 { ··· 93 94 94 95 /* 95 96 * __wait_latch - Wait up to 100us for a port latch to get a certain value, 96 - * returning zero if the value is obtained. Callers must hold hdaps_mutex. 97 + * returning zero if the value is obtained. Callers must hold hdaps_sem. 97 98 */ 98 99 static int __wait_latch(u16 port, u8 val) 99 100 { ··· 110 111 111 112 /* 112 113 * __device_refresh - request a refresh from the accelerometer. Does not wait 113 - * for refresh to complete. Callers must hold hdaps_mutex. 114 + * for refresh to complete. Callers must hold hdaps_sem. 114 115 */ 115 116 static void __device_refresh(void) 116 117 { ··· 124 125 /* 125 126 * __device_refresh_sync - request a synchronous refresh from the 126 127 * accelerometer. We wait for the refresh to complete. Returns zero if 127 - * successful and nonzero on error. Callers must hold hdaps_mutex. 128 + * successful and nonzero on error. Callers must hold hdaps_sem. 128 129 */ 129 130 static int __device_refresh_sync(void) 130 131 { ··· 134 135 135 136 /* 136 137 * __device_complete - indicate to the accelerometer that we are done reading 137 - * data, and then initiate an async refresh. Callers must hold hdaps_mutex. 138 + * data, and then initiate an async refresh. Callers must hold hdaps_sem. 138 139 */ 139 140 static inline void __device_complete(void) 140 141 { ··· 152 153 { 153 154 int ret; 154 155 155 - mutex_lock(&hdaps_mutex); 156 + down(&hdaps_sem); 156 157 157 158 /* do a sync refresh -- we need to be sure that we read fresh data */ 158 159 ret = __device_refresh_sync(); ··· 163 164 __device_complete(); 164 165 165 166 out: 166 - mutex_unlock(&hdaps_mutex); 167 + up(&hdaps_sem); 167 168 return ret; 168 169 } 169 170 ··· 198 199 { 199 200 int ret; 200 201 201 - mutex_lock(&hdaps_mutex); 202 + down(&hdaps_sem); 202 203 ret = __hdaps_read_pair(port1, port2, val1, val2); 203 - mutex_unlock(&hdaps_mutex); 204 + up(&hdaps_sem); 204 205 205 206 return ret; 206 207 } ··· 213 214 { 214 215 int total, ret = -ENXIO; 215 216 216 - mutex_lock(&hdaps_mutex); 217 + down(&hdaps_sem); 217 218 218 219 outb(0x13, 0x1610); 219 220 outb(0x01, 0x161f); ··· 279 280 } 280 281 281 282 out: 282 - mutex_unlock(&hdaps_mutex); 283 + up(&hdaps_sem); 283 284 return ret; 284 285 } 285 286 ··· 313 314 }; 314 315 315 316 /* 316 - * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_mutex. 317 + * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_sem. 317 318 */ 318 319 static void hdaps_calibrate(void) 319 320 { ··· 325 326 int x, y; 326 327 327 328 /* Cannot sleep. Try nonblockingly. If we fail, try again later. */ 328 - if (!mutex_trylock(&hdaps_mutex)) { 329 + if (down_trylock(&hdaps_sem)) { 329 330 mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD); 330 331 return; 331 332 } ··· 340 341 mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD); 341 342 342 343 out: 343 - mutex_unlock(&hdaps_mutex); 344 + up(&hdaps_sem); 344 345 } 345 346 346 347 ··· 420 421 struct device_attribute *attr, 421 422 const char *buf, size_t count) 422 423 { 423 - mutex_lock(&hdaps_mutex); 424 + down(&hdaps_sem); 424 425 hdaps_calibrate(); 425 - mutex_unlock(&hdaps_mutex); 426 + up(&hdaps_sem); 426 427 427 428 return count; 428 429 }