aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2006-04-11 01:55:12 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-04-11 09:18:50 -0400
commitabfd1dc7c18e4be89715071a524324c7b2515565 (patch)
tree84109f661246b66b2a7503164ec41e4382e37812 /drivers/isdn/gigaset
parent01371500b245ae63f542d74140a3d8ccb74d0318 (diff)
[PATCH] isdn4linux: Siemens Gigaset drivers: mutex conversion
With Hansjoerg Lipp <hjlipp@web.de> Convert the semaphores used by the Gigaset drivers to mutexes. Signed-off-by: Hansjoerg Lipp <hjlipp@web.de> Signed-off-by: Tilman Schmidt <tilman@imap.cc> Cc: Karsten Keil <kkeil@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/isdn/gigaset')
-rw-r--r--drivers/isdn/gigaset/common.c26
-rw-r--r--drivers/isdn/gigaset/gigaset.h2
-rw-r--r--drivers/isdn/gigaset/interface.c44
-rw-r--r--drivers/isdn/gigaset/proc.c6
4 files changed, 40 insertions, 38 deletions
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index e9bfcfd9f116..c3c9804796cd 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -408,7 +408,7 @@ void gigaset_freecs(struct cardstate *cs)
408 if (!cs) 408 if (!cs)
409 return; 409 return;
410 410
411 down(&cs->sem); 411 mutex_lock(&cs->mutex);
412 412
413 if (!cs->bcs) 413 if (!cs->bcs)
414 goto f_cs; 414 goto f_cs;
@@ -459,7 +459,7 @@ void gigaset_freecs(struct cardstate *cs)
459f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]"); 459f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]");
460 kfree(cs->bcs); 460 kfree(cs->bcs);
461f_cs: gig_dbg(DEBUG_INIT, "freeing cs"); 461f_cs: gig_dbg(DEBUG_INIT, "freeing cs");
462 up(&cs->sem); 462 mutex_unlock(&cs->mutex);
463 free_cs(cs); 463 free_cs(cs);
464} 464}
465EXPORT_SYMBOL_GPL(gigaset_freecs); 465EXPORT_SYMBOL_GPL(gigaset_freecs);
@@ -652,7 +652,9 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
652 spin_lock_init(&cs->ev_lock); 652 spin_lock_init(&cs->ev_lock);
653 atomic_set(&cs->ev_tail, 0); 653 atomic_set(&cs->ev_tail, 0);
654 atomic_set(&cs->ev_head, 0); 654 atomic_set(&cs->ev_head, 0);
655 init_MUTEX_LOCKED(&cs->sem); 655 mutex_init(&cs->mutex);
656 mutex_lock(&cs->mutex);
657
656 tasklet_init(&cs->event_tasklet, &gigaset_handle_event, 658 tasklet_init(&cs->event_tasklet, &gigaset_handle_event,
657 (unsigned long) cs); 659 (unsigned long) cs);
658 atomic_set(&cs->commands_pending, 0); 660 atomic_set(&cs->commands_pending, 0);
@@ -729,11 +731,11 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
729 add_timer(&cs->timer); 731 add_timer(&cs->timer);
730 732
731 gig_dbg(DEBUG_INIT, "cs initialized"); 733 gig_dbg(DEBUG_INIT, "cs initialized");
732 up(&cs->sem); 734 mutex_unlock(&cs->mutex);
733 return cs; 735 return cs;
734 736
735error: if (cs) 737error: if (cs)
736 up(&cs->sem); 738 mutex_unlock(&cs->mutex);
737 gig_dbg(DEBUG_INIT, "failed"); 739 gig_dbg(DEBUG_INIT, "failed");
738 gigaset_freecs(cs); 740 gigaset_freecs(cs);
739 return NULL; 741 return NULL;
@@ -831,7 +833,7 @@ static void cleanup_cs(struct cardstate *cs)
831 833
832int gigaset_start(struct cardstate *cs) 834int gigaset_start(struct cardstate *cs)
833{ 835{
834 if (down_interruptible(&cs->sem)) 836 if (mutex_lock_interruptible(&cs->mutex))
835 return 0; 837 return 0;
836 838
837 atomic_set(&cs->connected, 1); 839 atomic_set(&cs->connected, 1);
@@ -861,18 +863,18 @@ int gigaset_start(struct cardstate *cs)
861 /* set up device sysfs */ 863 /* set up device sysfs */
862 gigaset_init_dev_sysfs(cs); 864 gigaset_init_dev_sysfs(cs);
863 865
864 up(&cs->sem); 866 mutex_unlock(&cs->mutex);
865 return 1; 867 return 1;
866 868
867error: 869error:
868 up(&cs->sem); 870 mutex_unlock(&cs->mutex);
869 return 0; 871 return 0;
870} 872}
871EXPORT_SYMBOL_GPL(gigaset_start); 873EXPORT_SYMBOL_GPL(gigaset_start);
872 874
873void gigaset_shutdown(struct cardstate *cs) 875void gigaset_shutdown(struct cardstate *cs)
874{ 876{
875 down(&cs->sem); 877 mutex_lock(&cs->mutex);
876 878
877 cs->waiting = 1; 879 cs->waiting = 1;
878 880
@@ -902,13 +904,13 @@ void gigaset_shutdown(struct cardstate *cs)
902 cleanup_cs(cs); 904 cleanup_cs(cs);
903 905
904exit: 906exit:
905 up(&cs->sem); 907 mutex_unlock(&cs->mutex);
906} 908}
907EXPORT_SYMBOL_GPL(gigaset_shutdown); 909EXPORT_SYMBOL_GPL(gigaset_shutdown);
908 910
909void gigaset_stop(struct cardstate *cs) 911void gigaset_stop(struct cardstate *cs)
910{ 912{
911 down(&cs->sem); 913 mutex_lock(&cs->mutex);
912 914
913 /* clear device sysfs */ 915 /* clear device sysfs */
914 gigaset_free_dev_sysfs(cs); 916 gigaset_free_dev_sysfs(cs);
@@ -936,7 +938,7 @@ void gigaset_stop(struct cardstate *cs)
936 cleanup_cs(cs); 938 cleanup_cs(cs);
937 939
938exit: 940exit:
939 up(&cs->sem); 941 mutex_unlock(&cs->mutex);
940} 942}
941EXPORT_SYMBOL_GPL(gigaset_stop); 943EXPORT_SYMBOL_GPL(gigaset_stop);
942 944
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index 7a44caca8a17..12153acc23e4 100644
--- a/drivers/isdn/gigaset/gigaset.h
+++ b/drivers/isdn/gigaset/gigaset.h
@@ -497,7 +497,7 @@ struct cardstate {
497 int cs_init; 497 int cs_init;
498 int ignoreframes; /* frames to ignore after setting up the 498 int ignoreframes; /* frames to ignore after setting up the
499 B channel */ 499 B channel */
500 struct semaphore sem; /* locks this structure: 500 struct mutex mutex; /* locks this structure:
501 * connected is not changed, 501 * connected is not changed,
502 * hardware_up is not changed, 502 * hardware_up is not changed,
503 * MState is not changed to or from 503 * MState is not changed to or from
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index 25750864d206..ac408acaaf17 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -160,7 +160,7 @@ static int if_open(struct tty_struct *tty, struct file *filp)
160 if (!cs) 160 if (!cs)
161 return -ENODEV; 161 return -ENODEV;
162 162
163 if (down_interruptible(&cs->sem)) 163 if (mutex_lock_interruptible(&cs->mutex))
164 return -ERESTARTSYS; // FIXME -EINTR? 164 return -ERESTARTSYS; // FIXME -EINTR?
165 tty->driver_data = cs; 165 tty->driver_data = cs;
166 166
@@ -173,7 +173,7 @@ static int if_open(struct tty_struct *tty, struct file *filp)
173 tty->low_latency = 1; //FIXME test 173 tty->low_latency = 1; //FIXME test
174 } 174 }
175 175
176 up(&cs->sem); 176 mutex_unlock(&cs->mutex);
177 return 0; 177 return 0;
178} 178}
179 179
@@ -190,7 +190,7 @@ static void if_close(struct tty_struct *tty, struct file *filp)
190 190
191 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); 191 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
192 192
193 down(&cs->sem); 193 mutex_lock(&cs->mutex);
194 194
195 if (!cs->open_count) 195 if (!cs->open_count)
196 warn("%s: device not opened", __func__); 196 warn("%s: device not opened", __func__);
@@ -202,7 +202,7 @@ static void if_close(struct tty_struct *tty, struct file *filp)
202 } 202 }
203 } 203 }
204 204
205 up(&cs->sem); 205 mutex_unlock(&cs->mutex);
206} 206}
207 207
208static int if_ioctl(struct tty_struct *tty, struct file *file, 208static int if_ioctl(struct tty_struct *tty, struct file *file,
@@ -222,7 +222,7 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
222 222
223 gig_dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __func__, cmd); 223 gig_dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __func__, cmd);
224 224
225 if (down_interruptible(&cs->sem)) 225 if (mutex_lock_interruptible(&cs->mutex))
226 return -ERESTARTSYS; // FIXME -EINTR? 226 return -ERESTARTSYS; // FIXME -EINTR?
227 227
228 if (!cs->open_count) 228 if (!cs->open_count)
@@ -279,7 +279,7 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
279 } 279 }
280 } 280 }
281 281
282 up(&cs->sem); 282 mutex_unlock(&cs->mutex);
283 283
284 return retval; 284 return retval;
285} 285}
@@ -297,13 +297,13 @@ static int if_tiocmget(struct tty_struct *tty, struct file *file)
297 297
298 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); 298 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
299 299
300 if (down_interruptible(&cs->sem)) 300 if (mutex_lock_interruptible(&cs->mutex))
301 return -ERESTARTSYS; // FIXME -EINTR? 301 return -ERESTARTSYS; // FIXME -EINTR?
302 302
303 // FIXME read from device? 303 // FIXME read from device?
304 retval = cs->control_state & (TIOCM_RTS|TIOCM_DTR); 304 retval = cs->control_state & (TIOCM_RTS|TIOCM_DTR);
305 305
306 up(&cs->sem); 306 mutex_unlock(&cs->mutex);
307 307
308 return retval; 308 return retval;
309} 309}
@@ -324,7 +324,7 @@ static int if_tiocmset(struct tty_struct *tty, struct file *file,
324 gig_dbg(DEBUG_IF, "%u: %s(0x%x, 0x%x)", 324 gig_dbg(DEBUG_IF, "%u: %s(0x%x, 0x%x)",
325 cs->minor_index, __func__, set, clear); 325 cs->minor_index, __func__, set, clear);
326 326
327 if (down_interruptible(&cs->sem)) 327 if (mutex_lock_interruptible(&cs->mutex))
328 return -ERESTARTSYS; // FIXME -EINTR? 328 return -ERESTARTSYS; // FIXME -EINTR?
329 329
330 if (!atomic_read(&cs->connected)) { 330 if (!atomic_read(&cs->connected)) {
@@ -336,7 +336,7 @@ static int if_tiocmset(struct tty_struct *tty, struct file *file,
336 cs->control_state = mc; 336 cs->control_state = mc;
337 } 337 }
338 338
339 up(&cs->sem); 339 mutex_unlock(&cs->mutex);
340 340
341 return retval; 341 return retval;
342} 342}
@@ -354,7 +354,7 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
354 354
355 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); 355 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
356 356
357 if (down_interruptible(&cs->sem)) 357 if (mutex_lock_interruptible(&cs->mutex))
358 return -ERESTARTSYS; // FIXME -EINTR? 358 return -ERESTARTSYS; // FIXME -EINTR?
359 359
360 if (!cs->open_count) 360 if (!cs->open_count)
@@ -370,7 +370,7 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
370 &cs->if_wake_tasklet); 370 &cs->if_wake_tasklet);
371 } 371 }
372 372
373 up(&cs->sem); 373 mutex_unlock(&cs->mutex);
374 374
375 return retval; 375 return retval;
376} 376}
@@ -388,7 +388,7 @@ static int if_write_room(struct tty_struct *tty)
388 388
389 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); 389 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
390 390
391 if (down_interruptible(&cs->sem)) 391 if (mutex_lock_interruptible(&cs->mutex))
392 return -ERESTARTSYS; // FIXME -EINTR? 392 return -ERESTARTSYS; // FIXME -EINTR?
393 393
394 if (!cs->open_count) 394 if (!cs->open_count)
@@ -402,7 +402,7 @@ static int if_write_room(struct tty_struct *tty)
402 } else 402 } else
403 retval = cs->ops->write_room(cs); 403 retval = cs->ops->write_room(cs);
404 404
405 up(&cs->sem); 405 mutex_unlock(&cs->mutex);
406 406
407 return retval; 407 return retval;
408} 408}
@@ -420,7 +420,7 @@ static int if_chars_in_buffer(struct tty_struct *tty)
420 420
421 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); 421 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
422 422
423 if (down_interruptible(&cs->sem)) 423 if (mutex_lock_interruptible(&cs->mutex))
424 return -ERESTARTSYS; // FIXME -EINTR? 424 return -ERESTARTSYS; // FIXME -EINTR?
425 425
426 if (!cs->open_count) 426 if (!cs->open_count)
@@ -434,7 +434,7 @@ static int if_chars_in_buffer(struct tty_struct *tty)
434 } else 434 } else
435 retval = cs->ops->chars_in_buffer(cs); 435 retval = cs->ops->chars_in_buffer(cs);
436 436
437 up(&cs->sem); 437 mutex_unlock(&cs->mutex);
438 438
439 return retval; 439 return retval;
440} 440}
@@ -451,7 +451,7 @@ static void if_throttle(struct tty_struct *tty)
451 451
452 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); 452 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
453 453
454 down(&cs->sem); 454 mutex_lock(&cs->mutex);
455 455
456 if (!cs->open_count) 456 if (!cs->open_count)
457 warn("%s: device not opened", __func__); 457 warn("%s: device not opened", __func__);
@@ -459,7 +459,7 @@ static void if_throttle(struct tty_struct *tty)
459 //FIXME 459 //FIXME
460 } 460 }
461 461
462 up(&cs->sem); 462 mutex_unlock(&cs->mutex);
463} 463}
464 464
465static void if_unthrottle(struct tty_struct *tty) 465static void if_unthrottle(struct tty_struct *tty)
@@ -474,7 +474,7 @@ static void if_unthrottle(struct tty_struct *tty)
474 474
475 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); 475 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
476 476
477 down(&cs->sem); 477 mutex_lock(&cs->mutex);
478 478
479 if (!cs->open_count) 479 if (!cs->open_count)
480 warn("%s: device not opened", __func__); 480 warn("%s: device not opened", __func__);
@@ -482,7 +482,7 @@ static void if_unthrottle(struct tty_struct *tty)
482 //FIXME 482 //FIXME
483 } 483 }
484 484
485 up(&cs->sem); 485 mutex_unlock(&cs->mutex);
486} 486}
487 487
488static void if_set_termios(struct tty_struct *tty, struct termios *old) 488static void if_set_termios(struct tty_struct *tty, struct termios *old)
@@ -501,7 +501,7 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
501 501
502 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); 502 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
503 503
504 down(&cs->sem); 504 mutex_lock(&cs->mutex);
505 505
506 if (!cs->open_count) { 506 if (!cs->open_count) {
507 warn("%s: device not opened", __func__); 507 warn("%s: device not opened", __func__);
@@ -586,7 +586,7 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
586 cs->control_state = control_state; 586 cs->control_state = control_state;
587 587
588out: 588out:
589 up(&cs->sem); 589 mutex_unlock(&cs->mutex);
590} 590}
591 591
592 592
diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c
index 912fed670742..8f124e8e604b 100644
--- a/drivers/isdn/gigaset/proc.c
+++ b/drivers/isdn/gigaset/proc.c
@@ -37,14 +37,14 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
37 if (value < 0 || value > 1) 37 if (value < 0 || value > 1)
38 return -EINVAL; 38 return -EINVAL;
39 39
40 if (down_interruptible(&cs->sem)) 40 if (mutex_lock_interruptible(&cs->mutex))
41 return -ERESTARTSYS; // FIXME -EINTR? 41 return -ERESTARTSYS; // FIXME -EINTR?
42 42
43 cs->waiting = 1; 43 cs->waiting = 1;
44 if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE, 44 if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE,
45 NULL, value, NULL)) { 45 NULL, value, NULL)) {
46 cs->waiting = 0; 46 cs->waiting = 0;
47 up(&cs->sem); 47 mutex_unlock(&cs->mutex);
48 return -ENOMEM; 48 return -ENOMEM;
49 } 49 }
50 50
@@ -53,7 +53,7 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
53 53
54 wait_event(cs->waitqueue, !cs->waiting); 54 wait_event(cs->waitqueue, !cs->waiting);
55 55
56 up(&cs->sem); 56 mutex_unlock(&cs->mutex);
57 57
58 return count; 58 return count;
59} 59}