]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/isdn/gigaset/isocdata.c
Pull bugfix into test branch
[linux-2.6-omap-h63xx.git] / drivers / isdn / gigaset / isocdata.c
index 4a00d22c496edc14482cf41cb79b81175751f6a9..df988eb0e36fdd2bf6da36bba74cafd93f3cf6c8 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "gigaset.h"
 #include <linux/crc-ccitt.h>
+#include <linux/bitrev.h>
 
 /* access methods for isowbuf_t */
 /* ============================ */
@@ -247,8 +248,6 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
        static char dbgline[3 * 32 + 1];
        static const char hexdigit[] = "0123456789abcdef";
        int i = 0;
-       IFNULLRET(tag);
-       IFNULLRET(bytes);
        while (count-- > 0) {
                if (i > sizeof(dbgline) - 4) {
                        dbgline[i] = '\0';
@@ -489,7 +488,7 @@ static inline int trans_buildframe(struct isowbuf_t *iwb,
        gig_dbg(DEBUG_STREAM, "put %d bytes", count);
        write = atomic_read(&iwb->write);
        do {
-               c = gigaset_invtab[*in++];
+               c = bitrev8(*in++);
                iwb->data[write++] = c;
                write %= BAS_OUTBUFSIZE;
        } while (--count > 0);
@@ -534,7 +533,7 @@ static inline void hdlc_putbyte(unsigned char c, struct bc_state *bcs)
                bcs->skb = NULL;
                return;
        }
-       *gigaset_skb_put_quick(bcs->skb, 1) = c;
+       *__skb_put(bcs->skb, 1) = c;
 }
 
 /* hdlc_flush
@@ -663,14 +662,10 @@ static unsigned char bitcounts[256] = {
 static inline void hdlc_unpack(unsigned char *src, unsigned count,
                               struct bc_state *bcs)
 {
-       struct bas_bc_state *ubc;
+       struct bas_bc_state *ubc = bcs->hw.bas;
        int inputstate;
        unsigned seqlen, inbyte, inbits;
 
-       IFNULLRET(bcs);
-       ubc = bcs->hw.bas;
-       IFNULLRET(ubc);
-
        /* load previous state:
         * inputstate = set of flag bits:
         * - INS_flag_hunt: no complete opening flag received since connection setup or last abort
@@ -882,7 +877,7 @@ static inline void trans_receive(unsigned char *src, unsigned count,
        while (count > 0) {
                dst = skb_put(skb, count < dobytes ? count : dobytes);
                while (count > 0 && dobytes > 0) {
-                       *dst++ = gigaset_invtab[*src++];
+                       *dst++ = bitrev8(*src++);
                        count--;
                        dobytes--;
                }
@@ -963,11 +958,11 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
 
                if (atomic_read(&cs->mstate) == MS_LOCKED) {
                        gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response",
-                                          numbytes, src, 0);
+                                          numbytes, src);
                        gigaset_if_receive(inbuf->cs, src, numbytes);
                } else {
                        gigaset_dbg_buffer(DEBUG_CMD, "received response",
-                                          numbytes, src, 0);
+                                          numbytes, src);
                        cmd_loop(src, numbytes, inbuf);
                }
 
@@ -995,11 +990,14 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
  */
 int gigaset_isoc_send_skb(struct bc_state *bcs, struct sk_buff *skb)
 {
-       int len;
+       int len = skb->len;
+       unsigned long flags;
 
-       IFNULLRETVAL(bcs, -EFAULT);
-       IFNULLRETVAL(skb, -EFAULT);
-       len = skb->len;
+       spin_lock_irqsave(&bcs->cs->lock, flags);
+       if (!bcs->cs->connected) {
+               spin_unlock_irqrestore(&bcs->cs->lock, flags);
+               return -ENODEV;
+       }
 
        skb_queue_tail(&bcs->squeue, skb);
        gig_dbg(DEBUG_ISO, "%s: skb queued, qlen=%d",
@@ -1007,6 +1005,7 @@ int gigaset_isoc_send_skb(struct bc_state *bcs, struct sk_buff *skb)
 
        /* tasklet submits URB if necessary */
        tasklet_schedule(&bcs->hw.bas->sent_tasklet);
+       spin_unlock_irqrestore(&bcs->cs->lock, flags);
 
        return len;     /* ok so far */
 }