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