tree-wide: fix assorted typos all over the place
[safe/jmp/linux-2.6] / drivers / isdn / hisax / hfc_usb.c
index 1f18f19..ad5831f 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * hfc_usb.c
  *
- * $Id: hfc_usb.c,v 2.3.2.13 2006/02/17 17:17:22 mbachem Exp $
+ * $Id: hfc_usb.c,v 2.3.2.24 2007/10/14 08:40:29 mbachem Exp $
  *
  * modular HiSax ISDN driver for Colognechip HFC-S USB chip
  *
- * Authors : Peter Sprenger  (sprenger@moving-bytes.de)
- *           Martin Bachem   (info@colognechip.com)
+ * Authors : Peter Sprenger (sprenger@moving-bytes.de)
+ *           Martin Bachem (m.bachem@gmx.de, info@colognechip.com)
  *
  *           based on the first hfc_usb driver of
  *           Werner Cornelius (werner@isdn-development.de)
 #include <linux/kernel_stat.h>
 #include <linux/usb.h>
 #include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/moduleparam.h>
 #include "hisax.h"
 #include "hisax_if.h"
 #include "hfc_usb.h"
 
 static const char *hfcusb_revision =
-    "$Revision: 2.3.2.13 $ $Date: 2006/02/17 17:17:22 $ ";
+    "$Revision: 2.3.2.24 $ $Date: 2007/10/14 08:40:29 $ ";
 
 /* Hisax debug support
-* use "modprobe debug=x" where x is bitfield of USB_DBG & ISDN_DBG
+*  debug flags defined in hfc_usb.h as HFCUSB_DBG_[*]
 */
-#ifdef CONFIG_HISAX_DEBUG
-#include <linux/moduleparam.h>
 #define __debug_variable hfc_debug
 #include "hisax_debug.h"
 static u_int debug;
 module_param(debug, uint, 0);
 static int hfc_debug;
-#endif
+
 
 /* private vendor specific data */
 typedef struct {
@@ -63,9 +63,7 @@ typedef struct {
        char *vend_name;        // device name
 } hfcsusb_vdata;
 
-/****************************************/
-/* data defining the devices to be used */
-/****************************************/
+/* VID/PID device list */
 static struct usb_device_id hfcusb_idtab[] = {
        {
         USB_DEVICE(0x0959, 0x2bd0),
@@ -90,49 +88,53 @@ static struct usb_device_id hfcusb_idtab[] = {
         .driver_info = (unsigned long) &((hfcsusb_vdata)
                          {LED_SCHEME1, {4, 0, 2, 1},
                           "Stollmann USB TA"}),
-        },
+       },
        {
         USB_DEVICE(0x0742, 0x2009),
         .driver_info = (unsigned long) &((hfcsusb_vdata)
                          {LED_SCHEME1, {4, 0, 2, 1},
                           "Aceex USB ISDN TA"}),
-        },
+       },
        {
         USB_DEVICE(0x0742, 0x200A),
         .driver_info = (unsigned long) &((hfcsusb_vdata)
                          {LED_SCHEME1, {4, 0, 2, 1},
                           "OEM USB ISDN TA"}),
-        },
+       },
        {
         USB_DEVICE(0x08e3, 0x0301),
         .driver_info = (unsigned long) &((hfcsusb_vdata)
                          {LED_SCHEME1, {2, 0, 1, 4},
                           "Olitec USB RNIS"}),
-        },
+       },
        {
         USB_DEVICE(0x07fa, 0x0846),
         .driver_info = (unsigned long) &((hfcsusb_vdata)
                          {LED_SCHEME1, {0x80, -64, -32, -16},
                           "Bewan Modem RNIS USB"}),
-        },
+       },
        {
         USB_DEVICE(0x07fa, 0x0847),
         .driver_info = (unsigned long) &((hfcsusb_vdata)
                          {LED_SCHEME1, {0x80, -64, -32, -16},
                           "Djinn Numeris USB"}),
-        },
+       },
        {
         USB_DEVICE(0x07b0, 0x0006),
         .driver_info = (unsigned long) &((hfcsusb_vdata)
                          {LED_SCHEME1, {0x80, -64, -32, -16},
                           "Twister ISDN TA"}),
-        },
+       },
+       {
+        USB_DEVICE(0x071d, 0x1005),
+        .driver_info = (unsigned long) &((hfcsusb_vdata)
+                         {LED_SCHEME1, {0x02, 0, 0x01, 0x04},
+                          "Eicon DIVA USB 4.0"}),
+       },
        { }
 };
 
-/***************************************************************/
 /* structure defining input+output fifos (interrupt/bulk mode) */
