aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/gigaset')
-rw-r--r--drivers/isdn/gigaset/asyncdata.c8
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c86
-rw-r--r--drivers/isdn/gigaset/common.c30
-rw-r--r--drivers/isdn/gigaset/ev-layer.c106
-rw-r--r--drivers/isdn/gigaset/gigaset.h16
-rw-r--r--drivers/isdn/gigaset/interface.c15
-rw-r--r--drivers/isdn/gigaset/isocdata.c51
-rw-r--r--drivers/isdn/gigaset/ser-gigaset.c10
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c22
9 files changed, 169 insertions, 175 deletions
diff --git a/drivers/isdn/gigaset/asyncdata.c b/drivers/isdn/gigaset/asyncdata.c
index 00a3be5b862b..091deb9d1c47 100644
--- a/drivers/isdn/gigaset/asyncdata.c
+++ b/drivers/isdn/gigaset/asyncdata.c
@@ -350,8 +350,8 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
350 unsigned char *src, c; 350 unsigned char *src, c;
351 int procbytes; 351 int procbytes;
352 352
353 head = atomic_read(&inbuf->head); 353 head = inbuf->head;
354 tail = atomic_read(&inbuf->tail); 354 tail = inbuf->tail;
355 gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail); 355 gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
356 356
357 if (head != tail) { 357 if (head != tail) {
@@ -361,7 +361,7 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
361 gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes); 361 gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes);
362 362
363 while (numbytes) { 363 while (numbytes) {
364 if (atomic_read(&cs->mstate) == MS_LOCKED) { 364 if (cs->mstate == MS_LOCKED) {
365 procbytes = lock_loop(src, numbytes, inbuf); 365 procbytes = lock_loop(src, numbytes, inbuf);
366 src += procbytes; 366 src += procbytes;
367 numbytes -= procbytes; 367 numbytes -= procbytes;
@@ -436,7 +436,7 @@ nextbyte:
436 } 436 }
437 437
438 gig_dbg(DEBUG_INTR, "setting head to %u", head); 438 gig_dbg(DEBUG_INTR, "setting head to %u", head);
439 atomic_set(&inbuf->head, head); 439 inbuf->head = head;
440 } 440 }
441} 441}
442EXPORT_SYMBOL_GPL(gigaset_m10x_input); 442EXPORT_SYMBOL_GPL(gigaset_m10x_input);
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 1c401b3f88e1..7c905305406b 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -113,7 +113,7 @@ struct bas_cardstate {
113 unsigned char int_in_buf[3]; 113 unsigned char int_in_buf[3];
114 114
115 spinlock_t lock; /* locks all following */ 115 spinlock_t lock; /* locks all following */
116 atomic_t basstate; /* bitmap (BS_*) */ 116 int basstate; /* bitmap (BS_*) */
117 int pending; /* uncompleted base request */ 117 int pending; /* uncompleted base request */
118 wait_queue_head_t waitqueue; 118 wait_queue_head_t waitqueue;
119 int rcvbuf_size; /* size of AT receive buffer */ 119 int rcvbuf_size; /* size of AT receive buffer */
@@ -370,27 +370,27 @@ static void check_pending(struct bas_cardstate *ucs)
370 case 0: 370 case 0:
371 break; 371 break;
372 case HD_OPEN_ATCHANNEL: 372 case HD_OPEN_ATCHANNEL:
373 if (atomic_read(&ucs->basstate) & BS_ATOPEN) 373 if (ucs->basstate & BS_ATOPEN)
374 ucs->pending = 0; 374 ucs->pending = 0;
375 break; 375 break;
376 case HD_OPEN_B1CHANNEL: 376 case HD_OPEN_B1CHANNEL:
377 if (atomic_read(&ucs->basstate) & BS_B1OPEN) 377 if (ucs->basstate & BS_B1OPEN)
378 ucs->pending = 0; 378 ucs->pending = 0;
379 break; 379 break;
380 case HD_OPEN_B2CHANNEL: 380 case HD_OPEN_B2CHANNEL:
381 if (atomic_read(&ucs->basstate) & BS_B2OPEN) 381 if (ucs->basstate & BS_B2OPEN)
382 ucs->pending = 0; 382 ucs->pending = 0;
383 break; 383 break;
384 case HD_CLOSE_ATCHANNEL: 384 case HD_CLOSE_ATCHANNEL:
385 if (!(atomic_read(&ucs->basstate) & BS_ATOPEN)) 385 if (!(ucs->basstate & BS_ATOPEN))
386 ucs->pending = 0; 386 ucs->pending = 0;
387 break; 387 break;
388 case HD_CLOSE_B1CHANNEL: 388 case HD_CLOSE_B1CHANNEL:
389 if (!(atomic_read(&ucs->basstate) & BS_B1OPEN)) 389 if (!(ucs->basstate & BS_B1OPEN))
390 ucs->pending = 0; 390 ucs->pending = 0;
391 break; 391 break;
392 case HD_CLOSE_B2CHANNEL: 392 case HD_CLOSE_B2CHANNEL:
393 if (!(atomic_read(&ucs->basstate) & BS_B2OPEN)) 393 if (!(ucs->basstate & BS_B2OPEN))
394 ucs->pending = 0; 394 ucs->pending = 0;
395 break; 395 break;
396 case HD_DEVICE_INIT_ACK: /* no reply expected */ 396 case HD_DEVICE_INIT_ACK: /* no reply expected */
@@ -456,8 +456,8 @@ inline static int update_basstate(struct bas_cardstate *ucs,
456 int state; 456 int state;
457 457
458 spin_lock_irqsave(&ucs->lock, flags); 458 spin_lock_irqsave(&ucs->lock, flags);
459 state = atomic_read(&ucs->basstate); 459 state = ucs->basstate;
460 atomic_set(&ucs->basstate, (state & ~clear) | set); 460 ucs->basstate = (state & ~clear) | set;
461 spin_unlock_irqrestore(&ucs->lock, flags); 461 spin_unlock_irqrestore(&ucs->lock, flags);
462 return state; 462 return state;
463} 463}
@@ -832,7 +832,7 @@ static void read_iso_callback(struct urb *urb)
832 urb->iso_frame_desc[i].status = 0; 832 urb->iso_frame_desc[i].status = 0;
833 urb->iso_frame_desc[i].actual_length = 0; 833 urb->iso_frame_desc[i].actual_length = 0;
834 } 834 }
835 if (likely(atomic_read(&ubc->running))) { 835 if (likely(ubc->running)) {
836 /* urb->dev is clobbered by USB subsystem */ 836 /* urb->dev is clobbered by USB subsystem */
837 urb->dev = bcs->cs->hw.bas->udev; 837 urb->dev = bcs->cs->hw.bas->udev;
838 urb->transfer_flags = URB_ISO_ASAP; 838 urb->transfer_flags = URB_ISO_ASAP;
@@ -909,7 +909,7 @@ static int starturbs(struct bc_state *bcs)
909 bcs->inputstate |= INS_flag_hunt; 909 bcs->inputstate |= INS_flag_hunt;
910 910
911 /* submit all isochronous input URBs */ 911 /* submit all isochronous input URBs */
912 atomic_set(&ubc->running, 1); 912 ubc->running = 1;
913 for (k = 0; k < BAS_INURBS; k++) { 913 for (k = 0; k < BAS_INURBS; k++) {
914 urb = ubc->isoinurbs[k]; 914 urb = ubc->isoinurbs[k];
915 if (!urb) { 915 if (!urb) {
@@ -992,7 +992,7 @@ static void stopurbs(struct bas_bc_state *ubc)
992{ 992{
993 int k, rc; 993 int k, rc;
994 994
995 atomic_set(&ubc->running, 0); 995 ubc->running = 0;
996 996
997 for (k = 0; k < BAS_INURBS; ++k) { 997 for (k = 0; k < BAS_INURBS; ++k) {
998 rc = usb_unlink_urb(ubc->isoinurbs[k]); 998 rc = usb_unlink_urb(ubc->isoinurbs[k]);
@@ -1068,7 +1068,7 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
1068 } 1068 }
1069 break; 1069 break;
1070 } 1070 }
1071 ucx->limit = atomic_read(&ubc->isooutbuf->nextread); 1071 ucx->limit = ubc->isooutbuf->nextread;
1072 ifd->status = 0; 1072 ifd->status = 0;
1073 ifd->actual_length = 0; 1073 ifd->actual_length = 0;
1074 } 1074 }
@@ -1115,7 +1115,7 @@ static void write_iso_tasklet(unsigned long data)
1115 1115
1116 /* loop while completed URBs arrive in time */ 1116 /* loop while completed URBs arrive in time */
1117 for (;;) { 1117 for (;;) {
1118 if (unlikely(!(atomic_read(&ubc->running)))) { 1118 if (unlikely(!(ubc->running))) {
1119 gig_dbg(DEBUG_ISO, "%s: not running", __func__); 1119 gig_dbg(DEBUG_ISO, "%s: not running", __func__);
1120 return; 1120 return;
1121 } 1121 }
@@ -1220,7 +1220,7 @@ static void write_iso_tasklet(unsigned long data)
1220 1220
1221 /* mark the write buffer area covered by this URB as free */ 1221 /* mark the write buffer area covered by this URB as free */
1222 if (done->limit >= 0) 1222 if (done->limit >= 0)
1223 atomic_set(&ubc->isooutbuf->read, done->limit); 1223 ubc->isooutbuf->read = done->limit;
1224 1224
1225 /* mark URB as free */ 1225 /* mark URB as free */
1226 spin_lock_irqsave(&ubc->isooutlock, flags); 1226 spin_lock_irqsave(&ubc->isooutlock, flags);
@@ -1294,7 +1294,7 @@ static void read_iso_tasklet(unsigned long data)
1294 } 1294 }
1295 spin_unlock_irqrestore(&ubc->isoinlock, flags); 1295 spin_unlock_irqrestore(&ubc->isoinlock, flags);
1296 1296
1297 if (unlikely(!(atomic_read(&ubc->running)))) { 1297 if (unlikely(!(ubc->running))) {
1298 gig_dbg(DEBUG_ISO, 1298 gig_dbg(DEBUG_ISO,
1299 "%s: channel not running, " 1299 "%s: channel not running, "
1300 "dropped URB with status: %s", 1300 "dropped URB with status: %s",
@@ -1488,7 +1488,7 @@ static void write_ctrl_callback(struct urb *urb)
1488 default: /* any failure */ 1488 default: /* any failure */
1489 /* don't retry if suspend requested */ 1489 /* don't retry if suspend requested */
1490 if (++ucs->retry_ctrl > BAS_RETRY || 1490 if (++ucs->retry_ctrl > BAS_RETRY ||
1491 (atomic_read(&ucs->basstate) & BS_SUSPEND)) { 1491 (ucs->basstate & BS_SUSPEND)) {
1492 dev_err(&ucs->interface->dev, 1492 dev_err(&ucs->interface->dev,
1493 "control request 0x%02x failed: %s\n", 1493 "control request 0x%02x failed: %s\n",
1494 ucs->dr_ctrl.bRequest, 1494 ucs->dr_ctrl.bRequest,
@@ -1603,7 +1603,7 @@ static int gigaset_init_bchannel(struct bc_state *bcs)
1603 return -ENODEV; 1603 return -ENODEV;
1604 } 1604 }
1605 1605
1606 if (atomic_read(&cs->hw.bas->basstate) & BS_SUSPEND) { 1606 if (cs->hw.bas->basstate & BS_SUSPEND) {
1607 dev_notice(cs->dev, 1607 dev_notice(cs->dev,
1608 "not starting isochronous I/O, " 1608 "not starting isochronous I/O, "
1609 "suspend in progress\n"); 1609 "suspend in progress\n");
@@ -1658,8 +1658,7 @@ static int gigaset_close_bchannel(struct bc_state *bcs)
1658 return -ENODEV; 1658 return -ENODEV;
1659 } 1659 }
1660 1660
1661 if (!(atomic_read(&cs->hw.bas->basstate) & 1661 if (!(cs->hw.bas->basstate & (bcs->channel ? BS_B2OPEN : BS_B1OPEN))) {
1662 (bcs->channel ? BS_B2OPEN : BS_B1OPEN))) {
1663 /* channel not running: just signal common.c */ 1662 /* channel not running: just signal common.c */
1664 spin_unlock_irqrestore(&cs->lock, flags); 1663 spin_unlock_irqrestore(&cs->lock, flags);
1665 gigaset_bchannel_down(bcs); 1664 gigaset_bchannel_down(bcs);
@@ -1747,7 +1746,7 @@ static void write_command_callback(struct urb *urb)
1747 ucs->retry_cmd_out); 1746 ucs->retry_cmd_out);
1748 break; 1747 break;
1749 } 1748 }
1750 if (atomic_read(&ucs->basstate) & BS_SUSPEND) { 1749 if (ucs->basstate & BS_SUSPEND) {
1751 dev_warn(cs->dev, 1750 dev_warn(cs->dev,
1752 "command write: %s, " 1751 "command write: %s, "
1753 "won't retry - suspend requested\n", 1752 "won't retry - suspend requested\n",
@@ -1863,13 +1862,13 @@ static int start_cbsend(struct cardstate *cs)
1863 int retval = 0; 1862 int retval = 0;
1864 1863
1865 /* check if suspend requested */ 1864 /* check if suspend requested */
1866 if (atomic_read(&ucs->basstate) & BS_SUSPEND) { 1865 if (ucs->basstate & BS_SUSPEND) {
1867 gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD, "suspending"); 1866 gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD, "suspending");
1868 return -EHOSTUNREACH; 1867 return -EHOSTUNREACH;
1869 } 1868 }
1870 1869
1871 /* check if AT channel is open */ 1870 /* check if AT channel is open */
1872 if (!(atomic_read(&ucs->basstate) & BS_ATOPEN)) { 1871 if (!(ucs->basstate & BS_ATOPEN)) {
1873 gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD, "AT channel not open"); 1872 gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD, "AT channel not open");
1874 rc = req_submit(cs->bcs, HD_OPEN_ATCHANNEL, 0, BAS_TIMEOUT); 1873 rc = req_submit(cs->bcs, HD_OPEN_ATCHANNEL, 0, BAS_TIMEOUT);
1875 if (rc < 0) { 1874 if (rc < 0) {
@@ -1885,8 +1884,7 @@ static int start_cbsend(struct cardstate *cs)
1885 /* try to send first command in queue */ 1884 /* try to send first command in queue */
1886 spin_lock_irqsave(&cs->cmdlock, flags); 1885 spin_lock_irqsave(&cs->cmdlock, flags);
1887 1886
1888 while ((cb = cs->cmdbuf) != NULL && 1887 while ((cb = cs->cmdbuf) != NULL && (ucs->basstate & BS_ATREADY)) {
1889 atomic_read(&ucs->basstate) & BS_ATREADY) {
1890 ucs->retry_cmd_out = 0; 1888 ucs->retry_cmd_out = 0;
1891 rc = atwrite_submit(cs, cb->buf, cb->len); 1889 rc = atwrite_submit(cs, cb->buf, cb->len);
1892 if (unlikely(rc)) { 1890 if (unlikely(rc)) {
@@ -1924,7 +1922,7 @@ static int gigaset_write_cmd(struct cardstate *cs,
1924 unsigned long flags; 1922 unsigned long flags;
1925 int rc; 1923 int rc;
1926 1924
1927 gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ? 1925 gigaset_dbg_buffer(cs->mstate != MS_LOCKED ?
1928 DEBUG_TRANSCMD : DEBUG_LOCKCMD, 1926 DEBUG_TRANSCMD : DEBUG_LOCKCMD,
1929 "CMD Transmit", len, buf); 1927 "CMD Transmit", len, buf);
1930 1928
@@ -2039,7 +2037,7 @@ static int gigaset_freebcshw(struct bc_state *bcs)
2039 return 0; 2037 return 0;
2040 2038
2041 /* kill URBs and tasklets before freeing - better safe than sorry */ 2039 /* kill URBs and tasklets before freeing - better safe than sorry */
2042 atomic_set(&ubc->running, 0); 2040 ubc->running = 0;
2043 gig_dbg(DEBUG_INIT, "%s: killing iso URBs", __func__); 2041 gig_dbg(DEBUG_INIT, "%s: killing iso URBs", __func__);
2044 for (i = 0; i < BAS_OUTURBS; ++i) { 2042 for (i = 0; i < BAS_OUTURBS; ++i) {
2045 usb_kill_urb(ubc->isoouturbs[i].urb); 2043 usb_kill_urb(ubc->isoouturbs[i].urb);
@@ -2074,7 +2072,7 @@ static int gigaset_initbcshw(struct bc_state *bcs)
2074 return 0; 2072 return 0;
2075 } 2073 }
2076 2074
2077 atomic_set(&ubc->running, 0); 2075 ubc->running = 0;
2078 atomic_set(&ubc->corrbytes, 0); 2076 atomic_set(&ubc->corrbytes, 0);
2079 spin_lock_init(&ubc->isooutlock); 2077 spin_lock_init(&ubc->isooutlock);
2080 for (i = 0; i < BAS_OUTURBS; ++i) { 2078 for (i = 0; i < BAS_OUTURBS; ++i) {
@@ -2119,7 +2117,7 @@ static void gigaset_reinitbcshw(struct bc_state *bcs)
2119{ 2117{
2120 struct bas_bc_state *ubc = bcs->hw.bas; 2118 struct bas_bc_state *ubc = bcs->hw.bas;
2121 2119
2122 atomic_set(&bcs->hw.bas->running, 0); 2120 bcs->hw.bas->running = 0;
2123 atomic_set(&bcs->hw.bas->corrbytes, 0); 2121 atomic_set(&bcs->hw.bas->corrbytes, 0);
2124 bcs->hw.bas->numsub = 0; 2122 bcs->hw.bas->numsub = 0;
2125 spin_lock_init(&ubc->isooutlock); 2123 spin_lock_init(&ubc->isooutlock);
@@ -2150,7 +2148,7 @@ static int gigaset_initcshw(struct cardstate *cs)
2150 spin_lock_init(&ucs->lock); 2148 spin_lock_init(&ucs->lock);
2151 ucs->pending = 0; 2149 ucs->pending = 0;
2152 2150
2153 atomic_set(&ucs->basstate, 0); 2151 ucs->basstate = 0;
2154 init_timer(&ucs->timer_ctrl); 2152 init_timer(&ucs->timer_ctrl);
2155 init_timer(&ucs->timer_atrdy); 2153 init_timer(&ucs->timer_atrdy);
2156 init_timer(&ucs->timer_cmd_in); 2154 init_timer(&ucs->timer_cmd_in);
@@ -2307,7 +2305,7 @@ static int gigaset_probe(struct usb_interface *interface,
2307 2305
2308 /* tell common part that the device is ready */ 2306 /* tell common part that the device is ready */
2309 if (startmode == SM_LOCKED) 2307 if (startmode == SM_LOCKED)
2310 atomic_set(&cs->mstate, MS_LOCKED); 2308 cs->mstate = MS_LOCKED;
2311 2309
2312 /* save address of controller structure */ 2310 /* save address of controller structure */
2313 usb_set_intfdata(interface, cs); 2311 usb_set_intfdata(interface, cs);
@@ -2342,7 +2340,7 @@ static void gigaset_disconnect(struct usb_interface *interface)
2342 dev_info(cs->dev, "disconnecting Gigaset base\n"); 2340 dev_info(cs->dev, "disconnecting Gigaset base\n");
2343 2341
2344 /* mark base as not ready, all channels disconnected */ 2342 /* mark base as not ready, all channels disconnected */
2345 atomic_set(&ucs->basstate, 0); 2343 ucs->basstate = 0;
2346 2344
2347 /* tell LL all channels are down */ 2345 /* tell LL all channels are down */
2348 for (j = 0; j < BAS_CHANNELS; ++j) 2346 for (j = 0; j < BAS_CHANNELS; ++j)
@@ -2374,7 +2372,6 @@ static int gigaset_suspend(struct usb_interface *intf, pm_message_t message)
2374{ 2372{
2375 struct cardstate *cs = usb_get_intfdata(intf); 2373 struct cardstate *cs = usb_get_intfdata(intf);
2376 struct bas_cardstate *ucs = cs->hw.bas; 2374 struct bas_cardstate *ucs = cs->hw.bas;
2377 int basstate;
2378 int rc; 2375 int rc;
2379 2376
2380 /* set suspend flag; this stops AT command/response traffic */ 2377 /* set suspend flag; this stops AT command/response traffic */
@@ -2385,29 +2382,28 @@ static int gigaset_suspend(struct usb_interface *intf, pm_message_t message)
2385 2382
2386 /* wait a bit for blocking conditions to go away */ 2383 /* wait a bit for blocking conditions to go away */
2387 rc = wait_event_timeout(ucs->waitqueue, 2384 rc = wait_event_timeout(ucs->waitqueue,
2388 !(atomic_read(&ucs->basstate) & 2385 !(ucs->basstate &
2389 (BS_B1OPEN|BS_B2OPEN|BS_ATRDPEND|BS_ATWRPEND)), 2386 (BS_B1OPEN|BS_B2OPEN|BS_ATRDPEND|BS_ATWRPEND)),
2390 BAS_TIMEOUT*HZ/10); 2387 BAS_TIMEOUT*HZ/10);
2391 gig_dbg(DEBUG_SUSPEND, "wait_event_timeout() -> %d", rc); 2388 gig_dbg(DEBUG_SUSPEND, "wait_event_timeout() -> %d", rc);
2392 2389
2393 /* check for conditions preventing suspend */ 2390 /* check for conditions preventing suspend */
2394 basstate = atomic_read(&ucs->basstate); 2391 if (ucs->basstate & (BS_B1OPEN|BS_B2OPEN|BS_ATRDPEND|BS_ATWRPEND)) {
2395 if (basstate & (BS_B1OPEN|BS_B2OPEN|BS_ATRDPEND|BS_ATWRPEND)) {
2396 dev_warn(cs->dev, "cannot suspend:\n"); 2392 dev_warn(cs->dev, "cannot suspend:\n");
2397 if (basstate & BS_B1OPEN) 2393 if (ucs->basstate & BS_B1OPEN)
2398 dev_warn(cs->dev, " B channel 1 open\n"); 2394 dev_warn(cs->dev, " B channel 1 open\n");
2399 if (basstate & BS_B2OPEN) 2395 if (ucs->basstate & BS_B2OPEN)
2400 dev_warn(cs->dev, " B channel 2 open\n"); 2396 dev_warn(cs->dev, " B channel 2 open\n");
2401 if (basstate & BS_ATRDPEND) 2397 if (ucs->basstate & BS_ATRDPEND)
2402 dev_warn(cs->dev, " receiving AT reply\n"); 2398 dev_warn(cs->dev, " receiving AT reply\n");
2403 if (basstate & BS_ATWRPEND) 2399 if (ucs->basstate & BS_ATWRPEND)
2404 dev_warn(cs->dev, " sending AT command\n"); 2400 dev_warn(cs->dev, " sending AT command\n");
2405 update_basstate(ucs, 0, BS_SUSPEND); 2401 update_basstate(ucs, 0, BS_SUSPEND);
2406 return -EBUSY; 2402 return -EBUSY;
2407 } 2403 }
2408 2404
2409 /* close AT channel if open */ 2405 /* close AT channel if open */
2410 if (basstate & BS_ATOPEN) { 2406 if (ucs->basstate & BS_ATOPEN) {
2411 gig_dbg(DEBUG_SUSPEND, "closing AT channel"); 2407 gig_dbg(DEBUG_SUSPEND, "closing AT channel");
2412 rc = req_submit(cs->bcs, HD_CLOSE_ATCHANNEL, 0, 0); 2408 rc = req_submit(cs->bcs, HD_CLOSE_ATCHANNEL, 0, 0);
2413 if (rc) { 2409 if (rc) {
@@ -2546,25 +2542,25 @@ static void __exit bas_gigaset_exit(void)
2546 /* from now on, no isdn callback should be possible */ 2542 /* from now on, no isdn callback should be possible */
2547 2543
2548 /* close all still open channels */ 2544 /* close all still open channels */
2549 if (atomic_read(&ucs->basstate) & BS_B1OPEN) { 2545 if (ucs->basstate & BS_B1OPEN) {
2550 gig_dbg(DEBUG_INIT, "closing B1 channel"); 2546 gig_dbg(DEBUG_INIT, "closing B1 channel");
2551 usb_control_msg(ucs->udev, usb_sndctrlpipe(ucs->udev, 0), 2547 usb_control_msg(ucs->udev, usb_sndctrlpipe(ucs->udev, 0),
2552 HD_CLOSE_B1CHANNEL, OUT_VENDOR_REQ, 0, 0, 2548 HD_CLOSE_B1CHANNEL, OUT_VENDOR_REQ, 0, 0,
2553 NULL, 0, BAS_TIMEOUT); 2549 NULL, 0, BAS_TIMEOUT);
2554 } 2550 }
2555 if (atomic_read(&ucs->basstate) & BS_B2OPEN) { 2551 if (ucs->basstate & BS_B2OPEN) {
2556 gig_dbg(DEBUG_INIT, "closing B2 channel"); 2552 gig_dbg(DEBUG_INIT, "closing B2 channel");
2557 usb_control_msg(ucs->udev, usb_sndctrlpipe(ucs->udev, 0), 2553 usb_control_msg(ucs->udev, usb_sndctrlpipe(ucs->udev, 0),
2558 HD_CLOSE_B2CHANNEL, OUT_VENDOR_REQ, 0, 0, 2554 HD_CLOSE_B2CHANNEL, OUT_VENDOR_REQ, 0, 0,
2559 NULL, 0, BAS_TIMEOUT); 2555 NULL, 0, BAS_TIMEOUT);
2560 } 2556 }
2561 if (atomic_read(&ucs->basstate) & BS_ATOPEN) { 2557 if (ucs->basstate & BS_ATOPEN) {
2562 gig_dbg(DEBUG_INIT, "closing AT channel"); 2558 gig_dbg(DEBUG_INIT, "closing AT channel");
2563 usb_control_msg(ucs->udev, usb_sndctrlpipe(ucs->udev, 0), 2559 usb_control_msg(ucs->udev, usb_sndctrlpipe(ucs->udev, 0),
2564 HD_CLOSE_ATCHANNEL, OUT_VENDOR_REQ, 0, 0, 2560 HD_CLOSE_ATCHANNEL, OUT_VENDOR_REQ, 0, 0,
2565 NULL, 0, BAS_TIMEOUT); 2561 NULL, 0, BAS_TIMEOUT);
2566 } 2562 }
2567 atomic_set(&ucs->basstate, 0); 2563 ucs->basstate = 0;
2568 2564
2569 /* deregister this driver with the USB subsystem */ 2565 /* deregister this driver with the USB subsystem */
2570 usb_deregister(&gigaset_usb_driver); 2566 usb_deregister(&gigaset_usb_driver);
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index acd417197d03..f8f7d7e553bf 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -501,11 +501,11 @@ static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct bc_state *bcs,
501 struct cardstate *cs, int inputstate) 501 struct cardstate *cs, int inputstate)
502/* inbuf->read must be allocated before! */ 502/* inbuf->read must be allocated before! */
503{ 503{
504 atomic_set(&inbuf->head, 0); 504 inbuf->head = 0;
505 atomic_set(&inbuf->tail, 0); 505 inbuf->tail = 0;
506 inbuf->cs = cs; 506 inbuf->cs = cs;
507 inbuf->bcs = bcs; /*base driver: NULL*/ 507 inbuf->bcs = bcs; /*base driver: NULL*/
508 inbuf->rcvbuf = NULL; //FIXME 508 inbuf->rcvbuf = NULL;
509 inbuf->inputstate = inputstate; 509 inbuf->inputstate = inputstate;
510} 510}
511 511
@@ -521,8 +521,8 @@ int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
521 return 0; 521 return 0;
522 522
523 bytesleft = numbytes; 523 bytesleft = numbytes;
524 tail = atomic_read(&inbuf->tail); 524 tail = inbuf->tail;
525 head = atomic_read(&inbuf->head); 525 head = inbuf->head;
526 gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail); 526 gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
527 527
528 while (bytesleft) { 528 while (bytesleft) {
@@ -546,7 +546,7 @@ int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
546 src += n; 546 src += n;
547 } 547 }
548 gig_dbg(DEBUG_INTR, "setting tail to %u", tail); 548 gig_dbg(DEBUG_INTR, "setting tail to %u", tail);
549 atomic_set(&inbuf->tail, tail); 549 inbuf->tail = tail;
550 return numbytes != bytesleft; 550 return numbytes != bytesleft;
551} 551}
552EXPORT_SYMBOL_GPL(gigaset_fill_inbuf); 552EXPORT_SYMBOL_GPL(gigaset_fill_inbuf);
@@ -668,7 +668,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
668 668
669 tasklet_init(&cs->event_tasklet, &gigaset_handle_event, 669 tasklet_init(&cs->event_tasklet, &gigaset_handle_event,
670 (unsigned long) cs); 670 (unsigned long) cs);
671 atomic_set(&cs->commands_pending, 0); 671 cs->commands_pending = 0;
672 cs->cur_at_seq = 0; 672 cs->cur_at_seq = 0;
673 cs->gotfwver = -1; 673 cs->gotfwver = -1;
674 cs->open_count = 0; 674 cs->open_count = 0;
@@ -688,8 +688,8 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
688 init_waitqueue_head(&cs->waitqueue); 688 init_waitqueue_head(&cs->waitqueue);
689 cs->waiting = 0; 689 cs->waiting = 0;
690 690
691 atomic_set(&cs->mode, M_UNKNOWN); 691 cs->mode = M_UNKNOWN;
692 atomic_set(&cs->mstate, MS_UNINITIALIZED); 692 cs->mstate = MS_UNINITIALIZED;
693 693
694 for (i = 0; i < channels; ++i) { 694 for (i = 0; i < channels; ++i) {
695 gig_dbg(DEBUG_INIT, "setting up bcs[%d].read", i); 695 gig_dbg(DEBUG_INIT, "setting up bcs[%d].read", i);
@@ -806,8 +806,8 @@ static void cleanup_cs(struct cardstate *cs)
806 806
807 spin_lock_irqsave(&cs->lock, flags); 807 spin_lock_irqsave(&cs->lock, flags);
808 808
809 atomic_set(&cs->mode, M_UNKNOWN); 809 cs->mode = M_UNKNOWN;
810 atomic_set(&cs->mstate, MS_UNINITIALIZED); 810 cs->mstate = MS_UNINITIALIZED;
811 811
812 clear_at_state(&cs->at_state); 812 clear_at_state(&cs->at_state);
813 dealloc_at_states(cs); 813 dealloc_at_states(cs);
@@ -817,8 +817,8 @@ static void cleanup_cs(struct cardstate *cs)
817 kfree(cs->inbuf->rcvbuf); 817 kfree(cs->inbuf->rcvbuf);
818 cs->inbuf->rcvbuf = NULL; 818 cs->inbuf->rcvbuf = NULL;
819 cs->inbuf->inputstate = INS_command; 819 cs->inbuf->inputstate = INS_command;
820 atomic_set(&cs->inbuf->head, 0); 820 cs->inbuf->head = 0;
821 atomic_set(&cs->inbuf->tail, 0); 821 cs->inbuf->tail = 0;
822 822
823 cb = cs->cmdbuf; 823 cb = cs->cmdbuf;
824 while (cb) { 824 while (cb) {
@@ -832,7 +832,7 @@ static void cleanup_cs(struct cardstate *cs)
832 cs->gotfwver = -1; 832 cs->gotfwver = -1;
833 cs->dle = 0; 833 cs->dle = 0;
834 cs->cur_at_seq = 0; 834 cs->cur_at_seq = 0;
835 atomic_set(&cs->commands_pending, 0); 835 cs->commands_pending = 0;
836 cs->cbytes = 0; 836 cs->cbytes = 0;
837 837
838 spin_unlock_irqrestore(&cs->lock, flags); 838 spin_unlock_irqrestore(&cs->lock, flags);
@@ -862,7 +862,7 @@ int gigaset_start(struct cardstate *cs)
862 cs->connected = 1; 862 cs->connected = 1;
863 spin_unlock_irqrestore(&cs->lock, flags); 863 spin_unlock_irqrestore(&cs->lock, flags);
864 864
865 if (atomic_read(&cs->mstate) != MS_LOCKED) { 865 if (cs->mstate != MS_LOCKED) {
866 cs->ops->set_modem_ctrl(cs, 0, TIOCM_DTR|TIOCM_RTS); 866 cs->ops->set_modem_ctrl(cs, 0, TIOCM_DTR|TIOCM_RTS);
867 cs->ops->baud_rate(cs, B115200); 867 cs->ops->baud_rate(cs, B115200);
868 cs->ops->set_line_ctrl(cs, CS8); 868 cs->ops->set_line_ctrl(cs, CS8);
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index cec1ef342fcc..5cbf64d850ee 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -735,7 +735,7 @@ static void disconnect(struct at_state_t **at_state_p)
735 /* revert to selected idle mode */ 735 /* revert to selected idle mode */
736 if (!cs->cidmode) { 736 if (!cs->cidmode) {
737 cs->at_state.pending_commands |= PC_UMMODE; 737 cs->at_state.pending_commands |= PC_UMMODE;
738 atomic_set(&cs->commands_pending, 1); //FIXME 738 cs->commands_pending = 1;
739 gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE"); 739 gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
740 } 740 }
741 spin_unlock_irqrestore(&cs->lock, flags); 741 spin_unlock_irqrestore(&cs->lock, flags);
@@ -793,15 +793,15 @@ static void init_failed(struct cardstate *cs, int mode)
793 struct at_state_t *at_state; 793 struct at_state_t *at_state;
794 794
795 cs->at_state.pending_commands &= ~PC_INIT; 795 cs->at_state.pending_commands &= ~PC_INIT;
796 atomic_set(&cs->mode, mode); 796 cs->mode = mode;
797 atomic_set(&cs->mstate, MS_UNINITIALIZED); 797 cs->mstate = MS_UNINITIALIZED;
798 gigaset_free_channels(cs); 798 gigaset_free_channels(cs);
799 for (i = 0; i < cs->channels; ++i) { 799 for (i = 0; i < cs->channels; ++i) {
800 at_state = &cs->bcs[i].at_state; 800 at_state = &cs->bcs[i].at_state;
801 if (at_state->pending_commands & PC_CID) { 801 if (at_state->pending_commands & PC_CID) {
802 at_state->pending_commands &= ~PC_CID; 802 at_state->pending_commands &= ~PC_CID;
803 at_state->pending_commands |= PC_NOCID; 803 at_state->pending_commands |= PC_NOCID;
804 atomic_set(&cs->commands_pending, 1); 804 cs->commands_pending = 1;
805 } 805 }
806 } 806 }
807} 807}
@@ -812,11 +812,11 @@ static void schedule_init(struct cardstate *cs, int state)
812 gig_dbg(DEBUG_CMD, "not scheduling PC_INIT again"); 812 gig_dbg(DEBUG_CMD, "not scheduling PC_INIT again");
813 return; 813 return;
814 } 814 }
815 atomic_set(&cs->mstate, state); 815 cs->mstate = state;
816 atomic_set(&cs->mode, M_UNKNOWN); 816 cs->mode = M_UNKNOWN;
817 gigaset_block_channels(cs); 817 gigaset_block_channels(cs);
818 cs->at_state.pending_commands |= PC_INIT; 818 cs->at_state.pending_commands |= PC_INIT;
819 atomic_set(&cs->commands_pending, 1); 819 cs->commands_pending = 1;
820 gig_dbg(DEBUG_CMD, "Scheduling PC_INIT"); 820 gig_dbg(DEBUG_CMD, "Scheduling PC_INIT");
821} 821}
822 822
@@ -953,13 +953,13 @@ static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_ind
953 953
954 at_state->pending_commands |= PC_CID; 954 at_state->pending_commands |= PC_CID;
955 gig_dbg(DEBUG_CMD, "Scheduling PC_CID"); 955 gig_dbg(DEBUG_CMD, "Scheduling PC_CID");
956 atomic_set(&cs->commands_pending, 1); 956 cs->commands_pending = 1;
957 return; 957 return;
958 958
959error: 959error:
960 at_state->pending_commands |= PC_NOCID; 960 at_state->pending_commands |= PC_NOCID;
961 gig_dbg(DEBUG_CMD, "Scheduling PC_NOCID"); 961 gig_dbg(DEBUG_CMD, "Scheduling PC_NOCID");
962 atomic_set(&cs->commands_pending, 1); 962 cs->commands_pending = 1;
963 return; 963 return;
964} 964}
965 965
@@ -973,12 +973,12 @@ static void start_accept(struct at_state_t *at_state)
973 if (retval == 0) { 973 if (retval == 0) {
974 at_state->pending_commands |= PC_ACCEPT; 974 at_state->pending_commands |= PC_ACCEPT;
975 gig_dbg(DEBUG_CMD, "Scheduling PC_ACCEPT"); 975 gig_dbg(DEBUG_CMD, "Scheduling PC_ACCEPT");
976 atomic_set(&cs->commands_pending, 1); 976 cs->commands_pending = 1;
977 } else { 977 } else {
978 //FIXME 978 /* error reset */
979 at_state->pending_commands |= PC_HUP; 979 at_state->pending_commands |= PC_HUP;
980 gig_dbg(DEBUG_CMD, "Scheduling PC_HUP"); 980 gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
981 atomic_set(&cs->commands_pending, 1); 981 cs->commands_pending = 1;
982 } 982 }
983} 983}
984 984
@@ -986,7 +986,7 @@ static void do_start(struct cardstate *cs)
986{ 986{
987 gigaset_free_channels(cs); 987 gigaset_free_channels(cs);
988 988
989 if (atomic_read(&cs->mstate) != MS_LOCKED) 989 if (cs->mstate != MS_LOCKED)
990 schedule_init(cs, MS_INIT); 990 schedule_init(cs, MS_INIT);
991 991
992 cs->isdn_up = 1; 992 cs->isdn_up = 1;
@@ -1000,9 +1000,9 @@ static void do_start(struct cardstate *cs)
1000 1000
1001static void finish_shutdown(struct cardstate *cs) 1001static void finish_shutdown(struct cardstate *cs)
1002{ 1002{
1003 if (atomic_read(&cs->mstate) != MS_LOCKED) { 1003 if (cs->mstate != MS_LOCKED) {
1004 atomic_set(&cs->mstate, MS_UNINITIALIZED); 1004 cs->mstate = MS_UNINITIALIZED;
1005 atomic_set(&cs->mode, M_UNKNOWN); 1005 cs->mode = M_UNKNOWN;
1006 } 1006 }
1007 1007
1008 /* Tell the LL that the device is not available .. */ 1008 /* Tell the LL that the device is not available .. */
@@ -1022,10 +1022,10 @@ static void do_shutdown(struct cardstate *cs)
1022{ 1022{
1023 gigaset_block_channels(cs); 1023 gigaset_block_channels(cs);
1024 1024
1025 if (atomic_read(&cs->mstate) == MS_READY) { 1025 if (cs->mstate == MS_READY) {
1026 atomic_set(&cs->mstate, MS_SHUTDOWN); 1026 cs->mstate = MS_SHUTDOWN;
1027 cs->at_state.pending_commands |= PC_SHUTDOWN; 1027 cs->at_state.pending_commands |= PC_SHUTDOWN;
1028 atomic_set(&cs->commands_pending, 1); 1028 cs->commands_pending = 1;
1029 gig_dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN"); 1029 gig_dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN");
1030 } else 1030 } else
1031 finish_shutdown(cs); 1031 finish_shutdown(cs);
@@ -1120,7 +1120,7 @@ static void handle_icall(struct cardstate *cs, struct bc_state *bcs,
1120 * In fact it doesn't. 1120 * In fact it doesn't.
1121 */ 1121 */
1122 at_state->pending_commands |= PC_HUP; 1122 at_state->pending_commands |= PC_HUP;
1123 atomic_set(&cs->commands_pending, 1); 1123 cs->commands_pending = 1;
1124 break; 1124 break;
1125 } 1125 }
1126} 1126}
@@ -1130,7 +1130,7 @@ static int do_lock(struct cardstate *cs)
1130 int mode; 1130 int mode;
1131 int i; 1131 int i;
1132 1132
1133 switch (atomic_read(&cs->mstate)) { 1133 switch (cs->mstate) {
1134 case MS_UNINITIALIZED: 1134 case MS_UNINITIALIZED:
1135 case MS_READY: 1135 case MS_READY:
1136 if (cs->cur_at_seq || !list_empty(&cs->temp_at_states) || 1136 if (cs->cur_at_seq || !list_empty(&cs->temp_at_states) ||
@@ -1152,20 +1152,20 @@ static int do_lock(struct cardstate *cs)
1152 return -EBUSY; 1152 return -EBUSY;
1153 } 1153 }
1154 1154
1155 mode = atomic_read(&cs->mode); 1155 mode = cs->mode;
1156 atomic_set(&cs->mstate, MS_LOCKED); 1156 cs->mstate = MS_LOCKED;
1157 atomic_set(&cs->mode, M_UNKNOWN); 1157 cs->mode = M_UNKNOWN;
1158 1158
1159 return mode; 1159 return mode;
1160} 1160}
1161 1161
1162static int do_unlock(struct cardstate *cs) 1162static int do_unlock(struct cardstate *cs)
1163{ 1163{
1164 if (atomic_read(&cs->mstate) != MS_LOCKED) 1164 if (cs->mstate != MS_LOCKED)
1165 return -EINVAL; 1165 return -EINVAL;
1166 1166
1167 atomic_set(&cs->mstate, MS_UNINITIALIZED); 1167 cs->mstate = MS_UNINITIALIZED;
1168 atomic_set(&cs->mode, M_UNKNOWN); 1168 cs->mode = M_UNKNOWN;
1169 gigaset_free_channels(cs); 1169 gigaset_free_channels(cs);
1170 if (cs->connected) 1170 if (cs->connected)
1171 schedule_init(cs, MS_INIT); 1171 schedule_init(cs, MS_INIT);
@@ -1198,17 +1198,17 @@ static void do_action(int action, struct cardstate *cs,
1198 case ACT_INIT: 1198 case ACT_INIT:
1199 cs->at_state.pending_commands &= ~PC_INIT; 1199 cs->at_state.pending_commands &= ~PC_INIT;
1200 cs->cur_at_seq = SEQ_NONE; 1200 cs->cur_at_seq = SEQ_NONE;
1201 atomic_set(&cs->mode, M_UNIMODEM); 1201 cs->mode = M_UNIMODEM;
1202 spin_lock_irqsave(&cs->lock, flags); 1202 spin_lock_irqsave(&cs->lock, flags);
1203 if (!cs->cidmode) { 1203 if (!cs->cidmode) {
1204 spin_unlock_irqrestore(&cs->lock, flags); 1204 spin_unlock_irqrestore(&cs->lock, flags);
1205 gigaset_free_channels(cs); 1205 gigaset_free_channels(cs);
1206 atomic_set(&cs->mstate, MS_READY); 1206 cs->mstate = MS_READY;
1207 break; 1207 break;
1208 } 1208 }
1209 spin_unlock_irqrestore(&cs->lock, flags); 1209 spin_unlock_irqrestore(&cs->lock, flags);
1210 cs->at_state.pending_commands |= PC_CIDMODE; 1210 cs->at_state.pending_commands |= PC_CIDMODE;
1211 atomic_set(&cs->commands_pending, 1); 1211 cs->commands_pending = 1;
1212 gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE"); 1212 gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
1213 break; 1213 break;
1214 case ACT_FAILINIT: 1214 case ACT_FAILINIT:
@@ -1234,22 +1234,20 @@ static void do_action(int action, struct cardstate *cs,
1234 | INS_command; 1234 | INS_command;
1235 break; 1235 break;
1236 case ACT_CMODESET: 1236 case ACT_CMODESET:
1237 if (atomic_read(&cs->mstate) == MS_INIT || 1237 if (cs->mstate == MS_INIT || cs->mstate == MS_RECOVER) {
1238 atomic_read(&cs->mstate) == MS_RECOVER) {
1239 gigaset_free_channels(cs); 1238 gigaset_free_channels(cs);
1240 atomic_set(&cs->mstate, MS_READY); 1239 cs->mstate = MS_READY;
1241 } 1240 }
1242 atomic_set(&cs->mode, M_CID); 1241 cs->mode = M_CID;
1243 cs->cur_at_seq = SEQ_NONE; 1242 cs->cur_at_seq = SEQ_NONE;
1244 break; 1243 break;
1245 case ACT_UMODESET: 1244 case ACT_UMODESET:
1246 atomic_set(&cs->mode, M_UNIMODEM); 1245 cs->mode = M_UNIMODEM;
1247 cs->cur_at_seq = SEQ_NONE; 1246 cs->cur_at_seq = SEQ_NONE;
1248 break; 1247 break;
1249 case ACT_FAILCMODE: 1248 case ACT_FAILCMODE:
1250 cs->cur_at_seq = SEQ_NONE; 1249 cs->cur_at_seq = SEQ_NONE;
1251 if (atomic_read(&cs->mstate) == MS_INIT || 1250 if (cs->mstate == MS_INIT || cs->mstate == MS_RECOVER) {
1252 atomic_read(&cs->mstate) == MS_RECOVER) {
1253 init_failed(cs, M_UNKNOWN); 1251 init_failed(cs, M_UNKNOWN);
1254 break; 1252 break;
1255 } 1253 }
@@ -1307,7 +1305,7 @@ static void do_action(int action, struct cardstate *cs,
1307 case ACT_CONNECT: 1305 case ACT_CONNECT:
1308 if (cs->onechannel) { 1306 if (cs->onechannel) {
1309 at_state->pending_commands |= PC_DLE1; 1307 at_state->pending_commands |= PC_DLE1;
1310 atomic_set(&cs->commands_pending, 1); 1308 cs->commands_pending = 1;
1311 break; 1309 break;
1312 } 1310 }
1313 bcs->chstate |= CHS_D_UP; 1311 bcs->chstate |= CHS_D_UP;
@@ -1333,7 +1331,7 @@ static void do_action(int action, struct cardstate *cs,
1333 * DLE only used for M10x with one B channel. 1331 * DLE only used for M10x with one B channel.
1334 */ 1332 */
1335 at_state->pending_commands |= PC_DLE0; 1333 at_state->pending_commands |= PC_DLE0;
1336 atomic_set(&cs->commands_pending, 1); 1334 cs->commands_pending = 1;
1337 } else 1335 } else
1338 disconnect(p_at_state); 1336 disconnect(p_at_state);
1339 break; 1337 break;
@@ -1369,7 +1367,7 @@ static void do_action(int action, struct cardstate *cs,
1369 "Could not enter DLE mode. Trying to hang up.\n"); 1367 "Could not enter DLE mode. Trying to hang up.\n");
1370 channel = cs->curchannel; 1368 channel = cs->curchannel;
1371 cs->bcs[channel].at_state.pending_commands |= PC_HUP; 1369 cs->bcs[channel].at_state.pending_commands |= PC_HUP;
1372 atomic_set(&cs->commands_pending, 1); 1370 cs->commands_pending = 1;
1373 break; 1371 break;
1374 1372
1375 case ACT_CID: /* got cid; start dialing */ 1373 case ACT_CID: /* got cid; start dialing */
@@ -1379,7 +1377,7 @@ static void do_action(int action, struct cardstate *cs,
1379 cs->bcs[channel].at_state.cid = ev->parameter; 1377 cs->bcs[channel].at_state.cid = ev->parameter;
1380 cs->bcs[channel].at_state.pending_commands |= 1378 cs->bcs[channel].at_state.pending_commands |=
1381 PC_DIAL; 1379 PC_DIAL;
1382 atomic_set(&cs->commands_pending, 1); 1380 cs->commands_pending = 1;
1383 break; 1381 break;
1384 } 1382 }
1385 /* fall through */ 1383 /* fall through */
@@ -1411,14 +1409,14 @@ static void do_action(int action, struct cardstate *cs,
1411 case ACT_ABORTDIAL: /* error/timeout during dial preparation */ 1409 case ACT_ABORTDIAL: /* error/timeout during dial preparation */
1412 cs->cur_at_seq = SEQ_NONE; 1410 cs->cur_at_seq = SEQ_NONE;
1413 at_state->pending_commands |= PC_HUP; 1411 at_state->pending_commands |= PC_HUP;
1414 atomic_set(&cs->commands_pending, 1); 1412 cs->commands_pending = 1;
1415 break; 1413 break;
1416 1414
1417 case ACT_REMOTEREJECT: /* DISCONNECT_IND after dialling */ 1415 case ACT_REMOTEREJECT: /* DISCONNECT_IND after dialling */
1418 case ACT_CONNTIMEOUT: /* timeout waiting for ZSAU=ACTIVE */ 1416 case ACT_CONNTIMEOUT: /* timeout waiting for ZSAU=ACTIVE */
1419 case ACT_REMOTEHUP: /* DISCONNECT_IND with established connection */ 1417 case ACT_REMOTEHUP: /* DISCONNECT_IND with established connection */
1420 at_state->pending_commands |= PC_HUP; 1418 at_state->pending_commands |= PC_HUP;
1421 atomic_set(&cs->commands_pending, 1); 1419 cs->commands_pending = 1;
1422 break; 1420 break;
1423 case ACT_GETSTRING: /* warning: RING, ZDLE, ... 1421 case ACT_GETSTRING: /* warning: RING, ZDLE, ...
1424 are not handled properly anymore */ 1422 are not handled properly anymore */
@@ -1515,7 +1513,7 @@ static void do_action(int action, struct cardstate *cs,
1515 break; 1513 break;
1516 case ACT_HUP: 1514 case ACT_HUP:
1517 at_state->pending_commands |= PC_HUP; 1515 at_state->pending_commands |= PC_HUP;
1518 atomic_set(&cs->commands_pending, 1); 1516 cs->commands_pending = 1;
1519 gig_dbg(DEBUG_CMD, "Scheduling PC_HUP"); 1517 gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
1520 break; 1518 break;
1521 1519
@@ -1558,7 +1556,7 @@ static void do_action(int action, struct cardstate *cs,
1558 cs->at_state.pending_commands |= PC_UMMODE; 1556 cs->at_state.pending_commands |= PC_UMMODE;
1559 gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE"); 1557 gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
1560 } 1558 }
1561 atomic_set(&cs->commands_pending, 1); 1559 cs->commands_pending = 1;
1562 } 1560 }
1563 spin_unlock_irqrestore(&cs->lock, flags); 1561 spin_unlock_irqrestore(&cs->lock, flags);
1564 cs->waiting = 0; 1562 cs->waiting = 0;
@@ -1741,7 +1739,7 @@ static void process_command_flags(struct cardstate *cs)
1741 int sequence; 1739 int sequence;
1742 unsigned long flags; 1740 unsigned long flags;
1743 1741
1744 atomic_set(&cs->commands_pending, 0); 1742 cs->commands_pending = 0;
1745 1743
1746 if (cs->cur_at_seq) { 1744 if (cs->cur_at_seq) {
1747 gig_dbg(DEBUG_CMD, "not searching scheduled commands: busy"); 1745 gig_dbg(DEBUG_CMD, "not searching scheduled commands: busy");
@@ -1779,7 +1777,7 @@ static void process_command_flags(struct cardstate *cs)
1779 ~(PC_DLE1 | PC_ACCEPT | PC_DIAL); 1777 ~(PC_DLE1 | PC_ACCEPT | PC_DIAL);
1780 if (at_state->cid > 0) 1778 if (at_state->cid > 0)
1781 at_state->pending_commands |= PC_HUP; 1779 at_state->pending_commands |= PC_HUP;
1782 if (atomic_read(&cs->mstate) == MS_RECOVER) { 1780 if (cs->mstate == MS_RECOVER) {
1783 if (at_state->pending_commands & PC_CID) { 1781 if (at_state->pending_commands & PC_CID) {
1784 at_state->pending_commands |= PC_NOCID; 1782 at_state->pending_commands |= PC_NOCID;
1785 at_state->pending_commands &= ~PC_CID; 1783 at_state->pending_commands &= ~PC_CID;
@@ -1793,7 +1791,7 @@ static void process_command_flags(struct cardstate *cs)
1793 if (cs->at_state.pending_commands == PC_UMMODE 1791 if (cs->at_state.pending_commands == PC_UMMODE
1794 && !cs->cidmode 1792 && !cs->cidmode
1795 && list_empty(&cs->temp_at_states) 1793 && list_empty(&cs->temp_at_states)
1796 && atomic_read(&cs->mode) == M_CID) { 1794 && cs->mode == M_CID) {
1797 sequence = SEQ_UMMODE; 1795 sequence = SEQ_UMMODE;
1798 at_state = &cs->at_state; 1796 at_state = &cs->at_state;
1799 for (i = 0; i < cs->channels; ++i) { 1797 for (i = 0; i < cs->channels; ++i) {
@@ -1860,7 +1858,7 @@ static void process_command_flags(struct cardstate *cs)
1860 } 1858 }
1861 if (cs->at_state.pending_commands & PC_CIDMODE) { 1859 if (cs->at_state.pending_commands & PC_CIDMODE) {
1862 cs->at_state.pending_commands &= ~PC_CIDMODE; 1860 cs->at_state.pending_commands &= ~PC_CIDMODE;
1863 if (atomic_read(&cs->mode) == M_UNIMODEM) { 1861 if (cs->mode == M_UNIMODEM) {
1864 cs->retry_count = 1; 1862 cs->retry_count = 1;
1865 schedule_sequence(cs, &cs->at_state, SEQ_CIDMODE); 1863 schedule_sequence(cs, &cs->at_state, SEQ_CIDMODE);
1866 return; 1864 return;
@@ -1886,11 +1884,11 @@ static void process_command_flags(struct cardstate *cs)
1886 return; 1884 return;
1887 } 1885 }
1888 if (bcs->at_state.pending_commands & PC_CID) { 1886 if (bcs->at_state.pending_commands & PC_CID) {
1889 switch (atomic_read(&cs->mode)) { 1887 switch (cs->mode) {
1890 case M_UNIMODEM: 1888 case M_UNIMODEM:
1891 cs->at_state.pending_commands |= PC_CIDMODE; 1889 cs->at_state.pending_commands |= PC_CIDMODE;
1892 gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE"); 1890 gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
1893 atomic_set(&cs->commands_pending, 1); 1891 cs->commands_pending = 1;
1894 return; 1892 return;
1895#ifdef GIG_MAYINITONDIAL 1893#ifdef GIG_MAYINITONDIAL
1896 case M_UNKNOWN: 1894 case M_UNKNOWN:
@@ -1926,7 +1924,7 @@ static void process_events(struct cardstate *cs)
1926 for (i = 0; i < 2 * MAX_EVENTS; ++i) { 1924 for (i = 0; i < 2 * MAX_EVENTS; ++i) {
1927 tail = cs->ev_tail; 1925 tail = cs->ev_tail;
1928 if (tail == head) { 1926 if (tail == head) {
1929 if (!check_flags && !atomic_read(&cs->commands_pending)) 1927 if (!check_flags && !cs->commands_pending)
1930 break; 1928 break;
1931 check_flags = 0; 1929 check_flags = 0;
1932 spin_unlock_irqrestore(&cs->ev_lock, flags); 1930 spin_unlock_irqrestore(&cs->ev_lock, flags);
@@ -1934,7 +1932,7 @@ static void process_events(struct cardstate *cs)
1934 spin_lock_irqsave(&cs->ev_lock, flags); 1932 spin_lock_irqsave(&cs->ev_lock, flags);
1935 tail = cs->ev_tail; 1933 tail = cs->ev_tail;
1936 if (tail == head) { 1934 if (tail == head) {
1937 if (!atomic_read(&cs->commands_pending)) 1935 if (!cs->commands_pending)
1938 break; 1936 break;
1939 continue; 1937 continue;
1940 } 1938 }
@@ -1971,7 +1969,7 @@ void gigaset_handle_event(unsigned long data)
1971 struct cardstate *cs = (struct cardstate *) data; 1969 struct cardstate *cs = (struct cardstate *) data;
1972 1970
1973 /* handle incoming data on control/common channel */ 1971 /* handle incoming data on control/common channel */
1974 if (atomic_read(&cs->inbuf->head) != atomic_read(&cs->inbuf->tail)) { 1972 if (cs->inbuf->head != cs->inbuf->tail) {
1975 gig_dbg(DEBUG_INTR, "processing new data"); 1973 gig_dbg(DEBUG_INTR, "processing new data");
1976 cs->ops->handle_input(cs->inbuf); 1974 cs->ops->handle_input(cs->inbuf);
1977 } 1975 }
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index 8303625d0401..92986a5d4055 100644
--- a/drivers/isdn/gigaset/gigaset.h
+++ b/drivers/isdn/gigaset/gigaset.h
@@ -307,7 +307,7 @@ struct inbuf_t {
307 struct bc_state *bcs; 307 struct bc_state *bcs;
308 struct cardstate *cs; 308 struct cardstate *cs;
309 int inputstate; 309 int inputstate;
310 atomic_t head, tail; 310 int head, tail;
311 unsigned char data[RBUFSIZE]; 311 unsigned char data[RBUFSIZE];
312}; 312};
313 313
@@ -329,9 +329,9 @@ struct inbuf_t {
329 * are also filled with that value 329 * are also filled with that value
330 */ 330 */
331struct isowbuf_t { 331struct isowbuf_t {
332 atomic_t read; 332 int read;
333 atomic_t nextread; 333 int nextread;
334 atomic_t write; 334 int write;
335 atomic_t writesem; 335 atomic_t writesem;
336 int wbits; 336 int wbits;
337 unsigned char data[BAS_OUTBUFSIZE + BAS_OUTBUFPAD]; 337 unsigned char data[BAS_OUTBUFSIZE + BAS_OUTBUFPAD];
@@ -441,8 +441,8 @@ struct cardstate {
441 /* Stuff to handle communication */ 441 /* Stuff to handle communication */
442 wait_queue_head_t waitqueue; 442 wait_queue_head_t waitqueue;
443 int waiting; 443 int waiting;
444 atomic_t mode; /* see M_XXXX */ 444 int mode; /* see M_XXXX */
445 atomic_t mstate; /* Modem state: see MS_XXXX */ 445 int mstate; /* Modem state: see MS_XXXX */
446 /* only changed by the event layer */ 446 /* only changed by the event layer */
447 int cmd_result; 447 int cmd_result;
448 448
@@ -499,7 +499,7 @@ struct cardstate {
499 processed */ 499 processed */
500 int curchannel; /* channel those commands are meant 500 int curchannel; /* channel those commands are meant
501 for */ 501 for */
502 atomic_t commands_pending; /* flag(s) in xxx.commands_pending have 502 int commands_pending; /* flag(s) in xxx.commands_pending have
503 been set */ 503 been set */
504 struct tasklet_struct event_tasklet; 504 struct tasklet_struct event_tasklet;
505 /* tasklet for serializing AT commands. 505 /* tasklet for serializing AT commands.
@@ -555,7 +555,7 @@ struct cmdbuf_t {
555 555
556struct bas_bc_state { 556struct bas_bc_state {
557 /* isochronous output state */ 557 /* isochronous output state */
558 atomic_t running; 558 int running;
559 atomic_t corrbytes; 559 atomic_t corrbytes;
560 spinlock_t isooutlock; 560 spinlock_t isooutlock;
561 struct isow_urbctx_t isoouturbs[BAS_OUTURBS]; 561 struct isow_urbctx_t isoouturbs[BAS_OUTURBS];
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index eb50f3dab5f7..f4731c9984f6 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -28,12 +28,11 @@ static int if_lock(struct cardstate *cs, int *arg)
28 return -EINVAL; 28 return -EINVAL;
29 29
30 if (cmd < 0) { 30 if (cmd < 0) {
31 *arg = atomic_read(&cs->mstate) == MS_LOCKED; //FIXME remove? 31 *arg = cs->mstate == MS_LOCKED;
32 return 0; 32 return 0;
33 } 33 }
34 34
35 if (!cmd && atomic_read(&cs->mstate) == MS_LOCKED 35 if (!cmd && cs->mstate == MS_LOCKED && cs->connected) {
36 && cs->connected) {
37 cs->ops->set_modem_ctrl(cs, 0, TIOCM_DTR|TIOCM_RTS); 36 cs->ops->set_modem_ctrl(cs, 0, TIOCM_DTR|TIOCM_RTS);
38 cs->ops->baud_rate(cs, B115200); 37 cs->ops->baud_rate(cs, B115200);
39 cs->ops->set_line_ctrl(cs, CS8); 38 cs->ops->set_line_ctrl(cs, CS8);
@@ -104,7 +103,7 @@ static int if_config(struct cardstate *cs, int *arg)
104 if (*arg != 1) 103 if (*arg != 1)
105 return -EINVAL; 104 return -EINVAL;
106 105
107 if (atomic_read(&cs->mstate) != MS_LOCKED) 106 if (cs->mstate != MS_LOCKED)
108 return -EBUSY; 107 return -EBUSY;
109 108
110 if (!cs->connected) { 109 if (!cs->connected) {
@@ -364,7 +363,7 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
364 363
365 if (!cs->open_count) 364 if (!cs->open_count)
366 warn("%s: device not opened", __func__); 365 warn("%s: device not opened", __func__);
367 else if (atomic_read(&cs->mstate) != MS_LOCKED) { 366 else if (cs->mstate != MS_LOCKED) {
368 warn("can't write to unlocked device"); 367 warn("can't write to unlocked device");
369 retval = -EBUSY; 368 retval = -EBUSY;
370 } else if (!cs->connected) { 369 } else if (!cs->connected) {
@@ -398,9 +397,9 @@ static int if_write_room(struct tty_struct *tty)
398 397
399 if (!cs->open_count) 398 if (!cs->open_count)
400 warn("%s: device not opened", __func__); 399 warn("%s: device not opened", __func__);
401 else if (atomic_read(&cs->mstate) != MS_LOCKED) { 400 else if (cs->mstate != MS_LOCKED) {
402 warn("can't write to unlocked device"); 401 warn("can't write to unlocked device");
403 retval = -EBUSY; //FIXME 402 retval = -EBUSY;
404 } else if (!cs->connected) { 403 } else if (!cs->connected) {
405 gig_dbg(DEBUG_ANY, "can't write to unplugged device"); 404 gig_dbg(DEBUG_ANY, "can't write to unplugged device");
406 retval = -EBUSY; //FIXME 405 retval = -EBUSY; //FIXME
@@ -430,7 +429,7 @@ static int if_chars_in_buffer(struct tty_struct *tty)
430 429
431 if (!cs->open_count) 430 if (!cs->open_count)
432 warn("%s: device not opened", __func__); 431 warn("%s: device not opened", __func__);
433 else if (atomic_read(&cs->mstate) != MS_LOCKED) { 432 else if (cs->mstate != MS_LOCKED) {
434 warn("can't write to unlocked device"); 433 warn("can't write to unlocked device");
435 retval = -EBUSY; 434 retval = -EBUSY;
436 } else if (!cs->connected) { 435 } else if (!cs->connected) {
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c
index e0505f238807..e30a7773f93c 100644
--- a/drivers/isdn/gigaset/isocdata.c
+++ b/drivers/isdn/gigaset/isocdata.c
@@ -23,9 +23,9 @@
23 */ 23 */
24void gigaset_isowbuf_init(struct isowbuf_t *iwb, unsigned char idle) 24void gigaset_isowbuf_init(struct isowbuf_t *iwb, unsigned char idle)
25{ 25{
26 atomic_set(&iwb->read, 0); 26 iwb->read = 0;
27 atomic_set(&iwb->nextread, 0); 27 iwb->nextread = 0;
28 atomic_set(&iwb->write, 0); 28 iwb->write = 0;
29 atomic_set(&iwb->writesem, 1); 29 atomic_set(&iwb->writesem, 1);
30 iwb->wbits = 0; 30 iwb->wbits = 0;
31 iwb->idle = idle; 31 iwb->idle = idle;
@@ -39,8 +39,8 @@ static inline int isowbuf_freebytes(struct isowbuf_t *iwb)
39{ 39{
40 int read, write, freebytes; 40 int read, write, freebytes;
41 41
42 read = atomic_read(&iwb->read); 42 read = iwb->read;
43 write = atomic_read(&iwb->write); 43 write = iwb->write;
44 if ((freebytes = read - write) > 0) { 44 if ((freebytes = read - write) > 0) {
45 /* no wraparound: need padding space within regular area */ 45 /* no wraparound: need padding space within regular area */
46 return freebytes - BAS_OUTBUFPAD; 46 return freebytes - BAS_OUTBUFPAD;
@@ -62,7 +62,7 @@ static inline int isowbuf_poscmp(struct isowbuf_t *iwb, int a, int b)
62 int read; 62 int read;
63 if (a == b) 63 if (a == b)
64 return 0; 64 return 0;
65 read = atomic_read(&iwb->read); 65 read = iwb->read;
66 if (a < b) { 66 if (a < b) {
67 if (a < read && read <= b) 67 if (a < read && read <= b)
68 return +1; 68 return +1;
@@ -91,18 +91,18 @@ static inline int isowbuf_startwrite(struct isowbuf_t *iwb)
91#ifdef CONFIG_GIGASET_DEBUG 91#ifdef CONFIG_GIGASET_DEBUG
92 gig_dbg(DEBUG_ISO, 92 gig_dbg(DEBUG_ISO,
93 "%s: acquired iso write semaphore, data[write]=%02x, nbits=%d", 93 "%s: acquired iso write semaphore, data[write]=%02x, nbits=%d",
94 __func__, iwb->data[atomic_read(&iwb->write)], iwb->wbits); 94 __func__, iwb->data[iwb->write], iwb->wbits);
95#endif 95#endif
96 return 1; 96 return 1;
97} 97}
98 98
99/* finish writing 99/* finish writing
100 * release the write semaphore and update the maximum buffer fill level 100 * release the write semaphore
101 * returns the current write position 101 * returns the current write position
102 */ 102 */
103static inline int isowbuf_donewrite(struct isowbuf_t *iwb) 103static inline int isowbuf_donewrite(struct isowbuf_t *iwb)
104{ 104{
105 int write = atomic_read(&iwb->write); 105 int write = iwb->write;
106 atomic_inc(&iwb->writesem); 106 atomic_inc(&iwb->writesem);
107 return write; 107 return write;
108} 108}
@@ -116,7 +116,7 @@ static inline int isowbuf_donewrite(struct isowbuf_t *iwb)
116 */ 116 */
117static inline void isowbuf_putbits(struct isowbuf_t *iwb, u32 data, int nbits) 117static inline void isowbuf_putbits(struct isowbuf_t *iwb, u32 data, int nbits)
118{ 118{
119 int write = atomic_read(&iwb->write); 119 int write = iwb->write;
120 data <<= iwb->wbits; 120 data <<= iwb->wbits;
121 data |= iwb->data[write]; 121 data |= iwb->data[write];
122 nbits += iwb->wbits; 122 nbits += iwb->wbits;
@@ -128,7 +128,7 @@ static inline void isowbuf_putbits(struct isowbuf_t *iwb, u32 data, int nbits)
128 } 128 }
129 iwb->wbits = nbits; 129 iwb->wbits = nbits;
130 iwb->data[write] = data & 0xff; 130 iwb->data[write] = data & 0xff;
131 atomic_set(&iwb->write, write); 131 iwb->write = write;
132} 132}
133 133
134/* put final flag on HDLC bitstream 134/* put final flag on HDLC bitstream
@@ -142,7 +142,7 @@ static inline void isowbuf_putflag(struct isowbuf_t *iwb)
142 /* add two flags, thus reliably covering one byte */ 142 /* add two flags, thus reliably covering one byte */
143 isowbuf_putbits(iwb, 0x7e7e, 8); 143 isowbuf_putbits(iwb, 0x7e7e, 8);
144 /* recover the idle flag byte */ 144 /* recover the idle flag byte */
145 write = atomic_read(&iwb->write); 145 write = iwb->write;
146 iwb->idle = iwb->data[write]; 146 iwb->idle = iwb->data[write];
147 gig_dbg(DEBUG_ISO, "idle fill byte %02x", iwb->idle); 147 gig_dbg(DEBUG_ISO, "idle fill byte %02x", iwb->idle);
148 /* mask extraneous bits in buffer */ 148 /* mask extraneous bits in buffer */
@@ -160,8 +160,8 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
160 int read, write, limit, src, dst; 160 int read, write, limit, src, dst;
161 unsigned char pbyte; 161 unsigned char pbyte;
162 162
163 read = atomic_read(&iwb->nextread); 163 read = iwb->nextread;
164 write = atomic_read(&iwb->write); 164 write = iwb->write;
165 if (likely(read == write)) { 165 if (likely(read == write)) {
166 /* return idle frame */ 166 /* return idle frame */
167 return read < BAS_OUTBUFPAD ? 167 return read < BAS_OUTBUFPAD ?
@@ -176,7 +176,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
176 err("invalid size %d", size); 176 err("invalid size %d", size);
177 return -EINVAL; 177 return -EINVAL;
178 } 178 }
179 src = atomic_read(&iwb->read); 179 src = iwb->read;
180 if (unlikely(limit > BAS_OUTBUFSIZE + BAS_OUTBUFPAD || 180 if (unlikely(limit > BAS_OUTBUFSIZE + BAS_OUTBUFPAD ||
181 (read < src && limit >= src))) { 181 (read < src && limit >= src))) {
182 err("isoc write buffer frame reservation violated"); 182 err("isoc write buffer frame reservation violated");
@@ -191,7 +191,8 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
191 if (!isowbuf_startwrite(iwb)) 191 if (!isowbuf_startwrite(iwb))
192 return -EBUSY; 192 return -EBUSY;
193 /* write position could have changed */ 193 /* write position could have changed */
194 if (limit >= (write = atomic_read(&iwb->write))) { 194 write = iwb->write;
195 if (limit >= write) {
195 pbyte = iwb->data[write]; /* save 196 pbyte = iwb->data[write]; /* save
196 partial byte */ 197 partial byte */
197 limit = write + BAS_OUTBUFPAD; 198 limit = write + BAS_OUTBUFPAD;
@@ -213,7 +214,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
213 __func__, pbyte, limit); 214 __func__, pbyte, limit);
214 iwb->data[limit] = pbyte; /* restore 215 iwb->data[limit] = pbyte; /* restore
215 partial byte */ 216 partial byte */
216 atomic_set(&iwb->write, limit); 217 iwb->write = limit;
217 } 218 }
218 isowbuf_donewrite(iwb); 219 isowbuf_donewrite(iwb);
219 } 220 }
@@ -233,7 +234,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
233 limit = src; 234 limit = src;
234 } 235 }
235 } 236 }
236 atomic_set(&iwb->nextread, limit); 237 iwb->nextread = limit;
237 return read; 238 return read;
238} 239}
239 240
@@ -477,7 +478,7 @@ static inline int trans_buildframe(struct isowbuf_t *iwb,
477 unsigned char c; 478 unsigned char c;
478 479
479 if (unlikely(count <= 0)) 480 if (unlikely(count <= 0))
480 return atomic_read(&iwb->write); /* better ideas? */ 481 return iwb->write;
481 482
482 if (isowbuf_freebytes(iwb) < count || 483 if (isowbuf_freebytes(iwb) < count ||
483 !isowbuf_startwrite(iwb)) { 484 !isowbuf_startwrite(iwb)) {
@@ -486,13 +487,13 @@ static inline int trans_buildframe(struct isowbuf_t *iwb,
486 } 487 }
487 488
488 gig_dbg(DEBUG_STREAM, "put %d bytes", count); 489 gig_dbg(DEBUG_STREAM, "put %d bytes", count);
489 write = atomic_read(&iwb->write); 490 write = iwb->write;
490 do { 491 do {
491 c = bitrev8(*in++); 492 c = bitrev8(*in++);
492 iwb->data[write++] = c; 493 iwb->data[write++] = c;
493 write %= BAS_OUTBUFSIZE; 494 write %= BAS_OUTBUFSIZE;
494 } while (--count > 0); 495 } while (--count > 0);
495 atomic_set(&iwb->write, write); 496 iwb->write = write;
496 iwb->idle = c; 497 iwb->idle = c;
497 498
498 return isowbuf_donewrite(iwb); 499 return isowbuf_donewrite(iwb);
@@ -947,8 +948,8 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
947 unsigned tail, head, numbytes; 948 unsigned tail, head, numbytes;
948 unsigned char *src; 949 unsigned char *src;
949 950
950 head = atomic_read(&inbuf->head); 951 head = inbuf->head;
951 while (head != (tail = atomic_read(&inbuf->tail))) { 952 while (head != (tail = inbuf->tail)) {
952 gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail); 953 gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
953 if (head > tail) 954 if (head > tail)
954 tail = RBUFSIZE; 955 tail = RBUFSIZE;
@@ -956,7 +957,7 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
956 numbytes = tail - head; 957 numbytes = tail - head;
957 gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes); 958 gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes);
958 959
959 if (atomic_read(&cs->mstate) == MS_LOCKED) { 960 if (cs->mstate == MS_LOCKED) {
960 gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response", 961 gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response",
961 numbytes, src); 962 numbytes, src);
962 gigaset_if_receive(inbuf->cs, src, numbytes); 963 gigaset_if_receive(inbuf->cs, src, numbytes);
@@ -970,7 +971,7 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
970 if (head == RBUFSIZE) 971 if (head == RBUFSIZE)
971 head = 0; 972 head = 0;
972 gig_dbg(DEBUG_INTR, "setting head to %u", head); 973 gig_dbg(DEBUG_INTR, "setting head to %u", head);
973 atomic_set(&inbuf->head, head); 974 inbuf->head = head;
974 } 975 }
975} 976}
976 977
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index ea44302e6e7e..f2bb1aeb0c80 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -240,7 +240,7 @@ static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
240 struct cmdbuf_t *cb; 240 struct cmdbuf_t *cb;
241 unsigned long flags; 241 unsigned long flags;
242 242
243 gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ? 243 gigaset_dbg_buffer(cs->mstate != MS_LOCKED ?
244 DEBUG_TRANSCMD : DEBUG_LOCKCMD, 244 DEBUG_TRANSCMD : DEBUG_LOCKCMD,
245 "CMD Transmit", len, buf); 245 "CMD Transmit", len, buf);
246 246
@@ -536,7 +536,7 @@ gigaset_tty_open(struct tty_struct *tty)
536 * startup system and notify the LL that we are ready to run 536 * startup system and notify the LL that we are ready to run
537 */ 537 */
538 if (startmode == SM_LOCKED) 538 if (startmode == SM_LOCKED)
539 atomic_set(&cs->mstate, MS_LOCKED); 539 cs->mstate = MS_LOCKED;
540 if (!gigaset_start(cs)) { 540 if (!gigaset_start(cs)) {
541 tasklet_kill(&cs->write_tasklet); 541 tasklet_kill(&cs->write_tasklet);
542 goto error; 542 goto error;
@@ -714,8 +714,8 @@ gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
714 return; 714 return;
715 } 715 }
716 716
717 tail = atomic_read(&inbuf->tail); 717 tail = inbuf->tail;
718 head = atomic_read(&inbuf->head); 718 head = inbuf->head;
719 gig_dbg(DEBUG_INTR, "buffer state: %u -> %u, receive %u bytes", 719 gig_dbg(DEBUG_INTR, "buffer state: %u -> %u, receive %u bytes",
720 head, tail, count); 720 head, tail, count);
721 721
@@ -742,7 +742,7 @@ gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
742 } 742 }
743 743
744 gig_dbg(DEBUG_INTR, "setting tail to %u", tail); 744 gig_dbg(DEBUG_INTR, "setting tail to %u", tail);
745 atomic_set(&inbuf->tail, tail); 745 inbuf->tail = tail;
746 746
747 /* Everything was received .. Push data into handler */ 747 /* Everything was received .. Push data into handler */
748 gig_dbg(DEBUG_INTR, "%s-->BH", __func__); 748 gig_dbg(DEBUG_INTR, "%s-->BH", __func__);
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index 7028911d91ed..c58ddee68dea 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -133,7 +133,7 @@ static struct usb_driver gigaset_usb_driver = {
133struct usb_cardstate { 133struct usb_cardstate {
134 struct usb_device *udev; /* usb device pointer */ 134 struct usb_device *udev; /* usb device pointer */
135 struct usb_interface *interface; /* interface for this device */ 135 struct usb_interface *interface; /* interface for this device */
136 atomic_t busy; /* bulk output in progress */ 136 int busy; /* bulk output in progress */
137 137
138 /* Output buffer */ 138 /* Output buffer */
139 unsigned char *bulk_out_buffer; 139 unsigned char *bulk_out_buffer;
@@ -325,7 +325,7 @@ static void gigaset_modem_fill(unsigned long data)
325 325
326 gig_dbg(DEBUG_OUTPUT, "modem_fill"); 326 gig_dbg(DEBUG_OUTPUT, "modem_fill");
327 327
328 if (atomic_read(&cs->hw.usb->busy)) { 328 if (cs->hw.usb->busy) {
329 gig_dbg(DEBUG_OUTPUT, "modem_fill: busy"); 329 gig_dbg(DEBUG_OUTPUT, "modem_fill: busy");
330 return; 330 return;
331 } 331 }
@@ -430,7 +430,7 @@ static void gigaset_write_bulk_callback(struct urb *urb)
430 break; 430 break;
431 case -ENOENT: /* killed */ 431 case -ENOENT: /* killed */
432 gig_dbg(DEBUG_ANY, "%s: killed", __func__); 432 gig_dbg(DEBUG_ANY, "%s: killed", __func__);
433 atomic_set(&cs->hw.usb->busy, 0); 433 cs->hw.usb->busy = 0;
434 return; 434 return;
435 default: 435 default:
436 dev_err(cs->dev, "bulk transfer failed (status %d)\n", 436 dev_err(cs->dev, "bulk transfer failed (status %d)\n",
@@ -443,7 +443,7 @@ static void gigaset_write_bulk_callback(struct urb *urb)
443 if (!cs->connected) { 443 if (!cs->connected) {
444 err("%s: not connected", __func__); 444 err("%s: not connected", __func__);
445 } else { 445 } else {
446 atomic_set(&cs->hw.usb->busy, 0); 446 cs->hw.usb->busy = 0;
447 tasklet_schedule(&cs->write_tasklet); 447 tasklet_schedule(&cs->write_tasklet);
448 } 448 }
449 spin_unlock_irqrestore(&cs->lock, flags); 449 spin_unlock_irqrestore(&cs->lock, flags);
@@ -491,14 +491,14 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
491 491
492 cb->offset += count; 492 cb->offset += count;
493 cb->len -= count; 493 cb->len -= count;
494 atomic_set(&ucs->busy, 1); 494 ucs->busy = 1;
495 495
496 spin_lock_irqsave(&cs->lock, flags); 496 spin_lock_irqsave(&cs->lock, flags);
497 status = cs->connected ? usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC) : -ENODEV; 497 status = cs->connected ? usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC) : -ENODEV;
498 spin_unlock_irqrestore(&cs->lock, flags); 498 spin_unlock_irqrestore(&cs->lock, flags);
499 499
500 if (status) { 500 if (status) {
501 atomic_set(&ucs->busy, 0); 501 ucs->busy = 0;
502 err("could not submit urb (error %d)\n", 502 err("could not submit urb (error %d)\n",
503 -status); 503 -status);
504 cb->len = 0; /* skip urb => remove cb+wakeup 504 cb->len = 0; /* skip urb => remove cb+wakeup
@@ -517,7 +517,7 @@ static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
517 struct cmdbuf_t *cb; 517 struct cmdbuf_t *cb;
518 unsigned long flags; 518 unsigned long flags;
519 519
520 gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ? 520 gigaset_dbg_buffer(cs->mstate != MS_LOCKED ?
521 DEBUG_TRANSCMD : DEBUG_LOCKCMD, 521 DEBUG_TRANSCMD : DEBUG_LOCKCMD,
522 "CMD Transmit", len, buf); 522 "CMD Transmit", len, buf);
523 523
@@ -654,7 +654,7 @@ static int write_modem(struct cardstate *cs)
654 count = min(bcs->tx_skb->len, (unsigned) ucs->bulk_out_size); 654 count = min(bcs->tx_skb->len, (unsigned) ucs->bulk_out_size);
655 skb_copy_from_linear_data(bcs->tx_skb, ucs->bulk_out_buffer, count); 655 skb_copy_from_linear_data(bcs->tx_skb, ucs->bulk_out_buffer, count);
656 skb_pull(bcs->tx_skb, count); 656 skb_pull(bcs->tx_skb, count);
657 atomic_set(&ucs->busy, 1); 657 ucs->busy = 1;
658 gig_dbg(DEBUG_OUTPUT, "write_modem: send %d bytes", count); 658 gig_dbg(DEBUG_OUTPUT, "write_modem: send %d bytes", count);
659 659
660 spin_lock_irqsave(&cs->lock, flags); 660 spin_lock_irqsave(&cs->lock, flags);
@@ -672,7 +672,7 @@ static int write_modem(struct cardstate *cs)
672 672
673 if (ret) { 673 if (ret) {
674 err("could not submit urb (error %d)\n", -ret); 674 err("could not submit urb (error %d)\n", -ret);
675 atomic_set(&ucs->busy, 0); 675 ucs->busy = 0;
676 } 676 }
677 677
678 if (!bcs->tx_skb->len) { 678 if (!bcs->tx_skb->len) {
@@ -764,7 +764,7 @@ static int gigaset_probe(struct usb_interface *interface,
764 764
765 endpoint = &hostif->endpoint[1].desc; 765 endpoint = &hostif->endpoint[1].desc;
766 766
767 atomic_set(&ucs->busy, 0); 767 ucs->busy = 0;
768 768
769 ucs->read_urb = usb_alloc_urb(0, GFP_KERNEL); 769 ucs->read_urb = usb_alloc_urb(0, GFP_KERNEL);
770 if (!ucs->read_urb) { 770 if (!ucs->read_urb) {
@@ -797,7 +797,7 @@ static int gigaset_probe(struct usb_interface *interface,
797 797
798 /* tell common part that the device is ready */ 798 /* tell common part that the device is ready */
799 if (startmode == SM_LOCKED) 799 if (startmode == SM_LOCKED)
800 atomic_set(&cs->mstate, MS_LOCKED); 800 cs->mstate = MS_LOCKED;
801 801
802 if (!gigaset_start(cs)) { 802 if (!gigaset_start(cs)) {
803 tasklet_kill(&cs->write_tasklet); 803 tasklet_kill(&cs->write_tasklet);