aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2012-01-21 04:33:38 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-02-18 18:15:32 -0500
commitcae154767a96563d33924872aacfdc63d584f707 (patch)
tree5071f9b5c462bb48b8f6539aeb62664a3e7ab20a /drivers
parentddb1e04a35846b6c5b6039e92555dafaf6ee03d2 (diff)
MFD: ucb1x00-core: use mutexes instead of semaphores
Convert the ucb1x00 driver to use mutexes rather than the depreciated semaphores for exclusive access to the ADC. Acked-by: Jochen Friedrich <jochen@scram.de> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mfd/ucb1x00-core.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c
index c2757c11ce7b..7386f822d4cd 100644
--- a/drivers/mfd/ucb1x00-core.c
+++ b/drivers/mfd/ucb1x00-core.c
@@ -27,7 +27,6 @@
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/mfd/ucb1x00.h> 28#include <linux/mfd/ucb1x00.h>
29#include <linux/gpio.h> 29#include <linux/gpio.h>
30#include <linux/semaphore.h>
31 30
32static DEFINE_MUTEX(ucb1x00_mutex); 31static DEFINE_MUTEX(ucb1x00_mutex);
33static LIST_HEAD(ucb1x00_drivers); 32static LIST_HEAD(ucb1x00_drivers);
@@ -99,7 +98,7 @@ void ucb1x00_io_write(struct ucb1x00 *ucb, unsigned int set, unsigned int clear)
99 * ucb1x00_enable must have been called to enable the comms 98 * ucb1x00_enable must have been called to enable the comms
100 * before using this function. 99 * before using this function.
101 * 100 *
102 * This function does not take any semaphores or spinlocks. 101 * This function does not take any mutexes or spinlocks.
103 */ 102 */
104unsigned int ucb1x00_io_read(struct ucb1x00 *ucb) 103unsigned int ucb1x00_io_read(struct ucb1x00 *ucb)
105{ 104{
@@ -183,7 +182,7 @@ static int ucb1x00_gpio_direction_output(struct gpio_chip *chip, unsigned offset
183 * Any code wishing to use the ADC converter must call this 182 * Any code wishing to use the ADC converter must call this
184 * function prior to using it. 183 * function prior to using it.
185 * 184 *
186 * This function takes the ADC semaphore to prevent two or more 185 * This function takes the ADC mutex to prevent two or more
187 * concurrent uses, and therefore may sleep. As a result, it 186 * concurrent uses, and therefore may sleep. As a result, it
188 * can only be called from process context, not interrupt 187 * can only be called from process context, not interrupt
189 * context. 188 * context.
@@ -193,7 +192,7 @@ static int ucb1x00_gpio_direction_output(struct gpio_chip *chip, unsigned offset
193 */ 192 */
194void ucb1x00_adc_enable(struct ucb1x00 *ucb) 193void ucb1x00_adc_enable(struct ucb1x00 *ucb)
195{ 194{
196 down(&ucb->adc_sem); 195 mutex_lock(&ucb->adc_mutex);
197 196
198 ucb->adc_cr |= UCB_ADC_ENA; 197 ucb->adc_cr |= UCB_ADC_ENA;
199 198
@@ -215,7 +214,7 @@ void ucb1x00_adc_enable(struct ucb1x00 *ucb)
215 * complete (2 frames max without sync). 214 * complete (2 frames max without sync).
216 * 215 *
217 * If called for a synchronised ADC conversion, it may sleep 216 * If called for a synchronised ADC conversion, it may sleep
218 * with the ADC semaphore held. 217 * with the ADC mutex held.
219 */ 218 */
220unsigned int ucb1x00_adc_read(struct ucb1x00 *ucb, int adc_channel, int sync) 219unsigned int ucb1x00_adc_read(struct ucb1x00 *ucb, int adc_channel, int sync)
221{ 220{
@@ -243,7 +242,7 @@ unsigned int ucb1x00_adc_read(struct ucb1x00 *ucb, int adc_channel, int sync)
243 * ucb1x00_adc_disable - disable the ADC converter 242 * ucb1x00_adc_disable - disable the ADC converter
244 * @ucb: UCB1x00 structure describing chip 243 * @ucb: UCB1x00 structure describing chip
245 * 244 *
246 * Disable the ADC converter and release the ADC semaphore. 245 * Disable the ADC converter and release the ADC mutex.
247 */ 246 */
248void ucb1x00_adc_disable(struct ucb1x00 *ucb) 247void ucb1x00_adc_disable(struct ucb1x00 *ucb)
249{ 248{
@@ -251,7 +250,7 @@ void ucb1x00_adc_disable(struct ucb1x00 *ucb)
251 ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr); 250 ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr);
252 ucb1x00_disable(ucb); 251 ucb1x00_disable(ucb);
253 252
254 up(&ucb->adc_sem); 253 mutex_unlock(&ucb->adc_mutex);
255} 254}
256 255
257/* 256/*
@@ -560,7 +559,7 @@ static int ucb1x00_probe(struct mcp *mcp)
560 559
561 spin_lock_init(&ucb->lock); 560 spin_lock_init(&ucb->lock);
562 spin_lock_init(&ucb->io_lock); 561 spin_lock_init(&ucb->io_lock);
563 sema_init(&ucb->adc_sem, 1); 562 mutex_init(&ucb->adc_mutex);
564 563
565 ucb->id = id; 564 ucb->id = id;
566 ucb->mcp = mcp; 565 ucb->mcp = mcp;