-/***************************************************************/
 struct usb_fifo;               /* forward definition */
 typedef struct iso_urb_struct {
        struct urb *purb;
@@ -140,8 +142,8 @@ typedef struct iso_urb_struct {
        struct usb_fifo *owner_fifo;    /* pointer to owner fifo */
 } iso_urb_struct;
 
-
 struct hfcusb_data;            /* forward definition */
+
 typedef struct usb_fifo {
        int fifonum;            /* fifo index attached to this structure */
        int active;             /* fifo is currently active */
@@ -160,15 +162,12 @@ typedef struct usb_fifo {
        struct hisax_if *hif;   /* hisax interface */
        int delete_flg;         /* only delete skbuff once */
        int last_urblen;        /* remember length of last packet */
-
 } usb_fifo;
 
-/*********************************************/
 /* structure holding all data for one device */
-/*********************************************/
 typedef struct hfcusb_data {
        /* HiSax Interface for loadable Layer1 drivers */
-       struct hisax_d_if d_if; /* see hisax_if.h */
+       struct hisax_d_if d_if;         /* see hisax_if.h */
        struct hisax_b_if b_if[2];      /* see hisax_if.h */
        int protocol;
 
@@ -176,12 +175,13 @@ typedef struct hfcusb_data {
        int if_used;            /* used interface number */
        int alt_used;           /* used alternate config */
        int ctrl_paksize;       /* control pipe packet size */
-       int ctrl_in_pipe, ctrl_out_pipe;        /* handles for control pipe */
+       int ctrl_in_pipe,       /* handles for control pipe */
+           ctrl_out_pipe;
        int cfg_used;           /* configuration index used */
        int vend_idx;           /* vendor found */
        int b_mode[2];          /* B-channel mode */
        int l1_activated;       /* layer 1 activated */
-       int disc_flag;          /* 'true' if device was disonnected to avoid some USB actions */
+       int disc_flag;          /* TRUE if device was disonnected to avoid some USB actions */
        int packet_size, iso_packet_size;
 
        /* control pipe background handling */
@@ -192,7 +192,7 @@ typedef struct hfcusb_data {
        struct usb_ctrlrequest ctrl_write;      /* buffer for control write request */
        struct usb_ctrlrequest ctrl_read;       /* same for read request */
 
-       __u8 old_led_state, led_state, led_new_data, led_b_active;
+       __u8 old_led_state, led_state;
 
        volatile __u8 threshold_mask;   /* threshold actually reported */
        volatile __u8 bch_enables;      /* or mask for sctrl_r and sctrl register values */
@@ -208,7 +208,6 @@ typedef struct hfcusb_data {
 static void collect_rx_frame(usb_fifo * fifo, __u8 * data, int len,
                             int finish);
 
-
 static inline const char *
 symbolic(struct hfcusb_symbolic_list list[], const int num)
 {
@@ -219,10 +218,6 @@ symbolic(struct hfcusb_symbolic_list list[], const int num)
        return "<unknown ERROR>";
 }
 
-
-/******************************************************/
-/* start next background transfer for control channel */
-/******************************************************/
 static void
 ctrl_start_transfer(hfcusb_data * hfc)
 {
@@ -240,10 +235,6 @@ ctrl_start_transfer(hfcusb_data * hfc)
        }
 }                              /* ctrl_start_transfer */
 
-/************************************/
-/* queue a control transfer request */
-/* return 0 on success.             */
-/************************************/
 static int
 queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val, int action)
 {
@@ -260,19 +251,8 @@ queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val, int action)
        if (++hfc->ctrl_cnt == 1)
                ctrl_start_transfer(hfc);
        return (0);
-}                              /* queue_control_request */
-
-static int
-control_action_handler(hfcusb_data * hfc, int reg, int val, int action)
-{
-       if (!action)
-               return (1);     /* no action defined */
-       return (0);
 }
 
-/***************************************************************/
-/* control completion routine handling background control cmds */
-/***************************************************************/
 static void
 ctrl_complete(struct urb *urb)
 {
@@ -282,20 +262,15 @@ ctrl_complete(struct urb *urb)
        urb->dev = hfc->dev;
        if (hfc->ctrl_cnt) {
                buf = &hfc->ctrl_buff[hfc->ctrl_out_idx];
-               control_action_handler(hfc, buf->hfc_reg, buf->reg_val,
-                                      buf->action);
-
                hfc->ctrl_cnt--;        /* decrement actual count */
                if (++hfc->ctrl_out_idx >= HFC_CTRL_BUFSIZE)
                        hfc->ctrl_out_idx = 0;  /* pointer wrap */
 
                ctrl_start_transfer(hfc);       /* start next transfer */
        }
-}                              /* ctrl_complete */
+}
 
-/***************************************************/
 /* write led data to auxport & invert if necessary */
-/***************************************************/
 static void
 write_led(hfcusb_data * hfc, __u8 led_state)
 {
@@ -305,28 +280,23 @@ write_led(hfcusb_data * hfc, __u8 led_state)
        }
 }
 
-/**************************/
-/* handle LED bits        */
-/**************************/
 static void
-set_led_bit(hfcusb_data * hfc, signed short led_bits, int unset)
+set_led_bit(hfcusb_data * hfc, signed short led_bits, int on)
 {
-       if (unset) {
+       if (on) {
                if (led_bits < 0)
-                       hfc->led_state |= abs(led_bits);
+                       hfc->led_state &= ~abs(led_bits);
                else
-                       hfc->led_state &= ~led_bits;
+                       hfc->led_state |= led_bits;
        } else {
                if (led_bits < 0)
-                       hfc->led_state &= ~abs(led_bits);
+                       hfc->led_state |= abs(led_bits);
                else
-                       hfc->led_state |= led_bits;
+                       hfc->led_state &= ~led_bits;
        }
 }
 
-/**************************/
-/* handle LED requests    */
-/**************************/
+/* handle LED requests */
 static void
 handle_led(hfcusb_data * hfc, int event)
 {
@@ -339,85 +309,73 @@ handle_led(hfcusb_data * hfc, int event)
 
        switch (event) {
                case LED_POWER_ON:
-                       set_led_bit(hfc, driver_info->led_bits[0],
-                                   0);
-                       set_led_bit(hfc, driver_info->led_bits[1],
-                                   1);
-                       set_led_bit(hfc, driver_info->led_bits[2],
-                                   1);
-                       set_led_bit(hfc, driver_info->led_bits[3],
-                                   1);
+                       set_led_bit(hfc, driver_info->led_bits[0], 1);
+                       set_led_bit(hfc, driver_info->led_bits[1], 0);
+                       set_led_bit(hfc, driver_info->led_bits[2], 0);
+                       set_led_bit(hfc, driver_info->led_bits[3], 0);
                        break;
-               case LED_POWER_OFF:     /* no Power off handling */
+               case LED_POWER_OFF:
+                       set_led_bit(hfc, driver_info->led_bits[0], 0);
+                       set_led_bit(hfc, driver_info->led_bits[1], 0);
+                       set_led_bit(hfc, driver_info->led_bits[2], 0);
+                       set_led_bit(hfc, driver_info->led_bits[3], 0);
                        break;
                case LED_S0_ON:
-                       set_led_bit(hfc, driver_info->led_bits[1],
-                                   0);
+                       set_led_bit(hfc, driver_info->led_bits[1], 1);
                        break;
                case LED_S0_OFF:
-                       set_led_bit(hfc, driver_info->led_bits[1],
-                                   1);
+                       set_led_bit(hfc, driver_info->led_bits[1], 0);
                        break;
                case LED_B1_ON:
-                       set_led_bit(hfc, driver_info->led_bits[2],
-                                   0);
+                       set_led_bit(hfc, driver_info->led_bits[2], 1);
                        break;
                case LED_B1_OFF:
-                       set_led_bit(hfc, driver_info->led_bits[2],
-                                   1);
+                       set_led_bit(hfc, driver_info->led_bits[2], 0);
                        break;
                case LED_B2_ON:
-                       set_led_bit(hfc, driver_info->led_bits[3],
-                                   0);
+                       set_led_bit(hfc, driver_info->led_bits[3], 1);
                        break;
                case LED_B2_OFF:
-                       set_led_bit(hfc, driver_info->led_bits[3],
-                                   1);
+                       set_led_bit(hfc, driver_info->led_bits[3], 0);
                        break;
        }
        write_led(hfc, hfc->led_state);
 }
 
-/********************************/
-/* called when timer t3 expires */
-/********************************/
+/* ISDN l1 timer T3 expires */
 static void
 l1_timer_expire_t3(hfcusb_data * hfc)
 {
        hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION,
                           NULL);
-#ifdef CONFIG_HISAX_DEBUG
-       DBG(ISDN_DBG,
+
+       DBG(HFCUSB_DBG_STATES,
            "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T3 expire)");
-#endif
-       hfc->l1_activated = false;
+
+       hfc->l1_activated = 0;
        handle_led(hfc, LED_S0_OFF);
        /* deactivate : */
        queue_control_request(hfc, HFCUSB_STATES, 0x10, 1);
        queue_control_request(hfc, HFCUSB_STATES, 3, 1);
 }
 
-/********************************/
-/* called when timer t4 expires */
-/********************************/
+/* ISDN l1 timer T4 expires */
 static void
 l1_timer_expire_t4(hfcusb_data * hfc)
 {
        hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION,
                           NULL);
-#ifdef CONFIG_HISAX_DEBUG
-       DBG(ISDN_DBG,
+
+       DBG(HFCUSB_DBG_STATES,
            "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T4 expire)");
-#endif
-       hfc->l1_activated = false;
+
+       hfc->l1_activated = 0;
        handle_led(hfc, LED_S0_OFF);
 }
 
-/*****************************/
-/* handle S0 state changes   */
-/*****************************/
+/* S0 state changed */
 static void
-state_handler(hfcusb_data * hfc, __u8 state)
+s0_state_handler(hfcusb_data * hfc, __u8 state)
 {
        __u8 old_state;
 
@@ -425,38 +383,29 @@ state_handler(hfcusb_data * hfc, __u8 state)
        if (state == old_state || state < 1 || state > 8)
                return;
 
-#ifdef CONFIG_HISAX_DEBUG
-       DBG(ISDN_DBG, "HFC-S USB: new S0 state:%d old_state:%d", state,
-           old_state);
-#endif
+       DBG(HFCUSB_DBG_STATES, "HFC-S USB: S0 statechange(%d -> %d)",
+           old_state, state);
+
        if (state < 4 || state == 7 || state == 8) {
                if (timer_pending(&hfc->t3_timer))
                        del_timer(&hfc->t3_timer);
-#ifdef CONFIG_HISAX_DEBUG
-               DBG(ISDN_DBG, "HFC-S USB: T3 deactivated");
-#endif
+               DBG(HFCUSB_DBG_STATES, "HFC-S USB: T3 deactivated");
        }
        if (state >= 7) {
                if (timer_pending(&hfc->t4_timer))
                        del_timer(&hfc->t4_timer);
-#ifdef CONFIG_HISAX_DEBUG
-               DBG(ISDN_DBG, "HFC-S USB: T4 deactivated");
-#endif
+               DBG(HFCUSB_DBG_STATES, "HFC-S USB: T4 deactivated");
        }
 
        if (state == 7 && !hfc->l1_activated) {
                hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,
                                   PH_ACTIVATE | INDICATION, NULL);
-#ifdef CONFIG_HISAX_DEBUG
-               DBG(ISDN_DBG, "HFC-S USB: PH_ACTIVATE | INDICATION sent");
-#endif
-               hfc->l1_activated = true;
+               DBG(HFCUSB_DBG_STATES, "HFC-S USB: PH_ACTIVATE | INDICATION sent");
+               hfc->l1_activated = 1;
                handle_led(hfc, LED_S0_ON);
        } else if (state <= 3 /* && activated */ ) {
                if (old_state == 7 || old_state == 8) {
-#ifdef CONFIG_HISAX_DEBUG
-                       DBG(ISDN_DBG, "HFC-S USB: T4 activated");
-#endif
+                       DBG(HFCUSB_DBG_STATES, "HFC-S USB: T4 activated");
                        if (!timer_pending(&hfc->t4_timer)) {
                                hfc->t4_timer.expires =
                                    jiffies + (HFC_TIMER_T4 * HZ) / 1000;
@@ -466,18 +415,15 @@ state_handler(hfcusb_data * hfc, __u8 state)
                        hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,
                                           PH_DEACTIVATE | INDICATION,
                                           NULL);
-#ifdef CONFIG_HISAX_DEBUG
-                       DBG(ISDN_DBG,
+                       DBG(HFCUSB_DBG_STATES,
                            "HFC-S USB: PH_DEACTIVATE | INDICATION sent");
-#endif
-                       hfc->l1_activated = false;
+                       hfc->l1_activated = 0;
                        handle_led(hfc, LED_S0_OFF);
                }
        }
        hfc->l1_state = state;
 }
 
-/* prepare iso urb */
 static void
 fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe,
              void *buf, int num_packets, int packet_size, int interval,
@@ -485,7 +431,6 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe,
 {
        int k;
 
-       spin_lock_init(&urb->lock);
        urb->dev = dev;
        urb->pipe = pipe;
        urb->complete = complete;
@@ -504,15 +449,16 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe,
 }
 
 /* allocs urbs and start isoc transfer with two pending urbs to avoid
-   gaps in the transfer chain */
+ * gaps in the transfer chain
+ */
 static int
 start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb,
                 usb_complete_t complete, int packet_size)
 {
        int i, k, errcode;
 
-       printk(KERN_INFO "HFC-S USB: starting ISO-chain for Fifo %i\n",
-              fifo->fifonum);
+       DBG(HFCUSB_DBG_INIT, "HFC-S USB: starting ISO-URBs for fifo:%d\n",
+           fifo->fifonum);
 
        /* allocate Memory for Iso out Urbs */
        for (i = 0; i < 2; i++) {
@@ -557,10 +503,9 @@ start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb,
 
                errcode = usb_submit_urb(fifo->iso[i].purb, GFP_KERNEL);
                fifo->active = (errcode >= 0) ? 1 : 0;
-               if (errcode < 0) {
-                       printk(KERN_INFO "HFC-S USB: %s  URB nr:%d\n",
-                              symbolic(urb_errlist, errcode), i);
-               };
+               if (errcode < 0)
+                       printk(KERN_INFO "HFC-S USB: usb_submit_urb URB nr:%d, error(%i): '%s'\n",
+                              i, errcode, symbolic(urb_errlist, errcode));
        }
        return (fifo->active);
 }
@@ -573,21 +518,18 @@ stop_isoc_chain(usb_fifo * fifo)
 
        for (i = 0; i < 2; i++) {
                if (fifo->iso[i].purb) {
-#ifdef CONFIG_HISAX_DEBUG
-                       DBG(USB_DBG,
+                       DBG(HFCUSB_DBG_INIT,
                            "HFC-S USB: Stopping iso chain for fifo %i.%i",
                            fifo->fifonum, i);
-#endif
-                       usb_unlink_urb(fifo->iso[i].purb);
+                       usb_kill_urb(fifo->iso[i].purb);
                        usb_free_urb(fifo->iso[i].purb);
                        fifo->iso[i].purb = NULL;
                }
        }
-       if (fifo->urb) {
-               usb_unlink_urb(fifo->urb);
-               usb_free_urb(fifo->urb);
-               fifo->urb = NULL;
-       }
+
+       usb_kill_urb(fifo->urb);
+       usb_free_urb(fifo->urb);
+       fifo->urb = NULL;
        fifo->active = 0;
 }
 
@@ -597,9 +539,6 @@ static int iso_packets[8] =
        ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D
 };
 
