1 # patch found at http://freiburg.linux.de/~zeisberg/howtos/fritzcarddsl.html
2 --- fritz.old/src.drv/driver.c.orig 2003-12-19 00:00:00.000000000 +0200
3 +++ fritz/src.drv/driver.c 2004-07-18 17:03:36.000000000 +0200
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
13 + * Saturday Jul 24 2004, Oswin Horvath
14 + * small modifications to make the patch work for the Fritz!Card SL USB (03.11.94)
25 #if defined (LOG_MESSAGES)
29 static bundle_t ctrl_context[2];
30 static per_ctrl_t ctrl_params[2];
31 static unsigned long qt_flags;
32 +#if defined (SINGLE_LOCK)
33 +# define stack_lock qt_lock
35 static spinlock_t qt_lock = SPIN_LOCK_UNLOCKED;
37 static atomic_t thread_flag = ATOMIC_INIT (0);
38 static atomic_t thread_capi_flag = ATOMIC_INIT (0);
39 static int thread_pid = -1;
41 } /* fdslusb_remove_ctrl */
43 /*---------------------------------------------------------------------------*\
44 -\*-L-------------------------------------------------------------------------*/
45 +\*---------------------------------------------------------------------------*/
47 unsigned long local_flags;
50 /*---------------------------------------------------------------------------*\
51 \*-C-------------------------------------------------------------------------*/
52 static inline void check (void) {
53 + unsigned long flags;
55 if (atomic_read (&rx_flag) > 0) {
56 + spin_lock_irqsave (&stack_lock, flags);
57 rx_handler (fcslusb_capi_card);
58 + spin_unlock_irqrestore (&stack_lock, flags);
60 if (atomic_read (&tx_flag) > 0) {
61 + spin_lock_irqsave (&stack_lock, flags);
62 tx_handler (fcslusb_capi_card);
63 + spin_unlock_irqrestore (&stack_lock, flags);
68 /*-S-------------------------------------------------------------------------*\
69 \*---------------------------------------------------------------------------*/
70 static int scheduler (void * arg) {
71 + unsigned long flags;
78 /* Body of thread, invoke scheduler */
79 + local_irq_save(flags);
80 if (spin_trylock (&stack_lock)) {
81 info (!atomic_xchg (&in_scheduler, 1));
84 debug (atomic_set (&in_scheduler, 0));
85 spin_unlock (&stack_lock);
87 + local_irq_restore(flags);
89 log ("Scheduler thread stopped.\n");
91 @@ -1743,22 +1765,43 @@
92 /*---------------------------------------------------------------------------*\
93 \*---------------------------------------------------------------------------*/
94 static void tx_task (unsigned long data) {
96 + unsigned long flags;
98 - if (!in_critical () && spin_trylock (&stack_lock)) {
99 - tx_handler (fcslusb_capi_card);
100 - spin_unlock (&stack_lock);
102 + if (in_critical ()){
103 + atomic_set (&tx_flag, 1);
106 + local_irq_save(flags);
107 + if (spin_trylock (&stack_lock)) {
108 + tx_handler (fcslusb_capi_card);
109 + spin_unlock (&stack_lock);
111 + atomic_set (&tx_flag, 1);
114 + local_irq_restore(flags);
118 /*---------------------------------------------------------------------------*\
119 \*---------------------------------------------------------------------------*/
120 static void rx_task (unsigned long data) {
122 + unsigned long flags;
124 - if (!in_critical () && spin_trylock (&stack_lock)) {
125 - rx_handler (fcslusb_capi_card);
126 - spin_unlock (&stack_lock);
127 + if (in_critical ()){
128 + atomic_set (&rx_flag, 1);
131 + local_irq_save(flags);
132 + if (spin_trylock (&stack_lock)) {
133 + rx_handler (fcslusb_capi_card);
134 + spin_unlock (&stack_lock);
136 + atomic_set (&rx_flag, 1);
139 + local_irq_restore(flags);