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

CAPI: Use atomics for capiminor's datahandle and msgid

The capiminor members datahandle and msgid are incremented outside any
lock, so better do this atomically.
Signed-off-by: default avatarJan Kiszka <jan.kiszka@web.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 42651b5c
...@@ -89,8 +89,8 @@ struct capiminor { ...@@ -89,8 +89,8 @@ struct capiminor {
struct capi20_appl *ap; struct capi20_appl *ap;
u32 ncci; u32 ncci;
u16 datahandle; atomic_t datahandle;
u16 msgid; atomic_t msgid;
struct tty_port port; struct tty_port port;
int ttyinstop; int ttyinstop;
...@@ -227,7 +227,6 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci) ...@@ -227,7 +227,6 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)
mp->ap = ap; mp->ap = ap;
mp->ncci = ncci; mp->ncci = ncci;
mp->msgid = 0;
INIT_LIST_HEAD(&mp->ackqueue); INIT_LIST_HEAD(&mp->ackqueue);
spin_lock_init(&mp->ackqlock); spin_lock_init(&mp->ackqlock);
...@@ -427,7 +426,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb) ...@@ -427,7 +426,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
capimsg_setu16(s, 2, mp->ap->applid); capimsg_setu16(s, 2, mp->ap->applid);
capimsg_setu8 (s, 4, CAPI_DATA_B3); capimsg_setu8 (s, 4, CAPI_DATA_B3);
capimsg_setu8 (s, 5, CAPI_RESP); capimsg_setu8 (s, 5, CAPI_RESP);
capimsg_setu16(s, 6, mp->msgid++); capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
capimsg_setu32(s, 8, mp->ncci); capimsg_setu32(s, 8, mp->ncci);
capimsg_setu16(s, 12, datahandle); capimsg_setu16(s, 12, datahandle);
} }
...@@ -554,7 +553,7 @@ static int handle_minor_send(struct capiminor *mp) ...@@ -554,7 +553,7 @@ static int handle_minor_send(struct capiminor *mp)
} }
while ((skb = skb_dequeue(&mp->outqueue)) != NULL) { while ((skb = skb_dequeue(&mp->outqueue)) != NULL) {
datahandle = mp->datahandle; datahandle = atomic_inc_return(&mp->datahandle);
len = (u16)skb->len; len = (u16)skb->len;
skb_push(skb, CAPI_DATA_B3_REQ_LEN); skb_push(skb, CAPI_DATA_B3_REQ_LEN);
memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN); memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
...@@ -562,7 +561,7 @@ static int handle_minor_send(struct capiminor *mp) ...@@ -562,7 +561,7 @@ static int handle_minor_send(struct capiminor *mp)
capimsg_setu16(skb->data, 2, mp->ap->applid); capimsg_setu16(skb->data, 2, mp->ap->applid);
capimsg_setu8 (skb->data, 4, CAPI_DATA_B3); capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
capimsg_setu8 (skb->data, 5, CAPI_REQ); capimsg_setu8 (skb->data, 5, CAPI_REQ);
capimsg_setu16(skb->data, 6, mp->msgid++); capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */ capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */ capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
capimsg_setu16(skb->data, 16, len); /* Data length */ capimsg_setu16(skb->data, 16, len); /* Data length */
...@@ -577,7 +576,6 @@ static int handle_minor_send(struct capiminor *mp) ...@@ -577,7 +576,6 @@ static int handle_minor_send(struct capiminor *mp)
} }
errcode = capi20_put_message(mp->ap, skb); errcode = capi20_put_message(mp->ap, skb);
if (errcode == CAPI_NOERROR) { if (errcode == CAPI_NOERROR) {
mp->datahandle++;
count++; count++;
mp->outbytes -= len; mp->outbytes -= len;
#ifdef _DEBUG_DATAFLOW #ifdef _DEBUG_DATAFLOW
......
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