aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMaxim Levitsky <maximlevitsky@gmail.com>2010-07-31 10:59:16 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-08-08 22:42:59 -0400
commit45a568fa6f6bf8e5b9c32e52292f297e8473a985 (patch)
treeb64adef3e5a75e7f00b477d43724986a0c3aacea /drivers/media
parent510fcb70ff375b0cec6638fcfafdf36233690bfc (diff)
V4L/DVB: IR: replace spinlock with mutex
Some handlers (lirc for example) allocates memory on initialization, doing so in atomic context is cumbersome. Fixes warning about sleeping function in atomic context. Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/IR/ir-raw-event.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c
index 51f65daa086b..9d5c029cfc0c 100644
--- a/drivers/media/IR/ir-raw-event.c
+++ b/drivers/media/IR/ir-raw-event.c
@@ -13,7 +13,7 @@
13 */ 13 */
14 14
15#include <linux/workqueue.h> 15#include <linux/workqueue.h>
16#include <linux/spinlock.h> 16#include <linux/mutex.h>
17#include <linux/sched.h> 17#include <linux/sched.h>
18#include "ir-core-priv.h" 18#include "ir-core-priv.h"
19 19
@@ -24,7 +24,7 @@
24static LIST_HEAD(ir_raw_client_list); 24static LIST_HEAD(ir_raw_client_list);
25 25
26/* Used to handle IR raw handler extensions */ 26/* Used to handle IR raw handler extensions */
27static DEFINE_SPINLOCK(ir_raw_handler_lock); 27static DEFINE_MUTEX(ir_raw_handler_lock);
28static LIST_HEAD(ir_raw_handler_list); 28static LIST_HEAD(ir_raw_handler_list);
29static u64 available_protocols; 29static u64 available_protocols;
30 30
@@ -41,10 +41,10 @@ static void ir_raw_event_work(struct work_struct *work)
41 container_of(work, struct ir_raw_event_ctrl, rx_work); 41 container_of(work, struct ir_raw_event_ctrl, rx_work);
42 42
43 while (kfifo_out(&raw->kfifo, &ev, sizeof(ev)) == sizeof(ev)) { 43 while (kfifo_out(&raw->kfifo, &ev, sizeof(ev)) == sizeof(ev)) {
44 spin_lock(&ir_raw_handler_lock); 44 mutex_lock(&ir_raw_handler_lock);
45 list_for_each_entry(handler, &ir_raw_handler_list, list) 45 list_for_each_entry(handler, &ir_raw_handler_list, list)
46 handler->decode(raw->input_dev, ev); 46 handler->decode(raw->input_dev, ev);
47 spin_unlock(&ir_raw_handler_lock); 47 mutex_unlock(&ir_raw_handler_lock);
48 raw->prev_ev = ev; 48 raw->prev_ev = ev;
49 } 49 }
50} 50}
@@ -150,9 +150,9 @@ u64
150ir_raw_get_allowed_protocols() 150ir_raw_get_allowed_protocols()
151{ 151{
152 u64 protocols; 152 u64 protocols;
153 spin_lock(&ir_raw_handler_lock); 153 mutex_lock(&ir_raw_handler_lock);
154 protocols = available_protocols; 154 protocols = available_protocols;
155 spin_unlock(&ir_raw_handler_lock); 155 mutex_unlock(&ir_raw_handler_lock);
156 return protocols; 156 return protocols;
157} 157}
158 158
@@ -180,12 +180,12 @@ int ir_raw_event_register(struct input_dev *input_dev)
180 return rc; 180 return rc;
181 } 181 }
182 182
183 spin_lock(&ir_raw_handler_lock); 183 mutex_lock(&ir_raw_handler_lock);
184 list_add_tail(&ir->raw->list, &ir_raw_client_list); 184 list_add_tail(&ir->raw->list, &ir_raw_client_list);
185 list_for_each_entry(handler, &ir_raw_handler_list, list) 185 list_for_each_entry(handler, &ir_raw_handler_list, list)
186 if (handler->raw_register) 186 if (handler->raw_register)
187 handler->raw_register(ir->raw->input_dev); 187 handler->raw_register(ir->raw->input_dev);
188 spin_unlock(&ir_raw_handler_lock); 188 mutex_unlock(&ir_raw_handler_lock);
189 189
190 return 0; 190 return 0;
191} 191}
@@ -200,12 +200,12 @@ void ir_raw_event_unregister(struct input_dev *input_dev)
200 200
201 cancel_work_sync(&ir->raw->rx_work); 201 cancel_work_sync(&ir->raw->rx_work);
202 202
203 spin_lock(&ir_raw_handler_lock); 203 mutex_lock(&ir_raw_handler_lock);
204 list_del(&ir->raw->list); 204 list_del(&ir->raw->list);
205 list_for_each_entry(handler, &ir_raw_handler_list, list) 205 list_for_each_entry(handler, &ir_raw_handler_list, list)
206 if (handler->raw_unregister) 206 if (handler->raw_unregister)
207 handler->raw_unregister(ir->raw->input_dev); 207 handler->raw_unregister(ir->raw->input_dev);
208 spin_unlock(&ir_raw_handler_lock); 208 mutex_unlock(&ir_raw_handler_lock);
209 209
210 kfifo_free(&ir->raw->kfifo); 210 kfifo_free(&ir->raw->kfifo);
211 kfree(ir->raw); 211 kfree(ir->raw);
@@ -220,13 +220,13 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler)
220{ 220{
221 struct ir_raw_event_ctrl *raw; 221 struct ir_raw_event_ctrl *raw;
222 222
223 spin_lock(&ir_raw_handler_lock); 223 mutex_lock(&ir_raw_handler_lock);
224 list_add_tail(&ir_raw_handler->list, &ir_raw_handler_list); 224 list_add_tail(&ir_raw_handler->list, &ir_raw_handler_list);
225 if (ir_raw_handler->raw_register) 225 if (ir_raw_handler->raw_register)
226 list_for_each_entry(raw, &ir_raw_client_list, list) 226 list_for_each_entry(raw, &ir_raw_client_list, list)
227 ir_raw_handler->raw_register(raw->input_dev); 227 ir_raw_handler->raw_register(raw->input_dev);
228 available_protocols |= ir_raw_handler->protocols; 228 available_protocols |= ir_raw_handler->protocols;
229 spin_unlock(&ir_raw_handler_lock); 229 mutex_unlock(&ir_raw_handler_lock);
230 230
231 return 0; 231 return 0;
232} 232}
@@ -236,13 +236,13 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler)
236{ 236{
237 struct ir_raw_event_ctrl *raw; 237 struct ir_raw_event_ctrl *raw;
238 238
239 spin_lock(&ir_raw_handler_lock); 239 mutex_lock(&ir_raw_handler_lock);
240 list_del(&ir_raw_handler->list); 240 list_del(&ir_raw_handler->list);
241 if (ir_raw_handler->raw_unregister) 241 if (ir_raw_handler->raw_unregister)
242 list_for_each_entry(raw, &ir_raw_client_list, list) 242 list_for_each_entry(raw, &ir_raw_client_list, list)
243 ir_raw_handler->raw_unregister(raw->input_dev); 243 ir_raw_handler->raw_unregister(raw->input_dev);
244 available_protocols &= ~ir_raw_handler->protocols; 244 available_protocols &= ~ir_raw_handler->protocols;
245 spin_unlock(&ir_raw_handler_lock); 245 mutex_unlock(&ir_raw_handler_lock);
246} 246}
247EXPORT_SYMBOL(ir_raw_handler_unregister); 247EXPORT_SYMBOL(ir_raw_handler_unregister);
248 248