aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmol Lad <amol@verismonetworks.com>2006-10-17 03:10:36 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-17 11:18:48 -0400
commit0d9ba869e103d91d471146378ad85bf1fb8e74b4 (patch)
tree9892fa0c36e9ac88ab6810a8b233426747a28423
parentbd5349cfd2b9bbb10a3dbcd3fe5cbaabe0b2ab9e (diff)
[PATCH] drivers/isdn/hysdn: save_flags()/cli(), restore_flags() replaced appropriately
With Karsten Keil <kkeil@suse.de> save_flags()/cli() pair is replaced with spin_lock_irqsave() and restore_flags() replaced with spin_unlock_irqrestore() Tested compile only using allmodconfig Signed-off-by: Amol Lad <amol@verismonetworks.com> Acked-by: Karsten Keil <kkeil@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/isdn/hysdn/boardergo.c32
-rw-r--r--drivers/isdn/hysdn/hysdn_defs.h2
-rw-r--r--drivers/isdn/hysdn/hysdn_proclog.c17
-rw-r--r--drivers/isdn/hysdn/hysdn_sched.c9
4 files changed, 27 insertions, 33 deletions
diff --git a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c
index 160f22fa5941..8bbe33ae06db 100644
--- a/drivers/isdn/hysdn/boardergo.c
+++ b/drivers/isdn/hysdn/boardergo.c
@@ -45,11 +45,10 @@ ergo_interrupt(int intno, void *dev_id)
45 if (!card->irq_enabled) 45 if (!card->irq_enabled)
46 return IRQ_NONE; /* other device interrupting or irq switched off */ 46 return IRQ_NONE; /* other device interrupting or irq switched off */
47 47
48 save_flags(flags); 48 spin_lock_irqsave(&card->hysdn_lock, flags); /* no further irqs allowed */
49 cli(); /* no further irqs allowed */
50 49
51 if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) { 50 if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) {
52 restore_flags(flags); /* restore old state */ 51 spin_unlock_irqrestore(&card->hysdn_lock, flags); /* restore old state */
53 return IRQ_NONE; /* no interrupt requested by E1 */ 52 return IRQ_NONE; /* no interrupt requested by E1 */
54 } 53 }
55 /* clear any pending ints on the board */ 54 /* clear any pending ints on the board */
@@ -61,7 +60,7 @@ ergo_interrupt(int intno, void *dev_id)
61 /* start kernel task immediately after leaving all interrupts */ 60 /* start kernel task immediately after leaving all interrupts */
62 if (!card->hw_lock) 61 if (!card->hw_lock)
63 schedule_work(&card->irq_queue); 62 schedule_work(&card->irq_queue);
64 restore_flags(flags); 63 spin_unlock_irqrestore(&card->hysdn_lock, flags);
65 return IRQ_HANDLED; 64 return IRQ_HANDLED;
66} /* ergo_interrupt */ 65} /* ergo_interrupt */
67 66
@@ -83,10 +82,9 @@ ergo_irq_bh(hysdn_card * card)
83 82
84 dpr = card->dpram; /* point to DPRAM */ 83 dpr = card->dpram; /* point to DPRAM */
85 84
86 save_flags(flags); 85 spin_lock_irqsave(&card->hysdn_lock, flags);
87 cli();
88 if (card->hw_lock) { 86 if (card->hw_lock) {
89 restore_flags(flags); /* hardware currently unavailable */ 87 spin_unlock_irqrestore(&card->hysdn_lock, flags); /* hardware currently unavailable */
90 return; 88 return;
91 } 89 }
92 card->hw_lock = 1; /* we now lock the hardware */ 90 card->hw_lock = 1; /* we now lock the hardware */
@@ -120,7 +118,7 @@ ergo_irq_bh(hysdn_card * card)
120 card->hw_lock = 0; /* free hardware again */ 118 card->hw_lock = 0; /* free hardware again */
121 } while (again); /* until nothing more to do */ 119 } while (again); /* until nothing more to do */
122 120
123 restore_flags(flags); 121 spin_unlock_irqrestore(&card->hysdn_lock, flags);
124} /* ergo_irq_bh */ 122} /* ergo_irq_bh */
125 123
126 124
@@ -137,8 +135,7 @@ ergo_stopcard(hysdn_card * card)
137#ifdef CONFIG_HYSDN_CAPI 135#ifdef CONFIG_HYSDN_CAPI
138 hycapi_capi_stop(card); 136 hycapi_capi_stop(card);
139#endif /* CONFIG_HYSDN_CAPI */ 137#endif /* CONFIG_HYSDN_CAPI */
140 save_flags(flags); 138 spin_lock_irqsave(&card->hysdn_lock, flags);
141 cli();
142 val = bytein(card->iobase + PCI9050_INTR_REG); /* get actual value */ 139 val = bytein(card->iobase + PCI9050_INTR_REG); /* get actual value */
143 val &= ~(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1); /* mask irq */ 140 val &= ~(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1); /* mask irq */
144 byteout(card->iobase + PCI9050_INTR_REG, val); 141 byteout(card->iobase + PCI9050_INTR_REG, val);
@@ -147,7 +144,7 @@ ergo_stopcard(hysdn_card * card)
147 card->state = CARD_STATE_UNUSED; 144 card->state = CARD_STATE_UNUSED;
148 card->err_log_state = ERRLOG_STATE_OFF; /* currently no log active */ 145 card->err_log_state = ERRLOG_STATE_OFF; /* currently no log active */
149 146
150 restore_flags(flags); 147 spin_unlock_irqrestore(&card->hysdn_lock, flags);
151} /* ergo_stopcard */ 148} /* ergo_stopcard */
152 149
153/**************************************************************************/ 150/**************************************************************************/
@@ -162,12 +159,11 @@ ergo_set_errlog_state(hysdn_card * card, int on)
162 card->err_log_state = ERRLOG_STATE_OFF; /* must be off */ 159 card->err_log_state = ERRLOG_STATE_OFF; /* must be off */
163 return; 160 return;
164 } 161 }
165 save_flags(flags); 162 spin_lock_irqsave(&card->hysdn_lock, flags);
166 cli();
167 163
168 if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) || 164 if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) ||
169 ((card->err_log_state == ERRLOG_STATE_ON) && on)) { 165 ((card->err_log_state == ERRLOG_STATE_ON) && on)) {
170 restore_flags(flags); 166 spin_unlock_irqrestore(&card->hysdn_lock, flags);
171 return; /* nothing to do */ 167 return; /* nothing to do */
172 } 168 }
173 if (on) 169 if (on)
@@ -175,7 +171,7 @@ ergo_set_errlog_state(hysdn_card * card, int on)
175 else 171 else
176 card->err_log_state = ERRLOG_STATE_STOP; /* request stop */ 172 card->err_log_state = ERRLOG_STATE_STOP; /* request stop */
177 173
178 restore_flags(flags); 174 spin_unlock_irqrestore(&card->hysdn_lock, flags);
179 schedule_work(&card->irq_queue); 175 schedule_work(&card->irq_queue);
180} /* ergo_set_errlog_state */ 176} /* ergo_set_errlog_state */
181 177
@@ -356,8 +352,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
356 352
357 if (card->debug_flags & LOG_POF_RECORD) 353 if (card->debug_flags & LOG_POF_RECORD)
358 hysdn_addlog(card, "ERGO: pof boot success"); 354 hysdn_addlog(card, "ERGO: pof boot success");
359 save_flags(flags); 355 spin_lock_irqsave(&card->hysdn_lock, flags);
360 cli();
361 356
362 card->state = CARD_STATE_RUN; /* now card is running */ 357 card->state = CARD_STATE_RUN; /* now card is running */
363 /* enable the cards interrupt */ 358 /* enable the cards interrupt */
@@ -370,7 +365,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
370 dpr->ToHyInt = 1; 365 dpr->ToHyInt = 1;
371 dpr->ToPcInt = 1; /* interrupt to E1 for all cards */ 366 dpr->ToPcInt = 1; /* interrupt to E1 for all cards */
372 367
373 restore_flags(flags); 368 spin_unlock_irqrestore(&card->hysdn_lock, flags);
374 if ((hynet_enable & (1 << card->myid)) 369 if ((hynet_enable & (1 << card->myid))
375 && (i = hysdn_net_create(card))) 370 && (i = hysdn_net_create(card)))
376 { 371 {
@@ -448,6 +443,7 @@ ergo_inithardware(hysdn_card * card)
448 card->waitpofready = ergo_waitpofready; 443 card->waitpofready = ergo_waitpofready;
449 card->set_errlog_state = ergo_set_errlog_state; 444 card->set_errlog_state = ergo_set_errlog_state;
450 INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card); 445 INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card);
446 card->hysdn_lock = SPIN_LOCK_UNLOCKED;
451 447
452 return (0); 448 return (0);
453} /* ergo_inithardware */ 449} /* ergo_inithardware */
diff --git a/drivers/isdn/hysdn/hysdn_defs.h b/drivers/isdn/hysdn/hysdn_defs.h
index 461e831592dd..729df4089385 100644
--- a/drivers/isdn/hysdn/hysdn_defs.h
+++ b/drivers/isdn/hysdn/hysdn_defs.h
@@ -188,6 +188,8 @@ typedef struct HYSDN_CARD {
188 /* init and deinit stopcard for booting, too */ 188 /* init and deinit stopcard for booting, too */
189 void (*stopcard) (struct HYSDN_CARD *); 189 void (*stopcard) (struct HYSDN_CARD *);
190 void (*releasehardware) (struct HYSDN_CARD *); 190 void (*releasehardware) (struct HYSDN_CARD *);
191
192 spinlock_t hysdn_lock;
191#ifdef CONFIG_HYSDN_CAPI 193#ifdef CONFIG_HYSDN_CAPI
192 struct hycapictrl_info { 194 struct hycapictrl_info {
193 char cardname[32]; 195 char cardname[32];
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index c4301e8338ef..fcd49920b220 100644
--- a/drivers/isdn/hysdn/hysdn_proclog.c
+++ b/drivers/isdn/hysdn/hysdn_proclog.c
@@ -116,8 +116,7 @@ put_log_buffer(hysdn_card * card, char *cp)
116 strcpy(ib->log_start, cp); /* set output string */ 116 strcpy(ib->log_start, cp); /* set output string */
117 ib->next = NULL; 117 ib->next = NULL;
118 ib->proc_ctrl = pd; /* point to own control structure */ 118 ib->proc_ctrl = pd; /* point to own control structure */
119 save_flags(flags); 119 spin_lock_irqsave(&card->hysdn_lock, flags);
120 cli();
121 ib->usage_cnt = pd->if_used; 120 ib->usage_cnt = pd->if_used;
122 if (!pd->log_head) 121 if (!pd->log_head)
123 pd->log_head = ib; /* new head */ 122 pd->log_head = ib; /* new head */
@@ -125,7 +124,7 @@ put_log_buffer(hysdn_card * card, char *cp)
125 pd->log_tail->next = ib; /* follows existing messages */ 124 pd->log_tail->next = ib; /* follows existing messages */
126 pd->log_tail = ib; /* new tail */ 125 pd->log_tail = ib; /* new tail */
127 i = pd->del_lock++; /* get lock state */ 126 i = pd->del_lock++; /* get lock state */
128 restore_flags(flags); 127 spin_unlock_irqrestore(&card->hysdn_lock, flags);
129 128
130 /* delete old entrys */ 129 /* delete old entrys */
131 if (!i) 130 if (!i)
@@ -270,14 +269,13 @@ hysdn_log_open(struct inode *ino, struct file *filep)
270 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { 269 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
271 270
272 /* read access -> log/debug read */ 271 /* read access -> log/debug read */
273 save_flags(flags); 272 spin_lock_irqsave(&card->hysdn_lock, flags);
274 cli();
275 pd->if_used++; 273 pd->if_used++;
276 if (pd->log_head) 274 if (pd->log_head)
277 filep->private_data = &pd->log_tail->next; 275 filep->private_data = &pd->log_tail->next;
278 else 276 else
279 filep->private_data = &pd->log_head; 277 filep->private_data = &pd->log_head;
280 restore_flags(flags); 278 spin_unlock_irqrestore(&card->hysdn_lock, flags);
281 } else { /* simultaneous read/write access forbidden ! */ 279 } else { /* simultaneous read/write access forbidden ! */
282 unlock_kernel(); 280 unlock_kernel();
283 return (-EPERM); /* no permission this time */ 281 return (-EPERM); /* no permission this time */
@@ -301,7 +299,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
301 hysdn_card *card; 299 hysdn_card *card;
302 int retval = 0; 300 int retval = 0;
303 unsigned long flags; 301 unsigned long flags;
304 302 spinlock_t hysdn_lock = SPIN_LOCK_UNLOCKED;
305 303
306 lock_kernel(); 304 lock_kernel();
307 if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) { 305 if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
@@ -311,8 +309,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
311 /* read access -> log/debug read, mark one further file as closed */ 309 /* read access -> log/debug read, mark one further file as closed */
312 310
313 pd = NULL; 311 pd = NULL;
314 save_flags(flags); 312 spin_lock_irqsave(&hysdn_lock, flags);
315 cli();
316 inf = *((struct log_data **) filep->private_data); /* get first log entry */ 313 inf = *((struct log_data **) filep->private_data); /* get first log entry */
317 if (inf) 314 if (inf)
318 pd = (struct procdata *) inf->proc_ctrl; /* still entries there */ 315 pd = (struct procdata *) inf->proc_ctrl; /* still entries there */
@@ -335,7 +332,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
335 inf->usage_cnt--; /* decrement usage count for buffers */ 332 inf->usage_cnt--; /* decrement usage count for buffers */
336 inf = inf->next; 333 inf = inf->next;
337 } 334 }
338 restore_flags(flags); 335 spin_unlock_irqrestore(&hysdn_lock, flags);
339 336
340 if (pd) 337 if (pd)
341 if (pd->if_used <= 0) /* delete buffers if last file closed */ 338 if (pd->if_used <= 0) /* delete buffers if last file closed */
diff --git a/drivers/isdn/hysdn/hysdn_sched.c b/drivers/isdn/hysdn/hysdn_sched.c
index 1c0d54ac12ab..1fadf0133e9b 100644
--- a/drivers/isdn/hysdn/hysdn_sched.c
+++ b/drivers/isdn/hysdn/hysdn_sched.c
@@ -155,8 +155,7 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
155 if (card->debug_flags & LOG_SCHED_ASYN) 155 if (card->debug_flags & LOG_SCHED_ASYN)
156 hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1); 156 hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1);
157 157
158 save_flags(flags); 158 spin_lock_irqsave(&card->hysdn_lock, flags);
159 cli();
160 while (card->async_busy) { 159 while (card->async_busy) {
161 sti(); 160 sti();
162 161
@@ -165,7 +164,7 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
165 164
166 msleep_interruptible(20); /* Timeout 20ms */ 165 msleep_interruptible(20); /* Timeout 20ms */
167 if (!--cnt) { 166 if (!--cnt) {
168 restore_flags(flags); 167 spin_unlock_irqrestore(&card->hysdn_lock, flags);
169 return (-ERR_ASYNC_TIME); /* timed out */ 168 return (-ERR_ASYNC_TIME); /* timed out */
170 } 169 }
171 cli(); 170 cli();
@@ -194,13 +193,13 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
194 193
195 msleep_interruptible(20); /* Timeout 20ms */ 194 msleep_interruptible(20); /* Timeout 20ms */
196 if (!--cnt) { 195 if (!--cnt) {
197 restore_flags(flags); 196 spin_unlock_irqrestore(&card->hysdn_lock, flags);
198 return (-ERR_ASYNC_TIME); /* timed out */ 197 return (-ERR_ASYNC_TIME); /* timed out */
199 } 198 }
200 cli(); 199 cli();
201 } /* wait for buffer to become free again */ 200 } /* wait for buffer to become free again */
202 201
203 restore_flags(flags); 202 spin_unlock_irqrestore(&card->hysdn_lock, flags);
204 203
205 if (card->debug_flags & LOG_SCHED_ASYN) 204 if (card->debug_flags & LOG_SCHED_ASYN)
206 hysdn_addlog(card, "async tx-cfg data send"); 205 hysdn_addlog(card, "async tx-cfg data send");