xpp: stability -- cleaner xpp_open/close
* No need to use spinlock. * Just correctly use the atomic open_counter. Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
This commit is contained in:
parent
08127e14f7
commit
dfa7304f51
@ -722,7 +722,7 @@ int xpp_open(struct dahdi_chan *chan)
|
|||||||
xpd_t *xpd;
|
xpd_t *xpd;
|
||||||
xbus_t *xbus;
|
xbus_t *xbus;
|
||||||
int pos;
|
int pos;
|
||||||
unsigned long flags;
|
int open_counter;
|
||||||
|
|
||||||
if (!chan) {
|
if (!chan) {
|
||||||
NOTICE("open called on a null chan\n");
|
NOTICE("open called on a null chan\n");
|
||||||
@ -743,11 +743,9 @@ int xpp_open(struct dahdi_chan *chan)
|
|||||||
LINE_NOTICE(xpd, pos, "Cannot open -- device not ready\n");
|
LINE_NOTICE(xpd, pos, "Cannot open -- device not ready\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
spin_lock_irqsave(&xbus->lock, flags);
|
open_counter = atomic_inc_return(&PHONEDEV(xpd).open_counter);
|
||||||
atomic_inc(&PHONEDEV(xpd).open_counter);
|
|
||||||
LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n", current->comm,
|
LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n", current->comm,
|
||||||
current->pid, atomic_read(&PHONEDEV(xpd).open_counter));
|
current->pid, open_counter);
|
||||||
spin_unlock_irqrestore(&xbus->lock, flags);
|
|
||||||
if (PHONE_METHOD(card_open, xpd))
|
if (PHONE_METHOD(card_open, xpd))
|
||||||
CALL_PHONE_METHOD(card_open, xpd, pos);
|
CALL_PHONE_METHOD(card_open, xpd, pos);
|
||||||
return 0;
|
return 0;
|
||||||
@ -757,17 +755,15 @@ EXPORT_SYMBOL(xpp_open);
|
|||||||
int xpp_close(struct dahdi_chan *chan)
|
int xpp_close(struct dahdi_chan *chan)
|
||||||
{
|
{
|
||||||
xpd_t *xpd = chan->pvt;
|
xpd_t *xpd = chan->pvt;
|
||||||
xbus_t *xbus = xpd->xbus;
|
|
||||||
int pos = chan->chanpos - 1;
|
int pos = chan->chanpos - 1;
|
||||||
unsigned long flags;
|
int open_counter;
|
||||||
|
|
||||||
spin_lock_irqsave(&xbus->lock, flags);
|
|
||||||
spin_unlock_irqrestore(&xbus->lock, flags);
|
|
||||||
if (PHONE_METHOD(card_close, xpd))
|
if (PHONE_METHOD(card_close, xpd))
|
||||||
CALL_PHONE_METHOD(card_close, xpd, pos);
|
CALL_PHONE_METHOD(card_close, xpd, pos);
|
||||||
|
/* from xpp_open(): */
|
||||||
|
open_counter = atomic_dec_return(&PHONEDEV(xpd).open_counter);
|
||||||
LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n", current->comm,
|
LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n", current->comm,
|
||||||
current->pid, atomic_read(&PHONEDEV(xpd).open_counter));
|
current->pid, open_counter);
|
||||||
atomic_dec(&PHONEDEV(xpd).open_counter); /* from xpp_open() */
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(xpp_close);
|
EXPORT_SYMBOL(xpp_close);
|
||||||
|
Loading…
Reference in New Issue
Block a user