-/*****************************************************/
-/* transmit completion routine for all ISO tx fifos */
-/*****************************************************/
 static void
 tx_iso_complete(struct urb *urb)
 {
@@ -610,20 +549,38 @@ tx_iso_complete(struct urb *urb)
            errcode;
        int frame_complete, transp_mode, fifon, status;
        __u8 threshbit;
-       __u8 threshtable[8] = { 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80 };
 
        fifon = fifo->fifonum;
        status = urb->status;
 
        tx_offset = 0;
 
+       /* ISO transfer only partially completed,
+          look at individual frame status for details */
+       if (status == -EXDEV) {
+               DBG(HFCUSB_DBG_VERBOSE_USB, "HFC-S USB: tx_iso_complete with -EXDEV"
+                   ", urb->status %d, fifonum %d\n",
+                   status, fifon);
+
+               for (k = 0; k < iso_packets[fifon]; ++k) {
+                       errcode = urb->iso_frame_desc[k].status;
+                       if (errcode)
+                               DBG(HFCUSB_DBG_VERBOSE_USB, "HFC-S USB: tx_iso_complete "
+                                      "packet %i, status: %i\n",
+                                      k, errcode);
+               }
+
+               // clear status, so go on with ISO transfers
+               status = 0;
+       }
+
        if (fifo->active && !status) {
                transp_mode = 0;
                if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS)
-                       transp_mode = true;
+                       transp_mode = 1;
 
                /* is FifoFull-threshold set for our channel? */
-               threshbit = threshtable[fifon] & hfc->threshold_mask;
+               threshbit = (hfc->threshold_mask & (1 << fifon));
                num_isoc_packets = iso_packets[fifon];
 
                /* predict dataflow to avoid fifo overflow */
@@ -638,8 +595,9 @@ tx_iso_complete(struct urb *urb)
                              tx_iso_complete, urb->context);
                memset(context_iso_urb->buffer, 0,
                       sizeof(context_iso_urb->buffer));
