[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>
This commit is contained in:
parent
bd5349cfd2
commit
0d9ba869e1
|
@ -45,11 +45,10 @@ ergo_interrupt(int intno, void *dev_id)
|
||||||
if (!card->irq_enabled)
|
if (!card->irq_enabled)
|
||||||
return IRQ_NONE; /* other device interrupting or irq switched off */
|
return IRQ_NONE; /* other device interrupting or irq switched off */
|
||||||
|
|
||||||
save_flags(flags);
|
spin_lock_irqsave(&card->hysdn_lock, flags); /* no further irqs allowed */
|
||||||
cli(); /* no further irqs allowed */
|
|
||||||
|
|
||||||
if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) {
|
if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) {
|
||||||
restore_flags(flags); /* restore old state */
|
spin_unlock_irqrestore(&card->hysdn_lock, flags); /* restore old state */
|
||||||
return IRQ_NONE; /* no interrupt requested by E1 */
|
return IRQ_NONE; /* no interrupt requested by E1 */
|
||||||
}
|
}
|
||||||
/* clear any pending ints on the board */
|
/* clear any pending ints on the board */
|
||||||
|
@ -61,7 +60,7 @@ ergo_interrupt(int intno, void *dev_id)
|
||||||
/* start kernel task immediately after leaving all interrupts */
|
/* start kernel task immediately after leaving all interrupts */
|
||||||
if (!card->hw_lock)
|
if (!card->hw_lock)
|
||||||
schedule_work(&card->irq_queue);
|
schedule_work(&card->irq_queue);
|
||||||
restore_flags(flags);
|
spin_unlock_irqrestore(&card->hysdn_lock, flags);
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
} /* ergo_interrupt */
|
} /* ergo_interrupt */
|
||||||
|
|
||||||
|
@ -83,10 +82,9 @@ ergo_irq_bh(hysdn_card * card)
|
||||||
|
|
||||||
dpr = card->dpram; /* point to DPRAM */
|
dpr = card->dpram; /* point to DPRAM */
|
||||||
|
|
||||||
save_flags(flags);
|
spin_lock_irqsave(&card->hysdn_lock, flags);
|
||||||
cli();
|
|
||||||
if (card->hw_lock) {
|
if (card->hw_lock) {
|
||||||
restore_flags(flags); /* hardware currently unavailable */
|
spin_unlock_irqrestore(&card->hysdn_lock, flags); /* hardware currently unavailable */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
card->hw_lock = 1; /* we now lock the hardware */
|
card->hw_lock = 1; /* we now lock the hardware */
|
||||||
|
@ -120,7 +118,7 @@ ergo_irq_bh(hysdn_card * card)
|
||||||
card->hw_lock = 0; /* free hardware again */
|
card->hw_lock = 0; /* free hardware again */
|
||||||
} while (again); /* until nothing more to do */
|
} while (again); /* until nothing more to do */
|
||||||
|
|
||||||
restore_flags(flags);
|
spin_unlock_irqrestore(&card->hysdn_lock, flags);
|
||||||
} /* ergo_irq_bh */
|
} /* ergo_irq_bh */
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,8 +135,7 @@ ergo_stopcard(hysdn_card * card)
|
||||||
#ifdef CONFIG_HYSDN_CAPI
|
#ifdef CONFIG_HYSDN_CAPI
|
||||||
hycapi_capi_stop(card);
|
hycapi_capi_stop(card);
|
||||||
#endif /* CONFIG_HYSDN_CAPI */
|
#endif /* CONFIG_HYSDN_CAPI */
|
||||||
save_flags(flags);
|
spin_lock_irqsave(&card->hysdn_lock, flags);
|
||||||
cli();
|
|
||||||
val = bytein(card->iobase + PCI9050_INTR_REG); /* get actual value */
|
val = bytein(card->iobase + PCI9050_INTR_REG); /* get actual value */
|
||||||
val &= ~(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1); /* mask irq */
|
val &= ~(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1); /* mask irq */
|
||||||
byteout(card->iobase + PCI9050_INTR_REG, val);
|
byteout(card->iobase + PCI9050_INTR_REG, val);
|
||||||
|
@ -147,7 +144,7 @@ ergo_stopcard(hysdn_card * card)
|
||||||
card->state = CARD_STATE_UNUSED;
|
card->state = CARD_STATE_UNUSED;
|
||||||
card->err_log_state = ERRLOG_STATE_OFF; /* currently no log active */
|
card->err_log_state = ERRLOG_STATE_OFF; /* currently no log active */
|
||||||
|
|
||||||
restore_flags(flags);
|
spin_unlock_irqrestore(&card->hysdn_lock, flags);
|
||||||
} /* ergo_stopcard */
|
} /* ergo_stopcard */
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
@ -162,12 +159,11 @@ ergo_set_errlog_state(hysdn_card * card, int on)
|
||||||
card->err_log_state = ERRLOG_STATE_OFF; /* must be off */
|
card->err_log_state = ERRLOG_STATE_OFF; /* must be off */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
save_flags(flags);
|
spin_lock_irqsave(&card->hysdn_lock, flags);
|
||||||
cli();
|
|
||||||
|
|
||||||
if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) ||
|
if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) ||
|
||||||
((card->err_log_state == ERRLOG_STATE_ON) && on)) {
|
((card->err_log_state == ERRLOG_STATE_ON) && on)) {
|
||||||
restore_flags(flags);
|
spin_unlock_irqrestore(&card->hysdn_lock, flags);
|
||||||
return; /* nothing to do */
|
return; /* nothing to do */
|
||||||
}
|
}
|
||||||
if (on)
|
if (on)
|
||||||
|
@ -175,7 +171,7 @@ ergo_set_errlog_state(hysdn_card * card, int on)
|
||||||
else
|
else
|
||||||
card->err_log_state = ERRLOG_STATE_STOP; /* request stop */
|
card->err_log_state = ERRLOG_STATE_STOP; /* request stop */
|
||||||
|
|
||||||
restore_flags(flags);
|
spin_unlock_irqrestore(&card->hysdn_lock, flags);
|
||||||
schedule_work(&card->irq_queue);
|
schedule_work(&card->irq_queue);
|
||||||
} /* ergo_set_errlog_state */
|
} /* ergo_set_errlog_state */
|
||||||
|
|
||||||
|
@ -356,8 +352,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
|
||||||
|
|
||||||
if (card->debug_flags & LOG_POF_RECORD)
|
if (card->debug_flags & LOG_POF_RECORD)
|
||||||
hysdn_addlog(card, "ERGO: pof boot success");
|
hysdn_addlog(card, "ERGO: pof boot success");
|
||||||
save_flags(flags);
|
spin_lock_irqsave(&card->hysdn_lock, flags);
|
||||||
cli();
|
|
||||||
|
|
||||||
card->state = CARD_STATE_RUN; /* now card is running */
|
card->state = CARD_STATE_RUN; /* now card is running */
|
||||||
/* enable the cards interrupt */
|
/* enable the cards interrupt */
|
||||||
|
@ -370,7 +365,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
|
||||||
dpr->ToHyInt = 1;
|
dpr->ToHyInt = 1;
|
||||||
dpr->ToPcInt = 1; /* interrupt to E1 for all cards */
|
dpr->ToPcInt = 1; /* interrupt to E1 for all cards */
|
||||||
|
|
||||||
restore_flags(flags);
|
spin_unlock_irqrestore(&card->hysdn_lock, flags);
|
||||||
if ((hynet_enable & (1 << card->myid))
|
if ((hynet_enable & (1 << card->myid))
|
||||||
&& (i = hysdn_net_create(card)))
|
&& (i = hysdn_net_create(card)))
|
||||||
{
|
{
|
||||||
|
@ -448,6 +443,7 @@ ergo_inithardware(hysdn_card * card)
|
||||||
card->waitpofready = ergo_waitpofready;
|
card->waitpofready = ergo_waitpofready;
|
||||||
card->set_errlog_state = ergo_set_errlog_state;
|
card->set_errlog_state = ergo_set_errlog_state;
|
||||||
INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card);
|
INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card);
|
||||||
|
card->hysdn_lock = SPIN_LOCK_UNLOCKED;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
} /* ergo_inithardware */
|
} /* ergo_inithardware */
|
||||||
|
|
|
@ -188,6 +188,8 @@ typedef struct HYSDN_CARD {
|
||||||
/* init and deinit stopcard for booting, too */
|
/* init and deinit stopcard for booting, too */
|
||||||
void (*stopcard) (struct HYSDN_CARD *);
|
void (*stopcard) (struct HYSDN_CARD *);
|
||||||
void (*releasehardware) (struct HYSDN_CARD *);
|
void (*releasehardware) (struct HYSDN_CARD *);
|
||||||
|
|
||||||
|
spinlock_t hysdn_lock;
|
||||||
#ifdef CONFIG_HYSDN_CAPI
|
#ifdef CONFIG_HYSDN_CAPI
|
||||||
struct hycapictrl_info {
|
struct hycapictrl_info {
|
||||||
char cardname[32];
|
char cardname[32];
|
||||||
|
|
|
@ -116,8 +116,7 @@ put_log_buffer(hysdn_card * card, char *cp)
|
||||||
strcpy(ib->log_start, cp); /* set output string */
|
strcpy(ib->log_start, cp); /* set output string */
|
||||||
ib->next = NULL;
|
ib->next = NULL;
|
||||||
ib->proc_ctrl = pd; /* point to own control structure */
|
ib->proc_ctrl = pd; /* point to own control structure */
|
||||||
save_flags(flags);
|
spin_lock_irqsave(&card->hysdn_lock, flags);
|
||||||
cli();
|
|
||||||
ib->usage_cnt = pd->if_used;
|
ib->usage_cnt = pd->if_used;
|
||||||
if (!pd->log_head)
|
if (!pd->log_head)
|
||||||
pd->log_head = ib; /* new head */
|
pd->log_head = ib; /* new head */
|
||||||
|
@ -125,7 +124,7 @@ put_log_buffer(hysdn_card * card, char *cp)
|
||||||
pd->log_tail->next = ib; /* follows existing messages */
|
pd->log_tail->next = ib; /* follows existing messages */
|
||||||
pd->log_tail = ib; /* new tail */
|
pd->log_tail = ib; /* new tail */
|
||||||
i = pd->del_lock++; /* get lock state */
|
i = pd->del_lock++; /* get lock state */
|
||||||
restore_flags(flags);
|
spin_unlock_irqrestore(&card->hysdn_lock, flags);
|
||||||
|
|
||||||
/* delete old entrys */
|
/* delete old entrys */
|
||||||
if (!i)
|
if (!i)
|
||||||
|
@ -270,14 +269,13 @@ hysdn_log_open(struct inode *ino, struct file *filep)
|
||||||
} else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
|
} else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
|
||||||
|
|
||||||
/* read access -> log/debug read */
|
/* read access -> log/debug read */
|
||||||
save_flags(flags);
|
spin_lock_irqsave(&card->hysdn_lock, flags);
|
||||||
cli();
|
|
||||||
pd->if_used++;
|
pd->if_used++;
|
||||||
if (pd->log_head)
|
if (pd->log_head)
|
||||||
filep->private_data = &pd->log_tail->next;
|
filep->private_data = &pd->log_tail->next;
|
||||||
else
|
else
|
||||||
filep->private_data = &pd->log_head;
|
filep->private_data = &pd->log_head;
|
||||||
restore_flags(flags);
|
spin_unlock_irqrestore(&card->hysdn_lock, flags);
|
||||||
} else { /* simultaneous read/write access forbidden ! */
|
} else { /* simultaneous read/write access forbidden ! */
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
return (-EPERM); /* no permission this time */
|
return (-EPERM); /* no permission this time */
|
||||||
|
@ -301,7 +299,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
|
||||||
hysdn_card *card;
|
hysdn_card *card;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
spinlock_t hysdn_lock = SPIN_LOCK_UNLOCKED;
|
||||||
|
|
||||||
lock_kernel();
|
lock_kernel();
|
||||||
if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
|
if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
|
||||||
|
@ -311,8 +309,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
|
||||||
/* read access -> log/debug read, mark one further file as closed */
|
/* read access -> log/debug read, mark one further file as closed */
|
||||||
|
|
||||||
pd = NULL;
|
pd = NULL;
|
||||||
save_flags(flags);
|
spin_lock_irqsave(&hysdn_lock, flags);
|
||||||
cli();
|
|
||||||
inf = *((struct log_data **) filep->private_data); /* get first log entry */
|
inf = *((struct log_data **) filep->private_data); /* get first log entry */
|
||||||
if (inf)
|
if (inf)
|
||||||
pd = (struct procdata *) inf->proc_ctrl; /* still entries there */
|
pd = (struct procdata *) inf->proc_ctrl; /* still entries there */
|
||||||
|
@ -335,7 +332,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
|
||||||
inf->usage_cnt--; /* decrement usage count for buffers */
|
inf->usage_cnt--; /* decrement usage count for buffers */
|
||||||
inf = inf->next;
|
inf = inf->next;
|
||||||
}
|
}
|
||||||
restore_flags(flags);
|
spin_unlock_irqrestore(&hysdn_lock, flags);
|
||||||
|
|
||||||
if (pd)
|
if (pd)
|
||||||
if (pd->if_used <= 0) /* delete buffers if last file closed */
|
if (pd->if_used <= 0) /* delete buffers if last file closed */
|
||||||
|
|
|
@ -155,8 +155,7 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
|
||||||
if (card->debug_flags & LOG_SCHED_ASYN)
|
if (card->debug_flags & LOG_SCHED_ASYN)
|
||||||
hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1);
|
hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1);
|
||||||
|
|
||||||
save_flags(flags);
|
spin_lock_irqsave(&card->hysdn_lock, flags);
|
||||||
cli();
|
|
||||||
while (card->async_busy) {
|
while (card->async_busy) {
|
||||||
sti();
|
sti();
|
||||||
|
|
||||||
|
@ -165,7 +164,7 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
|
||||||
|
|
||||||
msleep_interruptible(20); /* Timeout 20ms */
|
msleep_interruptible(20); /* Timeout 20ms */
|
||||||
if (!--cnt) {
|
if (!--cnt) {
|
||||||
restore_flags(flags);
|
spin_unlock_irqrestore(&card->hysdn_lock, flags);
|
||||||
return (-ERR_ASYNC_TIME); /* timed out */
|
return (-ERR_ASYNC_TIME); /* timed out */
|
||||||
}
|
}
|
||||||
cli();
|
cli();
|
||||||
|
@ -194,13 +193,13 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
|
||||||
|
|
||||||
msleep_interruptible(20); /* Timeout 20ms */
|
msleep_interruptible(20); /* Timeout 20ms */
|
||||||
if (!--cnt) {
|
if (!--cnt) {
|
||||||
restore_flags(flags);
|
spin_unlock_irqrestore(&card->hysdn_lock, flags);
|
||||||
return (-ERR_ASYNC_TIME); /* timed out */
|
return (-ERR_ASYNC_TIME); /* timed out */
|
||||||
}
|
}
|
||||||
cli();
|
cli();
|
||||||
} /* wait for buffer to become free again */
|
} /* wait for buffer to become free again */
|
||||||
|
|
||||||
restore_flags(flags);
|
spin_unlock_irqrestore(&card->hysdn_lock, flags);
|
||||||
|
|
||||||
if (card->debug_flags & LOG_SCHED_ASYN)
|
if (card->debug_flags & LOG_SCHED_ASYN)
|
||||||
hysdn_addlog(card, "async tx-cfg data send");
|
hysdn_addlog(card, "async tx-cfg data send");
|
||||||
|
|
Loading…
Reference in New Issue