gigaset: atomic cleanup
Convert atomic_t variables that don't actually use atomic_t functionality to int. Signed-off-by: Tilman Schmidt <tilman@imap.cc> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
这个提交包含在:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
在新工单中引用
屏蔽一个用户