-               frame_complete = false;
-               /* Generate next Iso Packets */
+               frame_complete = 0;
+
+               /* Generate next ISO Packets */
                for (k = 0; k < num_isoc_packets; ++k) {
                        if (fifo->skbuff) {
                                len = fifo->skbuff->len;
@@ -664,7 +622,7 @@ tx_iso_complete(struct urb *urb)
                                                /* add 2 byte flags and 16bit CRC at end of ISDN frame */
                                                fifo->bit_line += 32;
                                        }
-                                       frame_complete = true;
+                                       frame_complete = 1;
                                }
 
                                memcpy(context_iso_urb->buffer +
@@ -691,7 +649,7 @@ tx_iso_complete(struct urb *urb)
                        }
 
                        if (frame_complete) {
-                               fifo->delete_flg = true;
+                               fifo->delete_flg = 1;
                                fifo->hif->l1l2(fifo->hif,
                                                PH_DATA | CONFIRM,
                                                (void *) (unsigned long) fifo->skbuff->
@@ -699,30 +657,26 @@ tx_iso_complete(struct urb *urb)
                                if (fifo->skbuff && fifo->delete_flg) {
                                        dev_kfree_skb_any(fifo->skbuff);
                                        fifo->skbuff = NULL;
-                                       fifo->delete_flg = false;
+                                       fifo->delete_flg = 0;
                                }
-                               frame_complete = false;
+                               frame_complete = 0;
                        }
                }
                errcode = usb_submit_urb(urb, GFP_ATOMIC);
                if (errcode < 0) {
                        printk(KERN_INFO
-                              "HFC-S USB: error submitting ISO URB: %d \n",
+                              "HFC-S USB: error submitting ISO URB: %d\n",
                               errcode);
                }
        } else {
                if (status && !hfc->disc_flag) {
                        printk(KERN_INFO
-                              "HFC-S USB: tx_iso_complete : urb->status %s (%i), fifonum=%d\n",
-                              symbolic(urb_errlist, status), status,
-                              fifon);
+                              "HFC-S USB: tx_iso_complete: error(%i): '%s', fifonum=%d\n",
+                              status, symbolic(urb_errlist, status), fifon);
                }
        }
-}                              /* tx_iso_complete */
+}
 
