From dfa7304f515509555866cb877eb3f6a618b9f211 Mon Sep 17 00:00:00 2001 From: Oron Peled Date: Mon, 12 May 2014 10:04:28 -0400 Subject: [PATCH] xpp: stability -- cleaner xpp_open/close * No need to use spinlock. * Just correctly use the atomic open_counter. Signed-off-by: Tzafrir Cohen --- drivers/dahdi/xpp/xpp_dahdi.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/dahdi/xpp/xpp_dahdi.c b/drivers/dahdi/xpp/xpp_dahdi.c index c0e441a..3e54ca2 100644 --- a/drivers/dahdi/xpp/xpp_dahdi.c +++ b/drivers/dahdi/xpp/xpp_dahdi.c @@ -722,7 +722,7 @@ int xpp_open(struct dahdi_chan *chan) xpd_t *xpd; xbus_t *xbus; int pos; - unsigned long flags; + int open_counter; if (!chan) { 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"); return -ENODEV; } - spin_lock_irqsave(&xbus->lock, flags); - atomic_inc(&PHONEDEV(xpd).open_counter); + open_counter = atomic_inc_return(&PHONEDEV(xpd).open_counter); LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n", current->comm, - current->pid, atomic_read(&PHONEDEV(xpd).open_counter)); - spin_unlock_irqrestore(&xbus->lock, flags); + current->pid, open_counter); if (PHONE_METHOD(card_open, xpd)) CALL_PHONE_METHOD(card_open, xpd, pos); return 0; @@ -757,17 +755,15 @@ EXPORT_SYMBOL(xpp_open); int xpp_close(struct dahdi_chan *chan) { xpd_t *xpd = chan->pvt; - xbus_t *xbus = xpd->xbus; 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)) 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, - current->pid, atomic_read(&PHONEDEV(xpd).open_counter)); - atomic_dec(&PHONEDEV(xpd).open_counter); /* from xpp_open() */ + current->pid, open_counter); return 0; } EXPORT_SYMBOL(xpp_close);