aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@web.de>2010-02-08 05:12:38 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-16 19:01:33 -0500
commit42792713f7f2664cf07501e1244d6da33a73ffc1 (patch)
tree6e1ee9e4e4592fff6734039a77e1ef611a91cba3 /drivers
parent42651b5c1aabf5eb60fbe98375ba127f4f6eb943 (diff)
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: Jan Kiszka <jan.kiszka@web.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/isdn/capi/capi.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 9d4750a0aece..08d5a8aa2fec 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -87,10 +87,10 @@ struct capiminor {
87 unsigned int minor; 87 unsigned int minor;
88 struct dentry *capifs_dentry; 88 struct dentry *capifs_dentry;
89 89
90 struct capi20_appl *ap; 90 struct capi20_appl *ap;
91 u32 ncci; 91 u32 ncci;
92 u16 datahandle; 92 atomic_t datahandle;
93 u16 msgid; 93 atomic_t msgid;
94 94
95 struct tty_port port; 95 struct tty_port port;
96 int ttyinstop; 96 int ttyinstop;
@@ -227,7 +227,6 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)
227 227
228 mp->ap = ap; 228 mp->ap = ap;
229 mp->ncci = ncci; 229 mp->ncci = ncci;
230 mp->msgid = 0;
231 INIT_LIST_HEAD(&mp->ackqueue); 230 INIT_LIST_HEAD(&mp->ackqueue);
232 spin_lock_init(&mp->ackqlock); 231 spin_lock_init(&mp->ackqlock);
233 232
@@ -427,7 +426,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
427 capimsg_setu16(s, 2, mp->ap->applid); 426 capimsg_setu16(s, 2, mp->ap->applid);
428 capimsg_setu8 (s, 4, CAPI_DATA_B3); 427 capimsg_setu8 (s, 4, CAPI_DATA_B3);
429 capimsg_setu8 (s, 5, CAPI_RESP); 428 capimsg_setu8 (s, 5, CAPI_RESP);
430 capimsg_setu16(s, 6, mp->msgid++); 429 capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
431 capimsg_setu32(s, 8, mp->ncci); 430 capimsg_setu32(s, 8, mp->ncci);
432 capimsg_setu16(s, 12, datahandle); 431 capimsg_setu16(s, 12, datahandle);
433 } 432 }
@@ -554,7 +553,7 @@ static int handle_minor_send(struct capiminor *mp)
554 } 553 }
555 554
556 while ((skb = skb_dequeue(&mp->outqueue)) != NULL) { 555 while ((skb = skb_dequeue(&mp->outqueue)) != NULL) {
557 datahandle = mp->datahandle; 556 datahandle = atomic_inc_return(&mp->datahandle);
558 len = (u16)skb->len; 557 len = (u16)skb->len;
559 skb_push(skb, CAPI_DATA_B3_REQ_LEN); 558 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
560 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN); 559 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
@@ -562,7 +561,7 @@ static int handle_minor_send(struct capiminor *mp)
562 capimsg_setu16(skb->data, 2, mp->ap->applid); 561 capimsg_setu16(skb->data, 2, mp->ap->applid);
563 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3); 562 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
564 capimsg_setu8 (skb->data, 5, CAPI_REQ); 563 capimsg_setu8 (skb->data, 5, CAPI_REQ);
565 capimsg_setu16(skb->data, 6, mp->msgid++); 564 capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
566 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */ 565 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
567 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */ 566 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
568 capimsg_setu16(skb->data, 16, len); /* Data length */ 567 capimsg_setu16(skb->data, 16, len); /* Data length */
@@ -577,7 +576,6 @@ static int handle_minor_send(struct capiminor *mp)
577 } 576 }
578 errcode = capi20_put_message(mp->ap, skb); 577 errcode = capi20_put_message(mp->ap, skb);
579 if (errcode == CAPI_NOERROR) { 578 if (errcode == CAPI_NOERROR) {
580 mp->datahandle++;
581 count++; 579 count++;
582 mp->outbytes -= len; 580 mp->outbytes -= len;
583#ifdef _DEBUG_DATAFLOW 581#ifdef _DEBUG_DATAFLOW