X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fisdn%2Fgigaset%2Fisocdata.c;h=e30a7773f93cefecdf315db52daf65c12948f4be;hb=1b2b03f8e514e4f68e293846ba511a948b80243c;hp=8c0eb522dab14336d8c7140660146375bff03ad0;hpb=4935361766cc73949fe032cd157d314f288922ba;p=linux-2.6 diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c index 8c0eb522da..e30a7773f9 100644 --- a/drivers/isdn/gigaset/isocdata.c +++ b/drivers/isdn/gigaset/isocdata.c @@ -23,9 +23,9 @@ */ void gigaset_isowbuf_init(struct isowbuf_t *iwb, unsigned char idle) { - atomic_set(&iwb->read, 0); - atomic_set(&iwb->nextread, 0); - atomic_set(&iwb->write, 0); + iwb->read = 0; + iwb->nextread = 0; + iwb->write = 0; atomic_set(&iwb->writesem, 1); iwb->wbits = 0; iwb->idle = idle; @@ -39,8 +39,8 @@ static inline int isowbuf_freebytes(struct isowbuf_t *iwb) { int read, write, freebytes; - read = atomic_read(&iwb->read); - write = atomic_read(&iwb->write); + read = iwb->read; + write = iwb->write; if ((freebytes = read - write) > 0) { /* no wraparound: need padding space within regular area */ return freebytes - BAS_OUTBUFPAD; @@ -62,7 +62,7 @@ static inline int isowbuf_poscmp(struct isowbuf_t *iwb, int a, int b) int read; if (a == b) return 0; - read = atomic_read(&iwb->read); + read = iwb->read; if (a < b) { if (a < read && read <= b) return +1; @@ -91,18 +91,18 @@ static inline int isowbuf_startwrite(struct isowbuf_t *iwb) #ifdef CONFIG_GIGASET_DEBUG gig_dbg(DEBUG_ISO, "%s: acquired iso write semaphore, data[write]=%02x, nbits=%d", - __func__, iwb->data[atomic_read(&iwb->write)], iwb->wbits); + __func__, iwb->data[iwb->write], iwb->wbits); #endif return 1; } /* finish writing - * release the write semaphore and update the maximum buffer fill level + * release the write semaphore * returns the current write position */ static inline int isowbuf_donewrite(struct isowbuf_t *iwb) { - int write = atomic_read(&iwb->write); + int write = iwb->write; atomic_inc(&iwb->writesem); return write; } @@ -116,7 +116,7 @@ static inline int isowbuf_donewrite(struct isowbuf_t *iwb) */ static inline void isowbuf_putbits(struct isowbuf_t *iwb, u32 data, int nbits) { - int write = atomic_read(&iwb->write); + int write = iwb->write; data <<= iwb->wbits; data |= iwb->data[write]; nbits += iwb->wbits; @@ -128,7 +128,7 @@ static inline void isowbuf_putbits(struct isowbuf_t *iwb, u32 data, int nbits) } iwb->wbits = nbits; iwb->data[write] = data & 0xff; - atomic_set(&iwb->write, write); + iwb->write = write; } /* put final flag on HDLC bitstream @@ -142,7 +142,7 @@ static inline void isowbuf_putflag(struct isowbuf_t *iwb) /* add two flags, thus reliably covering one byte */ isowbuf_putbits(iwb, 0x7e7e, 8); /* recover the idle flag byte */ - write = atomic_read(&iwb->write); + write = iwb->write; iwb->idle = iwb->data[write]; gig_dbg(DEBUG_ISO, "idle fill byte %02x", iwb->idle); /* mask extraneous bits in buffer */ @@ -160,8 +160,8 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size) int read, write, limit, src, dst; unsigned char pbyte; - read = atomic_read(&iwb->nextread); - write = atomic_read(&iwb->write); + read = iwb->nextread; + write = iwb->write; if (likely(read == write)) { /* return idle frame */ return read < BAS_OUTBUFPAD ? @@ -176,7 +176,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size) err("invalid size %d", size); return -EINVAL; } - src = atomic_read(&iwb->read); + src = iwb->read; if (unlikely(limit > BAS_OUTBUFSIZE + BAS_OUTBUFPAD || (read < src && limit >= src))) { err("isoc write buffer frame reservation violated"); @@ -191,7 +191,8 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size) if (!isowbuf_startwrite(iwb)) return -EBUSY; /* write position could have changed */ - if (limit >= (write = atomic_read(&iwb->write))) { + write = iwb->write; + if (limit >= write) { pbyte = iwb->data[write]; /* save partial byte */ limit = write + BAS_OUTBUFPAD; @@ -213,7 +214,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size) __func__, pbyte, limit); iwb->data[limit] = pbyte; /* restore partial byte */ - atomic_set(&iwb->write, limit); + iwb->write = limit; } isowbuf_donewrite(iwb); } @@ -233,7 +234,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size) limit = src; } } - atomic_set(&iwb->nextread, limit); + iwb->nextread = limit; return read; } @@ -274,7 +275,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag, * bit 12..10 = number of trailing '1' bits in result * bit 14..13 = number of bits added by stuffing */ -static u16 stufftab[5 * 256] = { +static const u16 stufftab[5 * 256] = { // previous 1s = 0: 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x201f, @@ -477,7 +478,7 @@ static inline int trans_buildframe(struct isowbuf_t *iwb, unsigned char c; if (unlikely(count <= 0)) - return atomic_read(&iwb->write); /* better ideas? */ + return iwb->write; if (isowbuf_freebytes(iwb) < count || !isowbuf_startwrite(iwb)) { @@ -486,13 +487,13 @@ static inline int trans_buildframe(struct isowbuf_t *iwb, } gig_dbg(DEBUG_STREAM, "put %d bytes", count); - write = atomic_read(&iwb->write); + write = iwb->write; do { c = bitrev8(*in++); iwb->data[write++] = c; write %= BAS_OUTBUFSIZE; } while (--count > 0); - atomic_set(&iwb->write, write); + iwb->write = write; iwb->idle = c; return isowbuf_donewrite(iwb); @@ -629,7 +630,7 @@ static inline void hdlc_frag(struct bc_state *bcs, unsigned inbits) * (replacing 8 by 7 to make it fit; the algorithm won't care) * bit 7 set if there are 5 or more "interior" consecutive '1' bits */ -static unsigned char bitcounts[256] = { +static const unsigned char bitcounts[256] = { 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, @@ -947,8 +948,8 @@ void gigaset_isoc_input(struct inbuf_t *inbuf) unsigned tail, head, numbytes; unsigned char *src; - head = atomic_read(&inbuf->head); - while (head != (tail = atomic_read(&inbuf->tail))) { + head = inbuf->head; + while (head != (tail = inbuf->tail)) { gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail); if (head > tail) tail = RBUFSIZE; @@ -956,7 +957,7 @@ void gigaset_isoc_input(struct inbuf_t *inbuf) numbytes = tail - head; gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes); - if (atomic_read(&cs->mstate) == MS_LOCKED) { + if (cs->mstate == MS_LOCKED) { gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response", numbytes, src); gigaset_if_receive(inbuf->cs, src, numbytes); @@ -970,7 +971,7 @@ void gigaset_isoc_input(struct inbuf_t *inbuf) if (head == RBUFSIZE) head = 0; gig_dbg(DEBUG_INTR, "setting head to %u", head); - atomic_set(&inbuf->head, head); + inbuf->head = head; } }