Commit 2b72b5bd authored by Jan Kiszka's avatar Jan Kiszka Committed by David S. Miller

CAPI: Clean up capiminor_*_ack

No need for irqsave acquisition of acklock, bh-safe is sufficient.
Moverover, move kfree out of the lock and do not take acklock at all
in capiminor_del_all_ack as we are the last user of the list here.
Signed-off-by: default avatarJan Kiszka <jan.kiszka@web.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dfbb84ff
...@@ -149,7 +149,6 @@ static struct tty_driver *capinc_tty_driver; ...@@ -149,7 +149,6 @@ static struct tty_driver *capinc_tty_driver;
static int capiminor_add_ack(struct capiminor *mp, u16 datahandle) static int capiminor_add_ack(struct capiminor *mp, u16 datahandle)
{ {
struct ackqueue_entry *n; struct ackqueue_entry *n;
unsigned long flags;
n = kmalloc(sizeof(*n), GFP_ATOMIC); n = kmalloc(sizeof(*n), GFP_ATOMIC);
if (unlikely(!n)) { if (unlikely(!n)) {
...@@ -158,44 +157,40 @@ static int capiminor_add_ack(struct capiminor *mp, u16 datahandle) ...@@ -158,44 +157,40 @@ static int capiminor_add_ack(struct capiminor *mp, u16 datahandle)
} }
n->datahandle = datahandle; n->datahandle = datahandle;
INIT_LIST_HEAD(&n->list); INIT_LIST_HEAD(&n->list);
spin_lock_irqsave(&mp->ackqlock, flags); spin_lock_bh(&mp->ackqlock);
list_add_tail(&n->list, &mp->ackqueue); list_add_tail(&n->list, &mp->ackqueue);
mp->nack++; mp->nack++;
spin_unlock_irqrestore(&mp->ackqlock, flags); spin_unlock_bh(&mp->ackqlock);
return 0; return 0;
} }
static int capiminor_del_ack(struct capiminor *mp, u16 datahandle) static int capiminor_del_ack(struct capiminor *mp, u16 datahandle)
{ {
struct ackqueue_entry *p, *tmp; struct ackqueue_entry *p, *tmp;
unsigned long flags;
spin_lock_irqsave(&mp->ackqlock, flags); spin_lock_bh(&mp->ackqlock);
list_for_each_entry_safe(p, tmp, &mp->ackqueue, list) { list_for_each_entry_safe(p, tmp, &mp->ackqueue, list) {
if (p->datahandle == datahandle) { if (p->datahandle == datahandle) {
list_del(&p->list); list_del(&p->list);
kfree(p);
mp->nack--; mp->nack--;
spin_unlock_irqrestore(&mp->ackqlock, flags); spin_unlock_bh(&mp->ackqlock);
kfree(p);
return 0; return 0;
} }
} }
spin_unlock_irqrestore(&mp->ackqlock, flags); spin_unlock_bh(&mp->ackqlock);
return -1; return -1;
} }
static void capiminor_del_all_ack(struct capiminor *mp) static void capiminor_del_all_ack(struct capiminor *mp)
{ {
struct ackqueue_entry *p, *tmp; struct ackqueue_entry *p, *tmp;
unsigned long flags;
spin_lock_irqsave(&mp->ackqlock, flags);
list_for_each_entry_safe(p, tmp, &mp->ackqueue, list) { list_for_each_entry_safe(p, tmp, &mp->ackqueue, list) {
list_del(&p->list); list_del(&p->list);
kfree(p); kfree(p);
mp->nack--; mp->nack--;
} }
spin_unlock_irqrestore(&mp->ackqlock, flags);
} }
...@@ -676,7 +671,7 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb) ...@@ -676,7 +671,7 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb)
CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4+2)); CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4+2));
#endif #endif
kfree_skb(skb); kfree_skb(skb);
(void)capiminor_del_ack(mp, datahandle); capiminor_del_ack(mp, datahandle);
tty = tty_port_tty_get(&mp->port); tty = tty_port_tty_get(&mp->port);
if (tty) { if (tty) {
tty_wakeup(tty); tty_wakeup(tty);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment