1 # patch found at http://freiburg.linux.de/~zeisberg/howtos/fritzcarddsl.html
2 --- fritz.old/src.drv/driver.c.orig Sun Dec 7 17:46:27 2003
3 +++ fritz/src.drv/driver.c Wed Dec 17 23:46:53 2003
5 * http://www.opensource.org/licenses/lgpl-license.html
7 * Contact: AVM GmbH, Alt-Moabit 95, 10559 Berlin, Germany, email: info@avm.de
9 + * Sunday Dec 07 18:10 2003
10 + * Modified by Christian 'greeny' Heckhoff to improve locking
11 + * based on modifications by Joerg Lehrke for Fritz!Card DSL
22 #if defined (LOG_MESSAGES)
26 static bundle_t ctrl_context[2];
27 static per_ctrl_t ctrl_params[2];
28 static unsigned long qt_flags;
29 +#if defined (SINGLE_LOCK)
30 +# define stack_lock qt_lock
32 static spinlock_t qt_lock = SPIN_LOCK_UNLOCKED;
34 static atomic_t thread_flag = ATOMIC_INIT (0);
35 static atomic_t thread_capi_flag = ATOMIC_INIT (0);
36 static int thread_pid = -1;
40 /*---------------------------------------------------------------------------*\
41 -\*-L-------------------------------------------------------------------------*/
42 +\*---------------------------------------------------------------------------*/
44 unsigned long local_flags;
46 @@ -1146,15 +1157,14 @@
49 /*---------------------------------------------------------------------------*\
50 -\*-C-------------------------------------------------------------------------*/
51 +\*---------------------------------------------------------------------------*/
52 static inline void check (void) {
54 - spinlock_t chk_lock = SPIN_LOCK_UNLOCKED;
56 if (atomic_xchg (&xfer_flag, 0)) {
57 - spin_lock_irqsave (&chk_lock, flags);
58 + spin_lock_irqsave (&stack_lock, flags);
59 xfer_handler (capi_card);
60 - spin_unlock_irqrestore (&chk_lock, flags);
61 + spin_unlock_irqrestore (&stack_lock, flags);
65 @@ -1687,9 +1697,10 @@
66 return ncci_data_buffer (capi_card->appls, appp, ncci, handle);
69 -/*-S-------------------------------------------------------------------------*\
70 +/*---------------------------------------------------------------------------*\
71 \*---------------------------------------------------------------------------*/
72 static int sched_thread (void * arg) {
73 + unsigned long flags;
80 /* Body of thread, invoke scheduler */
81 + local_irq_save(flags);
82 if (spin_trylock (&stack_lock)) {
84 assert (capi_lib->cm_schedule);
87 spin_unlock (&stack_lock);
89 + local_irq_restore(flags);
91 log ("Scheduler thread stopped.\n");