-/*****************************************************/
-/* receive completion routine for all ISO tx fifos   */
-/*****************************************************/
 static void
 rx_iso_complete(struct urb *urb)
 {
@@ -734,21 +688,25 @@ rx_iso_complete(struct urb *urb)
        unsigned int iso_status;
        __u8 *buf;
        static __u8 eof[8];
-#ifdef CONFIG_HISAX_DEBUG
-       __u8 i;
-#endif
 
        fifon = fifo->fifonum;
        status = urb->status;
 
        if (urb->status == -EOVERFLOW) {
-#ifdef CONFIG_HISAX_DEBUG
-               DBG(USB_DBG,
-                   "HFC-USB: ignoring USB DATAOVERRUN  for fifo  %i \n",
-                   fifon);
-#endif
+               DBG(HFCUSB_DBG_VERBOSE_USB,
+                   "HFC-USB: ignoring USB DATAOVERRUN fifo(%i)", fifon);
+               status = 0;
+       }
+
+       /* ISO transfer only partially completed,
+          look at individual frame status for details */
+       if (status == -EXDEV) {
+               DBG(HFCUSB_DBG_VERBOSE_USB, "HFC-S USB: rx_iso_complete with -EXDEV "
+                   "urb->status %d, fifonum %d\n",
+                   status, fifon);
                status = 0;
        }
+
        if (fifo->active && !status) {
                num_isoc_packets = iso_packets[fifon];
                maxlen = fifo->usb_packet_maxlen;
@@ -757,40 +715,38 @@ rx_iso_complete(struct urb *urb)
                        offset = urb->iso_frame_desc[k].offset;
                        buf = context_iso_urb->buffer + offset;
                        iso_status = urb->iso_frame_desc[k].status;
-#ifdef CONFIG_HISAX_DEBUG
+
                        if (iso_status && !hfc->disc_flag)
-                               DBG(USB_DBG,
-                                   "HFC-S USB: ISO packet failure - status:%x",
-                                   iso_status);
+                               DBG(HFCUSB_DBG_VERBOSE_USB,
+                                   "HFC-S USB: rx_iso_complete "
+                                   "ISO packet %i, status: %i\n",
+                                   k, iso_status);
 
-                       if ((fifon == 5) && (debug > 1)) {
-                               printk(KERN_INFO
+                       if (fifon == HFCUSB_D_RX) {
+                               DBG(HFCUSB_DBG_VERBOSE_USB,
                                       "HFC-S USB: ISO-D-RX lst_urblen:%2d "
-                                      "act_urblen:%2d max-urblen:%2d "
-                                      "EOF:0x%0x DATA: ",
+                                      "act_urblen:%2d max-urblen:%2d EOF:0x%0x",
                                       fifo->last_urblen, len, maxlen,
                                       eof[5]);
-                               for (i = 0; i < len; i++)
-                                       printk("%.2x ", buf[i]);
-                               printk("\n");
+
+                               DBG_PACKET(HFCUSB_DBG_VERBOSE_USB, buf, len);
                        }
-#endif
+
                        if (fifo->last_urblen != maxlen) {
                                /* the threshold mask is in the 2nd status byte */
                                hfc->threshold_mask = buf[1];
                                /* care for L1 state only for D-Channel
                                   to avoid overlapped iso completions */
-                               if (fifon == 5) {
+                               if (fifon == HFCUSB_D_RX) {
                                        /* the S0 state is in the upper half
                                           of the 1st status byte */
-                                       state_handler(hfc, buf[0] >> 4);
+                                       s0_state_handler(hfc, buf[0] >> 4);
                                }
                                eof[fifon] = buf[0] & 1;
                                if (len > 2)
                                        collect_rx_frame(fifo, buf + 2,
                                                         len - 2,
-                                                        (len <
-                                                         maxlen) ?
+                                                        (len < maxlen) ?
                                                         eof[fifon] : 0);
                        } else {
                                collect_rx_frame(fifo, buf, len,
@@ -807,41 +763,37 @@ rx_iso_complete(struct urb *urb)
                              rx_iso_complete, urb->context);
                errcode = usb_submit_urb(urb, GFP_ATOMIC);
                if (errcode < 0) {
-                       printk(KERN_INFO
-                              "HFC-S USB: error submitting ISO URB: %d \n",
+                       printk(KERN_ERR
+                              "HFC-S USB: error submitting ISO URB: %d\n",
                               errcode);
                }
        } else {
                if (status && !hfc->disc_flag) {
-                       printk(KERN_INFO
+                       printk(KERN_ERR
                               "HFC-S USB: rx_iso_complete : "
                               "urb->status %d, fifonum %d\n",
                               status, fifon);
                }
        }
-}                              /* rx_iso_complete */
+}
 
-/*****************************************************/
-/* collect data from interrupt or isochron in        */
-/*****************************************************/
+/* collect rx data from INT- and ISO-URBs  */
 static void
 collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish)
 {
        hfcusb_data *hfc = fifo->hfc;
        int transp_mode, fifon;
-#ifdef CONFIG_HISAX_DEBUG
-       int i;
-#endif
+
        fifon = fifo->fifonum;
        transp_mode = 0;
        if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS)
-               transp_mode = true;
+               transp_mode = 1;
 
        if (!fifo->skbuff) {
                fifo->skbuff = dev_alloc_skb(fifo->max_size + 3);
                if (!fifo->skbuff) {
-                       printk(KERN_INFO
-                              "HFC-S USB: cannot allocate buffer (dev_alloc_skb) fifo:%d\n",
+                       printk(KERN_ERR
+                              "HFC-S USB: cannot allocate buffer for fifo(%d)\n",
                               fifon);
                        return;
                }
@@ -850,17 +802,11 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish)
                if (fifo->skbuff->len + len < fifo->max_size) {
                        memcpy(skb_put(fifo->skbuff, len), data, len);
                } else {
-#ifdef CONFIG_HISAX_DEBUG
-                       printk(KERN_INFO "HFC-S USB: ");
-                       for (i = 0; i < 15; i++)
-                               printk("%.2x ",
-                                      fifo->skbuff->data[fifo->skbuff->
-                                                         len - 15 + i]);
-                       printk("\n");
-#endif
-                       printk(KERN_INFO
-                              "HCF-USB: got frame exceeded fifo->max_size:%d on fifo:%d\n",
+                       DBG(HFCUSB_DBG_FIFO_ERR,
+                              "HCF-USB: got frame exceeded fifo->max_size(%d) fifo(%d)",
                               fifo->max_size, fifon);
+                       DBG_SKB(HFCUSB_DBG_VERBOSE_USB, fifo->skbuff);
+                       skb_trim(fifo->skbuff, 0);
                }
        }
        if (transp_mode && fifo->skbuff->len >= 128) {
@@ -873,6 +819,13 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish)
        if (finish) {
                if ((!fifo->skbuff->data[fifo->skbuff->len - 1])
                    && (fifo->skbuff->len > 3)) {
+
+                       if (fifon == HFCUSB_D_RX) {
+                               DBG(HFCUSB_DBG_DCHANNEL,
+                                   "HFC-S USB: D-RX len(%d)", fifo->skbuff->len);
+                               DBG_SKB(HFCUSB_DBG_DCHANNEL, fifo->skbuff);
+                       }
+
                        /* remove CRC & status */
                        skb_trim(fifo->skbuff, fifo->skbuff->len - 3);
                        if (fifon == HFCUSB_PCM_RX) {
@@ -885,39 +838,17 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish)
                                                fifo->skbuff);
                        fifo->skbuff = NULL;    /* buffer was freed from upper layer */
                } else {
-                       if (fifo->skbuff->len > 3) {
-                               printk(KERN_INFO
-                                      "HFC-S USB: got frame %d bytes but CRC ERROR on fifo:%d!!!\n",
-                                      fifo->skbuff->len, fifon);
-#ifdef CONFIG_HISAX_DEBUG
-                               if (debug > 1) {
-                                       printk(KERN_INFO "HFC-S USB: ");
-                                       for (i = 0; i < 15; i++)
-                                               printk("%.2x ",
-                                                      fifo->skbuff->
-                                                      data[fifo->skbuff->
-                                                           len - 15 + i]);
-                                       printk("\n");
-                               }
-#endif
-                       }
-#ifdef CONFIG_HISAX_DEBUG
-                       else {
-                               printk(KERN_INFO
-                                      "HFC-S USB: frame to small (%d bytes)!!!\n",
-                                      fifo->skbuff->len);
-                       }
-#endif
+                       DBG(HFCUSB_DBG_FIFO_ERR,
+                           "HFC-S USB: ERROR frame len(%d) fifo(%d)",
+                           fifo->skbuff->len, fifon);
+                       DBG_SKB(HFCUSB_DBG_VERBOSE_USB, fifo->skbuff);
                        skb_trim(fifo->skbuff, 0);
                }
        }
 }
 
-/***********************************************/
-/* receive completion routine for all rx fifos */
-/***********************************************/
 static void
-rx_complete(struct urb *urb)
+rx_int_complete(struct urb *urb)
 {
        int len;
        int status;
@@ -925,18 +856,14 @@ rx_complete(struct urb *urb)
        usb_fifo *fifo = (usb_fifo *) urb->context;
        hfcusb_data *hfc = fifo->hfc;
        static __u8 eof[8];
-#ifdef CONFIG_HISAX_DEBUG
-       __u8 i;
-#endif
 
        urb->dev = hfc->dev;    /* security init */
 
        fifon = fifo->fifonum;
        if ((!fifo->active) || (urb->status)) {
-#ifdef CONFIG_HISAX_DEBUG
-               DBG(USB_DBG, "HFC-S USB: RX-Fifo %i is going down (%i)",
+               DBG(HFCUSB_DBG_INIT, "HFC-S USB: RX-Fifo %i is going down (%i)",
                    fifon, urb->status);
-#endif
+
                fifo->urb->interval = 0;        /* cancel automatic rescheduling */
                if (fifo->skbuff) {
                        dev_kfree_skb_any(fifo->skbuff);
@@ -948,22 +875,20 @@ rx_complete(struct urb *urb)
        buf = fifo->buffer;
        maxlen = fifo->usb_packet_maxlen;
 
-#ifdef CONFIG_HISAX_DEBUG
-       if ((fifon == 5) && (debug > 1)) {
-               printk(KERN_INFO
-                      "HFC-S USB: INT-D-RX lst_urblen:%2d act_urblen:%2d max-urblen:%2d EOF:0x%0x DATA: ",
-                      fifo->last_urblen, len, maxlen, eof[5]);
-               for (i = 0; i < len; i++)
-                       printk("%.2x ", buf[i]);
-               printk("\n");
+       if (fifon == HFCUSB_D_RX) {
+               DBG(HFCUSB_DBG_VERBOSE_USB,
+                      "HFC-S USB: INT-D-RX lst_urblen:%2d "
+                      "act_urblen:%2d max-urblen:%2d EOF:0x%0x",
+                      fifo->last_urblen, len, maxlen,
+                      eof[5]);
+               DBG_PACKET(HFCUSB_DBG_VERBOSE_USB, buf, len);
        }
-#endif
 
        if (fifo->last_urblen != fifo->usb_packet_maxlen) {
                /* the threshold mask is in the 2nd status byte */
                hfc->threshold_mask = buf[1];
                /* the S0 state is in the upper half of the 1st status byte */
-               state_handler(hfc, buf[0] >> 4);
+               s0_state_handler(hfc, buf[0] >> 4);
                eof[fifon] = buf[0] & 1;
                /* if we have more than the 2 status bytes -> collect data */
                if (len > 2)
@@ -978,20 +903,19 @@ rx_complete(struct urb *urb)
        status = usb_submit_urb(urb, GFP_ATOMIC);
        if (status) {
                printk(KERN_INFO
-                      "HFC-S USB: error resubmitting URN at rx_complete...\n");
+                      "HFC-S USB: %s error resubmitting URB fifo(%d)\n",
+                      __func__, fifon);
        }
-}                              /* rx_complete */
+}
 
-/***************************************************/
-/* start the interrupt transfer for the given fifo */
-/***************************************************/
+/* start initial INT-URB for certain fifo */
 static void
 start_int_fifo(usb_fifo * fifo)
 {
        int errcode;
 
-       printk(KERN_INFO "HFC-S USB: starting intr IN fifo:%d\n",
-              fifo->fifonum);
+       DBG(HFCUSB_DBG_INIT, "HFC-S USB: starting RX INT-URB for fifo:%d\n",
+           fifo->fifonum);
 
        if (!fifo->urb) {
                fifo->urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -1000,33 +924,28 @@ start_int_fifo(usb_fifo * fifo)
        }
        usb_fill_int_urb(fifo->urb, fifo->hfc->dev, fifo->pipe,
                         fifo->buffer, fifo->usb_packet_maxlen,
-                        rx_complete, fifo, fifo->intervall);
+                        rx_int_complete, fifo, fifo->intervall);
        fifo->active = 1;       /* must be marked active */
        errcode = usb_submit_urb(fifo->urb, GFP_KERNEL);
        if (errcode) {
-               printk(KERN_INFO
+               printk(KERN_ERR
                       "HFC-S USB: submit URB error(start_int_info): status:%i\n",
                       errcode);
                fifo->active = 0;
                fifo->skbuff = NULL;
        }
-}                              /* start_int_fifo */
+}
 
-/*****************************/
-/* set the B-channel mode    */
-/*****************************/
 static void
-set_hfcmode(hfcusb_data * hfc, int channel, int mode)
+setup_bchannel(hfcusb_data * hfc, int channel, int mode)
 {
        __u8 val, idx_table[2] = { 0, 2 };
 
        if (hfc->disc_flag) {
                return;
        }
-#ifdef CONFIG_HISAX_DEBUG
-       DBG(ISDN_DBG, "HFC-S USB: setting channel %d to mode %d", channel,
-           mode);
-#endif
+       DBG(HFCUSB_DBG_STATES, "HFC-S USB: setting channel %d to mode %d",
+           channel, mode);
        hfc->b_mode[channel] = mode;
 
        /* setup CON_HDLC */
@@ -1083,20 +1002,17 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
        switch (pr) {
                case PH_ACTIVATE | REQUEST:
                        if (fifo->fifonum == HFCUSB_D_TX) {
-#ifdef CONFIG_HISAX_DEBUG
-                               DBG(ISDN_DBG,
+                               DBG(HFCUSB_DBG_STATES,
                                    "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_ACTIVATE | REQUEST");
-#endif
+
                                if (hfc->l1_state != 3
                                    && hfc->l1_state != 7) {
                                        hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,
                                                           PH_DEACTIVATE |
                                                           INDICATION,
                                                           NULL);
-#ifdef CONFIG_HISAX_DEBUG
-                                       DBG(ISDN_DBG,
+                                       DBG(HFCUSB_DBG_STATES,
                                            "HFC-S USB: PH_DEACTIVATE | INDICATION sent (not state 3 or 7)");
-#endif
                                } else {
                                        if (hfc->l1_state == 7) {       /* l1 already active */
                                                hfc->d_if.ifc.l1l2(&hfc->
@@ -1106,10 +1022,8 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
                                                                   |
                                                                   INDICATION,
                                                                   NULL);
-#ifdef CONFIG_HISAX_DEBUG
-                                               DBG(ISDN_DBG,
+                                               DBG(HFCUSB_DBG_STATES,
                                                    "HFC-S USB: PH_ACTIVATE | INDICATION sent again ;)");
-#endif
                                        } else {
                                                /* force sending sending INFO1 */
                                                queue_control_request(hfc,
@@ -1135,11 +1049,9 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
                                        }
                                }
                        } else {
-#ifdef CONFIG_HISAX_DEBUG
-                               DBG(ISDN_DBG,
-                                   "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_ACTIVATE | REQUEST");
-#endif
-                               set_hfcmode(hfc,
+                               DBG(HFCUSB_DBG_STATES,
+                                   "HFC_USB: hfc_usb_d_l2l1 B-chan: PH_ACTIVATE | REQUEST");
+                               setup_bchannel(hfc,
                                            (fifo->fifonum ==
                                             HFCUSB_B1_TX) ? 0 : 1,
                                            (long) arg);
@@ -1150,18 +1062,12 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
                        break;
                case PH_DEACTIVATE | REQUEST:
                        if (fifo->fifonum == HFCUSB_D_TX) {
-#ifdef CONFIG_HISAX_DEBUG
-                               DBG(ISDN_DBG,
+                               DBG(HFCUSB_DBG_STATES,
                                    "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_DEACTIVATE | REQUEST");
-#endif
-                               printk(KERN_INFO
-                                      "HFC-S USB: ISDN TE device should not deativate...\n");
                        } else {
-#ifdef CONFIG_HISAX_DEBUG
-                               DBG(ISDN_DBG,
+                               DBG(HFCUSB_DBG_STATES,
                                    "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_DEACTIVATE | REQUEST");
-#endif
-                               set_hfcmode(hfc,
+                               setup_bchannel(hfc,
                                            (fifo->fifonum ==
                                             HFCUSB_B1_TX) ? 0 : 1,
                                            (int) L1_MODE_NULL);
@@ -1174,25 +1080,20 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
                        if (fifo->skbuff && fifo->delete_flg) {
                                dev_kfree_skb_any(fifo->skbuff);
                                fifo->skbuff = NULL;
-                               fifo->delete_flg = false;
+                               fifo->delete_flg = 0;
                        }
                        fifo->skbuff = arg;     /* we have a new buffer */
                        break;
                default:
-                       printk(KERN_INFO
-                              "HFC_USB: hfc_usb_d_l2l1: unkown state : %#x\n",
-                              pr);
+                       DBG(HFCUSB_DBG_STATES,
+                              "HFC_USB: hfc_usb_d_l2l1: unknown state : %#x", pr);
                        break;
        }
 }
 
-/***************************************************************************/
-/* usb_init is called once when a new matching device is detected to setup */
-/* main parameters. It registers the driver at the main hisax module.      */
-/* on success 0 is returned.                                               */
-/***************************************************************************/
+/* initial init HFC-S USB chip registers, HiSax interface, USB URBs */
 static int
-usb_init(hfcusb_data * hfc)
+hfc_usb_init(hfcusb_data * hfc)
 {
        usb_fifo *fifo;
        int i, err;
@@ -1217,11 +1118,11 @@ usb_init(hfcusb_data * hfc)
        /* aux = output, reset off */
        write_usb(hfc, HFCUSB_CIRM, 0x10);
 
-       /* set USB_SIZE to match the wMaxPacketSize for INT or BULK transfers */
+       /* set USB_SIZE to match wMaxPacketSize for INT or BULK transfers */
        write_usb(hfc, HFCUSB_USB_SIZE,
                  (hfc->packet_size / 8) | ((hfc->packet_size / 8) << 4));
 
-       /* set USB_SIZE_I to match the wMaxPacketSize for ISO transfers */
+       /* set USB_SIZE_I to match wMaxPacketSize for ISO transfers */
        write_usb(hfc, HFCUSB_USB_SIZE_I, hfc->iso_packet_size);
 
        /* enable PCM/GCI master mode */
@@ -1260,10 +1161,9 @@ usb_init(hfcusb_data * hfc)
        hfc->b_mode[0] = L1_MODE_NULL;
        hfc->b_mode[1] = L1_MODE_NULL;
 
-       hfc->l1_activated = false;
-       hfc->disc_flag = false;
+       hfc->l1_activated = 0;
+       hfc->disc_flag = 0;
        hfc->led_state = 0;
-       hfc->led_new_data = 0;
        hfc->old_led_state = 0;
 
        /* init the t3 timer */
@@ -1305,7 +1205,11 @@ usb_init(hfcusb_data * hfc)
        }
        /* default Prot: EURO ISDN, should be a module_param */
        hfc->protocol = 2;
-       hisax_register(&hfc->d_if, p_b_if, "hfc_usb", hfc->protocol);
+       i = hisax_register(&hfc->d_if, p_b_if, "hfc_usb", hfc->protocol);
+       if (i) {
+               printk(KERN_INFO "HFC-S USB: hisax_register -> %d\n", i);
+               return i;
+       }
 
 #ifdef CONFIG_HISAX_DEBUG
        hfc_debug = debug;
@@ -1348,11 +1252,9 @@ usb_init(hfcusb_data * hfc)
        handle_led(hfc, LED_POWER_ON);
 
        return (0);
-}                              /* usb_init */
+}
 
-/*************************************************/
-/* function called to probe a new plugged device */
-/*************************************************/
+/* initial callback for each plugged USB device */
 static int
 hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
 {
@@ -1377,11 +1279,6 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
                }
        }
 
-#ifdef CONFIG_HISAX_DEBUG
-       DBG(USB_DBG,
-           "HFC-USB: probing interface(%d) actalt(%d) minor(%d)\n", ifnum,
-           iface->desc.bAlternateSetting, intf->minor);
-#endif
        printk(KERN_INFO
               "HFC-S USB: probing interface(%d) actalt(%d) minor(%d)\n",
               ifnum, iface->desc.bAlternateSetting, intf->minor);
@@ -1402,15 +1299,11 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
 
                        /* check for config EOL element */
                        while (validconf[cfg_used][0]) {
-                               cfg_found = true;
+                               cfg_found = 1;
                                vcf = validconf[cfg_used];
                                /* first endpoint descriptor */
                                ep = iface->endpoint;
-#ifdef CONFIG_HISAX_DEBUG
-                               DBG(USB_DBG,
-                                   "HFC-S USB: (if=%d alt=%d cfg_used=%d)\n",
-                                   ifnum, probe_alt_setting, cfg_used);
-#endif
+
                                memcpy(cmptbl, vcf, 16 * sizeof(int));
 
                                /* check for all endpoints in this alternate setting */
@@ -1424,7 +1317,7 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
                                                idx++;
                                        attr = ep->desc.bmAttributes;
                                        if (cmptbl[idx] == EP_NUL) {
-                                               cfg_found = false;
+                                               cfg_found = 0;
                                        }
                                        if (attr == USB_ENDPOINT_XFER_INT
                                            && cmptbl[idx] == EP_INT)
@@ -1437,16 +1330,9 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
                                                cmptbl[idx] = EP_NUL;
 
                                        /* check if all INT endpoints match minimum interval */
-                                       if (attr == USB_ENDPOINT_XFER_INT
-                                           && ep->desc.bInterval <
-                                           vcf[17]) {
-#ifdef CONFIG_HISAX_DEBUG
-                                               if (cfg_found)
-                                                       DBG(USB_DBG,
-                                                           "HFC-S USB: Interrupt Endpoint interval < %d found - skipping config",
-                                                           vcf[17]);
-#endif
-                                               cfg_found = false;
+                                       if ((attr == USB_ENDPOINT_XFER_INT)
+                                           && (ep->desc.bInterval < vcf[17])) {
+                                               cfg_found = 0;
                                        }
                                        ep++;
                                }
@@ -1454,7 +1340,7 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
                                        /* all entries must be EP_NOP or EP_NUL for a valid config */
                                        if (cmptbl[i] != EP_NOP
                                            && cmptbl[i] != EP_NUL)
-                                               cfg_found = false;
+                                               cfg_found = 0;
                                }
                                if (cfg_found) {
                                        if (cfg_used < small_match) {
@@ -1463,23 +1349,16 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
                                                    probe_alt_setting;
                                                iface_used = iface;
                                        }
-#ifdef CONFIG_HISAX_DEBUG
-                                       DBG(USB_DBG,
-                                           "HFC-USB: small_match=%x %x\n",
-                                           small_match, alt_used);
-#endif
                                }
                                cfg_used++;
                        }
                        alt_idx++;
-               }               /* (alt_idx < intf->num_altsetting) */
+               } /* (alt_idx < intf->num_altsetting) */
 
                /* found a valid USB Ta Endpint config */
                if (small_match != 0xffff) {
                        iface = iface_used;
-                       if (!
-                           (context =
-                            kzalloc(sizeof(hfcusb_data), GFP_KERNEL)))
+                       if (!(context = kzalloc(sizeof(hfcusb_data), GFP_KERNEL)))
                                return (-ENOMEM);       /* got no mem */
 
                        ep = iface->endpoint;
@@ -1612,25 +1491,18 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
                            driver_info;
                        printk(KERN_INFO "HFC-S USB: detected \"%s\"\n",
                               driver_info->vend_name);
-#ifdef CONFIG_HISAX_DEBUG
-                       DBG(USB_DBG,
-                           "HFC-S USB: Endpoint-Config: %s (if=%d alt=%d)\n",
+
+                       DBG(HFCUSB_DBG_INIT,
+                           "HFC-S USB: Endpoint-Config: %s (if=%d alt=%d), E-Channel(%d)",
                            conf_str[small_match], context->if_used,
-                           context->alt_used);
-                       printk(KERN_INFO
-                              "HFC-S USB: E-channel (\"ECHO:\") logging ");
-                       if (validconf[small_match][18])
-                               printk(" possible\n");
-                       else
-                               printk("NOT possible\n");
-#endif
+                           context->alt_used,
+                           validconf[small_match][18]);
+
                        /* init the chip and register the driver */
-                       if (usb_init(context)) {
-                               if (context->ctrl_urb) {
-                                       usb_unlink_urb(context->ctrl_urb);
-                                       usb_free_urb(context->ctrl_urb);
-                                       context->ctrl_urb = NULL;
-                               }
+                       if (hfc_usb_init(context)) {
+                               usb_kill_urb(context->ctrl_urb);
+                               usb_free_urb(context->ctrl_urb);
+                               context->ctrl_urb = NULL;
                                kfree(context);
                                return (-EIO);
                        }
@@ -1644,89 +1516,75 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
        return (-EIO);
 }
 
-/****************************************************/
-/* function called when an active device is removed */
-/****************************************************/
+/* callback for unplugged USB device */
 static void
-hfc_usb_disconnect(struct usb_interface
-                  *intf)
+hfc_usb_disconnect(struct usb_interface *intf)
 {
        hfcusb_data *context = usb_get_intfdata(intf);
        int i;
+
+       handle_led(context, LED_POWER_OFF);
+       schedule_timeout(HZ / 100);
+
        printk(KERN_INFO "HFC-S USB: device disconnect\n");
-       context->disc_flag = true;
+       context->disc_flag = 1;
        usb_set_intfdata(intf, NULL);
-       if (!context)
-               return;
+
        if (timer_pending(&context->t3_timer))
                del_timer(&context->t3_timer);
        if (timer_pending(&context->t4_timer))
                del_timer(&context->t4_timer);
+
        /* tell all fifos to terminate */
        for (i = 0; i < HFCUSB_NUM_FIFOS; i++) {
                if (context->fifos[i].usb_transfer_mode == USB_ISOC) {
                        if (context->fifos[i].active > 0) {
                                stop_isoc_chain(&context->fifos[i]);
-#ifdef CONFIG_HISAX_DEBUG
-                               DBG(USB_DBG,
-                                   "HFC-S USB: hfc_usb_disconnect: stopping ISOC chain Fifo no %i",
-                                   i);
-#endif
+                               DBG(HFCUSB_DBG_INIT,
+                                   "HFC-S USB: %s stopping ISOC chain Fifo(%i)",
+                                   __func__, i);
                        }
                } else {
                        if (context->fifos[i].active > 0) {
                                context->fifos[i].active = 0;
-#ifdef CONFIG_HISAX_DEBUG
-                               DBG(USB_DBG,
-                                   "HFC-S USB: hfc_usb_disconnect: unlinking URB for Fifo no %i",
-                                   i);
-#endif
-                       }
-                       if (context->fifos[i].urb) {
-                               usb_unlink_urb(context->fifos[i].urb);
-                               usb_free_urb(context->fifos[i].urb);
-                               context->fifos[i].urb = NULL;
+                               DBG(HFCUSB_DBG_INIT,
+                                   "HFC-S USB: %s unlinking URB for Fifo(%i)",
+                                   __func__, i);
                        }
+                       usb_kill_urb(context->fifos[i].urb);
+                       usb_free_urb(context->fifos[i].urb);
+                       context->fifos[i].urb = NULL;
                }
                context->fifos[i].active = 0;
        }
-       /* wait for all URBS to terminate */
-       mdelay(10);
-       if (context->ctrl_urb) {
-               usb_unlink_urb(context->ctrl_urb);
-               usb_free_urb(context->ctrl_urb);
-               context->ctrl_urb = NULL;
-       }
+       usb_kill_urb(context->ctrl_urb);
+       usb_free_urb(context->ctrl_urb);
+       context->ctrl_urb = NULL;
        hisax_unregister(&context->d_if);
        kfree(context);         /* free our structure again */
-}                              /* hfc_usb_disconnect */
+}
 
-/************************************/
-/* our driver information structure */
-/************************************/
 static struct usb_driver hfc_drv = {
        .name  = "hfc_usb",
        .id_table = hfcusb_idtab,
        .probe = hfc_usb_probe,
        .disconnect = hfc_usb_disconnect,
 };
+
 static void __exit
-hfc_usb_exit(void)
+hfc_usb_mod_exit(void)
 {
-#ifdef CONFIG_HISAX_DEBUG
-       DBG(USB_DBG, "HFC-S USB: calling \"hfc_usb_exit\" ...");
-#endif
-       usb_deregister(&hfc_drv);       /* release our driver */
+       usb_deregister(&hfc_drv); /* release our driver */
        printk(KERN_INFO "HFC-S USB: module removed\n");
 }
 
 static int __init
-hfc_usb_init(void)
+hfc_usb_mod_init(void)
 {
+       char revstr[30], datestr[30], dummy[30];
 #ifndef CONFIG_HISAX_DEBUG
-       unsigned int debug = -1;
+       hfc_debug = debug;
 #endif
-       char revstr[30], datestr[30], dummy[30];
        sscanf(hfcusb_revision,
               "%s %s $ %s %s %s $ ", dummy, revstr,
               dummy, datestr, dummy);
@@ -1741,8 +1599,8 @@ hfc_usb_init(void)
        return (0);
 }
 
-module_init(hfc_usb_init);
-module_exit(hfc_usb_exit);
+module_init(hfc_usb_mod_init);
+module_exit(hfc_usb_mod_exit);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");