Merge staging-next tree into Linus's latest version
authorGreg Kroah-Hartman <gregkh@suse.de>
Fri, 21 May 2010 19:48:55 +0000 (12:48 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 21 May 2010 19:48:55 +0000 (12:48 -0700)
Conflicts:
drivers/staging/arlan/arlan-main.c
drivers/staging/comedi/drivers/cb_das16_cs.c
drivers/staging/cx25821/cx25821-alsa.c
drivers/staging/dt3155/dt3155_drv.c
drivers/staging/hv/hv.c
drivers/staging/netwave/netwave_cs.c
drivers/staging/wavelan/wavelan.c
drivers/staging/wavelan/wavelan_cs.c
drivers/staging/wlags49_h2/wl_cs.c

This required a bit of hand merging due to the conflicts
that happened in the later .34-rc releases, as well as
some staging driver changing coming in through other trees
(v4l and pcmcia).

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
31 files changed:
1  2 
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/comedi/drivers/cb_das16_cs.c
drivers/staging/comedi/drivers/das08_cs.c
drivers/staging/comedi/drivers/ni_daq_700.c
drivers/staging/comedi/drivers/ni_daq_dio24.c
drivers/staging/comedi/drivers/ni_labpc_cs.c
drivers/staging/comedi/drivers/ni_mio_cs.c
drivers/staging/comedi/drivers/quatech_daqp_cs.c
drivers/staging/cx25821/cx25821-audio-upstream.c
drivers/staging/cx25821/cx25821-video-upstream.c
drivers/staging/dt3155/dt3155_drv.c
drivers/staging/et131x/et131x_netdev.c
drivers/staging/hv/netvsc_drv.c
drivers/staging/hv/rndis_filter.c
drivers/staging/iio/accel/lis3l02dq_ring.c
drivers/staging/iio/adc/max1363_core.c
drivers/staging/iio/industrialio-core.c
drivers/staging/iio/light/tsl2563.c
drivers/staging/rt2860/usb_main_dev.c
drivers/staging/rtl8192su/r8192U_core.c
drivers/staging/udlfb/udlfb.c
drivers/staging/usbip/stub_rx.c
drivers/staging/vme/bridges/vme_tsi148.c
drivers/staging/vt6655/device_main.c
drivers/staging/vt6655/rxtx.c
drivers/staging/vt6656/main_usb.c
drivers/staging/vt6656/rxtx.c
drivers/staging/winbond/wbusb.c
drivers/staging/wlags49_h2/wl_cs.c
drivers/staging/wlags49_h2/wl_netdev.c

diff --combined drivers/staging/Kconfig
@@@ -49,8 -49,6 +49,8 @@@ source "drivers/staging/go7007/Kconfig
  
  source "drivers/staging/cx25821/Kconfig"
  
 +source "drivers/staging/tm6000/Kconfig"
 +
  source "drivers/staging/usbip/Kconfig"
  
  source "drivers/staging/winbond/Kconfig"
@@@ -59,8 -57,6 +59,6 @@@ source "drivers/staging/wlan-ng/Kconfig
  
  source "drivers/staging/echo/Kconfig"
  
- source "drivers/staging/poch/Kconfig"
  source "drivers/staging/otus/Kconfig"
  
  source "drivers/staging/rt2860/Kconfig"
@@@ -113,6 -109,8 +111,8 @@@ source "drivers/staging/vme/Kconfig
  
  source "drivers/staging/rar_register/Kconfig"
  
+ source "drivers/staging/memrar/Kconfig"
  source "drivers/staging/sep/Kconfig"
  
  source "drivers/staging/iio/Kconfig"
@@@ -127,19 -125,19 +127,19 @@@ source "drivers/staging/batman-adv/Kcon
  
  source "drivers/staging/samsung-laptop/Kconfig"
  
- source "drivers/staging/strip/Kconfig"
+ source "drivers/staging/sm7xx/Kconfig"
  
- source "drivers/staging/arlan/Kconfig"
+ source "drivers/staging/dt3155/Kconfig"
  
- source "drivers/staging/wavelan/Kconfig"
+ source "drivers/staging/dt3155v4l/Kconfig"
  
- source "drivers/staging/netwave/Kconfig"
+ source "drivers/staging/crystalhd/Kconfig"
  
- source "drivers/staging/sm7xx/Kconfig"
+ source "drivers/staging/cxt1e1/Kconfig"
  
- source "drivers/staging/dt3155/Kconfig"
+ source "drivers/staging/ti-st/Kconfig"
  
- source "drivers/staging/crystalhd/Kconfig"
+ source "drivers/staging/adis16255/Kconfig"
  
  endif # !STAGING_EXCLUDE_BUILD
  endif # STAGING
diff --combined drivers/staging/Makefile
@@@ -7,12 -7,10 +7,11 @@@ obj-$(CONFIG_ET131X)          += et131x
  obj-$(CONFIG_SLICOSS)         += slicoss/
  obj-$(CONFIG_VIDEO_GO7007)    += go7007/
  obj-$(CONFIG_VIDEO_CX25821)   += cx25821/
 +obj-$(CONFIG_VIDEO_TM6000)    += tm6000/
  obj-$(CONFIG_USB_IP_COMMON)   += usbip/
  obj-$(CONFIG_W35UND)          += winbond/
  obj-$(CONFIG_PRISM2_USB)      += wlan-ng/
  obj-$(CONFIG_ECHO)            += echo/
- obj-$(CONFIG_POCH)            += poch/
  obj-$(CONFIG_OTUS)            += otus/
  obj-$(CONFIG_RT2860)          += rt2860/
  obj-$(CONFIG_RT2870)          += rt2870/
@@@ -37,6 -35,7 +36,7 @@@ obj-$(CONFIG_FB_UDL)          += udlfb
  obj-$(CONFIG_HYPERV)          += hv/
  obj-$(CONFIG_VME_BUS)         += vme/
  obj-$(CONFIG_RAR_REGISTER)    += rar_register/
+ obj-$(CONFIG_MRST_RAR_HANDLER)        += memrar/
  obj-$(CONFIG_DX_SEP)          += sep/
  obj-$(CONFIG_IIO)             += iio/
  obj-$(CONFIG_RAMZSWAP)                += ramzswap/
@@@ -44,11 -43,10 +44,10 @@@ obj-$(CONFIG_WLAGS49_H2)   += wlags49_h2
  obj-$(CONFIG_WLAGS49_H25)     += wlags49_h25/
  obj-$(CONFIG_BATMAN_ADV)      += batman-adv/
  obj-$(CONFIG_SAMSUNG_LAPTOP)  += samsung-laptop/
- obj-$(CONFIG_STRIP)           += strip/
- obj-$(CONFIG_ARLAN)           += arlan/
- obj-$(CONFIG_WAVELAN)         += wavelan/
- obj-$(CONFIG_PCMCIA_WAVELAN)  += wavelan/
- obj-$(CONFIG_PCMCIA_NETWAVE)  += netwave/
  obj-$(CONFIG_FB_SM7XX)                += sm7xx/
  obj-$(CONFIG_DT3155)          += dt3155/
+ obj-$(CONFIG_VIDEO_DT3155)    += dt3155v4l/
  obj-$(CONFIG_CRYSTALHD)               += crystalhd/
+ obj-$(CONFIG_CXT1E1)          += cxt1e1/
+ obj-$(CONFIG_TI_ST)           += ti-st/
+ obj-$(CONFIG_ADIS16255)               += adis16255/
@@@ -175,17 -175,17 +175,18 @@@ static int das16cs_attach(struct comedi
        printk("I/O base=0x%04lx ", dev->iobase);
  
        printk("fingerprint:\n");
-       for (i = 0; i < 48; i += 2) {
+       for (i = 0; i < 48; i += 2)
                printk("%04x ", inw(dev->iobase + i));
-       }
        printk("\n");
  
 -      ret = request_irq(link->irq.AssignedIRQ, das16cs_interrupt,
 +      ret = request_irq(link->irq, das16cs_interrupt,
                          IRQF_SHARED, "cb_das16_cs", dev);
-       if (ret < 0) {
+       if (ret < 0)
                return ret;
-       }
 -      dev->irq = link->irq.AssignedIRQ;
 +      dev->irq = link->irq;
++
        printk("irq=%u ", dev->irq);
  
        dev->board_ptr = das16cs_probe(dev, link);
@@@ -262,9 -262,9 +263,9 @@@ static int das16cs_detach(struct comedi
  {
        printk("comedi%d: das16cs: remove\n", dev->minor);
  
-       if (dev->irq) {
+       if (dev->irq)
                free_irq(dev->irq, dev);
-       }
  
        return 0;
  }
@@@ -671,6 -671,7 +672,6 @@@ static dev_info_t dev_info = "cb_das16_
  
  struct local_info_t {
        struct pcmcia_device *link;
 -      dev_node_t node;
        int stop;
        struct bus_operations *bus;
  };
@@@ -701,6 -702,10 +702,6 @@@ static int das16cs_pcmcia_attach(struc
        link->priv = local;
  
        /* Initialize the pcmcia_device structure */
 -      /* Interrupt setup */
 -      link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
 -      link->irq.Handler = NULL;
 -
        link->conf.Attributes = 0;
        link->conf.IntType = INT_MEMORY_AND_IO;
  
@@@ -715,8 -720,10 +716,8 @@@ static void das16cs_pcmcia_detach(struc
  {
        dev_dbg(&link->dev, "das16cs_pcmcia_detach\n");
  
 -      if (link->dev_node) {
 -              ((struct local_info_t *)link->priv)->stop = 1;
 -              das16cs_pcmcia_release(link);
 -      }
 +      ((struct local_info_t *)link->priv)->stop = 1;
 +      das16cs_pcmcia_release(link);
        /* This points to the parent struct local_info_t struct */
        if (link->priv)
                kfree(link->priv);
@@@ -733,7 -740,8 +734,7 @@@ static int das16cs_pcmcia_config_loop(s
                return -EINVAL;
  
        /* Do we need to allocate an interrupt? */
 -      if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
 -              p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 +      p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
  
        /* IO window settings */
        p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
  
  static void das16cs_pcmcia_config(struct pcmcia_device *link)
  {
 -      struct local_info_t *dev = link->priv;
        int ret;
  
        dev_dbg(&link->dev, "das16cs_pcmcia_config\n");
                goto failed;
        }
  
 -      /*
 -         Allocate an interrupt line.  Note that this does not assign a
 -         handler to the interrupt, unless the 'Handler' member of the
 -         irq structure is initialized.
 -       */
 -      if (link->conf.Attributes & CONF_ENABLE_IRQ) {
 -              ret = pcmcia_request_irq(link, &link->irq);
 -              if (ret)
 -                      goto failed;
 -      }
 +      if (!link->irq)
 +              goto failed;
 +
        /*
           This actually configures the PCMCIA socket -- setting up
           the I/O windows and the interrupt mapping, and putting the
        if (ret)
                goto failed;
  
 -      /*
 -         At this point, the dev_node_t structure(s) need to be
 -         initialized and arranged in a linked list at link->dev.
 -       */
 -      sprintf(dev->node.dev_name, "cb_das16_cs");
 -      dev->node.major = dev->node.minor = 0;
 -      link->dev_node = &dev->node;
 -
        /* Finally, report what we've done */
 -      printk(KERN_INFO "%s: index 0x%02x",
 -             dev->node.dev_name, link->conf.ConfigIndex);
 +      dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
        if (link->conf.Attributes & CONF_ENABLE_IRQ)
 -              printk(", irq %u", link->irq.AssignedIRQ);
 +              printk(", irq %u", link->irq);
        if (link->io.NumPorts1)
                printk(", io 0x%04x-0x%04x", link->io.BasePort1,
                       link->io.BasePort1 + link->io.NumPorts1 - 1);
@@@ -834,6 -859,9 +835,9 @@@ static struct pcmcia_device_id das16cs_
  };
  
  MODULE_DEVICE_TABLE(pcmcia, das16cs_id_table);
+ MODULE_AUTHOR("David A. Schleef <ds@schleef.org>");
+ MODULE_DESCRIPTION("Comedi driver for Computer Boards PC-CARD DAS16/16");
+ MODULE_LICENSE("GPL");
  
  struct pcmcia_driver das16cs_driver = {
        .probe = das16cs_pcmcia_attach,
@@@ -142,6 -142,7 +142,6 @@@ static const dev_info_t dev_info = "pcm
  
  struct local_info_t {
        struct pcmcia_device *link;
 -      dev_node_t node;
        int stop;
        struct bus_operations *bus;
  };
@@@ -171,6 -172,10 +171,6 @@@ static int das08_pcmcia_attach(struct p
        local->link = link;
        link->priv = local;
  
 -      /* Interrupt setup */
 -      link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
 -      link->irq.Handler = NULL;
 -
        /*
           General socket configuration defaults can go here.  In this
           client, we assume very little, and rely on the CIS for almost
@@@ -202,8 -207,10 +202,8 @@@ static void das08_pcmcia_detach(struct 
  
        dev_dbg(&link->dev, "das08_pcmcia_detach\n");
  
 -      if (link->dev_node) {
 -              ((struct local_info_t *)link->priv)->stop = 1;
 -              das08_pcmcia_release(link);
 -      }
 +      ((struct local_info_t *)link->priv)->stop = 1;
 +      das08_pcmcia_release(link);
  
        /* This points to the parent struct local_info_t struct */
        if (link->priv)
@@@ -222,7 -229,8 +222,7 @@@ static int das08_pcmcia_config_loop(str
                return -ENODEV;
  
        /* Do we need to allocate an interrupt? */
 -      if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
 -              p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 +      p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
  
        /* IO window settings */
        p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
  
  static void das08_pcmcia_config(struct pcmcia_device *link)
  {
 -      struct local_info_t *dev = link->priv;
        int ret;
  
        dev_dbg(&link->dev, "das08_pcmcia_config\n");
                goto failed;
        }
  
 -      if (link->conf.Attributes & CONF_ENABLE_IRQ) {
 -              ret = pcmcia_request_irq(link, &link->irq);
 -              if (ret)
 -                      goto failed;
 -      }
 +      if (!link->irq)
 +              goto failed;
  
        /*
           This actually configures the PCMCIA socket -- setting up
        if (ret)
                goto failed;
  
 -      /*
 -         At this point, the dev_node_t structure(s) need to be
 -         initialized and arranged in a linked list at link->dev.
 -       */
 -      sprintf(dev->node.dev_name, "pcm-das08");
 -      dev->node.major = dev->node.minor = 0;
 -      link->dev_node = &dev->node;
 -
        /* Finally, report what we've done */
 -      printk(KERN_INFO "%s: index 0x%02x",
 -             dev->node.dev_name, link->conf.ConfigIndex);
 +      dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
        if (link->conf.Attributes & CONF_ENABLE_IRQ)
 -              printk(", irq %u", link->irq.AssignedIRQ);
 +              printk(", irq %u", link->irq);
        if (link->io.NumPorts1)
                printk(", io 0x%04x-0x%04x", link->io.BasePort1,
                       link->io.BasePort1 + link->io.NumPorts1 - 1);
@@@ -350,6 -371,10 +350,10 @@@ static struct pcmcia_device_id das08_cs
  };
  
  MODULE_DEVICE_TABLE(pcmcia, das08_cs_id_table);
+ MODULE_AUTHOR("David A. Schleef <ds@schleef.org>, "
+             "Frank Mori Hess <fmhess@users.sourceforge.net>");
+ MODULE_DESCRIPTION("Comedi driver for ComputerBoards DAS-08 PCMCIA boards");
+ MODULE_LICENSE("GPL");
  
  struct pcmcia_driver das08_cs_driver = {
        .probe = das08_pcmcia_attach,
@@@ -392,6 -417,5 +396,5 @@@ static void __exit das08_cs_exit_module
        comedi_driver_unregister(&driver_das08_cs);
  }
  
- MODULE_LICENSE("GPL");
  module_init(das08_cs_init_module);
  module_exit(das08_cs_exit_module);
@@@ -145,6 -145,7 +145,7 @@@ void subdev_700_interrupt(struct comedi
  
        comedi_event(dev, s);
  }
+ EXPORT_SYMBOL(subdev_700_interrupt);
  
  static int subdev_700_cb(int dir, int port, int data, unsigned long arg)
  {
@@@ -326,6 -327,7 +327,7 @@@ int subdev_700_init(struct comedi_devic
  
        return 0;
  }
+ EXPORT_SYMBOL(subdev_700_init);
  
  int subdev_700_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
                        int (*cb) (int, int, int, unsigned long),
  
        return 0;
  }
+ EXPORT_SYMBOL(subdev_700_init_irq);
  
  void subdev_700_cleanup(struct comedi_device *dev, struct comedi_subdevice *s)
  {
  
                        kfree(s->private);
  }
- EXPORT_SYMBOL(subdev_700_init);
- EXPORT_SYMBOL(subdev_700_init_irq);
  EXPORT_SYMBOL(subdev_700_cleanup);
- EXPORT_SYMBOL(subdev_700_interrupt);
  
  static int dio700_attach(struct comedi_device *dev, struct comedi_devconfig *it)
  {
                        return -EIO;
                iobase = link->io.BasePort1;
  #ifdef incomplete
 -              irq = link->irq.AssignedIRQ;
 +              irq = link->irq;
  #endif
                break;
        default:
@@@ -470,6 -469,7 +469,6 @@@ static const dev_info_t dev_info = "ni_
  
  struct local_info_t {
        struct pcmcia_device *link;
 -      dev_node_t node;
        int stop;
        struct bus_operations *bus;
  };
@@@ -501,6 -501,10 +500,6 @@@ static int dio700_cs_attach(struct pcmc
        local->link = link;
        link->priv = local;
  
 -      /* Interrupt setup */
 -      link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
 -      link->irq.Handler = NULL;
 -
        /*
           General socket configuration defaults can go here.  In this
           client, we assume very little, and rely on the CIS for almost
@@@ -534,8 -538,10 +533,8 @@@ static void dio700_cs_detach(struct pcm
  
        dev_dbg(&link->dev, "dio700_cs_detach\n");
  
 -      if (link->dev_node) {
 -              ((struct local_info_t *)link->priv)->stop = 1;
 -              dio700_release(link);
 -      }
 +      ((struct local_info_t *)link->priv)->stop = 1;
 +      dio700_release(link);
  
        /* This points to the parent struct local_info_t struct */
        if (link->priv)
@@@ -570,7 -576,8 +569,7 @@@ static int dio700_pcmcia_config_loop(st
        }
  
        /* Do we need to allocate an interrupt? */
 -      if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
 -              p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 +      p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
  
        /* IO window settings */
        p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
  
  static void dio700_config(struct pcmcia_device *link)
  {
 -      struct local_info_t *dev = link->priv;
        win_req_t req;
        int ret;
  
                goto failed;
        }
  
 -      /*
 -         Allocate an interrupt line.  Note that this does not assign a
 -         handler to the interrupt, unless the 'Handler' member of the
 -         irq structure is initialized.
 -       */
 -      if (link->conf.Attributes & CONF_ENABLE_IRQ) {
 -              ret = pcmcia_request_irq(link, &link->irq);
 -              if (ret)
 -                      goto failed;
 -      }
 +      if (!link->irq)
 +              goto failed;
  
        /*
           This actually configures the PCMCIA socket -- setting up
        if (ret != 0)
                goto failed;
  
 -      /*
 -         At this point, the dev_node_t structure(s) need to be
 -         initialized and arranged in a linked list at link->dev.
 -       */
 -      sprintf(dev->node.dev_name, "ni_daq_700");
 -      dev->node.major = dev->node.minor = 0;
 -      link->dev_node = &dev->node;
 -
        /* Finally, report what we've done */
 -      printk(KERN_INFO "%s: index 0x%02x",
 -             dev->node.dev_name, link->conf.ConfigIndex);
 +      dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
        if (link->conf.Attributes & CONF_ENABLE_IRQ)
 -              printk(", irq %d", link->irq.AssignedIRQ);
 +              printk(", irq %d", link->irq);
        if (link->io.NumPorts1)
                printk(", io 0x%04x-0x%04x", link->io.BasePort1,
                       link->io.BasePort1 + link->io.NumPorts1 - 1);
@@@ -709,8 -734,12 +708,12 @@@ static struct pcmcia_device_id dio700_c
        PCMCIA_DEVICE_NULL
  };
  
- MODULE_LICENSE("GPL");
  MODULE_DEVICE_TABLE(pcmcia, dio700_cs_ids);
+ MODULE_AUTHOR("Fred Brooks <nsaspook@nsaspook.com>");
+ MODULE_DESCRIPTION("Comedi driver for National Instruments "
+                  "PCMCIA DAQCard-700 DIO");
+ MODULE_LICENSE("GPL");
  
  struct pcmcia_driver dio700_cs_driver = {
        .probe = dio700_cs_attach,
@@@ -131,7 -131,7 +131,7 @@@ static int dio24_attach(struct comedi_d
                        return -EIO;
                iobase = link->io.BasePort1;
  #ifdef incomplete
 -              irq = link->irq.AssignedIRQ;
 +              irq = link->irq;
  #endif
                break;
        default:
@@@ -221,6 -221,7 +221,6 @@@ static const dev_info_t dev_info = "ni_
  
  struct local_info_t {
        struct pcmcia_device *link;
 -      dev_node_t node;
        int stop;
        struct bus_operations *bus;
  };
@@@ -252,6 -253,10 +252,6 @@@ static int dio24_cs_attach(struct pcmci
        local->link = link;
        link->priv = local;
  
 -      /* Interrupt setup */
 -      link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
 -      link->irq.Handler = NULL;
 -
        /*
           General socket configuration defaults can go here.  In this
           client, we assume very little, and rely on the CIS for almost
@@@ -285,8 -290,10 +285,8 @@@ static void dio24_cs_detach(struct pcmc
  
        dev_dbg(&link->dev, "dio24_cs_detach\n");
  
 -      if (link->dev_node) {
 -              ((struct local_info_t *)link->priv)->stop = 1;
 -              dio24_release(link);
 -      }
 +      ((struct local_info_t *)link->priv)->stop = 1;
 +      dio24_release(link);
  
        /* This points to the parent local_info_t struct */
        if (link->priv)
@@@ -321,7 -328,8 +321,7 @@@ static int dio24_pcmcia_config_loop(str
        }
  
        /* Do we need to allocate an interrupt? */
 -      if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
 -              p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 +      p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
  
        /* IO window settings */
        p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
  
  static void dio24_config(struct pcmcia_device *link)
  {
 -      struct local_info_t *dev = link->priv;
        int ret;
        win_req_t req;
  
                goto failed;
        }
  
 -      /*
 -         Allocate an interrupt line.  Note that this does not assign a
 -         handler to the interrupt, unless the 'Handler' member of the
 -         irq structure is initialized.
 -       */
 -      if (link->conf.Attributes & CONF_ENABLE_IRQ) {
 -              ret = pcmcia_request_irq(link, &link->irq);
 -              if (ret)
 -                      goto failed;
 -      }
 +      if (!link->irq)
 +              goto failed;
  
        /*
           This actually configures the PCMCIA socket -- setting up
        if (ret)
                goto failed;
  
 -      /*
 -         At this point, the dev_node_t structure(s) need to be
 -         initialized and arranged in a linked list at link->dev.
 -       */
 -      sprintf(dev->node.dev_name, "ni_daq_dio24");
 -      dev->node.major = dev->node.minor = 0;
 -      link->dev_node = &dev->node;
 -
        /* Finally, report what we've done */
 -      printk(KERN_INFO "%s: index 0x%02x",
 -             dev->node.dev_name, link->conf.ConfigIndex);
 +      dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
        if (link->conf.Attributes & CONF_ENABLE_IRQ)
 -              printk(", irq %d", link->irq.AssignedIRQ);
 +              printk(", irq %d", link->irq);
        if (link->io.NumPorts1)
                printk(", io 0x%04x-0x%04x", link->io.BasePort1,
                       link->io.BasePort1 + link->io.NumPorts1 - 1);
@@@ -461,6 -487,10 +461,10 @@@ static struct pcmcia_device_id dio24_cs
  };
  
  MODULE_DEVICE_TABLE(pcmcia, dio24_cs_ids);
+ MODULE_AUTHOR("Daniel Vecino Castel <dvecino@able.es>");
+ MODULE_DESCRIPTION("Comedi driver for National Instruments "
+                  "PCMCIA DAQ-Card DIO-24");
+ MODULE_LICENSE("GPL");
  
  struct pcmcia_driver dio24_cs_driver = {
        .probe = dio24_cs_attach,
@@@ -144,7 -144,7 +144,7 @@@ static int labpc_attach(struct comedi_d
                if (!link)
                        return -EIO;
                iobase = link->io.BasePort1;
 -              irq = link->irq.AssignedIRQ;
 +              irq = link->irq;
                break;
        default:
                printk("bug! couldn't determine board type\n");
@@@ -199,6 -199,7 +199,6 @@@ static const dev_info_t dev_info = "daq
  
  struct local_info_t {
        struct pcmcia_device *link;
 -      dev_node_t node;
        int stop;
        struct bus_operations *bus;
  };
@@@ -228,6 -229,10 +228,6 @@@ static int labpc_cs_attach(struct pcmci
        local->link = link;
        link->priv = local;
  
 -      /* Interrupt setup */
 -      link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_FORCED_PULSE;
 -      link->irq.Handler = NULL;
 -
        /*
           General socket configuration defaults can go here.  In this
           client, we assume very little, and rely on the CIS for almost
@@@ -264,8 -269,10 +264,8 @@@ static void labpc_cs_detach(struct pcmc
           the release() function is called, that will trigger a proper
           detach().
         */
 -      if (link->dev_node) {
 -              ((struct local_info_t *)link->priv)->stop = 1;
 -              labpc_release(link);
 -      }
 +      ((struct local_info_t *)link->priv)->stop = 1;
 +      labpc_release(link);
  
        /* This points to the parent local_info_t struct (may be null) */
        kfree(link->priv);
@@@ -299,7 -306,8 +299,7 @@@ static int labpc_pcmcia_config_loop(str
        }
  
        /* Do we need to allocate an interrupt? */
 -      if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
 -              p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 +      p_dev->conf.Attributes |= CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ;
  
        /* IO window settings */
        p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
  
  static void labpc_config(struct pcmcia_device *link)
  {
 -      struct local_info_t *dev = link->priv;
        int ret;
        win_req_t req;
  
                goto failed;
        }
  
 -      /*
 -         Allocate an interrupt line.  Note that this does not assign a
 -         handler to the interrupt, unless the 'Handler' member of the
 -         irq structure is initialized.
 -       */
 -      if (link->conf.Attributes & CONF_ENABLE_IRQ) {
 -              ret = pcmcia_request_irq(link, &link->irq);
 -              if (ret)
 -                      goto failed;
 -      }
 +      if (!link->irq)
 +              goto failed;
  
        /*
           This actually configures the PCMCIA socket -- setting up
        if (ret)
                goto failed;
  
 -      /*
 -         At this point, the dev_node_t structure(s) need to be
 -         initialized and arranged in a linked list at link->dev.
 -       */
 -      sprintf(dev->node.dev_name, "daqcard-1200");
 -      dev->node.major = dev->node.minor = 0;
 -      link->dev_node = &dev->node;
 -
        /* Finally, report what we've done */
 -      printk(KERN_INFO "%s: index 0x%02x",
 -             dev->node.dev_name, link->conf.ConfigIndex);
 +      dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
        if (link->conf.Attributes & CONF_ENABLE_IRQ)
 -              printk(", irq %d", link->irq.AssignedIRQ);
 +              printk(", irq %d", link->irq);
        if (link->io.NumPorts1)
                printk(", io 0x%04x-0x%04x", link->io.BasePort1,
                       link->io.BasePort1 + link->io.NumPorts1 - 1);
@@@ -437,6 -463,9 +437,9 @@@ static struct pcmcia_device_id labpc_cs
  };
  
  MODULE_DEVICE_TABLE(pcmcia, labpc_cs_ids);
+ MODULE_AUTHOR("Frank Mori Hess <fmhess@users.sourceforge.net>");
+ MODULE_DESCRIPTION("Comedi driver for National Instruments Lab-PC");
+ MODULE_LICENSE("GPL");
  
  struct pcmcia_driver labpc_cs_driver = {
        .probe = labpc_cs_attach,
@@@ -478,6 -507,5 +481,5 @@@ void __exit labpc_exit_module(void
        comedi_driver_unregister(&driver_labpc_cs);
  }
  
- MODULE_LICENSE("GPL");
  module_init(labpc_init_module);
  module_exit(labpc_exit_module);
@@@ -262,11 -262,17 +262,11 @@@ static void cs_detach(struct pcmcia_dev
  
  static struct pcmcia_device *cur_dev = NULL;
  static const dev_info_t dev_info = "ni_mio_cs";
 -static dev_node_t dev_node = {
 -      "ni_mio_cs",
 -      COMEDI_MAJOR, 0,
 -      NULL
 -};
  
  static int cs_attach(struct pcmcia_device *link)
  {
        link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
        link->io.NumPorts1 = 16;
 -      link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
        link->conf.Attributes = CONF_ENABLE_IRQ;
        link->conf.IntType = INT_MEMORY_AND_IO;
  
@@@ -286,7 -292,8 +286,7 @@@ static void cs_detach(struct pcmcia_dev
  {
        DPRINTK("cs_detach(link=%p)\n", link);
  
 -      if (link->dev_node)
 -              cs_release(link);
 +      cs_release(link);
  }
  
  static int mio_cs_suspend(struct pcmcia_device *link)
@@@ -337,10 -344,14 +337,10 @@@ static void mio_cs_config(struct pcmcia
                return;
        }
  
 -      ret = pcmcia_request_irq(link, &link->irq);
 -      if (ret) {
 -              printk("pcmcia_request_irq() returned error: %i\n", ret);
 -      }
 +      if (!link->irq)
 +              dev_info(&link->dev, "no IRQ available\n");
  
        ret = pcmcia_request_configuration(link, &link->conf);
 -
 -      link->dev_node = &dev_node;
  }
  
  static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        dev->driver = &driver_ni_mio_cs;
        dev->iobase = link->io.BasePort1;
  
 -      irq = link->irq.AssignedIRQ;
 +      irq = link->irq;
  
        printk("comedi%d: %s: DAQCard: io 0x%04lx, irq %u, ",
               dev->minor, dev->driver->driver_name, dev->iobase, irq);
@@@ -428,8 -439,6 +428,6 @@@ static int ni_getboardtype(struct comed
  
  #ifdef MODULE
  
- MODULE_LICENSE("GPL");
  static struct pcmcia_device_id ni_mio_cs_ids[] = {
        PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010d),        /* DAQCard-ai-16xe-50 */
        PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010c),        /* DAQCard-ai-16e-4 */
  };
  
  MODULE_DEVICE_TABLE(pcmcia, ni_mio_cs_ids);
+ MODULE_AUTHOR("David A. Schleef <ds@schleef.org>");
+ MODULE_DESCRIPTION("Comedi driver for National Instruments DAQCard E series");
+ MODULE_LICENSE("GPL");
  
  struct pcmcia_driver ni_mio_cs_driver = {
        .probe = &cs_attach,
@@@ -55,18 -55,21 +55,20 @@@ Devices: [Quatech] DAQP-208 (daqp), DAQ
  #include <pcmcia/cisreg.h>
  #include <pcmcia/ds.h>
  
+ #include <linux/completion.h>
  /* Maximum number of separate DAQP devices we'll allow */
  #define MAX_DEV         4
  
  struct local_info_t {
        struct pcmcia_device *link;
 -      dev_node_t node;
        int stop;
        int table_index;
        char board_name[32];
  
        enum { semaphore, buffer } interrupt_mode;
  
-       struct semaphore eos;
+       struct completion eos;
  
        struct comedi_device *dev;
        struct comedi_subdevice *s;
@@@ -237,14 -240,13 +239,13 @@@ static int daqp_ai_cancel(struct comedi
  /* Interrupt handler
   *
   * Operates in one of two modes.  If local->interrupt_mode is
-  * 'semaphore', just signal the local->eos semaphore and return
+  * 'semaphore', just signal the local->eos completion and return
   * (one-shot mode).  Otherwise (continuous mode), read data in from
   * the card, transfer it to the buffer provided by the higher-level
   * comedi kernel module, and signal various comedi callback routines,
   * which run pretty quick.
   */
- static void daqp_interrupt(int irq, void *dev_id)
+ static enum irqreturn daqp_interrupt(int irq, void *dev_id)
  {
        struct local_info_t *local = (struct local_info_t *)dev_id;
        struct comedi_device *dev;
        if (local == NULL) {
                printk(KERN_WARNING
                       "daqp_interrupt(): irq %d for unknown device.\n", irq);
-               return;
+               return IRQ_NONE;
        }
  
        dev = local->dev;
        if (dev == NULL) {
                printk(KERN_WARNING "daqp_interrupt(): NULL comedi_device.\n");
-               return;
+               return IRQ_NONE;
        }
  
        if (!dev->attached) {
                printk(KERN_WARNING
                       "daqp_interrupt(): struct comedi_device not yet attached.\n");
-               return;
+               return IRQ_NONE;
        }
  
        s = local->s;
        if (s == NULL) {
                printk(KERN_WARNING
                       "daqp_interrupt(): NULL comedi_subdevice.\n");
-               return;
+               return IRQ_NONE;
        }
  
        if ((struct local_info_t *)s->private != local) {
                printk(KERN_WARNING
                       "daqp_interrupt(): invalid comedi_subdevice.\n");
-               return;
+               return IRQ_NONE;
        }
  
        switch (local->interrupt_mode) {
  
        case semaphore:
  
-               up(&local->eos);
+               complete(&local->eos);
                break;
  
        case buffer:
  
                comedi_event(dev, s);
        }
+       return IRQ_HANDLED;
  }
  
  /* One-shot analog data acquisition routine */
@@@ -400,8 -403,7 +402,7 @@@ static int daqp_ai_insn_read(struct com
                return -1;
        }
  
-       /* Make sure semaphore is blocked */
-       sema_init(&local->eos, 0);
+       init_completion(&local->eos);
        local->interrupt_mode = semaphore;
        local->dev = dev;
        local->s = s;
                outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA,
                     dev->iobase + DAQP_COMMAND);
  
-               /* Wait for interrupt service routine to unblock semaphore */
+               /* Wait for interrupt service routine to unblock completion */
                /* Maybe could use a timeout here, but it's interruptible */
-               if (down_interruptible(&local->eos))
+               if (wait_for_completion_interruptible(&local->eos))
                        return -EINTR;
  
                data[i] = inb(dev->iobase + DAQP_FIFO);
@@@ -579,7 -581,7 +580,7 @@@ static int daqp_ai_cmd(struct comedi_de
  {
        struct local_info_t *local = (struct local_info_t *)s->private;
        struct comedi_cmd *cmd = &s->async->cmd;
-       int counter = 100;
+       int counter;
        int scanlist_start_on_every_entry;
        int threshold;
  
         */
  
        if (cmd->convert_src == TRIG_TIMER) {
-               int counter = daqp_ns_to_timer(&cmd->convert_arg,
+               counter = daqp_ns_to_timer(&cmd->convert_arg,
                                               cmd->flags & TRIG_ROUND_MASK);
                outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
                outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
                outb((counter >> 16) & 0xff, dev->iobase + DAQP_PACER_HIGH);
                scanlist_start_on_every_entry = 1;
        } else {
-               int counter = daqp_ns_to_timer(&cmd->scan_begin_arg,
+               counter = daqp_ns_to_timer(&cmd->scan_begin_arg,
                                               cmd->flags & TRIG_ROUND_MASK);
                outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
                outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
        /* Reset any pending interrupts (my card has a tendancy to require
         * require multiple reads on the status register to achieve this)
         */
+       counter = 100;
        while (--counter
               && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS)) ;
        if (!counter) {
@@@ -1039,6 -1041,10 +1040,6 @@@ static int daqp_cs_attach(struct pcmcia
        local->link = link;
        link->priv = local;
  
 -      /* Interrupt setup */
 -      link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
 -      link->irq.Handler = daqp_interrupt;
 -
        /*
           General socket configuration defaults can go here.  In this
           client, we assume very little, and rely on the CIS for almost
@@@ -1069,8 -1075,10 +1070,8 @@@ static void daqp_cs_detach(struct pcmci
  
        dev_dbg(&link->dev, "daqp_cs_detach\n");
  
 -      if (link->dev_node) {
 -              dev->stop = 1;
 -              daqp_cs_release(link);
 -      }
 +      dev->stop = 1;
 +      daqp_cs_release(link);
  
        /* Unlink device structure, and free it */
        dev_table[dev->table_index] = NULL;
@@@ -1098,7 -1106,8 +1099,7 @@@ static int daqp_pcmcia_config_loop(stru
                return -ENODEV;
  
        /* Do we need to allocate an interrupt? */
 -      if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
 -              p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 +      p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
  
        /* IO window settings */
        p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
  
  static void daqp_cs_config(struct pcmcia_device *link)
  {
 -      struct local_info_t *dev = link->priv;
        int ret;
  
        dev_dbg(&link->dev, "daqp_cs_config\n");
                goto failed;
        }
  
 -      /*
 -         Allocate an interrupt line.  Note that this does not assign a
 -         handler to the interrupt, unless the 'Handler' member of the
 -         irq structure is initialized.
 -       */
 -      if (link->conf.Attributes & CONF_ENABLE_IRQ) {
 -              ret = pcmcia_request_irq(link, &link->irq);
 -              if (ret)
 -                      goto failed;
 -      }
 +      ret = pcmcia_request_irq(link, daqp_interrupt);
 +      if (ret)
 +              goto failed;
  
        /*
           This actually configures the PCMCIA socket -- setting up
        if (ret)
                goto failed;
  
 -      /*
 -         At this point, the dev_node_t structure(s) need to be
 -         initialized and arranged in a linked list at link->dev.
 -       */
 -      /* Comedi's PCMCIA script uses this device name (extracted
 -       * from /var/lib/pcmcia/stab) to pass to comedi_config
 -       */
 -      /* sprintf(dev->node.dev_name, "daqp%d", dev->table_index); */
 -      sprintf(dev->node.dev_name, "quatech_daqp_cs");
 -      dev->node.major = dev->node.minor = 0;
 -      link->dev_node = &dev->node;
 -
        /* Finally, report what we've done */
 -      printk(KERN_INFO "%s: index 0x%02x",
 -             dev->node.dev_name, link->conf.ConfigIndex);
 +      dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
        if (link->conf.Attributes & CONF_ENABLE_IRQ)
 -              printk(", irq %u", link->irq.AssignedIRQ);
 +              printk(", irq %u", link->irq);
        if (link->io.NumPorts1)
                printk(", io 0x%04x-0x%04x", link->io.BasePort1,
                       link->io.BasePort1 + link->io.NumPorts1 - 1);
@@@ -1214,8 -1244,11 +1215,11 @@@ static struct pcmcia_device_id daqp_cs_
  };
  
  MODULE_DEVICE_TABLE(pcmcia, daqp_cs_id_table);
+ MODULE_AUTHOR("Brent Baccala <baccala@freesoft.org>");
+ MODULE_DESCRIPTION("Comedi driver for Quatech DAQP PCMCIA data capture cards");
+ MODULE_LICENSE("GPL");
  
- struct pcmcia_driver daqp_cs_driver = {
+ static struct pcmcia_driver daqp_cs_driver = {
        .probe = daqp_cs_attach,
        .remove = daqp_cs_detach,
        .suspend = daqp_cs_suspend,
@@@ -33,7 -33,7 +33,7 @@@
  #include <linux/fcntl.h>
  #include <linux/delay.h>
  #include <linux/slab.h>
 -#include <asm/uaccess.h>
 +#include <linux/uaccess.h>
  
  MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards");
  MODULE_AUTHOR("Hiep Huynh <hiep.huynh@conexant.com>");
@@@ -62,8 -62,9 +62,8 @@@ int cx25821_sram_channel_setup_upstream
        cdt = ch->cdt;
        lines = ch->fifo_size / bpl;
  
 -      if (lines > 3) {
 +      if (lines > 3)
                lines = 3;
 -      }
  
        BUG_ON(lines < 2);
  
@@@ -83,7 -84,7 +83,7 @@@
        cx_write(ch->cmds_start + 12, AUDIO_CDT_SIZE_QW);
        cx_write(ch->cmds_start + 16, ch->ctrl_start);
  
 -      //IQ size
 +      /* IQ size */
        cx_write(ch->cmds_start + 20, AUDIO_IQ_SIZE_DW);
  
        for (i = 24; i < 80; i += 4)
  }
  
  static __le32 *cx25821_risc_field_upstream_audio(struct cx25821_dev *dev,
 -                                               __le32 * rp,
 +                                               __le32 *rp,
                                                 dma_addr_t databuf_phys_addr,
                                                 unsigned int bpl,
                                                 int fifo_enable)
                *(rp++) = cpu_to_le32(databuf_phys_addr + offset);
                *(rp++) = cpu_to_le32(0);       /* bits 63-32 */
  
 -              // Check if we need to enable the FIFO after the first 3 lines
 -              // For the upstream audio channel, the risc engine will enable the FIFO.
 +              /* Check if we need to enable the FIFO
 +               * after the first 3 lines.
 +               * For the upstream audio channel,
 +               * the risc engine will enable the FIFO */
                if (fifo_enable && line == 2) {
                        *(rp++) = RISC_WRITECR;
                        *(rp++) = sram_ch->dma_ctl;
@@@ -161,7 -160,7 +161,7 @@@ int cx25821_risc_buffer_upstream_audio(
                        risc_flag = RISC_CNT_INC;
                }
  
 -              //Calculate physical jump address
 +              /* Calculate physical jump address */
                if ((frame + 1) == NUM_AUDIO_FRAMES) {
                        risc_phys_jump_addr =
                            dev->_risc_phys_start_addr +
                                                       fifo_enable);
  
                if (USE_RISC_NOOP_AUDIO) {
 -                      for (i = 0; i < NUM_NO_OPS; i++) {
 +                      for (i = 0; i < NUM_NO_OPS; i++)
                                *(rp++) = cpu_to_le32(RISC_NOOP);
 -                      }
                }
  
 -              // Loop to (Nth)FrameRISC or to Start of Risc program & generate IRQ
 +              /* Loop to (Nth)FrameRISC or to Start of Risc program &
 +               * generate IRQ */
                *(rp++) = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | risc_flag);
                *(rp++) = cpu_to_le32(risc_phys_jump_addr);
                *(rp++) = cpu_to_le32(0);
  
 -              //Recalculate virtual address based on frame index
 +              /* Recalculate virtual address based on frame index */
                rp = dev->_risc_virt_addr + RISC_SYNC_INSTRUCTION_SIZE / 4 +
                    (AUDIO_RISC_DMA_BUF_SIZE * (frame + 1) / 4);
        }
@@@ -221,19 -220,19 +221,19 @@@ void cx25821_stop_upstream_audio(struc
        u32 tmp = 0;
  
        if (!dev->_audio_is_running) {
 -              printk
 -                  ("cx25821: No audio file is currently running so return!\n");
 +              printk(KERN_DEBUG
 +                  "cx25821: No audio file is currently running so return!\n");
                return;
        }
 -      //Disable RISC interrupts
 +      /* Disable RISC interrupts */
        cx_write(sram_ch->int_msk, 0);
  
 -      //Turn OFF risc and fifo enable in AUD_DMA_CNTRL
 +      /* Turn OFF risc and fifo enable in AUD_DMA_CNTRL */
        tmp = cx_read(sram_ch->dma_ctl);
        cx_write(sram_ch->dma_ctl,
                 tmp & ~(sram_ch->fld_aud_fifo_en | sram_ch->fld_aud_risc_en));
  
 -      //Clear data buffer memory
 +      /* Clear data buffer memory */
        if (dev->_audiodata_buf_virt_addr)
                memset(dev->_audiodata_buf_virt_addr, 0,
                       dev->_audiodata_buf_size);
  
  void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev)
  {
 -      if (dev->_audio_is_running) {
 +      if (dev->_audio_is_running)
                cx25821_stop_upstream_audio(dev);
 -      }
  
        cx25821_free_memory_audio(dev);
  }
@@@ -282,7 -282,7 +282,7 @@@ int cx25821_get_audio_data(struct cx258
  
        if (IS_ERR(myfile)) {
                const int open_errno = -PTR_ERR(myfile);
 -              printk("%s(): ERROR opening file(%s) with errno = %d! \n",
 +              printk(KERN_ERR "%s(): ERROR opening file(%s) with errno = %d!\n",
                       __func__, dev->_audiofilename, open_errno);
                return PTR_ERR(myfile);
        } else {
                }
  
                if (!myfile->f_op->read) {
 -                      printk("%s: File has no READ operations registered! \n",
 +                      printk("%s: File has no READ operations registered!\n",
                               __func__);
                        filp_close(myfile, NULL);
                        return -EIO;
@@@ -347,7 -347,7 +347,7 @@@ static void cx25821_audioups_handler(st
            container_of(work, struct cx25821_dev, _audio_work_entry);
  
        if (!dev) {
 -              printk("ERROR %s(): since container_of(work_struct) FAILED! \n",
 +              printk(KERN_ERR "ERROR %s(): since container_of(work_struct) FAILED!\n",
                       __func__);
                return;
        }
@@@ -373,19 -373,19 +373,19 @@@ int cx25821_openfile_audio(struct cx258
  
        if (IS_ERR(myfile)) {
                const int open_errno = -PTR_ERR(myfile);
 -              printk("%s(): ERROR opening file(%s) with errno = %d! \n",
 +              printk(KERN_ERR "%s(): ERROR opening file(%s) with errno = %d!\n",
                       __func__, dev->_audiofilename, open_errno);
                return PTR_ERR(myfile);
        } else {
                if (!(myfile->f_op)) {
 -                      printk("%s: File has no file operations registered! \n",
 +                      printk("%s: File has no file operations registered!\n",
                               __func__);
                        filp_close(myfile, NULL);
                        return -EIO;
                }
  
                if (!myfile->f_op->read) {
 -                      printk("%s: File has no READ operations registered! \n",
 +                      printk("%s: File has no READ operations registered!\n",
                               __func__);
                        filp_close(myfile, NULL);
                        return -EIO;
                                }
                        }
  
 -                      if (i > 0) {
 +                      if (i > 0)
                                dev->_audioframe_count++;
 -                      }
  
 -                      if (vfs_read_retval < line_size) {
 +                      if (vfs_read_retval < line_size)
                                break;
 -                      }
                }
  
                dev->_audiofile_status =
@@@ -458,14 -460,14 +458,14 @@@ static int cx25821_audio_upstream_buffe
        dev->_audiorisc_size = dev->audio_upstream_riscbuf_size;
  
        if (!dev->_risc_virt_addr) {
 -              printk
 -                  ("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for RISC program! Returning.\n");
 +              printk(KERN_DEBUG
 +                      "cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for RISC program! Returning.\n");
                return -ENOMEM;
        }
 -      //Clear out memory at address
 +      /* Clear out memory at address */
        memset(dev->_risc_virt_addr, 0, dev->_audiorisc_size);
  
 -      //For Audio Data buffer allocation
 +      /* For Audio Data buffer allocation */
        dev->_audiodata_buf_virt_addr =
            pci_alloc_consistent(dev->pci, dev->audio_upstream_databuf_size,
                                 &data_dma_addr);
        dev->_audiodata_buf_size = dev->audio_upstream_databuf_size;
  
        if (!dev->_audiodata_buf_virt_addr) {
 -              printk
 -                  ("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for data buffer! Returning. \n");
 +              printk(KERN_DEBUG
 +                      "cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for data buffer! Returning.\n");
                return -ENOMEM;
        }
 -      //Clear out memory at address
 +      /* Clear out memory at address */
        memset(dev->_audiodata_buf_virt_addr, 0, dev->_audiodata_buf_size);
  
        ret = cx25821_openfile_audio(dev, sram_ch);
        if (ret < 0)
                return ret;
  
 -      //Creating RISC programs
 +      /* Creating RISC programs */
        ret =
            cx25821_risc_buffer_upstream_audio(dev, dev->pci, bpl,
                                               dev->_audio_lines_count);
        if (ret < 0) {
                printk(KERN_DEBUG
 -                     "cx25821 ERROR creating audio upstream RISC programs! \n");
 +                    "cx25821 ERROR creating audio upstream RISC programs!\n");
                goto error;
        }
  
        return 0;
  
 -      error:
 +error:
        return ret;
  }
  
@@@ -510,22 -512,22 +510,22 @@@ int cx25821_audio_upstream_irq(struct c
        __le32 *rp;
  
        if (status & FLD_AUD_SRC_RISCI1) {
 -              //Get interrupt_index of the program that interrupted
 +              /* Get interrupt_index of the program that interrupted */
                u32 prog_cnt = cx_read(channel->gpcnt);
  
 -              //Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers
 +              /* Since we've identified our IRQ, clear our bits from the
 +               * interrupt mask and interrupt status registers */
                cx_write(channel->int_msk, 0);
                cx_write(channel->int_stat, cx_read(channel->int_stat));
  
                spin_lock(&dev->slock);
  
                while (prog_cnt != dev->_last_index_irq) {
 -                      //Update _last_index_irq
 -                      if (dev->_last_index_irq < (NUMBER_OF_PROGRAMS - 1)) {
 +                      /* Update _last_index_irq */
 +                      if (dev->_last_index_irq < (NUMBER_OF_PROGRAMS - 1))
                                dev->_last_index_irq++;
 -                      } else {
 +                      else
                                dev->_last_index_irq = 0;
 -                      }
  
                        dev->_audioframe_index = dev->_last_index_irq;
  
                                                    cpu_to_le32(RISC_NOOP);
                                        }
                                }
 -                              // Jump to 2nd Audio Frame
 +                              /* Jump to 2nd Audio Frame */
                                *(rp++) =
                                    cpu_to_le32(RISC_JUMP | RISC_IRQ1 |
                                                RISC_CNT_RESET);
                        printk("%s: Audio Received OpCode Error Interrupt!\n",
                               __func__);
  
 -              // Read and write back the interrupt status register to clear our bits
 +              /* Read and write back the interrupt status register to clear
 +               * our bits */
                cx_write(channel->int_stat, cx_read(channel->int_stat));
        }
  
                       dev->_audioframe_count);
                return -1;
        }
 -      //ElSE, set the interrupt mask register, re-enable irq.
 +      /* ElSE, set the interrupt mask register, re-enable irq. */
        int_msk_tmp = cx_read(channel->int_msk);
        cx_write(channel->int_msk, int_msk_tmp |= _intr_msk);
  
@@@ -612,7 -613,7 +612,7 @@@ static irqreturn_t cx25821_upstream_irq
        msk_stat = cx_read(sram_ch->int_mstat);
        audio_status = cx_read(sram_ch->int_stat);
  
 -      // Only deal with our interrupt
 +      /* Only deal with our interrupt */
        if (audio_status) {
                handled =
                    cx25821_audio_upstream_irq(dev,
                                               audio_status);
        }
  
 -      if (handled < 0) {
 +      if (handled < 0)
                cx25821_stop_upstream_audio(dev);
 -      } else {
 +      else
                handled += handled;
 -      }
  
        return IRQ_RETVAL(handled);
  }
@@@ -636,14 -638,13 +636,14 @@@ static void cx25821_wait_fifo_enable(st
        u32 tmp;
  
        do {
 -              //Wait 10 microsecond before checking to see if the FIFO is turned ON.
 +              /* Wait 10 microsecond before checking to see if the FIFO is
 +               * turned ON. */
                udelay(10);
  
                tmp = cx_read(sram_ch->dma_ctl);
  
 -              if (count++ > 1000)     //10 millisecond timeout
 -              {
 +              /* 10 millisecond timeout */
 +              if (count++ > 1000) {
                        printk
                            ("cx25821 ERROR: %s() fifo is NOT turned on. Timeout!\n",
                             __func__);
@@@ -660,34 -661,31 +660,34 @@@ int cx25821_start_audio_dma_upstream(st
        u32 tmp = 0;
        int err = 0;
  
 -      // Set the physical start address of the RISC program in the initial program counter(IPC) member of the CMDS.
 +      /* Set the physical start address of the RISC program in the initial
 +       * program counter(IPC) member of the CMDS. */
        cx_write(sram_ch->cmds_start + 0, dev->_risc_phys_addr);
 -      cx_write(sram_ch->cmds_start + 4, 0);   /* Risc IPC High 64 bits 63-32 */
 +      /* Risc IPC High 64 bits 63-32 */
 +      cx_write(sram_ch->cmds_start + 4, 0);
  
        /* reset counter */
        cx_write(sram_ch->gpcnt_ctl, 3);
  
 -      //Set the line length       (It looks like we do not need to set the line length)
 +      /* Set the line length       (It looks like we do not need to set the
 +       * line length) */
        cx_write(sram_ch->aud_length, AUDIO_LINE_SIZE & FLD_AUD_DST_LN_LNGTH);
  
 -      //Set the input mode to 16-bit
 +      /* Set the input mode to 16-bit */
        tmp = cx_read(sram_ch->aud_cfg);
        tmp |=
            FLD_AUD_SRC_ENABLE | FLD_AUD_DST_PK_MODE | FLD_AUD_CLK_ENABLE |
            FLD_AUD_MASTER_MODE | FLD_AUD_CLK_SELECT_PLL_D | FLD_AUD_SONY_MODE;
        cx_write(sram_ch->aud_cfg, tmp);
  
 -      // Read and write back the interrupt status register to clear it
 +      /* Read and write back the interrupt status register to clear it */
        tmp = cx_read(sram_ch->int_stat);
        cx_write(sram_ch->int_stat, tmp);
  
 -      // Clear our bits from the interrupt status register.
 +      /* Clear our bits from the interrupt status register. */
        cx_write(sram_ch->int_stat, _intr_msk);
  
 -      //Set the interrupt mask register, enable irq.
 +      /* Set the interrupt mask register, enable irq. */
        cx_set(PCI_INT_MSK, cx_read(PCI_INT_MSK) | (1 << sram_ch->irq_bit));
        tmp = cx_read(sram_ch->int_msk);
        cx_write(sram_ch->int_msk, tmp |= _intr_msk);
                goto fail_irq;
        }
  
 -      // Start the DMA  engine
 +      /* Start the DMA  engine */
        tmp = cx_read(sram_ch->dma_ctl);
        cx_set(sram_ch->dma_ctl, tmp | sram_ch->fld_aud_risc_en);
  
        dev->_audio_is_running = 1;
        dev->_is_first_audio_frame = 1;
  
 -      // The fifo_en bit turns on by the first Risc program
 +      /* The fifo_en bit turns on by the first Risc program */
        cx25821_wait_fifo_enable(dev, sram_ch);
  
        return 0;
  
 -      fail_irq:
 +fail_irq:
        cx25821_dev_unregister(dev);
        return err;
  }
@@@ -733,14 -731,14 +733,14 @@@ int cx25821_audio_upstream_init(struct 
        dev->_audio_upstream_channel_select = channel_select;
        sram_ch = &dev->sram_channels[channel_select];
  
 -      //Work queue
 +      /* Work queue */
        INIT_WORK(&dev->_audio_work_entry, cx25821_audioups_handler);
        dev->_irq_audio_queues =
            create_singlethread_workqueue("cx25821_audioworkqueue");
  
        if (!dev->_irq_audio_queues) {
 -              printk
 -                  ("cx25821 ERROR: create_singlethread_workqueue() for Audio FAILED!\n");
 +              printk(KERN_DEBUG
 +                      "cx25821 ERROR: create_singlethread_workqueue() for Audio FAILED!\n");
                return -ENOMEM;
        }
  
  
        if (dev->input_audiofilename) {
                str_length = strlen(dev->input_audiofilename);
-               dev->_audiofilename =
-                   (char *)kmalloc(str_length + 1, GFP_KERNEL);
+               dev->_audiofilename = kmalloc(str_length + 1, GFP_KERNEL);
  
                if (!dev->_audiofilename)
                        goto error;
                memcpy(dev->_audiofilename, dev->input_audiofilename,
                       str_length + 1);
  
 -              //Default if filename is empty string
 +              /* Default if filename is empty string */
                if (strcmp(dev->input_audiofilename, "") == 0) {
                        dev->_audiofilename = "/root/audioGOOD.wav";
                }
        } else {
                str_length = strlen(_defaultAudioName);
-               dev->_audiofilename =
-                   (char *)kmalloc(str_length + 1, GFP_KERNEL);
+               dev->_audiofilename = kmalloc(str_length + 1, GFP_KERNEL);
  
                if (!dev->_audiofilename)
                        goto error;
            RISC_SYNC_INSTRUCTION_SIZE;
        dev->audio_upstream_databuf_size = AUDIO_DATA_BUF_SZ * NUM_AUDIO_PROGS;
  
 -      //Allocating buffers and prepare RISC program
 +      /* Allocating buffers and prepare RISC program */
        retval =
            cx25821_audio_upstream_buffer_prepare(dev, sram_ch, _line_size);
        if (retval < 0) {
                       dev->name);
                goto error;
        }
 -      //Start RISC engine
 +      /* Start RISC engine */
        cx25821_start_audio_dma_upstream(dev, sram_ch);
  
        return 0;
  
 -      error:
 +error:
        cx25821_dev_unregister(dev);
  
        return err;
@@@ -32,7 -32,7 +32,7 @@@
  #include <linux/file.h>
  #include <linux/fcntl.h>
  #include <linux/slab.h>
 -#include <asm/uaccess.h>
 +#include <linux/uaccess.h>
  
  MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards");
  MODULE_AUTHOR("Hiep Huynh <hiep.huynh@conexant.com>");
@@@ -60,8 -60,9 +60,8 @@@ int cx25821_sram_channel_setup_upstream
        cdt = ch->cdt;
        lines = ch->fifo_size / bpl;
  
 -      if (lines > 4) {
 +      if (lines > 4)
                lines = 4;
 -      }
  
        BUG_ON(lines < 2);
  
@@@ -96,7 -97,7 +96,7 @@@
  }
  
  static __le32 *cx25821_update_riscprogram(struct cx25821_dev *dev,
 -                                        __le32 * rp, unsigned int offset,
 +                                        __le32 *rp, unsigned int offset,
                                          unsigned int bpl, u32 sync_line,
                                          unsigned int lines, int fifo_enable,
                                          int field_type)
        *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
  
        if (USE_RISC_NOOP_VIDEO) {
 -              for (i = 0; i < NUM_NO_OPS; i++) {
 +              for (i = 0; i < NUM_NO_OPS; i++)
                        *(rp++) = cpu_to_le32(RISC_NOOP);
 -              }
        }
  
        /* scan lines */
@@@ -138,12 -140,14 +138,12 @@@ static __le32 *cx25821_risc_field_upstr
        int dist_betwn_starts = bpl * 2;
  
        /* sync instruction */
 -      if (sync_line != NO_SYNC_LINE) {
 +      if (sync_line != NO_SYNC_LINE)
                *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
 -      }
  
        if (USE_RISC_NOOP_VIDEO) {
 -              for (i = 0; i < NUM_NO_OPS; i++) {
 +              for (i = 0; i < NUM_NO_OPS; i++)
                        *(rp++) = cpu_to_le32(RISC_NOOP);
 -              }
        }
  
        /* scan lines */
                *(rp++) = cpu_to_le32(0);       /* bits 63-32 */
  
                if ((lines <= NTSC_FIELD_HEIGHT)
 -                  || (line < (NTSC_FIELD_HEIGHT - 1)) || !(dev->_isNTSC)) {
 -                      offset += dist_betwn_starts;    //to skip the other field line
 -              }
 +                  || (line < (NTSC_FIELD_HEIGHT - 1)) || !(dev->_isNTSC))
 +                      /* to skip the other field line */
 +                      offset += dist_betwn_starts;
  
 -              // check if we need to enable the FIFO after the first 4 lines
 -              // For the upstream video channel, the risc engine will enable the FIFO.
 +              /* check if we need to enable the FIFO after the first 4 lines
 +               * For the upstream video channel, the risc engine will enable
 +               * the FIFO. */
                if (fifo_enable && line == 3) {
                        *(rp++) = RISC_WRITECR;
                        *(rp++) = sram_ch->dma_ctl;
@@@ -178,8 -181,7 +178,8 @@@ int cx25821_risc_buffer_upstream(struc
  {
        __le32 *rp;
        int fifo_enable = 0;
 -      int singlefield_lines = lines >> 1;     //get line count for single field
 +      /* get line count for single field */
 +      int singlefield_lines = lines >> 1;
        int odd_num_lines = singlefield_lines;
        int frame = 0;
        int frame_size = 0;
  
                fifo_enable = FIFO_DISABLE;
  
 -              //Even Field
 +              /* Even Field */
                rp = cx25821_risc_field_upstream(dev, rp,
                                                 dev->_data_buf_phys_addr +
                                                 databuf_offset, bottom_offset,
                        risc_flag = RISC_CNT_INC;
                }
  
 -              // Loop to 2ndFrameRISC or to Start of Risc program & generate IRQ
 +              /* Loop to 2ndFrameRISC or to Start of Risc
 +               * program & generate IRQ
 +               */
                *(rp++) = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | risc_flag);
                *(rp++) = cpu_to_le32(risc_phys_jump_addr);
                *(rp++) = cpu_to_le32(0);
@@@ -258,18 -258,18 +258,18 @@@ void cx25821_stop_upstream_video_ch1(st
  
        if (!dev->_is_running) {
                printk
 -                  ("cx25821: No video file is currently running so return!\n");
 +                 (KERN_INFO "cx25821: No video file is currently running so return!\n");
                return;
        }
 -      //Disable RISC interrupts
 +      /* Disable RISC interrupts */
        tmp = cx_read(sram_ch->int_msk);
        cx_write(sram_ch->int_msk, tmp & ~_intr_msk);
  
 -      //Turn OFF risc and fifo enable
 +      /* Turn OFF risc and fifo enable */
        tmp = cx_read(sram_ch->dma_ctl);
        cx_write(sram_ch->dma_ctl, tmp & ~(FLD_VID_FIFO_EN | FLD_VID_RISC_EN));
  
 -      //Clear data buffer memory
 +      /* Clear data buffer memory */
        if (dev->_data_buf_virt_addr)
                memset(dev->_data_buf_virt_addr, 0, dev->_data_buf_size);
  
  
  void cx25821_free_mem_upstream_ch1(struct cx25821_dev *dev)
  {
 -      if (dev->_is_running) {
 +      if (dev->_is_running)
                cx25821_stop_upstream_video_ch1(dev);
 -      }
  
        if (dev->_dma_virt_addr) {
                pci_free_consistent(dev->pci, dev->_risc_size,
@@@ -346,19 -347,19 +346,19 @@@ int cx25821_get_frame(struct cx25821_de
  
        if (IS_ERR(myfile)) {
                const int open_errno = -PTR_ERR(myfile);
 -              printk("%s(): ERROR opening file(%s) with errno = %d! \n",
 +              printk(KERN_ERR "%s(): ERROR opening file(%s) with errno = %d!\n",
                       __func__, dev->_filename, open_errno);
                return PTR_ERR(myfile);
        } else {
                if (!(myfile->f_op)) {
 -                      printk("%s: File has no file operations registered!",
 +                      printk(KERN_ERR "%s: File has no file operations registered!",
                               __func__);
                        filp_close(myfile, NULL);
                        return -EIO;
                }
  
                if (!myfile->f_op->read) {
 -                      printk("%s: File has no READ operations registered!",
 +                      printk(KERN_ERR "%s: File has no READ operations registered!",
                               __func__);
                        filp_close(myfile, NULL);
                        return -EIO;
@@@ -411,7 -412,7 +411,7 @@@ static void cx25821_vidups_handler(stru
            container_of(work, struct cx25821_dev, _irq_work_entry);
  
        if (!dev) {
 -              printk("ERROR %s(): since container_of(work_struct) FAILED! \n",
 +              printk(KERN_ERR "ERROR %s(): since container_of(work_struct) FAILED!\n",
                       __func__);
                return;
        }
@@@ -437,12 -438,12 +437,12 @@@ int cx25821_openfile(struct cx25821_de
  
        if (IS_ERR(myfile)) {
                const int open_errno = -PTR_ERR(myfile);
 -              printk("%s(): ERROR opening file(%s) with errno = %d! \n",
 +              printk(KERN_ERR "%s(): ERROR opening file(%s) with errno = %d!\n",
                       __func__, dev->_filename, open_errno);
                return PTR_ERR(myfile);
        } else {
                if (!(myfile->f_op)) {
 -                      printk("%s: File has no file operations registered!",
 +                      printk(KERN_ERR "%s: File has no file operations registered!",
                               __func__);
                        filp_close(myfile, NULL);
                        return -EIO;
  
                if (!myfile->f_op->read) {
                        printk
 -                          ("%s: File has no READ operations registered!  Returning.",
 +                          (KERN_ERR "%s: File has no READ operations registered!  Returning.",
                             __func__);
                        filp_close(myfile, NULL);
                        return -EIO;
                        if (i > 0)
                                dev->_frame_count++;
  
 -                      if (vfs_read_retval < line_size) {
 +                      if (vfs_read_retval < line_size)
                                break;
 -                      }
                }
  
                dev->_file_status =
@@@ -526,11 -528,11 +526,11 @@@ int cx25821_upstream_buffer_prepare(str
  
        if (!dev->_dma_virt_addr) {
                printk
 -                  ("cx25821: FAILED to allocate memory for Risc buffer! Returning.\n");
 +                  (KERN_ERR "cx25821: FAILED to allocate memory for Risc buffer! Returning.\n");
                return -ENOMEM;
        }
  
 -      //Clear memory at address
 +      /* Clear memory at address */
        memset(dev->_dma_virt_addr, 0, dev->_risc_size);
  
        if (dev->_data_buf_virt_addr != NULL) {
                                    dev->_data_buf_virt_addr,
                                    dev->_data_buf_phys_addr);
        }
 -      //For Video Data buffer allocation
 +      /* For Video Data buffer allocation */
        dev->_data_buf_virt_addr =
            pci_alloc_consistent(dev->pci, dev->upstream_databuf_size,
                                 &data_dma_addr);
  
        if (!dev->_data_buf_virt_addr) {
                printk
 -                  ("cx25821: FAILED to allocate memory for data buffer! Returning.\n");
 +                  (KERN_ERR "cx25821: FAILED to allocate memory for data buffer! Returning.\n");
                return -ENOMEM;
        }
  
 -      //Clear memory at address
 +      /* Clear memory at address */
        memset(dev->_data_buf_virt_addr, 0, dev->_data_buf_size);
  
        ret = cx25821_openfile(dev, sram_ch);
        if (ret < 0)
                return ret;
  
 -      //Create RISC programs
 +      /* Create RISC programs */
        ret =
            cx25821_risc_buffer_upstream(dev, dev->pci, 0, bpl,
                                         dev->_lines_count);
        if (ret < 0) {
                printk(KERN_INFO
 -                     "cx25821: Failed creating Video Upstream Risc programs! \n");
 +                  "cx25821: Failed creating Video Upstream Risc programs!\n");
                goto error;
        }
  
        return 0;
  
 -      error:
 +error:
        return ret;
  }
  
@@@ -586,11 -588,10 +586,11 @@@ int cx25821_video_upstream_irq(struct c
        __le32 *rp;
  
        if (status & FLD_VID_SRC_RISC1) {
 -              // We should only process one program per call
 +              /* We should only process one program per call */
                u32 prog_cnt = cx_read(channel->gpcnt);
  
 -              //Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers
 +              /* Since we've identified our IRQ, clear our bits from the
 +               * interrupt mask and interrupt status registers */
                int_msk_tmp = cx_read(channel->int_msk);
                cx_write(channel->int_msk, int_msk_tmp & ~_intr_msk);
                cx_write(channel->int_stat, _intr_msk);
                                                                FIFO_DISABLE,
                                                                ODD_FIELD);
  
 -                              // Jump to Even Risc program of 1st Frame
 +                              /* Jump to Even Risc program of 1st Frame */
                                *(rp++) = cpu_to_le32(RISC_JUMP);
                                *(rp++) = cpu_to_le32(risc_phys_jump_addr);
                                *(rp++) = cpu_to_le32(0);
        } else {
                if (status & FLD_VID_SRC_UF)
                        printk
 -                          ("%s: Video Received Underflow Error Interrupt!\n",
 +                          (KERN_ERR "%s: Video Received Underflow Error Interrupt!\n",
                             __func__);
  
                if (status & FLD_VID_SRC_SYNC)
 -                      printk("%s: Video Received Sync Error Interrupt!\n",
 +                      printk(KERN_ERR "%s: Video Received Sync Error Interrupt!\n",
                               __func__);
  
                if (status & FLD_VID_SRC_OPC_ERR)
 -                      printk("%s: Video Received OpCode Error Interrupt!\n",
 +                      printk(KERN_ERR "%s: Video Received OpCode Error Interrupt!\n",
                               __func__);
        }
  
        if (dev->_file_status == END_OF_FILE) {
 -              printk("cx25821: EOF Channel 1 Framecount = %d\n",
 +              printk(KERN_ERR "cx25821: EOF Channel 1 Framecount = %d\n",
                       dev->_frame_count);
                return -1;
        }
 -      //ElSE, set the interrupt mask register, re-enable irq.
 +      /* ElSE, set the interrupt mask register, re-enable irq. */
        int_msk_tmp = cx_read(channel->int_msk);
        cx_write(channel->int_msk, int_msk_tmp |= _intr_msk);
  
@@@ -684,16 -685,17 +684,16 @@@ static irqreturn_t cx25821_upstream_irq
        msk_stat = cx_read(sram_ch->int_mstat);
        vid_status = cx_read(sram_ch->int_stat);
  
 -      // Only deal with our interrupt
 +      /* Only deal with our interrupt */
        if (vid_status) {
                handled =
                    cx25821_video_upstream_irq(dev, channel_num, vid_status);
        }
  
 -      if (handled < 0) {
 +      if (handled < 0)
                cx25821_stop_upstream_video_ch1(dev);
 -      } else {
 +      else
                handled += handled;
 -      }
  
        return IRQ_RETVAL(handled);
  }
@@@ -712,19 -714,19 +712,19 @@@ void cx25821_set_pixelengine(struct cx2
        value |= dev->_isNTSC ? 0 : 0x10;
        cx_write(ch->vid_fmt_ctl, value);
  
 -      // set number of active pixels in each line. Default is 720 pixels in both NTSC and PAL format
 +      /* set number of active pixels in each line.
 +       * Default is 720 pixels in both NTSC and PAL format */
        cx_write(ch->vid_active_ctl1, width);
  
        num_lines = (height / 2) & 0x3FF;
        odd_num_lines = num_lines;
  
 -      if (dev->_isNTSC) {
 +      if (dev->_isNTSC)
                odd_num_lines += 1;
 -      }
  
        value = (num_lines << 16) | odd_num_lines;
  
 -      // set number of active lines in field 0 (top) and field 1 (bottom)
 +      /* set number of active lines in field 0 (top) and field 1 (bottom) */
        cx_write(ch->vid_active_ctl2, value);
  
        cx_write(ch->vid_cdt_size, VID_CDT_SIZE >> 3);
@@@ -736,26 -738,21 +736,26 @@@ int cx25821_start_video_dma_upstream(st
        u32 tmp = 0;
        int err = 0;
  
 -      // 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for channel A-C
 +      /* 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for
 +       * channel A-C
 +       */
        tmp = cx_read(VID_CH_MODE_SEL);
        cx_write(VID_CH_MODE_SEL, tmp | 0x1B0001FF);
  
 -      // Set the physical start address of the RISC program in the initial program counter(IPC) member of the cmds.
 +      /* Set the physical start address of the RISC program in the initial
 +       * program counter(IPC) member of the cmds.
 +       */
        cx_write(sram_ch->cmds_start + 0, dev->_dma_phys_addr);
 -      cx_write(sram_ch->cmds_start + 4, 0);   /* Risc IPC High 64 bits 63-32 */
 +      /* Risc IPC High 64 bits 63-32 */
 +      cx_write(sram_ch->cmds_start + 4, 0);
  
        /* reset counter */
        cx_write(sram_ch->gpcnt_ctl, 3);
  
 -      // Clear our bits from the interrupt status register.
 +      /* Clear our bits from the interrupt status register. */
        cx_write(sram_ch->int_stat, _intr_msk);
  
 -      //Set the interrupt mask register, enable irq.
 +      /* Set the interrupt mask register, enable irq. */
        cx_set(PCI_INT_MSK, cx_read(PCI_INT_MSK) | (1 << sram_ch->irq_bit));
        tmp = cx_read(sram_ch->int_msk);
        cx_write(sram_ch->int_msk, tmp |= _intr_msk);
                goto fail_irq;
        }
  
 -      // Start the DMA  engine
 +      /* Start the DMA  engine */
        tmp = cx_read(sram_ch->dma_ctl);
        cx_set(sram_ch->dma_ctl, tmp | FLD_VID_RISC_EN);
  
  
        return 0;
  
 -      fail_irq:
 +fail_irq:
        cx25821_dev_unregister(dev);
        return err;
  }
@@@ -795,7 -792,7 +795,7 @@@ int cx25821_vidupstream_init_ch1(struc
        int str_length = 0;
  
        if (dev->_is_running) {
 -              printk("Video Channel is still running so return!\n");
 +              printk(KERN_INFO "Video Channel is still running so return!\n");
                return 0;
        }
  
  
        if (!dev->_irq_queues) {
                printk
 -                  ("cx25821: create_singlethread_workqueue() for Video FAILED!\n");
 +                  (KERN_ERR "cx25821: create_singlethread_workqueue() for Video FAILED!\n");
                return -ENOMEM;
        }
 -      // 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for channel A-C
 +      /* 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for
 +       * channel A-C
 +       */
        tmp = cx_read(VID_CH_MODE_SEL);
        cx_write(VID_CH_MODE_SEL, tmp | 0x1B0001FF);
  
  
        if (dev->input_filename) {
                str_length = strlen(dev->input_filename);
-               dev->_filename = (char *)kmalloc(str_length + 1, GFP_KERNEL);
+               dev->_filename = kmalloc(str_length + 1, GFP_KERNEL);
  
                if (!dev->_filename)
                        goto error;
                memcpy(dev->_filename, dev->input_filename, str_length + 1);
        } else {
                str_length = strlen(dev->_defaultname);
-               dev->_filename = (char *)kmalloc(str_length + 1, GFP_KERNEL);
+               dev->_filename = kmalloc(str_length + 1, GFP_KERNEL);
  
                if (!dev->_filename)
                        goto error;
                memcpy(dev->_filename, dev->_defaultname, str_length + 1);
        }
  
 -      //Default if filename is empty string
 +      /* Default if filename is empty string */
        if (strcmp(dev->input_filename, "") == 0) {
                if (dev->_isNTSC) {
                        dev->_filename =
        dev->upstream_riscbuf_size = risc_buffer_size * 2;
        dev->upstream_databuf_size = data_frame_size * 2;
  
 -      //Allocating buffers and prepare RISC program
 +      /* Allocating buffers and prepare RISC program */
        retval = cx25821_upstream_buffer_prepare(dev, sram_ch, dev->_line_size);
        if (retval < 0) {
                printk(KERN_ERR
  
        return 0;
  
 -      error:
 +error:
        cx25821_dev_unregister(dev);
  
        return err;
@@@ -63,6 -63,7 +63,7 @@@ extern void printques(int)
  #include <linux/types.h>
  #include <linux/poll.h>
  #include <linux/sched.h>
+ #include <linux/smp_lock.h>
  
  #include <asm/io.h>
  #include <asm/uaccess.h>
@@@ -94,7 -95,7 +95,7 @@@ int dt3155_errno = 0
  #endif
  
  /* wait queue for interrupts */
- wait_queue_head_t dt3155_read_wait_queue[ MAXBOARDS ];
+ wait_queue_head_t dt3155_read_wait_queue[MAXBOARDS];
  
  #define DT_3155_SUCCESS 0
  #define DT_3155_FAILURE -EIO
@@@ -111,10 -112,10 +112,10 @@@ int dt3155_major = 0
  /* Global structures and variables */
  
  /* Status of each device */
- struct dt3155_status_s dt3155_status[ MAXBOARDS ];
+ struct dt3155_status dt3155_status[MAXBOARDS];
  
  /* kernel logical address of the board */
- u8 *dt3155_lbase[ MAXBOARDS ] = { NULL
+ u8 *dt3155_lbase[MAXBOARDS] = { NULL
  #if MAXBOARDS == 2
                                      , NULL
  #endif
  /* DT3155 registers              */
  u8 *dt3155_bbase = NULL;                /* kernel logical address of the *
                                           * buffer region                 */
- u32  dt3155_dev_open[ MAXBOARDS ] = {0
+ u32  dt3155_dev_open[MAXBOARDS] = {0
  #if MAXBOARDS == 2
                                       , 0
  #endif
@@@ -141,17 -142,17 +142,17 @@@ static void quick_stop (int minor
  {
    // TODO: scott was here
  #if 1
-   ReadMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg);
+   ReadMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
    /* disable interrupts */
    int_csr_r.fld.FLD_END_EVE_EN = 0;
    int_csr_r.fld.FLD_END_ODD_EN = 0;
-   WriteMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg );
+   WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
  
-   dt3155_status[ minor ].state &= ~(DT3155_STATE_STOP|0xff);
+   dt3155_status[minor].state &= ~(DT3155_STATE_STOP|0xff);
    /* mark the system stopped: */
-   dt3155_status[ minor ].state |= DT3155_STATE_IDLE;
-   dt3155_fbuffer[ minor ]->stop_acquire = 0;
-   dt3155_fbuffer[ minor ]->even_stopped = 0;
+   dt3155_status[minor].state |= DT3155_STATE_IDLE;
+   dt3155_fbuffer[minor]->stop_acquire = 0;
+   dt3155_fbuffer[minor]->even_stopped = 0;
  #else
    dt3155_status[minor].state |= DT3155_STATE_STOP;
    dt3155_status[minor].fbuffer.stop_acquire = 1;
   * - Assumes irq's are disabled, via SA_INTERRUPT flag
   * being set in request_irq() call from init_module()
   *****************************************************/
- static inline void dt3155_isr( int irq, void *dev_id, struct pt_regs *regs )
+ static void dt3155_isr(int irq, void *dev_id, struct pt_regs *regs)
  {
    int    minor = -1;
    int    index;
    u32 buffer_addr;
  
    /* find out who issued the interrupt */
-   for ( index = 0; index < ndevices; index++ ) {
-     if( dev_id == (void*) &dt3155_status[ index ])
+   for (index = 0; index < ndevices; index++) {
+     if(dev_id == (void*) &dt3155_status[index])
        {
        minor = index;
        break;
    }
  
    /* hopefully we should not get here */
-   if ( minor < 0 || minor >= MAXBOARDS ) {
+   if (minor < 0 || minor >= MAXBOARDS) {
      printk(KERN_ERR "dt3155_isr called with invalid dev_id\n");
      return;
    }
  
    /* Check for corruption and set a flag if so */
-   ReadMReg( (dt3155_lbase[ minor ] + CSR1), csr1_r.reg );
+   ReadMReg((dt3155_lbase[minor] + CSR1), csr1_r.reg);
  
-   if ( (csr1_r.fld.FLD_CRPT_EVE) || (csr1_r.fld.FLD_CRPT_ODD) )
+   if ((csr1_r.fld.FLD_CRPT_EVE) || (csr1_r.fld.FLD_CRPT_ODD))
      {
        /* TODO: this should probably stop acquisition */
        /* and set some flags so that dt3155_read      */
        return;
      }
  
-   ReadMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg);
+   ReadMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
  
    /* Handle the even field ... */
    if (int_csr_r.fld.FLD_END_EVE)
      {
-       if ( (dt3155_status[ minor ].state & DT3155_STATE_MODE) ==
-          DT3155_STATE_FLD )
+       if ((dt3155_status[minor].state & DT3155_STATE_MODE) ==
+          DT3155_STATE_FLD)
        {
-         dt3155_fbuffer[ minor ]->frame_count++;
+         dt3155_fbuffer[minor]->frame_count++;
        }
  
-       ReadI2C(dt3155_lbase[ minor ], EVEN_CSR, &i2c_even_csr.reg);
+       ReadI2C(dt3155_lbase[minor], EVEN_CSR, &i2c_even_csr.reg);
  
        /* Clear the interrupt? */
        int_csr_r.fld.FLD_END_EVE = 1;
  
        /* disable the interrupt if last field */
-       if (dt3155_fbuffer[ minor ]->stop_acquire)
+       if (dt3155_fbuffer[minor]->stop_acquire)
        {
          printk("dt3155:  even stopped.\n");
-         dt3155_fbuffer[ minor ]->even_stopped = 1;
+         dt3155_fbuffer[minor]->even_stopped = 1;
          if (i2c_even_csr.fld.SNGL_EVE)
            {
              int_csr_r.fld.FLD_END_EVE_EN = 0;
            }
        }
  
-       WriteMReg( (dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg );
+       WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
  
        /* Set up next DMA if we are doing FIELDS */
-       if ( (dt3155_status[ minor ].state & DT3155_STATE_MODE ) ==
+       if ((dt3155_status[minor].state & DT3155_STATE_MODE) ==
           DT3155_STATE_FLD)
        {
          /* GCS (Aug 2, 2002) -- In field mode, dma the odd field
             into the lower half of the buffer */
-         const u32 stride =  dt3155_status[ minor ].config.cols;
-         buffer_addr = dt3155_fbuffer[ minor ]->
-           frame_info[ dt3155_fbuffer[ minor ]->active_buf ].addr
+         const u32 stride =  dt3155_status[minor].config.cols;
+         buffer_addr = dt3155_fbuffer[minor]->
+           frame_info[dt3155_fbuffer[minor]->active_buf].addr
            + (DT3155_MAX_ROWS / 2) * stride;
          local_save_flags(flags);
          local_irq_disable();
-         wake_up_interruptible( &dt3155_read_wait_queue[ minor ] );
+         wake_up_interruptible(&dt3155_read_wait_queue[minor]);
  
          /* Set up the DMA address for the next field */
          local_irq_restore(flags);
-         WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_START), buffer_addr);
+         WriteMReg((dt3155_lbase[minor] + ODD_DMA_START), buffer_addr);
        }
  
        /* Check for errors. */
        i2c_even_csr.fld.DONE_EVE = 1;
-       if ( i2c_even_csr.fld.ERROR_EVE )
+       if (i2c_even_csr.fld.ERROR_EVE)
        dt3155_errno = DT_ERR_OVERRUN;
  
-       WriteI2C( dt3155_lbase[ minor ], EVEN_CSR, i2c_even_csr.reg );
+       WriteI2C(dt3155_lbase[minor], EVEN_CSR, i2c_even_csr.reg);
  
        /* Note that we actually saw an even field meaning  */
        /* that subsequent odd field complete the frame     */
-       dt3155_fbuffer[ minor ]->even_happened = 1;
+       dt3155_fbuffer[minor]->even_happened = 1;
  
        /* recording the time that the even field finished, this should be */
        /* about time in the middle of the frame */
-       do_gettimeofday( &(dt3155_fbuffer[ minor ]->
-                        frame_info[ dt3155_fbuffer[ minor ]->
-                                    active_buf ].time) );
+       do_gettimeofday(&(dt3155_fbuffer[minor]->
+                        frame_info[dt3155_fbuffer[minor]->
+                                    active_buf].time));
        return;
      }
  
    /* ... now handle the odd field */
-   if ( int_csr_r.fld.FLD_END_ODD )
+   if (int_csr_r.fld.FLD_END_ODD)
      {
-       ReadI2C( dt3155_lbase[ minor ], ODD_CSR, &i2c_odd_csr.reg );
+       ReadI2C(dt3155_lbase[minor], ODD_CSR, &i2c_odd_csr.reg);
  
        /* Clear the interrupt? */
        int_csr_r.fld.FLD_END_ODD = 1;
  
-       if (dt3155_fbuffer[ minor ]->even_happened ||
-         (dt3155_status[ minor ].state & DT3155_STATE_MODE) ==
+       if (dt3155_fbuffer[minor]->even_happened ||
+         (dt3155_status[minor].state & DT3155_STATE_MODE) ==
          DT3155_STATE_FLD)
        {
-         dt3155_fbuffer[ minor ]->frame_count++;
+         dt3155_fbuffer[minor]->frame_count++;
        }
  
-       if ( dt3155_fbuffer[ minor ]->stop_acquire &&
-          dt3155_fbuffer[ minor ]->even_stopped )
+       if (dt3155_fbuffer[minor]->stop_acquire &&
+          dt3155_fbuffer[minor]->even_stopped)
        {
          printk(KERN_DEBUG "dt3155:  stopping odd..\n");
-         if ( i2c_odd_csr.fld.SNGL_ODD )
+         if (i2c_odd_csr.fld.SNGL_ODD)
            {
              /* disable interrupts */
              int_csr_r.fld.FLD_END_ODD_EN = 0;
-             dt3155_status[ minor ].state &= ~(DT3155_STATE_STOP|0xff);
+             dt3155_status[minor].state &= ~(DT3155_STATE_STOP|0xff);
  
              /* mark the system stopped: */
-             dt3155_status[ minor ].state |= DT3155_STATE_IDLE;
-             dt3155_fbuffer[ minor ]->stop_acquire = 0;
-             dt3155_fbuffer[ minor ]->even_stopped = 0;
+             dt3155_status[minor].state |= DT3155_STATE_IDLE;
+             dt3155_fbuffer[minor]->stop_acquire = 0;
+             dt3155_fbuffer[minor]->even_stopped = 0;
  
              printk(KERN_DEBUG "dt3155:  state is now %x\n",
                     dt3155_status[minor].state);
            }
        }
  
-       WriteMReg( (dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg );
+       WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
  
        /* if the odd field has been acquired, then     */
        /* change the next dma location for both fields */
        /* and wake up the process if sleeping          */
-       if ( dt3155_fbuffer[ minor ]->even_happened ||
-          (dt3155_status[ minor ].state & DT3155_STATE_MODE) ==
-          DT3155_STATE_FLD )
+       if (dt3155_fbuffer[minor]->even_happened ||
+          (dt3155_status[minor].state & DT3155_STATE_MODE) ==
+          DT3155_STATE_FLD)
        {
  
          local_save_flags(flags);
          local_irq_disable();
  
  #ifdef DEBUG_QUES_B
-         printques( minor );
+         printques(minor);
  #endif
-         if ( dt3155_fbuffer[ minor ]->nbuffers > 2 )
+         if (dt3155_fbuffer[minor]->nbuffers > 2)
            {
-             if ( !are_empty_buffers( minor ) )
+             if (!are_empty_buffers(minor))
                {
                  /* The number of active + locked buffers is
                   * at most 2, and since there are none empty, there
                   * must be at least nbuffers-2 ready buffers.
                   * This is where we 'drop frames', oldest first. */
-                 push_empty( pop_ready( minor ),  minor );
+                 push_empty(pop_ready(minor),  minor);
                }
  
              /* The ready_que can't be full, since we know
               * there is one active buffer right now, so it's safe
               * to push the active buf on the ready_que. */
-             push_ready( minor, dt3155_fbuffer[ minor ]->active_buf );
+             push_ready(minor, dt3155_fbuffer[minor]->active_buf);
              /* There's at least 1 empty -- make it active */
-             dt3155_fbuffer[ minor ]->active_buf = pop_empty( minor );
-             dt3155_fbuffer[ minor ]->
-               frame_info[ dt3155_fbuffer[ minor ]->
-                           active_buf ].tag = ++unique_tag;
+             dt3155_fbuffer[minor]->active_buf = pop_empty(minor);
+             dt3155_fbuffer[minor]->
+               frame_info[dt3155_fbuffer[minor]->
+                           active_buf].tag = ++unique_tag;
            }
          else /* nbuffers == 2, special case */
            { /* There is 1 active buffer.
               * If there is a locked buffer, keep the active buffer
               * the same -- that means we drop a frame.
               */
-             if ( dt3155_fbuffer[ minor ]->locked_buf < 0 )
+             if (dt3155_fbuffer[minor]->locked_buf < 0)
                {
-                 push_ready( minor,
-                             dt3155_fbuffer[ minor ]->active_buf );
-                 if (are_empty_buffers( minor ) )
+                 push_ready(minor,
+                             dt3155_fbuffer[minor]->active_buf);
+                 if (are_empty_buffers(minor))
                    {
-                     dt3155_fbuffer[ minor ]->active_buf =
-                       pop_empty( minor );
+                     dt3155_fbuffer[minor]->active_buf =
+                       pop_empty(minor);
                    }
                  else
                    { /* no empty or locked buffers, so use a readybuf */
-                     dt3155_fbuffer[ minor ]->active_buf =
-                       pop_ready( minor );
+                     dt3155_fbuffer[minor]->active_buf =
+                       pop_ready(minor);
                    }
                }
            }
  
  #ifdef DEBUG_QUES_B
-         printques( minor );
+         printques(minor);
  #endif
  
-         dt3155_fbuffer[ minor ]->even_happened = 0;
+         dt3155_fbuffer[minor]->even_happened = 0;
  
-         wake_up_interruptible( &dt3155_read_wait_queue[ minor ] );
+         wake_up_interruptible(&dt3155_read_wait_queue[minor]);
  
          local_irq_restore(flags);
        }
  
  
        /* Set up the DMA address for the next frame/field */
-       buffer_addr = dt3155_fbuffer[ minor ]->
-       frame_info[ dt3155_fbuffer[ minor ]->active_buf ].addr;
-       if ( (dt3155_status[ minor ].state & DT3155_STATE_MODE) ==
-          DT3155_STATE_FLD )
+       buffer_addr = dt3155_fbuffer[minor]->
+       frame_info[dt3155_fbuffer[minor]->active_buf].addr;
+       if ((dt3155_status[minor].state & DT3155_STATE_MODE) ==
+          DT3155_STATE_FLD)
        {
-         WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START), buffer_addr);
+         WriteMReg((dt3155_lbase[minor] + EVEN_DMA_START), buffer_addr);
        }
        else
        {
-         WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START), buffer_addr);
+         WriteMReg((dt3155_lbase[minor] + EVEN_DMA_START), buffer_addr);
  
-         WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_START), buffer_addr
-                   + dt3155_status[ minor ].config.cols);
+         WriteMReg((dt3155_lbase[minor] + ODD_DMA_START), buffer_addr
+                   + dt3155_status[minor].config.cols);
        }
  
        /* Do error checking */
        i2c_odd_csr.fld.DONE_ODD = 1;
-       if ( i2c_odd_csr.fld.ERROR_ODD )
+       if (i2c_odd_csr.fld.ERROR_ODD)
        dt3155_errno = DT_ERR_OVERRUN;
  
-       WriteI2C(dt3155_lbase[ minor ], ODD_CSR, i2c_odd_csr.reg );
+       WriteI2C(dt3155_lbase[minor], ODD_CSR, i2c_odd_csr.reg);
  
        return;
      }
    /* If we get here, the Odd Field wasn't it either... */
-   printk( "neither even nor odd.  shared perhaps?\n");
+   printk("neither even nor odd.  shared perhaps?\n");
  }
  
  /*****************************************************
   *****************************************************/
  static void dt3155_init_isr(int minor)
  {
-   const u32 stride =  dt3155_status[ minor ].config.cols;
+   const u32 stride =  dt3155_status[minor].config.cols;
  
-   switch (dt3155_status[ minor ].state & DT3155_STATE_MODE)
+   switch (dt3155_status[minor].state & DT3155_STATE_MODE)
      {
      case DT3155_STATE_FLD:
        {
-       even_dma_start_r  = dt3155_status[ minor ].
-         fbuffer.frame_info[ dt3155_status[ minor ].fbuffer.active_buf ].addr;
+       even_dma_start_r  = dt3155_status[minor].
+         fbuffer.frame_info[dt3155_status[minor].fbuffer.active_buf].addr;
        even_dma_stride_r = 0;
        odd_dma_stride_r  = 0;
  
-       WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START),
+       WriteMReg((dt3155_lbase[minor] + EVEN_DMA_START),
                  even_dma_start_r);
-       WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_STRIDE),
+       WriteMReg((dt3155_lbase[minor] + EVEN_DMA_STRIDE),
                  even_dma_stride_r);
-       WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_STRIDE),
+       WriteMReg((dt3155_lbase[minor] + ODD_DMA_STRIDE),
                  odd_dma_stride_r);
        break;
        }
      case DT3155_STATE_FRAME:
      default:
        {
-       even_dma_start_r  = dt3155_status[ minor ].
-         fbuffer.frame_info[ dt3155_status[ minor ].fbuffer.active_buf ].addr;
+       even_dma_start_r  = dt3155_status[minor].
+         fbuffer.frame_info[dt3155_status[minor].fbuffer.active_buf].addr;
        odd_dma_start_r   =  even_dma_start_r + stride;
        even_dma_stride_r =  stride;
        odd_dma_stride_r  =  stride;
  
-       WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START),
+       WriteMReg((dt3155_lbase[minor] + EVEN_DMA_START),
                  even_dma_start_r);
-       WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_START),
+       WriteMReg((dt3155_lbase[minor] + ODD_DMA_START),
                  odd_dma_start_r);
-       WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_STRIDE),
+       WriteMReg((dt3155_lbase[minor] + EVEN_DMA_STRIDE),
                  even_dma_stride_r);
-       WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_STRIDE),
+       WriteMReg((dt3155_lbase[minor] + ODD_DMA_STRIDE),
                  odd_dma_stride_r);
        break;
        }
    /* 50/60 Hz should be set before this point but let's make sure it is */
    /* right anyway */
  
-   ReadI2C(dt3155_lbase[ minor ], CSR2, &i2c_csr2.reg);
 -  ReadI2C(dt3155_lbase[minor], CONFIG, &i2c_csr2.reg);
++  ReadI2C(dt3155_lbase[minor], CSR2, &i2c_csr2.reg);
    i2c_csr2.fld.HZ50 = FORMAT50HZ;
-   WriteI2C(dt3155_lbase[ minor ], CSR2, i2c_csr2.reg);
 -  WriteI2C(dt3155_lbase[minor], CONFIG, i2c_config.reg);
++  WriteI2C(dt3155_lbase[minor], CSR2, i2c_csr2.reg);
  
    /* enable busmaster chip, clear flags */
  
    csr1_r.fld.FLD_CRPT_EVE   = 1; /* writing a 1 clears flags */
    csr1_r.fld.FLD_CRPT_ODD   = 1;
  
-   WriteMReg((dt3155_lbase[ minor ] + CSR1),csr1_r.reg);
+   WriteMReg((dt3155_lbase[minor] + CSR1),csr1_r.reg);
  
    /* Enable interrupts at the end of each field */
  
    int_csr_r.fld.FLD_END_ODD_EN = 1;
    int_csr_r.fld.FLD_START_EN = 0;
  
-   WriteMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg);
+   WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
  
    /* start internal BUSY bits */
  
-   ReadI2C(dt3155_lbase[ minor ], CSR2, &i2c_csr2.reg);
+   ReadI2C(dt3155_lbase[minor], CSR2, &i2c_csr2.reg);
    i2c_csr2.fld.BUSY_ODD  = 1;
    i2c_csr2.fld.BUSY_EVE  = 1;
-   WriteI2C(dt3155_lbase[ minor ], CSR2, i2c_csr2.reg);
+   WriteI2C(dt3155_lbase[minor], CSR2, i2c_csr2.reg);
  
    /* Now its up to the interrupt routine!! */
  
@@@ -521,7 -522,7 +522,7 @@@ static int dt3155_ioctl(struct inode *i
  {
    int minor = MINOR(inode->i_rdev); /* What device are we ioctl()'ing? */
  
-   if ( minor >= MAXBOARDS || minor < 0 )
+   if (minor >= MAXBOARDS || minor < 0)
      return -ENODEV;
  
    /* make sure it is valid command */
          return -EBUSY;
  
        {
-         struct dt3155_config_s tmp;
+         struct dt3155_config tmp;
          if (copy_from_user((void *)&tmp, (void *) arg, sizeof(tmp)))
              return -EFAULT;
          /* check for valid settings */
      case DT3155_GET_CONFIG:
        {
        if (copy_to_user((void *) arg, (void *) &dt3155_status[minor],
-                    sizeof(dt3155_status_t) ))
+                    sizeof(struct dt3155_status)))
            return -EFAULT;
        return 0;
        }
  
        quick_stop(minor);
        if (copy_to_user((void *) arg, (void *) &dt3155_status[minor],
-                    sizeof(dt3155_status_t)))
+                    sizeof(struct dt3155_status)))
            return -EFAULT;
        return 0;
        }
          }
  
        dt3155_init_isr(minor);
-       if (copy_to_user( (void *) arg, (void *) &dt3155_status[minor],
-                     sizeof(dt3155_status_t)))
+       if (copy_to_user((void *) arg, (void *) &dt3155_status[minor],
+                     sizeof(struct dt3155_status)))
            return -EFAULT;
        return 0;
        }
@@@ -681,36 -682,36 +682,36 @@@ static int dt3155_mmap (struct file * f
   * MOD_INC_USE_COUNT make sure that the driver memory is not freed
   * while the device is in use.
   *****************************************************/
- static int dt3155_open( struct inode* inode, struct file* filep)
+ static int dt3155_open(struct inode* inode, struct file* filep)
  {
    int minor = MINOR(inode->i_rdev); /* what device are we opening? */
-   if (dt3155_dev_open[ minor ]) {
+   if (dt3155_dev_open[minor]) {
      printk ("DT3155:  Already opened by another process.\n");
      return -EBUSY;
    }
  
-   if (dt3155_status[ minor ].device_installed==0)
+   if (dt3155_status[minor].device_installed==0)
      {
        printk("DT3155 Open Error: No such device dt3155 minor number %d\n",
             minor);
        return -EIO;
      }
  
-   if (dt3155_status[ minor ].state != DT3155_STATE_IDLE) {
+   if (dt3155_status[minor].state != DT3155_STATE_IDLE) {
      printk ("DT3155:  Not in idle state (state = %x)\n",
-           dt3155_status[ minor ].state);
+           dt3155_status[minor].state);
      return -EBUSY;
    }
  
    printk("DT3155: Device opened.\n");
  
-   dt3155_dev_open[ minor ] = 1 ;
+   dt3155_dev_open[minor] = 1 ;
  
-   dt3155_flush( minor );
+   dt3155_flush(minor);
  
    /* Disable ALL interrupts */
    int_csr_r.reg = 0;
-   WriteMReg( (dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg );
+   WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
  
    init_waitqueue_head(&(dt3155_read_wait_queue[minor]));
  
   * Now decrement the use count.
   *
   *****************************************************/
- static int dt3155_close( struct inode *inode, struct file *filep)
+ static int dt3155_close(struct inode *inode, struct file *filep)
  {
    int minor;
  
    minor = MINOR(inode->i_rdev); /* which device are we closing */
-   if (!dt3155_dev_open[ minor ])
+   if (!dt3155_dev_open[minor])
      {
        printk("DT3155: attempt to CLOSE a not OPEN device\n");
      }
    else
      {
-       dt3155_dev_open[ minor ] = 0;
+       dt3155_dev_open[minor] = 0;
  
-       if (dt3155_status[ minor ].state != DT3155_STATE_IDLE)
+       if (dt3155_status[minor].state != DT3155_STATE_IDLE)
        {
          quick_stop(minor);
        }
@@@ -756,11 -757,11 +757,11 @@@ static ssize_t dt3155_read(struct file 
    int         minor = MINOR(filep->f_dentry->d_inode->i_rdev);
    u32         offset;
    int         frame_index;
-   frame_info_t        *frame_info_p;
+   struct frame_info   *frame_info;
  
    /* TODO: this should check the error flag and */
    /*   return an error on hardware failures */
-   if (count != sizeof(dt3155_read_t))
+   if (count != sizeof(struct dt3155_read))
      {
        printk("DT3155 ERROR (NJC): count is not right\n");
        return -EINVAL;
    if (filep->f_flags & O_NDELAY)
      {
        if ((frame_index = dt3155_get_ready_buffer(minor)) < 0) {
-       /*printk( "dt3155:  no buffers available (?)\n");*/
+       /*printk("dt3155:  no buffers available (?)\n");*/
        /*              printques(minor); */
        return -EAGAIN;
        }
        }
      }
  
-   frame_info_p = &dt3155_status[minor].fbuffer.frame_info[frame_index];
+   frame_info = &dt3155_status[minor].fbuffer.frame_info[frame_index];
  
    /* make this an offset */
-   offset = frame_info_p->addr - dt3155_status[minor].mem_addr;
+   offset = frame_info->addr - dt3155_status[minor].mem_addr;
  
    put_user(offset, (unsigned int *) buf);
    buf += sizeof(u32);
-   put_user( dt3155_status[minor].fbuffer.frame_count, (unsigned int *) buf);
+   put_user(dt3155_status[minor].fbuffer.frame_count, (unsigned int *) buf);
    buf += sizeof(u32);
    put_user(dt3155_status[minor].state, (unsigned int *) buf);
    buf += sizeof(u32);
-   if (copy_to_user(buf, frame_info_p, sizeof(frame_info_t)))
+   if (copy_to_user(buf, frame_info, sizeof(*frame_info)))
        return -EFAULT;
  
-   return sizeof(dt3155_read_t);
+   return sizeof(struct dt3155_read);
  }
  
  static unsigned int dt3155_poll (struct file * filp, poll_table *wait)
    return 0;
  }
  
+ static long
+ dt3155_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+ {
+       int ret;
+       lock_kernel();
+       ret = dt3155_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
+       unlock_kernel();
+       return ret;
+ }
  
  /*****************************************************
   * file operations supported by DT3155 driver
   *  register_chrdev
   *****************************************************/
  static struct file_operations dt3155_fops = {
-   read:               dt3155_read,
-   ioctl:              dt3155_ioctl,
-   mmap:               dt3155_mmap,
-   poll:           dt3155_poll,
-   open:               dt3155_open,
-   release:    dt3155_close
+       .read           = dt3155_read,
+       .unlocked_ioctl = dt3155_unlocked_ioctl,
+       .mmap           = dt3155_mmap,
+       .poll           = dt3155_poll,
+       .open           = dt3155_open,
+       .release        = dt3155_close
  };
  
  
@@@ -889,7 -901,7 +901,7 @@@ static int find_PCI (void
  
        /* Now, just go out and make sure that this/these device(s) is/are
         actually mapped into the kernel address space */
-       if ((error = pci_read_config_dword( pci_dev, PCI_BASE_ADDRESS_0,
+       if ((error = pci_read_config_dword(pci_dev, PCI_BASE_ADDRESS_0,
                                          (u32 *) &base)))
        {
          printk("DT3155: Was not able to find device \n");
  
        /* Remap the base address to a logical address through which we
         * can access it. */
-       dt3155_lbase[ pci_index - 1 ] = ioremap(base,PCI_PAGE_SIZE);
-       dt3155_status[ pci_index - 1 ].reg_addr = base;
+       dt3155_lbase[pci_index - 1] = ioremap(base,PCI_PAGE_SIZE);
+       dt3155_status[pci_index - 1].reg_addr = base;
        DT_3155_DEBUG_MSG("DT3155: New logical address is %p \n",
                        dt3155_lbase[pci_index-1]);
-       if ( !dt3155_lbase[pci_index-1] )
+       if (!dt3155_lbase[pci_index-1])
        {
          printk("DT3155: Unable to remap control registers\n");
          goto err;
        }
  
-       if ( (error = pci_read_config_byte( pci_dev, PCI_INTERRUPT_LINE, &irq)) )
+       if ((error = pci_read_config_byte(pci_dev, PCI_INTERRUPT_LINE, &irq)))
        {
          printk("DT3155: Was not able to find device \n");
          goto err;
        }
  
        DT_3155_DEBUG_MSG("DT3155: IRQ is %d \n",irq);
-       dt3155_status[ pci_index-1 ].irq = irq;
+       dt3155_status[pci_index-1].irq = irq;
        /* Set flag: kth device found! */
-       dt3155_status[ pci_index-1 ].device_installed = 1;
+       dt3155_status[pci_index-1].device_installed = 1;
        printk("DT3155: Installing device %d w/irq %d and address %p\n",
             pci_index,
             dt3155_status[pci_index-1].irq,
@@@ -945,89 -957,89 +957,89 @@@ int init_module(void
  {
    int index;
    int rcode = 0;
-   char *devname[ MAXBOARDS ];
+   char *devname[MAXBOARDS];
  
-   devname[ 0 ] = "dt3155a";
+   devname[0] = "dt3155a";
  #if MAXBOARDS == 2
-   devname[ 1 ] = "dt3155b";
+   devname[1] = "dt3155b";
  #endif
  
    printk("DT3155: Loading module...\n");
  
    /* Register the device driver */
-   rcode = register_chrdev( dt3155_major, "dt3155", &dt3155_fops );
-   if( rcode < 0 )
+   rcode = register_chrdev(dt3155_major, "dt3155", &dt3155_fops);
+   if(rcode < 0)
      {
-       printk( KERN_INFO "DT3155: register_chrdev failed \n");
+       printk(KERN_INFO "DT3155: register_chrdev failed \n");
        return rcode;
      }
  
-   if( dt3155_major == 0 )
+   if(dt3155_major == 0)
      dt3155_major = rcode; /* dynamic */
  
  
    /* init the status variables.                     */
    /* DMA memory is taken care of in setup_buffers() */
-   for ( index = 0; index < MAXBOARDS; index++ )
+   for (index = 0; index < MAXBOARDS; index++)
      {
-       dt3155_status[ index ].config.acq_mode   = DT3155_MODE_FRAME;
-       dt3155_status[ index ].config.continuous = DT3155_ACQ;
-       dt3155_status[ index ].config.cols       = DT3155_MAX_COLS;
-       dt3155_status[ index ].config.rows       = DT3155_MAX_ROWS;
-       dt3155_status[ index ].state = DT3155_STATE_IDLE;
+       dt3155_status[index].config.acq_mode   = DT3155_MODE_FRAME;
+       dt3155_status[index].config.continuous = DT3155_ACQ;
+       dt3155_status[index].config.cols       = DT3155_MAX_COLS;
+       dt3155_status[index].config.rows       = DT3155_MAX_ROWS;
+       dt3155_status[index].state = DT3155_STATE_IDLE;
  
        /* find_PCI() will check if devices are installed; */
        /* first assume they're not:                       */
-       dt3155_status[ index ].mem_addr          = 0;
-       dt3155_status[ index ].mem_size          = 0;
-       dt3155_status[ index ].state             = DT3155_STATE_IDLE;
-       dt3155_status[ index ].device_installed  = 0;
+       dt3155_status[index].mem_addr          = 0;
+       dt3155_status[index].mem_size          = 0;
+       dt3155_status[index].state             = DT3155_STATE_IDLE;
+       dt3155_status[index].device_installed  = 0;
      }
  
    /* Now let's find the hardware.  find_PCI() will set ndevices to the
     * number of cards found in this machine. */
      {
-       if ( (rcode = find_PCI()) !=  DT_3155_SUCCESS )
+       if ((rcode = find_PCI()) !=  DT_3155_SUCCESS)
        {
          printk("DT3155 error: find_PCI() failed to find dt3155 board(s)\n");
-         unregister_chrdev( dt3155_major, "dt3155" );
+         unregister_chrdev(dt3155_major, "dt3155");
          return rcode;
        }
      }
  
    /* Ok, time to setup the frame buffers */
-   if( (rcode = dt3155_setup_buffers(&allocatorAddr)) < 0 )
+   if((rcode = dt3155_setup_buffers(&allocatorAddr)) < 0)
      {
        printk("DT3155: Error: setting up buffer not large enough.");
-       unregister_chrdev( dt3155_major, "dt3155" );
+       unregister_chrdev(dt3155_major, "dt3155");
        return rcode;
      }
  
    /* If we are this far, then there is enough RAM */
    /* for the buffers: Print the configuration.    */
-   for(  index = 0;  index < ndevices;  index++ )
+   for( index = 0;  index < ndevices;  index++)
      {
        printk("DT3155: Device = %d; acq_mode = %d; "
             "continuous = %d; cols = %d; rows = %d;\n",
             index ,
-            dt3155_status[ index ].config.acq_mode,
-            dt3155_status[ index ].config.continuous,
-            dt3155_status[ index ].config.cols,
-            dt3155_status[ index ].config.rows);
+            dt3155_status[index].config.acq_mode,
+            dt3155_status[index].config.continuous,
+            dt3155_status[index].config.cols,
+            dt3155_status[index].config.rows);
        printk("DT3155: m_addr = 0x%x; m_size = %ld; "
             "state = %d; device_installed = %d\n",
-            dt3155_status[ index ].mem_addr,
-            (long int)dt3155_status[ index ].mem_size,
-            dt3155_status[ index ].state,
-            dt3155_status[ index ].device_installed);
+            dt3155_status[index].mem_addr,
+            (long int)dt3155_status[index].mem_size,
+            dt3155_status[index].state,
+            dt3155_status[index].device_installed);
      }
  
    /* Disable ALL interrupts */
    int_csr_r.reg = 0;
-   for(  index = 0;  index < ndevices;  index++ )
+   for( index = 0;  index < ndevices;  index++)
      {
-       WriteMReg( (dt3155_lbase[ index ] + INT_CSR), int_csr_r.reg );
-       if( dt3155_status[ index ].device_installed )
+       WriteMReg((dt3155_lbase[index] + INT_CSR), int_csr_r.reg);
+       if(dt3155_status[index].device_installed)
        {
          /*
           * This driver *looks* like it can handle sharing interrupts,
           * as a reminder in case any problems arise. (SS)
           */
          /* in older kernels flags are: SA_SHIRQ | SA_INTERRUPT */
-         rcode = request_irq( dt3155_status[ index ].irq, (void *)dt3155_isr,
-                              IRQF_SHARED | IRQF_DISABLED, devname[ index ],
+         rcode = request_irq(dt3155_status[index].irq, (void *)dt3155_isr,
+                              IRQF_SHARED | IRQF_DISABLED, devname[index],
                               (void*) &dt3155_status[index]);
-         if( rcode < 0 )
+         if(rcode < 0)
            {
              printk("DT3155: minor %d request_irq failed for IRQ %d\n",
                     index, dt3155_status[index].irq);
-             unregister_chrdev( dt3155_major, "dt3155" );
+             unregister_chrdev(dt3155_major, "dt3155");
              return rcode;
            }
        }
@@@ -1072,15 -1084,15 +1084,15 @@@ void cleanup_module(void
    allocator_cleanup();
  #endif
  
-   unregister_chrdev( dt3155_major, "dt3155" );
+   unregister_chrdev(dt3155_major, "dt3155");
  
-   for( index = 0; index < ndevices; index++ )
+   for(index = 0; index < ndevices; index++)
      {
-       if( dt3155_status[ index ].device_installed == 1 )
+       if(dt3155_status[index].device_installed == 1)
        {
-         printk( "DT3155: Freeing irq %d for device %d\n",
-                 dt3155_status[ index ].irq, index );
-         free_irq( dt3155_status[ index ].irq, (void*)&dt3155_status[index] );
+         printk("DT3155: Freeing irq %d for device %d\n",
+                 dt3155_status[index].irq, index);
+         free_irq(dt3155_status[index].irq, (void*)&dt3155_status[index]);
        }
      }
  }
@@@ -404,7 -404,7 +404,7 @@@ void et131x_multicast(struct net_devic
        struct et131x_adapter *adapter = netdev_priv(netdev);
        uint32_t PacketFilter = 0;
        unsigned long flags;
 -      struct dev_mc_list *mclist;
 +      struct netdev_hw_addr *ha;
        int i;
  
        spin_lock_irqsave(&adapter->Lock, flags);
         * accordingly
         */
  
-       if (netdev->flags & IFF_PROMISC) {
+       if (netdev->flags & IFF_PROMISC)
                adapter->PacketFilter |= ET131X_PACKET_TYPE_PROMISCUOUS;
-       } else {
+       else
                adapter->PacketFilter &= ~ET131X_PACKET_TYPE_PROMISCUOUS;
-       }
  
-       if (netdev->flags & IFF_ALLMULTI) {
+       if (netdev->flags & IFF_ALLMULTI)
                adapter->PacketFilter |= ET131X_PACKET_TYPE_ALL_MULTICAST;
-       }
  
-       if (netdev_mc_count(netdev) > NIC_MAX_MCAST_LIST) {
+       if (netdev_mc_count(netdev) > NIC_MAX_MCAST_LIST)
                adapter->PacketFilter |= ET131X_PACKET_TYPE_ALL_MULTICAST;
-       }
  
        if (netdev_mc_count(netdev) < 1) {
                adapter->PacketFilter &= ~ET131X_PACKET_TYPE_ALL_MULTICAST;
                adapter->PacketFilter &= ~ET131X_PACKET_TYPE_MULTICAST;
-       } else {
+       } else
                adapter->PacketFilter |= ET131X_PACKET_TYPE_MULTICAST;
-       }
  
        /* Set values in the private adapter struct */
        i = 0;
 -      netdev_for_each_mc_addr(mclist, netdev) {
 +      netdev_for_each_mc_addr(ha, netdev) {
                if (i == NIC_MAX_MCAST_LIST)
                        break;
 -              memcpy(adapter->MCList[i++], mclist->dmi_addr, ETH_ALEN);
 +              memcpy(adapter->MCList[i++], ha->addr, ETH_ALEN);
        }
        adapter->MCAddressCount = i;
  
  #include <linux/skbuff.h>
  #include <linux/in.h>
  #include <linux/slab.h>
+ #include <linux/dmi.h>
+ #include <linux/pci.h>
  #include <net/arp.h>
  #include <net/route.h>
  #include <net/sock.h>
  #include <net/pkt_sched.h>
  #include "osd.h"
  #include "logging.h"
- #include "VersionInfo.h"
+ #include "version_info.h"
  #include "vmbus.h"
- #include "NetVscApi.h"
+ #include "netvsc_api.h"
  
  struct net_device_context {
        /* point back to our device context */
        struct vm_device *device_ctx;
-       struct net_device_stats stats;
+       unsigned long avail;
  };
  
  struct netvsc_driver_context {
        struct netvsc_driver drv_obj;
  };
  
- static int netvsc_ringbuffer_size = NETVSC_DEVICE_RING_BUFFER_SIZE;
+ #define PACKET_PAGES_LOWATER  8
+ /* Need this many pages to handle worst case fragmented packet */
+ #define PACKET_PAGES_HIWATER  (MAX_SKB_FRAGS + 2)
+ static int ring_size = roundup_pow_of_two(2*MAX_SKB_FRAGS+1);
+ module_param(ring_size, int, S_IRUGO);
+ MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
  
  /* The one and only one */
  static struct netvsc_driver_context g_netvsc_drv;
  
- static struct net_device_stats *netvsc_get_stats(struct net_device *net)
- {
-       struct net_device_context *net_device_ctx = netdev_priv(net);
-       return &net_device_ctx->stats;
- }
  static void netvsc_set_multicast_list(struct net_device *net)
  {
  }
@@@ -78,9 -79,6 +79,6 @@@ static int netvsc_open(struct net_devic
        DPRINT_ENTER(NETVSC_DRV);
  
        if (netif_carrier_ok(net)) {
-               memset(&net_device_ctx->stats, 0,
-                      sizeof(struct net_device_stats));
                /* Open up the device */
                ret = RndisFilterOnOpen(device_obj);
                if (ret != 0) {
@@@ -122,22 -120,20 +120,20 @@@ static void netvsc_xmit_completion(voi
        struct hv_netvsc_packet *packet = (struct hv_netvsc_packet *)context;
        struct sk_buff *skb = (struct sk_buff *)
                (unsigned long)packet->Completion.Send.SendCompletionTid;
-       struct net_device *net;
  
        DPRINT_ENTER(NETVSC_DRV);
  
        kfree(packet);
  
        if (skb) {
-               net = skb->dev;
-               dev_kfree_skb_any(skb);
+               struct net_device *net = skb->dev;
+               struct net_device_context *net_device_ctx = netdev_priv(net);
+               unsigned int num_pages = skb_shinfo(skb)->nr_frags + 2;
  
-               if (netif_queue_stopped(net)) {
-                       DPRINT_INFO(NETVSC_DRV, "net device (%p) waking up...",
-                                   net);
+               dev_kfree_skb_any(skb);
  
-                       netif_wake_queue(net);
-               }
+               if ((net_device_ctx->avail += num_pages) >= PACKET_PAGES_HIWATER)
+                       netif_wake_queue(net);
        }
  
        DPRINT_EXIT(NETVSC_DRV);
@@@ -152,65 -148,58 +148,58 @@@ static int netvsc_start_xmit(struct sk_
                (struct netvsc_driver_context *)driver_ctx;
        struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj;
        struct hv_netvsc_packet *packet;
-       int i;
        int ret;
-       int num_frags;
-       int retries = 0;
+       unsigned int i, num_pages;
  
        DPRINT_ENTER(NETVSC_DRV);
  
-       /* Support only 1 chain of frags */
-       ASSERT(skb_shinfo(skb)->frag_list == NULL);
-       ASSERT(skb->dev == net);
        DPRINT_DBG(NETVSC_DRV, "xmit packet - len %d data_len %d",
                   skb->len, skb->data_len);
  
-       /* Add 1 for skb->data and any additional ones requested */
-       num_frags = skb_shinfo(skb)->nr_frags + 1 +
-                   net_drv_obj->AdditionalRequestPageBufferCount;
+       /* Add 1 for skb->data and additional one for RNDIS */
+       num_pages = skb_shinfo(skb)->nr_frags + 1 + 1;
+       if (num_pages > net_device_ctx->avail)
+               return NETDEV_TX_BUSY;
  
        /* Allocate a netvsc packet based on # of frags. */
        packet = kzalloc(sizeof(struct hv_netvsc_packet) +
-                        (num_frags * sizeof(struct hv_page_buffer)) +
+                        (num_pages * sizeof(struct hv_page_buffer)) +
                         net_drv_obj->RequestExtSize, GFP_ATOMIC);
        if (!packet) {
+               /* out of memory, silently drop packet */
                DPRINT_ERR(NETVSC_DRV, "unable to allocate hv_netvsc_packet");
-               return -1;
+               dev_kfree_skb(skb);
+               net->stats.tx_dropped++;
+               return NETDEV_TX_OK;
        }
  
        packet->Extension = (void *)(unsigned long)packet +
                                sizeof(struct hv_netvsc_packet) +
-                                   (num_frags * sizeof(struct hv_page_buffer));
+                                   (num_pages * sizeof(struct hv_page_buffer));
  
        /* Setup the rndis header */
-       packet->PageBufferCount = num_frags;
+       packet->PageBufferCount = num_pages;
  
        /* TODO: Flush all write buffers/ memory fence ??? */
        /* wmb(); */
  
        /* Initialize it from the skb */
-       ASSERT(skb->data);
        packet->TotalDataBufferLength   = skb->len;
  
-       /*
-        * Start filling in the page buffers starting at
-        * AdditionalRequestPageBufferCount offset
-        */
-       packet->PageBuffers[net_drv_obj->AdditionalRequestPageBufferCount].Pfn = virt_to_phys(skb->data) >> PAGE_SHIFT;
-       packet->PageBuffers[net_drv_obj->AdditionalRequestPageBufferCount].Offset = (unsigned long)skb->data & (PAGE_SIZE - 1);
-       packet->PageBuffers[net_drv_obj->AdditionalRequestPageBufferCount].Length = skb->len - skb->data_len;
-       ASSERT((skb->len - skb->data_len) <= PAGE_SIZE);
-       for (i = net_drv_obj->AdditionalRequestPageBufferCount + 1;
-            i < num_frags; i++) {
-               packet->PageBuffers[i].Pfn =
-                       page_to_pfn(skb_shinfo(skb)->frags[i-(net_drv_obj->AdditionalRequestPageBufferCount+1)].page);
-               packet->PageBuffers[i].Offset =
-                       skb_shinfo(skb)->frags[i-(net_drv_obj->AdditionalRequestPageBufferCount+1)].page_offset;
-               packet->PageBuffers[i].Length =
-                       skb_shinfo(skb)->frags[i-(net_drv_obj->AdditionalRequestPageBufferCount+1)].size;
+       /* Start filling in the page buffers starting after RNDIS buffer. */
+       packet->PageBuffers[1].Pfn = virt_to_phys(skb->data) >> PAGE_SHIFT;
+       packet->PageBuffers[1].Offset
+               = (unsigned long)skb->data & (PAGE_SIZE - 1);
+       packet->PageBuffers[1].Length = skb_headlen(skb);
+       /* Additional fragments are after SKB data */
+       for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
+               skb_frag_t *f = &skb_shinfo(skb)->frags[i];
+               packet->PageBuffers[i+2].Pfn = page_to_pfn(f->page);
+               packet->PageBuffers[i+2].Offset = f->page_offset;
+               packet->PageBuffers[i+2].Length = f->size;
        }
  
        /* Set the completion routine */
        packet->Completion.Send.SendCompletionContext = packet;
        packet->Completion.Send.SendCompletionTid = (unsigned long)skb;
  
- retry_send:
        ret = net_drv_obj->OnSend(&net_device_ctx->device_ctx->device_obj,
                                  packet);
        if (ret == 0) {
-               ret = NETDEV_TX_OK;
-               net_device_ctx->stats.tx_bytes += skb->len;
-               net_device_ctx->stats.tx_packets++;
-       } else {
-               retries++;
-               if (retries < 4) {
-                       DPRINT_ERR(NETVSC_DRV, "unable to send..."
-                                       "retrying %d...", retries);
-                       udelay(100);
-                       goto retry_send;
-               }
-               /* no more room or we are shutting down */
-               DPRINT_ERR(NETVSC_DRV, "unable to send (%d)..."
-                          "marking net device (%p) busy", ret, net);
-               DPRINT_INFO(NETVSC_DRV, "net device (%p) stopping", net);
+               net->stats.tx_bytes += skb->len;
+               net->stats.tx_packets++;
  
-               ret = NETDEV_TX_BUSY;
-               net_device_ctx->stats.tx_dropped++;
+               DPRINT_DBG(NETVSC_DRV, "# of xmits %lu total size %lu",
+                          net->stats.tx_packets,
+                          net->stats.tx_bytes);
  
-               netif_stop_queue(net);
-               /*
-                * Null it since the caller will free it instead of the
-                * completion routine
-                */
-               packet->Completion.Send.SendCompletionTid = 0;
-               /*
-                * Release the resources since we will not get any send
-                * completion
-                */
-               netvsc_xmit_completion((void *)packet);
+               if ((net_device_ctx->avail -= num_pages) < PACKET_PAGES_LOWATER)
+                       netif_stop_queue(net);
+       } else {
+               /* we are shutting down or bus overloaded, just drop packet */
+               net->stats.tx_dropped++;
+               netvsc_xmit_completion(packet);
        }
  
-       DPRINT_DBG(NETVSC_DRV, "# of xmits %lu total size %lu",
-                  net_device_ctx->stats.tx_packets,
-                  net_device_ctx->stats.tx_bytes);
        DPRINT_EXIT(NETVSC_DRV);
-       return ret;
+       return NETDEV_TX_OK;
  }
  
- /**
+ /*
   * netvsc_linkstatus_callback - Link up/down notification
   */
  static void netvsc_linkstatus_callback(struct hv_device *device_obj,
        DPRINT_EXIT(NETVSC_DRV);
  }
  
- /**
-  * netvsc_recv_callback -  Callback when we receive a packet from the "wire" on the specified device.
+ /*
+  * netvsc_recv_callback -  Callback when we receive a packet from the
+  * "wire" on the specified device.
   */
  static int netvsc_recv_callback(struct hv_device *device_obj,
                                struct hv_netvsc_packet *packet)
  {
        struct vm_device *device_ctx = to_vm_device(device_obj);
        struct net_device *net = dev_get_drvdata(&device_ctx->device);
-       struct net_device_context *net_device_ctx;
        struct sk_buff *skb;
        void *data;
-       int ret;
        int i;
        unsigned long flags;
  
                return 0;
        }
  
-       net_device_ctx = netdev_priv(net);
-       /* Allocate a skb - TODO preallocate this */
-       /* Pad 2-bytes to align IP header to 16 bytes */
-       skb = dev_alloc_skb(packet->TotalDataBufferLength + 2);
-       ASSERT(skb);
-       skb_reserve(skb, 2);
-       skb->dev = net;
+       /* Allocate a skb - TODO direct I/O to pages? */
+       skb = netdev_alloc_skb_ip_align(net, packet->TotalDataBufferLength);
+       if (unlikely(!skb)) {
+               ++net->stats.rx_dropped;
+               return 0;
+       }
  
        /* for kmap_atomic */
        local_irq_save(flags);
        local_irq_restore(flags);
  
        skb->protocol = eth_type_trans(skb, net);
        skb->ip_summed = CHECKSUM_NONE;
  
+       net->stats.rx_packets++;
+       net->stats.rx_bytes += skb->len;
        /*
         * Pass the skb back up. Network stack will deallocate the skb when it
-        * is done
+        * is done.
+        * TODO - use NAPI?
         */
-       ret = netif_rx(skb);
-       switch (ret) {
-       case NET_RX_DROP:
-               net_device_ctx->stats.rx_dropped++;
-               break;
-       default:
-               net_device_ctx->stats.rx_packets++;
-               net_device_ctx->stats.rx_bytes += skb->len;
-               break;
+       netif_rx(skb);
  
-       }
        DPRINT_DBG(NETVSC_DRV, "# of recvs %lu total size %lu",
-                  net_device_ctx->stats.rx_packets,
-                  net_device_ctx->stats.rx_bytes);
+                  net->stats.rx_packets, net->stats.rx_bytes);
  
        DPRINT_EXIT(NETVSC_DRV);
  
        return 0;
  }
  
+ static void netvsc_get_drvinfo(struct net_device *net,
+                              struct ethtool_drvinfo *info)
+ {
+       strcpy(info->driver, "hv_netvsc");
+       strcpy(info->version, HV_DRV_VERSION);
+       strcpy(info->fw_version, "N/A");
+ }
+ static const struct ethtool_ops ethtool_ops = {
+       .get_drvinfo    = netvsc_get_drvinfo,
+       .get_sg         = ethtool_op_get_sg,
+       .set_sg         = ethtool_op_set_sg,
+       .get_link       = ethtool_op_get_link,
+ };
  static const struct net_device_ops device_ops = {
        .ndo_open =                     netvsc_open,
        .ndo_stop =                     netvsc_close,
        .ndo_start_xmit =               netvsc_start_xmit,
-       .ndo_get_stats =                netvsc_get_stats,
        .ndo_set_multicast_list =       netvsc_set_multicast_list,
  };
  
@@@ -403,7 -369,8 +369,7 @@@ static int netvsc_probe(struct device *
        if (!net_drv_obj->Base.OnDeviceAdd)
                return -1;
  
 -      net = alloc_netdev(sizeof(struct net_device_context), "seth%d",
 -                         ether_setup);
 +      net = alloc_etherdev(sizeof(struct net_device_context));
        if (!net)
                return -1;
  
  
        net_device_ctx = netdev_priv(net);
        net_device_ctx->device_ctx = device_ctx;
+       net_device_ctx->avail = ring_size;
        dev_set_drvdata(device, net);
  
        /* Notify the netvsc driver of the new device */
  
        net->netdev_ops = &device_ops;
  
+       /* TODO: Add GSO and Checksum offload */
+       net->features = NETIF_F_SG;
+       SET_ETHTOOL_OPS(net, &ethtool_ops);
        SET_NETDEV_DEV(net, device);
  
        ret = register_netdev(net);
@@@ -559,7 -531,7 +530,7 @@@ static int netvsc_drv_init(int (*drv_in
  
        vmbus_get_interface(&net_drv_obj->Base.VmbusChannelInterface);
  
-       net_drv_obj->RingBufferSize = netvsc_ringbuffer_size;
+       net_drv_obj->RingBufferSize = ring_size * PAGE_SIZE;
        net_drv_obj->OnReceiveCallback = netvsc_recv_callback;
        net_drv_obj->OnLinkStatusChanged = netvsc_linkstatus_callback;
  
        return ret;
  }
  
+ static const struct dmi_system_id __initconst
+ hv_netvsc_dmi_table[] __maybe_unused  = {
+       {
+               .ident = "Hyper-V",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
+                       DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
+               },
+       },
+       { },
+ };
+ MODULE_DEVICE_TABLE(dmi, hv_netvsc_dmi_table);
  static int __init netvsc_init(void)
  {
        int ret;
        DPRINT_ENTER(NETVSC_DRV);
        DPRINT_INFO(NETVSC_DRV, "Netvsc initializing....");
  
+       if (!dmi_check_system(hv_netvsc_dmi_table))
+               return -ENODEV;
        ret = netvsc_drv_init(NetVscInitialize);
  
        DPRINT_EXIT(NETVSC_DRV);
@@@ -602,9 -591,16 +590,16 @@@ static void __exit netvsc_exit(void
        DPRINT_EXIT(NETVSC_DRV);
  }
  
+ static const struct pci_device_id __initconst
+ hv_netvsc_pci_table[] __maybe_unused = {
+       { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
+       { 0 }
+ };
+ MODULE_DEVICE_TABLE(pci, hv_netvsc_pci_table);
  MODULE_LICENSE("GPL");
  MODULE_VERSION(HV_DRV_VERSION);
module_param(netvsc_ringbuffer_size, int, S_IRUGO);
MODULE_DESCRIPTION("Microsoft Hyper-V network driver");
  
  module_init(netvsc_init);
  module_exit(netvsc_exit);
  #include <linux/highmem.h>
  #include <linux/slab.h>
  #include <linux/io.h>
+ #include <linux/if_ether.h>
  #include "osd.h"
  #include "logging.h"
- #include "NetVscApi.h"
- #include "RndisFilter.h"
+ #include "netvsc_api.h"
+ #include "rndis_filter.h"
  
  /* Data types */
  struct rndis_filter_driver_object {
@@@ -50,7 -52,7 +52,7 @@@ struct rndis_device 
        spinlock_t request_lock;
        struct list_head RequestList;
  
-       unsigned char HwMacAddr[HW_MACADDR_LEN];
+       unsigned char HwMacAddr[ETH_ALEN];
  };
  
  struct rndis_request {
@@@ -354,8 -356,8 +356,8 @@@ static void RndisFilterReceiveData(stru
        DPRINT_ENTER(NETVSC);
  
        /* empty ethernet frame ?? */
-       ASSERT(Packet->PageBuffers[0].Length >
-               RNDIS_MESSAGE_SIZE(struct rndis_packet));
+       /* ASSERT(Packet->PageBuffers[0].Length > */
+       /*      RNDIS_MESSAGE_SIZE(struct rndis_packet)); */
  
        rndisPacket = &Message->Message.Packet;
  
@@@ -389,7 -391,9 +391,9 @@@ static int RndisFilterOnReceive(struct 
  
        DPRINT_ENTER(NETVSC);
  
-       ASSERT(netDevice);
+       if (!netDevice)
+               return -EINVAL;
        /* Make sure the rndis device state is initialized */
        if (!netDevice->Extension) {
                DPRINT_ERR(NETVSC, "got rndis message but no rndis device..."
@@@ -490,7 -494,8 +494,8 @@@ static int RndisFilterQueryDevice(struc
  
        DPRINT_ENTER(NETVSC);
  
-       ASSERT(Result);
+       if (!Result)
+               return -EINVAL;
  
        *ResultSize = 0;
        request = GetRndisRequest(Device, REMOTE_NDIS_QUERY_MSG,
@@@ -538,7 -543,7 +543,7 @@@ Cleanup
  
  static int RndisFilterQueryDeviceMac(struct rndis_device *Device)
  {
-       u32 size = HW_MACADDR_LEN;
+       u32 size = ETH_ALEN;
  
        return RndisFilterQueryDevice(Device,
                                      RNDIS_OID_802_3_PERMANENT_ADDRESS,
@@@ -565,8 -570,8 +570,8 @@@ static int RndisFilterSetPacketFilter(s
  
        DPRINT_ENTER(NETVSC);
  
-       ASSERT(RNDIS_MESSAGE_SIZE(struct rndis_set_request) + sizeof(u32) <=
-               sizeof(struct rndis_message));
+       /* ASSERT(RNDIS_MESSAGE_SIZE(struct rndis_set_request) + sizeof(u32) <= */
+       /*      sizeof(struct rndis_message)); */
  
        request = GetRndisRequest(Device, REMOTE_NDIS_SET_MSG,
                        RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
@@@ -622,7 -627,6 +627,6 @@@ int RndisFilterInit(struct netvsc_drive
                   sizeof(struct rndis_filter_packet));
  
        Driver->RequestExtSize = sizeof(struct rndis_filter_packet);
-       Driver->AdditionalRequestPageBufferCount = 1; /* For rndis header */
  
        /* Driver->Context = rndisDriver; */
  
                                        Driver->Base.OnDeviceRemove;
        gRndisFilter.InnerDriver.Base.OnCleanup = Driver->Base.OnCleanup;
  
-       ASSERT(Driver->OnSend);
-       ASSERT(Driver->OnReceiveCallback);
+       /* ASSERT(Driver->OnSend); */
+       /* ASSERT(Driver->OnReceiveCallback); */
        gRndisFilter.InnerDriver.OnSend = Driver->OnSend;
        gRndisFilter.InnerDriver.OnReceiveCallback = Driver->OnReceiveCallback;
        gRndisFilter.InnerDriver.OnLinkStatusChanged =
@@@ -751,7 -755,6 +755,7 @@@ static int RndisFilterOpenDevice(struc
  
        ret = RndisFilterSetPacketFilter(Device,
                                         NDIS_PACKET_TYPE_BROADCAST |
 +                                       NDIS_PACKET_TYPE_ALL_MULTICAST |
                                         NDIS_PACKET_TYPE_DIRECTED);
        if (ret == 0)
                Device->State = RNDIS_DEV_DATAINITIALIZED;
@@@ -811,8 -814,8 +815,8 @@@ static int RndisFilterOnDeviceAdd(struc
  
        /* Initialize the rndis device */
        netDevice = Device->Extension;
-       ASSERT(netDevice);
-       ASSERT(netDevice->Device);
+       /* ASSERT(netDevice); */
+       /* ASSERT(netDevice->Device); */
  
        netDevice->Extension = rndisDevice;
        rndisDevice->NetDevice = netDevice;
                 */
        }
  
-       DPRINT_INFO(NETVSC, "Device 0x%p mac addr %02x%02x%02x%02x%02x%02x",
-                   rndisDevice,
-                   rndisDevice->HwMacAddr[0],
-                   rndisDevice->HwMacAddr[1],
-                   rndisDevice->HwMacAddr[2],
-                   rndisDevice->HwMacAddr[3],
-                   rndisDevice->HwMacAddr[4],
-                   rndisDevice->HwMacAddr[5]);
+       DPRINT_INFO(NETVSC, "Device 0x%p mac addr %pM",
+                   rndisDevice, rndisDevice->HwMacAddr);
  
-       memcpy(deviceInfo->MacAddr, rndisDevice->HwMacAddr, HW_MACADDR_LEN);
+       memcpy(deviceInfo->MacAddr, rndisDevice->HwMacAddr, ETH_ALEN);
  
        RndisFilterQueryDeviceLinkStatus(rndisDevice);
  
@@@ -891,7 -888,9 +889,9 @@@ int RndisFilterOnOpen(struct hv_device 
  
        DPRINT_ENTER(NETVSC);
  
-       ASSERT(netDevice);
+       if (!netDevice)
+               return -EINVAL;
        ret = RndisFilterOpenDevice(netDevice->Extension);
  
        DPRINT_EXIT(NETVSC);
@@@ -906,7 -905,9 +906,9 @@@ int RndisFilterOnClose(struct hv_devic
  
        DPRINT_ENTER(NETVSC);
  
-       ASSERT(netDevice);
+       if (!netDevice)
+               return -EINVAL;
        ret = RndisFilterCloseDevice(netDevice->Extension);
  
        DPRINT_EXIT(NETVSC);
@@@ -927,7 -928,7 +929,7 @@@ static int RndisFilterOnSend(struct hv_
  
        /* Add the rndis header */
        filterPacket = (struct rndis_filter_packet *)Packet->Extension;
-       ASSERT(filterPacket);
+       /* ASSERT(filterPacket); */
  
        memset(filterPacket, 0, sizeof(struct rndis_filter_packet));
  
@@@ -75,16 -75,16 +75,16 @@@ error_ret
        return ret;
  
  }
- static IIO_SCAN_EL_C(accel_x, LIS3L02DQ_SCAN_ACC_X, IIO_SIGNED(16),
+ static IIO_SCAN_EL_C(accel_x, 0, IIO_SIGNED(16),
                     LIS3L02DQ_REG_OUT_X_L_ADDR,
                     &lis3l02dq_scan_el_set_state);
- static IIO_SCAN_EL_C(accel_y, LIS3L02DQ_SCAN_ACC_Y, IIO_SIGNED(16),
+ static IIO_SCAN_EL_C(accel_y, 1, IIO_SIGNED(16),
                     LIS3L02DQ_REG_OUT_Y_L_ADDR,
                     &lis3l02dq_scan_el_set_state);
- static IIO_SCAN_EL_C(accel_z, LIS3L02DQ_SCAN_ACC_Z, IIO_SIGNED(16),
+ static IIO_SCAN_EL_C(accel_z, 2, IIO_SIGNED(16),
                     LIS3L02DQ_REG_OUT_Z_L_ADDR,
                     &lis3l02dq_scan_el_set_state);
- static IIO_SCAN_EL_TIMESTAMP;
+ static IIO_SCAN_EL_TIMESTAMP(3);
  
  static struct attribute *lis3l02dq_scan_el_attrs[] = {
        &iio_scan_el_accel_x.dev_attr.attr,
@@@ -192,8 -192,7 +192,7 @@@ error_ret
  
  }
  
- static const u8 read_all_tx_array[] =
- {
+ static const u8 read_all_tx_array[] = {
        LIS3L02DQ_READ_REG(LIS3L02DQ_REG_OUT_X_L_ADDR), 0,
        LIS3L02DQ_READ_REG(LIS3L02DQ_REG_OUT_X_H_ADDR), 0,
        LIS3L02DQ_READ_REG(LIS3L02DQ_REG_OUT_Y_L_ADDR), 0,
   * @rx_array: (dma capable) recieve array, must be at least
   *            4*number of channels
   **/
- int lis3l02dq_read_all(struct lis3l02dq_state *st, u8 *rx_array)
static int lis3l02dq_read_all(struct lis3l02dq_state *st, u8 *rx_array)
  {
        struct spi_transfer *xfers;
        struct spi_message msg;
@@@ -358,10 -357,10 +357,10 @@@ static int lis3l02dq_data_rdy_ring_pred
  
  
  /* Caller responsible for locking as necessary. */
- static int __lis3l02dq_write_data_ready_config(struct device *dev,
-                                              struct
-                                              iio_event_handler_list *list,
-                                              bool state)
+ static int
+ __lis3l02dq_write_data_ready_config(struct device *dev,
+                                   struct iio_event_handler_list *list,
+                                   bool state)
  {
        int ret;
        u8 valold;
@@@ -493,9 -492,6 +492,9 @@@ int lis3l02dq_probe_trigger(struct iio_
        struct lis3l02dq_state *state = indio_dev->dev_data;
  
        state->trig = iio_allocate_trigger();
 +      if (!state->trig)
 +              return -ENOMEM;
 +
        state->trig->name = kmalloc(IIO_TRIGGER_NAME_LENGTH, GFP_KERNEL);
        if (!state->trig->name) {
                ret = -ENOMEM;
@@@ -584,7 -580,7 +583,7 @@@ error_iio_sw_rb_free
  
  int lis3l02dq_initialize_ring(struct iio_ring_buffer *ring)
  {
-       return iio_ring_buffer_register(ring);
+       return iio_ring_buffer_register(ring, 0);
  }
  
  void lis3l02dq_uninitialize_ring(struct iio_ring_buffer *ring)
        iio_ring_buffer_unregister(ring);
  }
  
  int lis3l02dq_set_ring_length(struct iio_dev *indio_dev, int length)
  {
        /* Set sensible defaults for the ring buffer */
@@@ -1,27 -1,26 +1,26 @@@
   /*
-  * linux/drivers/industrialio/adc/max1363.c
-  * Copyright (C) 2008 Jonathan Cameron
-  *
-  * based on linux/drivers/i2c/chips/max123x
-  * Copyright (C) 2002-2004 Stefan Eletzhofer
-  *
-  * based on linux/drivers/acron/char/pcf8583.c
-  * Copyright (C) 2000 Russell King
-  *
-  * This program is free software; you can redistribute it and/or modify
-  * it under the terms of the GNU General Public License version 2 as
-  * published by the Free Software Foundation.
-  *
-  * max1363.c
-  *
-  * Partial support for max1363 and similar chips.
-  *
-  * Not currently implemented.
-  *
-  * - Monitor interrrupt generation.
-  * - Control of internal reference.
-  * - Sysfs scan interface currently assumes unipolar mode.
-  */
+   * iio/adc/max1363.c
+   * Copyright (C) 2008-2010 Jonathan Cameron
+   *
+   * based on linux/drivers/i2c/chips/max123x
+   * Copyright (C) 2002-2004 Stefan Eletzhofer
+   *
+   * based on linux/drivers/acron/char/pcf8583.c
+   * Copyright (C) 2000 Russell King
+   *
+   * This program is free software; you can redistribute it and/or modify
+   * it under the terms of the GNU General Public License version 2 as
+   * published by the Free Software Foundation.
+   *
+   * max1363.c
+   *
+   * Partial support for max1363 and similar chips.
+   *
+   * Not currently implemented.
+   *
+   * - Monitor interrrupt generation.
+   * - Control of internal reference.
+   */
  
  #include <linux/interrupt.h>
  #include <linux/gpio.h>
  #include "../iio.h"
  #include "../sysfs.h"
  
+ #include "../ring_generic.h"
+ #include "adc.h"
  #include "max1363.h"
  
- /* Available scan modes.
-  * Awkwardly the associated enum is in the header so it is available to
-  * the ring buffer code.
-  */
- static const struct  max1363_mode max1363_mode_table[] = {
-       MAX1363_MODE_SINGLE(0),
-       MAX1363_MODE_SINGLE(1),
-       MAX1363_MODE_SINGLE(2),
-       MAX1363_MODE_SINGLE(3),
-       MAX1363_MODE_SINGLE(4),
-       MAX1363_MODE_SINGLE(5),
-       MAX1363_MODE_SINGLE(6),
-       MAX1363_MODE_SINGLE(7),
-       MAX1363_MODE_SINGLE(8),
-       MAX1363_MODE_SINGLE(9),
-       MAX1363_MODE_SINGLE(10),
-       MAX1363_MODE_SINGLE(11),
-       MAX1363_MODE_SINGLE_TIMES_8(0),
-       MAX1363_MODE_SINGLE_TIMES_8(1),
-       MAX1363_MODE_SINGLE_TIMES_8(2),
-       MAX1363_MODE_SINGLE_TIMES_8(3),
-       MAX1363_MODE_SINGLE_TIMES_8(4),
-       MAX1363_MODE_SINGLE_TIMES_8(5),
-       MAX1363_MODE_SINGLE_TIMES_8(6),
-       MAX1363_MODE_SINGLE_TIMES_8(7),
-       MAX1363_MODE_SINGLE_TIMES_8(8),
-       MAX1363_MODE_SINGLE_TIMES_8(9),
-       MAX1363_MODE_SINGLE_TIMES_8(10),
-       MAX1363_MODE_SINGLE_TIMES_8(11),
-       MAX1363_MODE_SCAN_TO_CHANNEL(1),
-       MAX1363_MODE_SCAN_TO_CHANNEL(2),
-       MAX1363_MODE_SCAN_TO_CHANNEL(3),
-       MAX1363_MODE_SCAN_TO_CHANNEL(4),
-       MAX1363_MODE_SCAN_TO_CHANNEL(5),
-       MAX1363_MODE_SCAN_TO_CHANNEL(6),
-       MAX1363_MODE_SCAN_TO_CHANNEL(7),
-       MAX1363_MODE_SCAN_TO_CHANNEL(8),
-       MAX1363_MODE_SCAN_TO_CHANNEL(9),
-       MAX1363_MODE_SCAN_TO_CHANNEL(10),
-       MAX1363_MODE_SCAN_TO_CHANNEL(11),
-       MAX1363_MODE_DIFF_SINGLE(0, 1),
-       MAX1363_MODE_DIFF_SINGLE(2, 3),
-       MAX1363_MODE_DIFF_SINGLE(4, 5),
-       MAX1363_MODE_DIFF_SINGLE(6, 7),
-       MAX1363_MODE_DIFF_SINGLE(8, 9),
-       MAX1363_MODE_DIFF_SINGLE(10, 11),
-       MAX1363_MODE_DIFF_SINGLE(1, 0),
-       MAX1363_MODE_DIFF_SINGLE(3, 2),
-       MAX1363_MODE_DIFF_SINGLE(5, 4),
-       MAX1363_MODE_DIFF_SINGLE(7, 6),
-       MAX1363_MODE_DIFF_SINGLE(9, 8),
-       MAX1363_MODE_DIFF_SINGLE(11, 10),
-       MAX1363_MODE_DIFF_SINGLE_TIMES_8(0, 1),
-       MAX1363_MODE_DIFF_SINGLE_TIMES_8(2, 3),
-       MAX1363_MODE_DIFF_SINGLE_TIMES_8(4, 5),
-       MAX1363_MODE_DIFF_SINGLE_TIMES_8(6, 7),
-       MAX1363_MODE_DIFF_SINGLE_TIMES_8(8, 9),
-       MAX1363_MODE_DIFF_SINGLE_TIMES_8(10, 11),
-       MAX1363_MODE_DIFF_SINGLE_TIMES_8(1, 0),
-       MAX1363_MODE_DIFF_SINGLE_TIMES_8(3, 2),
-       MAX1363_MODE_DIFF_SINGLE_TIMES_8(5, 4),
-       MAX1363_MODE_DIFF_SINGLE_TIMES_8(7, 6),
-       MAX1363_MODE_DIFF_SINGLE_TIMES_8(9, 8),
-       MAX1363_MODE_DIFF_SINGLE_TIMES_8(11, 10),
-       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL_NAMED(0-1...2-3, 2, 2),
-       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL_NAMED(0-1...4-5, 4, 3),
-       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL_NAMED(0-1...6-7, 6, 4),
-       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL_NAMED(0-1...8-9, 8, 5),
-       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL_NAMED(0-1...10-11, 10, 6),
-       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL_NAMED(1-0...3-2, 3, 2),
-       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL_NAMED(1-0...5-4, 5, 3),
-       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL_NAMED(1-0...7-6, 7, 4),
-       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL_NAMED(1-0...9-8, 9, 5),
-       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL_NAMED(1-0...11-10, 11, 6),
-       MAX1236_MODE_SCAN_MID_TO_CHANNEL(2, 3),
-       MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 7),
-       MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 8),
-       MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 9),
-       MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 10),
-       MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 11),
-       MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL_NAMED(6-7...8-9, 8, 2),
-       MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL_NAMED(6-7...10-11, 10, 3),
-       MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL_NAMED(7-6...9-8, 9, 2),
-       MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL_NAMED(7-6...11-10, 11, 3),
+ /* Here we claim all are 16 bits. This currently does no harm and saves
+  * us a lot of scan element listings */
+ #define MAX1363_SCAN_EL(number)                                               \
+       IIO_SCAN_EL_C(in##number, number, IIO_UNSIGNED(16), 0, NULL);
+ #define MAX1363_SCAN_EL_D(p, n, number)                                       \
+       IIO_SCAN_NAMED_EL_C(in##p##m##in##n, in##p-in##n,               \
+                       number, IIO_SIGNED(16), 0 , NULL);
+ static MAX1363_SCAN_EL(0);
+ static MAX1363_SCAN_EL(1);
+ static MAX1363_SCAN_EL(2);
+ static MAX1363_SCAN_EL(3);
+ static MAX1363_SCAN_EL(4);
+ static MAX1363_SCAN_EL(5);
+ static MAX1363_SCAN_EL(6);
+ static MAX1363_SCAN_EL(7);
+ static MAX1363_SCAN_EL(8);
+ static MAX1363_SCAN_EL(9);
+ static MAX1363_SCAN_EL(10);
+ static MAX1363_SCAN_EL(11);
+ static MAX1363_SCAN_EL_D(0, 1, 12);
+ static MAX1363_SCAN_EL_D(2, 3, 13);
+ static MAX1363_SCAN_EL_D(4, 5, 14);
+ static MAX1363_SCAN_EL_D(6, 7, 15);
+ static MAX1363_SCAN_EL_D(8, 9, 16);
+ static MAX1363_SCAN_EL_D(10, 11, 17);
+ static MAX1363_SCAN_EL_D(1, 0, 18);
+ static MAX1363_SCAN_EL_D(3, 2, 19);
+ static MAX1363_SCAN_EL_D(5, 4, 20);
+ static MAX1363_SCAN_EL_D(7, 6, 21);
+ static MAX1363_SCAN_EL_D(9, 8, 22);
+ static MAX1363_SCAN_EL_D(11, 10, 23);
+ static const struct max1363_mode max1363_mode_table[] = {
+       /* All of the single channel options first */
+       MAX1363_MODE_SINGLE(0, 1 << 0),
+       MAX1363_MODE_SINGLE(1, 1 << 1),
+       MAX1363_MODE_SINGLE(2, 1 << 2),
+       MAX1363_MODE_SINGLE(3, 1 << 3),
+       MAX1363_MODE_SINGLE(4, 1 << 4),
+       MAX1363_MODE_SINGLE(5, 1 << 5),
+       MAX1363_MODE_SINGLE(6, 1 << 6),
+       MAX1363_MODE_SINGLE(7, 1 << 7),
+       MAX1363_MODE_SINGLE(8, 1 << 8),
+       MAX1363_MODE_SINGLE(9, 1 << 9),
+       MAX1363_MODE_SINGLE(10, 1 << 10),
+       MAX1363_MODE_SINGLE(11, 1 << 11),
+       MAX1363_MODE_DIFF_SINGLE(0, 1, 1 << 12),
+       MAX1363_MODE_DIFF_SINGLE(2, 3, 1 << 13),
+       MAX1363_MODE_DIFF_SINGLE(4, 5, 1 << 14),
+       MAX1363_MODE_DIFF_SINGLE(6, 7, 1 << 15),
+       MAX1363_MODE_DIFF_SINGLE(8, 9, 1 << 16),
+       MAX1363_MODE_DIFF_SINGLE(10, 11, 1 << 17),
+       MAX1363_MODE_DIFF_SINGLE(1, 0, 1 << 18),
+       MAX1363_MODE_DIFF_SINGLE(3, 2, 1 << 19),
+       MAX1363_MODE_DIFF_SINGLE(5, 4, 1 << 20),
+       MAX1363_MODE_DIFF_SINGLE(7, 6, 1 << 21),
+       MAX1363_MODE_DIFF_SINGLE(9, 8, 1 << 22),
+       MAX1363_MODE_DIFF_SINGLE(11, 10, 1 << 23),
+       /* The multichannel scans next */
+       MAX1363_MODE_SCAN_TO_CHANNEL(1, 0x003),
+       MAX1363_MODE_SCAN_TO_CHANNEL(2, 0x007),
+       MAX1236_MODE_SCAN_MID_TO_CHANNEL(2, 3, 0x00C),
+       MAX1363_MODE_SCAN_TO_CHANNEL(3, 0x00F),
+       MAX1363_MODE_SCAN_TO_CHANNEL(4, 0x01F),
+       MAX1363_MODE_SCAN_TO_CHANNEL(5, 0x03F),
+       MAX1363_MODE_SCAN_TO_CHANNEL(6, 0x07F),
+       MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 7, 0x0C0),
+       MAX1363_MODE_SCAN_TO_CHANNEL(7, 0x0FF),
+       MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 8, 0x1C0),
+       MAX1363_MODE_SCAN_TO_CHANNEL(8, 0x1FF),
+       MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 9, 0x3C0),
+       MAX1363_MODE_SCAN_TO_CHANNEL(9, 0x3FF),
+       MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 10, 0x7C0),
+       MAX1363_MODE_SCAN_TO_CHANNEL(10, 0x7FF),
+       MAX1236_MODE_SCAN_MID_TO_CHANNEL(6, 11, 0xFC0),
+       MAX1363_MODE_SCAN_TO_CHANNEL(11, 0xFFF),
+       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(2, 2, 0x003000),
+       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(4, 3, 0x007000),
+       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(6, 4, 0x00F000),
+       MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL(8, 2, 0x018000),
+       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(8, 5, 0x01F000),
+       MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL(10, 3, 0x038000),
+       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(10, 6, 0x3F000),
+       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(3, 2, 0x0C0000),
+       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(5, 3, 0x1C0000),
+       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(7, 4, 0x3C0000),
+       MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL(9, 2, 0x600000),
+       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(9, 5, 0x7C0000),
+       MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL(11, 3, 0xE00000),
+       MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(11, 6, 0xFC0000),
  };
  
+ const struct max1363_mode
+ *max1363_match_mode(u32 mask, const struct max1363_chip_info *ci)
+ {
+       int i;
+       if (mask)
+               for (i = 0; i < ci->num_modes; i++)
+                       if (!((~max1363_mode_table[ci->mode_list[i]].modemask) &
+                             mask))
+                               return &max1363_mode_table[ci->mode_list[i]];
+       return NULL;
+ };
+ static ssize_t max1363_show_precision(struct device *dev,
+                               struct device_attribute *attr,
+                               char *buf)
+ {
+       struct iio_dev *dev_info = dev_get_drvdata(dev);
+       struct max1363_state *st = iio_dev_get_devdata(dev_info);
+       return sprintf(buf, "%d\n", st->chip_info->bits);
+ }
+ static IIO_DEVICE_ATTR(in_precision, S_IRUGO, max1363_show_precision,
+                      NULL, 0);
+ static int max1363_write_basic_config(struct i2c_client *client,
+                                     unsigned char d1,
+                                     unsigned char d2)
+ {
+       int ret;
+       u8 *tx_buf = kmalloc(2 , GFP_KERNEL);
+       if (!tx_buf)
+               return -ENOMEM;
+       tx_buf[0] = d1;
+       tx_buf[1] = d2;
+       ret = i2c_master_send(client, tx_buf, 2);
+       kfree(tx_buf);
+       return (ret > 0) ? 0 : ret;
+ }
+ int max1363_set_scan_mode(struct max1363_state *st)
+ {
+       st->configbyte &= ~(MAX1363_CHANNEL_SEL_MASK
+                           | MAX1363_SCAN_MASK
+                           | MAX1363_SE_DE_MASK);
+       st->configbyte |= st->current_mode->conf;
+       return max1363_write_basic_config(st->client,
+                                         st->setupbyte,
+                                         st->configbyte);
+ }
+ static ssize_t max1363_read_single_channel(struct device *dev,
+                                  struct device_attribute *attr,
+                                  char *buf)
+ {
+       struct iio_dev *dev_info = dev_get_drvdata(dev);
+       struct max1363_state *st = iio_dev_get_devdata(dev_info);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       struct i2c_client *client = st->client;
+       int ret = 0, len = 0;
+       s32 data ;
+       char rxbuf[2];
+       long mask;
+       mutex_lock(&dev_info->mlock);
+       /* If ring buffer capture is occuring, query the buffer */
+       if (iio_ring_enabled(dev_info)) {
+               mask = max1363_mode_table[this_attr->address].modemask;
+               data = max1363_single_channel_from_ring(mask, st);
+               if (data < 0) {
+                       ret = data;
+                       goto error_ret;
+               }
+       } else {
+               /* Check to see if current scan mode is correct */
+               if (st->current_mode !=
+                   &max1363_mode_table[this_attr->address]) {
+                       /* Update scan mode if needed */
+                       st->current_mode
+                               = &max1363_mode_table[this_attr->address];
+                       ret = max1363_set_scan_mode(st);
+                       if (ret)
+                               goto error_ret;
+               }
+               if (st->chip_info->bits != 8) {
+                       /* Get reading */
+                       data = i2c_master_recv(client, rxbuf, 2);
+                       if (data < 0) {
+                               ret = data;
+                               goto error_ret;
+                       }
+                       data = (s32)(rxbuf[1]) | ((s32)(rxbuf[0] & 0x0F)) << 8;
+               } else {
+                       /* Get reading */
+                       data = i2c_master_recv(client, rxbuf, 1);
+                       if (data < 0) {
+                               ret = data;
+                               goto error_ret;
+                       }
+                       data = rxbuf[0];
+               }
+       }
+       /* Pretty print the result */
+       len = sprintf(buf, "%u\n", data);
+ error_ret:
+       mutex_unlock(&dev_info->mlock);
+       return ret ? ret : len;
+ }
+ /* Direct read attribtues */
+ static IIO_DEV_ATTR_IN_RAW(0, max1363_read_single_channel, _s0);
+ static IIO_DEV_ATTR_IN_RAW(1, max1363_read_single_channel, _s1);
+ static IIO_DEV_ATTR_IN_RAW(2, max1363_read_single_channel, _s2);
+ static IIO_DEV_ATTR_IN_RAW(3, max1363_read_single_channel, _s3);
+ static IIO_DEV_ATTR_IN_RAW(4, max1363_read_single_channel, _s4);
+ static IIO_DEV_ATTR_IN_RAW(5, max1363_read_single_channel, _s5);
+ static IIO_DEV_ATTR_IN_RAW(6, max1363_read_single_channel, _s6);
+ static IIO_DEV_ATTR_IN_RAW(7, max1363_read_single_channel, _s7);
+ static IIO_DEV_ATTR_IN_RAW(8, max1363_read_single_channel, _s8);
+ static IIO_DEV_ATTR_IN_RAW(9, max1363_read_single_channel, _s9);
+ static IIO_DEV_ATTR_IN_RAW(10, max1363_read_single_channel, _s10);
+ static IIO_DEV_ATTR_IN_RAW(11, max1363_read_single_channel, _s11);
+ static IIO_DEV_ATTR_IN_DIFF_RAW(0, 1, max1363_read_single_channel, d0m1);
+ static IIO_DEV_ATTR_IN_DIFF_RAW(2, 3, max1363_read_single_channel, d2m3);
+ static IIO_DEV_ATTR_IN_DIFF_RAW(4, 5, max1363_read_single_channel, d4m5);
+ static IIO_DEV_ATTR_IN_DIFF_RAW(6, 7, max1363_read_single_channel, d6m7);
+ static IIO_DEV_ATTR_IN_DIFF_RAW(8, 9, max1363_read_single_channel, d8m9);
+ static IIO_DEV_ATTR_IN_DIFF_RAW(10, 11, max1363_read_single_channel, d10m11);
+ static IIO_DEV_ATTR_IN_DIFF_RAW(1, 0, max1363_read_single_channel, d1m0);
+ static IIO_DEV_ATTR_IN_DIFF_RAW(3, 2, max1363_read_single_channel, d3m2);
+ static IIO_DEV_ATTR_IN_DIFF_RAW(5, 4, max1363_read_single_channel, d5m4);
+ static IIO_DEV_ATTR_IN_DIFF_RAW(7, 6, max1363_read_single_channel, d7m6);
+ static IIO_DEV_ATTR_IN_DIFF_RAW(9, 8, max1363_read_single_channel, d9m8);
+ static IIO_DEV_ATTR_IN_DIFF_RAW(11, 10, max1363_read_single_channel, d11m10);
+ static ssize_t max1363_show_scale(struct device *dev,
+                               struct device_attribute *attr,
+                               char *buf)
+ {
+       /* Driver currently only support internal vref */
+       struct iio_dev *dev_info = dev_get_drvdata(dev);
+       struct max1363_state *st = iio_dev_get_devdata(dev_info);
+       /* Corresponds to Vref / 2^(bits) */
+       if ((1 << (st->chip_info->bits + 1))
+           > st->chip_info->int_vref_mv)
+               return sprintf(buf, "0.5\n");
+       else
+               return sprintf(buf, "%d\n",
+                       st->chip_info->int_vref_mv >> st->chip_info->bits);
+ }
+ static IIO_DEVICE_ATTR(in_scale, S_IRUGO, max1363_show_scale, NULL, 0);
+ static ssize_t max1363_show_name(struct device *dev,
+                                struct device_attribute *attr,
+                                char *buf)
+ {
+       struct iio_dev *dev_info = dev_get_drvdata(dev);
+       struct max1363_state *st = iio_dev_get_devdata(dev_info);
+       return sprintf(buf, "%s\n", st->chip_info->name);
+ }
+ static IIO_DEVICE_ATTR(name, S_IRUGO, max1363_show_name, NULL, 0);
  /* Applies to max1363 */
  static const enum max1363_modes max1363_mode_list[] = {
        _s0, _s1, _s2, _s3,
-       se0, se1, se2, se3,
        s0to1, s0to2, s0to3,
        d0m1, d2m3, d1m0, d3m2,
-       de0m1, de2m3, de1m0, de3m2,
        d0m1to2m3, d1m0to3m2,
  };
  
+ static struct attribute *max1363_device_attrs[] = {
+       &iio_dev_attr_in0_raw.dev_attr.attr,
+       &iio_dev_attr_in1_raw.dev_attr.attr,
+       &iio_dev_attr_in2_raw.dev_attr.attr,
+       &iio_dev_attr_in3_raw.dev_attr.attr,
+       &iio_dev_attr_in0min1_raw.dev_attr.attr,
+       &iio_dev_attr_in2min3_raw.dev_attr.attr,
+       &iio_dev_attr_in1min0_raw.dev_attr.attr,
+       &iio_dev_attr_in3min2_raw.dev_attr.attr,
+       &iio_dev_attr_name.dev_attr.attr,
+       &iio_dev_attr_in_scale.dev_attr.attr,
+       NULL
+ };
+ static struct attribute_group max1363_dev_attr_group = {
+       .attrs = max1363_device_attrs,
+ };
+ static struct attribute *max1363_scan_el_attrs[] = {
+       &iio_scan_el_in0.dev_attr.attr,
+       &iio_scan_el_in1.dev_attr.attr,
+       &iio_scan_el_in2.dev_attr.attr,
+       &iio_scan_el_in3.dev_attr.attr,
+       &iio_scan_el_in0min1.dev_attr.attr,
+       &iio_scan_el_in2min3.dev_attr.attr,
+       &iio_scan_el_in1min0.dev_attr.attr,
+       &iio_scan_el_in3min2.dev_attr.attr,
+       &iio_dev_attr_in_precision.dev_attr.attr,
+       NULL,
+ };
+ static struct attribute_group max1363_scan_el_group = {
+       .name = "scan_elements",
+       .attrs = max1363_scan_el_attrs,
+ };
  /* Appies to max1236, max1237 */
  static const enum max1363_modes max1236_mode_list[] = {
        _s0, _s1, _s2, _s3,
-       se0, se1, se2, se3,
        s0to1, s0to2, s0to3,
        d0m1, d2m3, d1m0, d3m2,
-       de0m1, de2m3, de1m0, de3m2,
        d0m1to2m3, d1m0to3m2,
        s2to3,
  };
  /* Applies to max1238, max1239 */
  static const enum max1363_modes max1238_mode_list[] = {
        _s0, _s1, _s2, _s3, _s4, _s5, _s6, _s7, _s8, _s9, _s10, _s11,
-       se0, se1, se2, se3, se4, se5, se6, se7, se8, se9, se10, se11,
        s0to1, s0to2, s0to3, s0to4, s0to5, s0to6,
        s0to7, s0to8, s0to9, s0to10, s0to11,
        d0m1, d2m3, d4m5, d6m7, d8m9, d10m11,
        d1m0, d3m2, d5m4, d7m6, d9m8, d11m10,
-       de0m1, de2m3, de4m5, de6m7, de8m9, de10m11,
-       de1m0, de3m2, de5m4, de7m6, de9m8, de11m10,
        d0m1to2m3, d0m1to4m5, d0m1to6m7, d0m1to8m9, d0m1to10m11,
        d1m0to3m2, d1m0to5m4, d1m0to7m6, d1m0to9m8, d1m0to11m10,
        s6to7, s6to8, s6to9, s6to10, s6to11,
-       s6m7to8m9, s6m7to10m11, s7m6to9m8, s7m6to11m10,
+       d6m7to8m9, d6m7to10m11, d7m6to9m8, d7m6to11m10,
+ };
+ static struct attribute *max1238_device_attrs[] = {
+       &iio_dev_attr_in0_raw.dev_attr.attr,
+       &iio_dev_attr_in1_raw.dev_attr.attr,
+       &iio_dev_attr_in2_raw.dev_attr.attr,
+       &iio_dev_attr_in3_raw.dev_attr.attr,
+       &iio_dev_attr_in4_raw.dev_attr.attr,
+       &iio_dev_attr_in5_raw.dev_attr.attr,
+       &iio_dev_attr_in6_raw.dev_attr.attr,
+       &iio_dev_attr_in7_raw.dev_attr.attr,
+       &iio_dev_attr_in8_raw.dev_attr.attr,
+       &iio_dev_attr_in9_raw.dev_attr.attr,
+       &iio_dev_attr_in10_raw.dev_attr.attr,
+       &iio_dev_attr_in11_raw.dev_attr.attr,
+       &iio_dev_attr_in0min1_raw.dev_attr.attr,
+       &iio_dev_attr_in2min3_raw.dev_attr.attr,
+       &iio_dev_attr_in4min5_raw.dev_attr.attr,
+       &iio_dev_attr_in6min7_raw.dev_attr.attr,
+       &iio_dev_attr_in8min9_raw.dev_attr.attr,
+       &iio_dev_attr_in10min11_raw.dev_attr.attr,
+       &iio_dev_attr_in1min0_raw.dev_attr.attr,
+       &iio_dev_attr_in3min2_raw.dev_attr.attr,
+       &iio_dev_attr_in5min4_raw.dev_attr.attr,
+       &iio_dev_attr_in7min6_raw.dev_attr.attr,
+       &iio_dev_attr_in9min8_raw.dev_attr.attr,
+       &iio_dev_attr_in11min10_raw.dev_attr.attr,
+       &iio_dev_attr_name.dev_attr.attr,
+       &iio_dev_attr_in_scale.dev_attr.attr,
+       NULL
+ };
+ static struct attribute_group max1238_dev_attr_group = {
+       .attrs = max1238_device_attrs,
+ };
+ static struct attribute *max1238_scan_el_attrs[] = {
+       &iio_scan_el_in0.dev_attr.attr,
+       &iio_scan_el_in1.dev_attr.attr,
+       &iio_scan_el_in2.dev_attr.attr,
+       &iio_scan_el_in3.dev_attr.attr,
+       &iio_scan_el_in4.dev_attr.attr,
+       &iio_scan_el_in5.dev_attr.attr,
+       &iio_scan_el_in6.dev_attr.attr,
+       &iio_scan_el_in7.dev_attr.attr,
+       &iio_scan_el_in8.dev_attr.attr,
+       &iio_scan_el_in9.dev_attr.attr,
+       &iio_scan_el_in10.dev_attr.attr,
+       &iio_scan_el_in11.dev_attr.attr,
+       &iio_scan_el_in0min1.dev_attr.attr,
+       &iio_scan_el_in2min3.dev_attr.attr,
+       &iio_scan_el_in4min5.dev_attr.attr,
+       &iio_scan_el_in6min7.dev_attr.attr,
+       &iio_scan_el_in8min9.dev_attr.attr,
+       &iio_scan_el_in10min11.dev_attr.attr,
+       &iio_scan_el_in1min0.dev_attr.attr,
+       &iio_scan_el_in3min2.dev_attr.attr,
+       &iio_scan_el_in5min4.dev_attr.attr,
+       &iio_scan_el_in7min6.dev_attr.attr,
+       &iio_scan_el_in9min8.dev_attr.attr,
+       &iio_scan_el_in11min10.dev_attr.attr,
+       &iio_dev_attr_in_precision.dev_attr.attr,
+       NULL,
+ };
+ static struct attribute_group max1238_scan_el_group = {
+       .name = "scan_elements",
+       .attrs = max1238_scan_el_attrs,
  };
  
  
+ static const enum max1363_modes max11607_mode_list[] = {
+       _s0, _s1, _s2, _s3,
+       s0to1, s0to2, s0to3,
+       s2to3,
+       d0m1, d2m3, d1m0, d3m2,
+       d0m1to2m3, d1m0to3m2,
+ };
+ static const enum max1363_modes max11608_mode_list[] = {
+       _s0, _s1, _s2, _s3, _s4, _s5, _s6, _s7,
+       s0to1, s0to2, s0to3, s0to4, s0to5, s0to6, s0to7,
+       s6to7,
+       d0m1, d2m3, d4m5, d6m7,
+       d1m0, d3m2, d5m4, d7m6,
+       d0m1to2m3, d0m1to4m5, d0m1to6m7,
+       d1m0to3m2, d1m0to5m4, d1m0to7m6,
+ };
+ static struct attribute *max11608_device_attrs[] = {
+       &iio_dev_attr_in0_raw.dev_attr.attr,
+       &iio_dev_attr_in1_raw.dev_attr.attr,
+       &iio_dev_attr_in2_raw.dev_attr.attr,
+       &iio_dev_attr_in3_raw.dev_attr.attr,
+       &iio_dev_attr_in4_raw.dev_attr.attr,
+       &iio_dev_attr_in5_raw.dev_attr.attr,
+       &iio_dev_attr_in6_raw.dev_attr.attr,
+       &iio_dev_attr_in7_raw.dev_attr.attr,
+       &iio_dev_attr_in0min1_raw.dev_attr.attr,
+       &iio_dev_attr_in2min3_raw.dev_attr.attr,
+       &iio_dev_attr_in4min5_raw.dev_attr.attr,
+       &iio_dev_attr_in6min7_raw.dev_attr.attr,
+       &iio_dev_attr_in1min0_raw.dev_attr.attr,
+       &iio_dev_attr_in3min2_raw.dev_attr.attr,
+       &iio_dev_attr_in5min4_raw.dev_attr.attr,
+       &iio_dev_attr_in7min6_raw.dev_attr.attr,
+       &iio_dev_attr_name.dev_attr.attr,
+       &iio_dev_attr_in_scale.dev_attr.attr,
+       NULL
+ };
+ static struct attribute_group max11608_dev_attr_group = {
+       .attrs = max11608_device_attrs,
+ };
+ static struct attribute *max11608_scan_el_attrs[] = {
+       &iio_scan_el_in0.dev_attr.attr,
+       &iio_scan_el_in1.dev_attr.attr,
+       &iio_scan_el_in2.dev_attr.attr,
+       &iio_scan_el_in3.dev_attr.attr,
+       &iio_scan_el_in4.dev_attr.attr,
+       &iio_scan_el_in5.dev_attr.attr,
+       &iio_scan_el_in6.dev_attr.attr,
+       &iio_scan_el_in7.dev_attr.attr,
+       &iio_scan_el_in0min1.dev_attr.attr,
+       &iio_scan_el_in2min3.dev_attr.attr,
+       &iio_scan_el_in4min5.dev_attr.attr,
+       &iio_scan_el_in6min7.dev_attr.attr,
+       &iio_scan_el_in1min0.dev_attr.attr,
+       &iio_scan_el_in3min2.dev_attr.attr,
+       &iio_scan_el_in5min4.dev_attr.attr,
+       &iio_scan_el_in7min6.dev_attr.attr,
+       &iio_dev_attr_in_precision.dev_attr.attr,
+ };
+ static struct attribute_group max11608_scan_el_group = {
+       .name = "scan_elements",
+       .attrs = max11608_scan_el_attrs,
+ };
  enum { max1361,
         max1362,
         max1363,
         max1364,
+        max1036,
+        max1037,
+        max1038,
+        max1039,
         max1136,
         max1137,
         max1138,
         max1237,
         max1238,
         max1239,
+        max11600,
+        max11601,
+        max11602,
+        max11603,
+        max11604,
+        max11605,
+        max11606,
+        max11607,
+        max11608,
+        max11609,
+        max11610,
+        max11611,
+        max11612,
+        max11613,
+        max11614,
+        max11615,
+        max11616,
+        max11617,
  };
  
  /* max1363 and max1368 tested - rest from data sheet */
@@@ -190,118 -555,350 +555,350 @@@ static const struct max1363_chip_info m
        {
                .name = "max1361",
                .num_inputs = 4,
+               .bits = 10,
+               .int_vref_mv = 2048,
                .monitor_mode = 1,
                .mode_list = max1363_mode_list,
                .num_modes = ARRAY_SIZE(max1363_mode_list),
                .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
        }, {
                .name = "max1362",
                .num_inputs = 4,
+               .bits = 10,
+               .int_vref_mv = 4096,
                .monitor_mode = 1,
                .mode_list = max1363_mode_list,
                .num_modes = ARRAY_SIZE(max1363_mode_list),
                .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
        }, {
                .name = "max1363",
                .num_inputs = 4,
+               .bits = 12,
+               .int_vref_mv = 2048,
                .monitor_mode = 1,
                .mode_list = max1363_mode_list,
                .num_modes = ARRAY_SIZE(max1363_mode_list),
                .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
        }, {
                .name = "max1364",
                .num_inputs = 4,
+               .bits = 12,
+               .int_vref_mv = 4096,
                .monitor_mode = 1,
                .mode_list = max1363_mode_list,
                .num_modes = ARRAY_SIZE(max1363_mode_list),
                .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max1036",
+               .num_inputs = 4,
+               .bits = 8,
+               .int_vref_mv = 4096,
+               .mode_list = max1236_mode_list,
+               .num_modes = ARRAY_SIZE(max1236_mode_list),
+               .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max1037",
+               .num_inputs = 4,
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max1236_mode_list,
+               .num_modes = ARRAY_SIZE(max1236_mode_list),
+               .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max1038",
+               .num_inputs = 12,
+               .bits = 8,
+               .int_vref_mv = 4096,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
+       }, {
+               .name = "max1039",
+               .num_inputs = 12,
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
        }, {
                .name = "max1136",
                .num_inputs = 4,
+               .bits = 10,
                .int_vref_mv = 4096,
                .mode_list = max1236_mode_list,
                .num_modes = ARRAY_SIZE(max1236_mode_list),
                .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
        }, {
                .name = "max1137",
                .num_inputs = 4,
+               .bits = 10,
                .int_vref_mv = 2048,
                .mode_list = max1236_mode_list,
                .num_modes = ARRAY_SIZE(max1236_mode_list),
                .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
        }, {
                .name = "max1138",
                .num_inputs = 12,
+               .bits = 10,
                .int_vref_mv = 4096,
                .mode_list = max1238_mode_list,
                .num_modes = ARRAY_SIZE(max1238_mode_list),
                .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
        }, {
                .name = "max1139",
                .num_inputs = 12,
+               .bits = 10,
                .int_vref_mv = 2048,
                .mode_list = max1238_mode_list,
                .num_modes = ARRAY_SIZE(max1238_mode_list),
                .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
        }, {
                .name = "max1236",
                .num_inputs = 4,
+               .bits = 12,
                .int_vref_mv = 4096,
                .mode_list = max1236_mode_list,
                .num_modes = ARRAY_SIZE(max1236_mode_list),
                .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
        }, {
                .name = "max1237",
                .num_inputs = 4,
+               .bits = 12,
                .int_vref_mv = 2048,
                .mode_list = max1236_mode_list,
                .num_modes = ARRAY_SIZE(max1236_mode_list),
                .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
        }, {
                .name = "max1238",
                .num_inputs = 12,
+               .bits = 12,
                .int_vref_mv = 4096,
                .mode_list = max1238_mode_list,
                .num_modes = ARRAY_SIZE(max1238_mode_list),
                .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
        }, {
                .name = "max1239",
                .num_inputs = 12,
+               .bits = 12,
                .int_vref_mv = 2048,
                .mode_list = max1238_mode_list,
                .num_modes = ARRAY_SIZE(max1238_mode_list),
                .default_mode = s0to11,
-       },
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
+       }, {
+               .name = "max11600",
+               .num_inputs = 4,
+               .bits = 8,
+               .int_vref_mv = 4096,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max11601",
+               .num_inputs = 4,
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max11602",
+               .num_inputs = 8,
+               .bits = 8,
+               .int_vref_mv = 4096,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .dev_attrs = &max11608_dev_attr_group,
+               .scan_attrs = &max11608_scan_el_group,
+       }, {
+               .name = "max11603",
+               .num_inputs = 8,
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .dev_attrs = &max11608_dev_attr_group,
+               .scan_attrs = &max11608_scan_el_group,
+       }, {
+               .name = "max11604",
+               .num_inputs = 12,
+               .bits = 8,
+               .int_vref_mv = 4098,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
+       }, {
+               .name = "max11605",
+               .num_inputs = 12,
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
+       }, {
+               .name = "max11606",
+               .num_inputs = 4,
+               .bits = 10,
+               .int_vref_mv = 4096,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max11607",
+               .num_inputs = 4,
+               .bits = 10,
+               .int_vref_mv = 2048,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max11608",
+               .num_inputs = 8,
+               .bits = 10,
+               .int_vref_mv = 4096,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .dev_attrs = &max11608_dev_attr_group,
+               .scan_attrs = &max11608_scan_el_group,
+       }, {
+               .name = "max11609",
+               .num_inputs = 8,
+               .bits = 10,
+               .int_vref_mv = 2048,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .dev_attrs = &max11608_dev_attr_group,
+               .scan_attrs = &max11608_scan_el_group,
+       }, {
+               .name = "max11610",
+               .num_inputs = 12,
+               .bits = 10,
+               .int_vref_mv = 4098,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
+       }, {
+               .name = "max11611",
+               .num_inputs = 12,
+               .bits = 10,
+               .int_vref_mv = 2048,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
+       }, {
+               .name = "max11612",
+               .num_inputs = 4,
+               .bits = 12,
+               .int_vref_mv = 4096,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max11613",
+               .num_inputs = 4,
+               .bits = 12,
+               .int_vref_mv = 2048,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .dev_attrs = &max1363_dev_attr_group,
+               .scan_attrs = &max1363_scan_el_group,
+       }, {
+               .name = "max11614",
+               .num_inputs = 8,
+               .bits = 12,
+               .int_vref_mv = 4096,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .dev_attrs = &max11608_dev_attr_group,
+               .scan_attrs = &max11608_scan_el_group,
+       }, {
+               .name = "max11615",
+               .num_inputs = 8,
+               .bits = 12,
+               .int_vref_mv = 2048,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .dev_attrs = &max11608_dev_attr_group,
+               .scan_attrs = &max11608_scan_el_group,
+       }, {
+               .name = "max11616",
+               .num_inputs = 12,
+               .bits = 12,
+               .int_vref_mv = 4098,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
+       }, {
+               .name = "max11617",
+               .num_inputs = 12,
+               .bits = 12,
+               .int_vref_mv = 2048,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .dev_attrs = &max1238_dev_attr_group,
+               .scan_attrs = &max1238_scan_el_group,
+       }
  };
  
- static int max1363_write_basic_config(struct i2c_client *client,
-                                     unsigned char d1,
-                                     unsigned char d2)
- {
-       int ret;
-       u8 *tx_buf = kmalloc(2 , GFP_KERNEL);
-       if (!tx_buf)
-               return -ENOMEM;
-       tx_buf[0] = d1;
-       tx_buf[1] = d2;
-       ret = i2c_master_send(client, tx_buf, 2);
-       kfree(tx_buf);
-       return (ret > 0) ? 0 : ret;
- }
- static int max1363_set_scan_mode(struct max1363_state *st)
- {
-       st->configbyte &= ~(MAX1363_CHANNEL_SEL_MASK
-                           | MAX1363_SCAN_MASK
-                           | MAX1363_SE_DE_MASK);
-       st->configbyte |= st->current_mode->conf;
-       return max1363_write_basic_config(st->client,
-                                         st->setupbyte,
-                                         st->configbyte);
- }
  static int max1363_initial_setup(struct max1363_state *st)
  {
        st->setupbyte = MAX1363_SETUP_AIN3_IS_AIN3_REF_IS_VDD
        return max1363_set_scan_mode(st);
  }
  
- static ssize_t max1363_show_av_scan_modes(struct device *dev,
-                                         struct device_attribute *attr,
-                                         char *buf)
- {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = dev_info->dev_data;
-       int i, len = 0;
-       for (i = 0; i < st->chip_info->num_modes; i++)
-               len += sprintf(buf + len, "%s ",
-                              max1363_mode_table[st->chip_info
-                                                 ->mode_list[i]].name);
-       len += sprintf(buf + len, "\n");
-       return len;
- }
- /* The dev here is the sysfs related one, not the underlying i2c one */
- static ssize_t max1363_scan_direct(struct device *dev,
-                                  struct device_attribute *attr,
-                                  char *buf)
- {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = dev_info->dev_data;
-       int len = 0, ret, i;
-       struct i2c_client *client = st->client;
-       char *rxbuf;
-       if (st->current_mode->numvals == 0)
-               return 0;
-       rxbuf = kmalloc(st->current_mode->numvals*2, GFP_KERNEL);
-       if (rxbuf == NULL)
-               return -ENOMEM;
-       /* Interpretation depends on whether these are signed or not!*/
-       /* Assume not for now */
-       ret = i2c_master_recv(client, rxbuf, st->current_mode->numvals*2);
-       if (ret < 0)
-               return ret;
-       for (i = 0; i < st->current_mode->numvals; i++)
-               len += sprintf(buf+len, "%d ",
-                              ((int)(rxbuf[i*2+0]&0x0F) << 8)
-                              + ((int)(rxbuf[i*2+1])));
-       kfree(rxbuf);
-       len += sprintf(buf + len, "\n");
-       return len;
- }
- static ssize_t max1363_scan(struct device *dev,
-                           struct device_attribute *attr,
-                           char *buf)
- {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       int ret;
-       mutex_lock(&dev_info->mlock);
-       if (dev_info->currentmode == INDIO_RING_TRIGGERED)
-               ret = max1363_scan_from_ring(dev, attr, buf);
-       else
-               ret = max1363_scan_direct(dev, attr, buf);
-       mutex_unlock(&dev_info->mlock);
-       return ret;
- }
- /* Cannot query the device, so use local copy of state */
- static ssize_t max1363_show_scan_mode(struct device *dev,
-                                     struct device_attribute *attr,
-                                     char *buf)
- {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = dev_info->dev_data;
-       return sprintf(buf, "%s\n", st->current_mode->name);
- }
- static const struct max1363_mode
- *__max1363_find_mode_in_ci(const struct max1363_chip_info *info,
-                                 const char *buf)
- {
-       int i;
-       for (i = 0; i <  info->num_modes; i++)
-               if (strcmp(max1363_mode_table[info->mode_list[i]].name, buf)
-                   == 0)
-                       return &max1363_mode_table[info->mode_list[i]];
-       return NULL;
- }
- static ssize_t max1363_store_scan_mode(struct device *dev,
-                                      struct device_attribute *attr,
-                                      const char *buf,
-                                      size_t len)
- {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = dev_info->dev_data;
-       const struct max1363_mode *new_mode;
-       int ret;
-       mutex_lock(&dev_info->mlock);
-       new_mode = NULL;
-       /* Avoid state changes if a ring buffer is enabled */
-       if (!iio_ring_enabled(dev_info)) {
-               new_mode
-                       = __max1363_find_mode_in_ci(st->chip_info, buf);
-               if (!new_mode) {
-                       ret = -EINVAL;
-                       goto error_ret;
-               }
-               st->current_mode = new_mode;
-               ret =  max1363_set_scan_mode(st);
-               if (ret)
-                       goto error_ret;
-       } else {
-               ret = -EBUSY;
-               goto error_ret;
-       }
-       mutex_unlock(&dev_info->mlock);
-       return len;
- error_ret:
-       mutex_unlock(&dev_info->mlock);
-       return ret;
- }
- IIO_DEV_ATTR_AVAIL_SCAN_MODES(max1363_show_av_scan_modes);
- IIO_DEV_ATTR_SCAN_MODE(S_IRUGO | S_IWUSR,
-                      max1363_show_scan_mode,
-                      max1363_store_scan_mode);
- IIO_DEV_ATTR_SCAN(max1363_scan);
- static ssize_t max1363_show_name(struct device *dev,
-                                struct device_attribute *attr,
-                                char *buf)
- {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = dev_info->dev_data;
-       return sprintf(buf, "%s\n", st->chip_info->name);
- }
- IIO_DEVICE_ATTR(name, S_IRUGO, max1363_show_name, NULL, 0);
- /*name export */
- static struct attribute *max1363_attributes[] = {
-       &iio_dev_attr_available_scan_modes.dev_attr.attr,
-       &iio_dev_attr_scan_mode.dev_attr.attr,
-       &iio_dev_attr_scan.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
-       NULL,
- };
- static const struct attribute_group max1363_attribute_group = {
-       .attrs = max1363_attributes,
- };
  static int __devinit max1363_probe(struct i2c_client *client,
                                   const struct i2c_device_id *id)
  {
                ret = -ENODEV;
                goto error_free_st;
        }
        st->reg = regulator_get(&client->dev, "vcc");
        if (!IS_ERR(st->reg)) {
                ret = regulator_enable(st->reg);
                goto error_disable_reg;
        }
  
+       st->indio_dev->available_scan_masks
+               = kzalloc(sizeof(*st->indio_dev->available_scan_masks)*
+                         (st->chip_info->num_modes + 1), GFP_KERNEL);
+       if (!st->indio_dev->available_scan_masks) {
+               ret = -ENOMEM;
+               goto error_free_device;
+       }
+       for (i = 0; i < st->chip_info->num_modes; i++)
+               st->indio_dev->available_scan_masks[i] =
+                       max1363_mode_table[st->chip_info->mode_list[i]]
+                       .modemask;
        /* Estabilish that the iio_dev is a child of the i2c device */
        st->indio_dev->dev.parent = &client->dev;
-       st->indio_dev->attrs = &max1363_attribute_group;
+       st->indio_dev->attrs = st->chip_info->dev_attrs;
+       /* Todo: this shouldn't be here. */
+       st->indio_dev->scan_el_attrs = st->chip_info->scan_attrs;
        st->indio_dev->dev_data = (void *)(st);
        st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
  
        ret = max1363_initial_setup(st);
        if (ret)
-               goto error_free_device;
+               goto error_free_available_scan_masks;
  
        ret = max1363_register_ring_funcs_and_init(st->indio_dev);
        if (ret)
-               goto error_free_device;
+               goto error_free_available_scan_masks;
  
        ret = iio_device_register(st->indio_dev);
        if (ret)
        return 0;
  error_cleanup_ring:
        max1363_ring_cleanup(st->indio_dev);
+ error_free_available_scan_masks:
+       kfree(st->indio_dev->available_scan_masks);
  error_free_device:
        if (!regdone)
                iio_free_device(st->indio_dev);
@@@ -557,7 -1011,6 +1011,7 @@@ error_put_reg
        if (!IS_ERR(st->reg))
                regulator_put(st->reg);
  error_free_st:
 +      i2c_set_clientdata(client, NULL);
        kfree(st);
  
  error_ret:
@@@ -570,12 -1023,12 +1024,13 @@@ static int max1363_remove(struct i2c_cl
        struct iio_dev *indio_dev = st->indio_dev;
        max1363_uninitialize_ring(indio_dev->ring);
        max1363_ring_cleanup(indio_dev);
+       kfree(st->indio_dev->available_scan_masks);
        iio_device_unregister(indio_dev);
        if (!IS_ERR(st->reg)) {
                regulator_disable(st->reg);
                regulator_put(st->reg);
        }
 +      i2c_set_clientdata(client, NULL);
        kfree(st);
  
        return 0;
@@@ -586,6 -1039,10 +1041,10 @@@ static const struct i2c_device_id max13
        { "max1362", max1362 },
        { "max1363", max1363 },
        { "max1364", max1364 },
+       { "max1036", max1036 },
+       { "max1037", max1037 },
+       { "max1038", max1038 },
+       { "max1039", max1039 },
        { "max1136", max1136 },
        { "max1137", max1137 },
        { "max1138", max1138 },
        { "max1237", max1237 },
        { "max1238", max1238 },
        { "max1239", max1239 },
+       { "max11600", max11600 },
+       { "max11601", max11601 },
+       { "max11602", max11602 },
+       { "max11603", max11603 },
+       { "max11604", max11604 },
+       { "max11605", max11605 },
+       { "max11606", max11606 },
+       { "max11607", max11607 },
+       { "max11608", max11608 },
+       { "max11609", max11609 },
+       { "max11610", max11610 },
+       { "max11611", max11611 },
+       { "max11612", max11612 },
+       { "max11613", max11613 },
+       { "max11614", max11614 },
+       { "max11615", max11615 },
+       { "max11616", max11616 },
+       { "max11617", max11617 },
        {}
  };
  
@@@ -42,16 -42,10 +42,10 @@@ dev_t iio_devt
  EXPORT_SYMBOL(iio_devt);
  
  #define IIO_DEV_MAX 256
- static char *iio_devnode(struct device *dev, mode_t *mode)
- {
-       return kasprintf(GFP_KERNEL, "iio/%s", dev_name(dev));
- }
- struct class iio_class = {
+ struct bus_type iio_bus_type = {
        .name = "iio",
-       .devnode = iio_devnode,
  };
- EXPORT_SYMBOL(iio_class);
+ EXPORT_SYMBOL(iio_bus_type);
  
  void __iio_change_event(struct iio_detected_event_list *ev,
                        int ev_code,
@@@ -405,7 -399,7 +399,7 @@@ int iio_setup_ev_int(struct iio_event_i
  {
        int ret, minor;
  
-       ev_int->dev.class = &iio_class;
+       ev_int->dev.bus = &iio_bus_type;
        ev_int->dev.parent = dev;
        ev_int->dev.type = &iio_event_type;
        device_initialize(&ev_int->dev);
@@@ -478,23 -472,23 +472,23 @@@ static int __init iio_init(void
  {
        int ret;
  
-       /* Create sysfs class */
-       ret  = class_register(&iio_class);
+       /* Register sysfs bus */
+       ret  = bus_register(&iio_bus_type);
        if (ret < 0) {
                printk(KERN_ERR
-                      "%s could not create sysfs class\n",
+                      "%s could not register bus type\n",
                        __FILE__);
                goto error_nothing;
        }
  
        ret = iio_dev_init();
        if (ret < 0)
-               goto error_unregister_class;
+               goto error_unregister_bus_type;
  
        return 0;
  
- error_unregister_class:
-       class_unregister(&iio_class);
+ error_unregister_bus_type:
+       bus_unregister(&iio_bus_type);
  error_nothing:
        return ret;
  }
  static void __exit iio_exit(void)
  {
        iio_dev_exit();
-       class_unregister(&iio_class);
+       bus_unregister(&iio_bus_type);
  }
  
  static int iio_device_register_sysfs(struct iio_dev *dev_info)
@@@ -537,7 -531,6 +531,7 @@@ static void iio_device_unregister_sysfs
        sysfs_remove_group(&dev_info->dev.kobj, dev_info->attrs);
  }
  
 +/* Return a negative errno on failure */
  int iio_get_new_idr_val(struct idr *this_idr)
  {
        int ret;
@@@ -661,14 -654,15 +655,15 @@@ static int iio_device_register_eventset
        for (i = 0; i < dev_info->num_interrupt_lines; i++) {
                dev_info->event_interfaces[i].owner = dev_info->driver_module;
                ret = iio_get_new_idr_val(&iio_event_idr);
 -              if (ret)
 +              if (ret < 0)
                        goto error_free_setup_ev_ints;
                else
                        dev_info->event_interfaces[i].id = ret;
  
                snprintf(dev_info->event_interfaces[i]._name, 20,
-                        "event_line%d",
-                       dev_info->event_interfaces[i].id);
+                        "%s:event%d",
+                        dev_name(&dev_info->dev),
+                        dev_info->event_interfaces[i].id);
  
                ret = iio_setup_ev_int(&dev_info->event_interfaces[i],
                                       (const char *)(dev_info
                                         dev_info->event_interfaces[i].id);
                        goto error_free_setup_ev_ints;
                }
-       }
  
-       for (i = 0; i < dev_info->num_interrupt_lines; i++) {
-               snprintf(dev_info->event_interfaces[i]._attrname, 20,
-                       "event_line%d_sources", i);
-               dev_info->event_attrs[i].name
-                       = (const char *)
-                       (dev_info->event_interfaces[i]._attrname);
-               ret = sysfs_create_group(&dev_info->dev.kobj,
-                                        &dev_info->event_attrs[i]);
+               dev_set_drvdata(&dev_info->event_interfaces[i].dev,
+                               (void *)dev_info);
+               ret = sysfs_create_group(&dev_info
+                                       ->event_interfaces[i]
+                                       .dev.kobj,
+                                       &dev_info->event_attrs[i]);
                if (ret) {
                        dev_err(&dev_info->dev,
                                "Failed to register sysfs for event attrs");
@@@ -714,13 -706,13 +707,13 @@@ error_unregister_config_attrs
        i = dev_info->num_interrupt_lines - 1;
  error_remove_sysfs_interfaces:
        for (j = 0; j < i; j++)
-               sysfs_remove_group(&dev_info->dev.kobj,
+               sysfs_remove_group(&dev_info
+                                  ->event_interfaces[j].dev.kobj,
                                   &dev_info->event_attrs[j]);
-       i = dev_info->num_interrupt_lines - 1;
  error_free_setup_ev_ints:
        for (j = 0; j < i; j++) {
                iio_free_idr_val(&iio_event_idr,
-                                dev_info->event_interfaces[i].id);
+                                dev_info->event_interfaces[j].id);
                iio_free_ev_int(&dev_info->event_interfaces[j]);
        }
        kfree(dev_info->interrupts);
@@@ -738,7 -730,8 +731,8 @@@ static void iio_device_unregister_event
        if (dev_info->num_interrupt_lines == 0)
                return;
        for (i = 0; i < dev_info->num_interrupt_lines; i++)
-               sysfs_remove_group(&dev_info->dev.kobj,
+               sysfs_remove_group(&dev_info
+                                  ->event_interfaces[i].dev.kobj,
                                   &dev_info->event_attrs[i]);
  
        for (i = 0; i < dev_info->num_interrupt_lines; i++) {
@@@ -769,7 -762,7 +763,7 @@@ struct iio_dev *iio_allocate_device(voi
  
        if (dev) {
                dev->dev.type = &iio_dev_type;
-               dev->dev.class = &iio_class;
+               dev->dev.bus = &iio_bus_type;
                device_initialize(&dev->dev);
                dev_set_drvdata(&dev->dev, (void *)dev);
                mutex_init(&dev->mlock);
@@@ -810,7 -803,7 +804,7 @@@ int iio_device_register(struct iio_dev 
        ret = iio_device_register_eventset(dev_info);
        if (ret) {
                dev_err(dev_info->dev.parent,
-                       "Failed to register event set \n");
+                       "Failed to register event set\n");
                goto error_free_sysfs;
        }
        if (dev_info->modes & INDIO_RING_TRIGGERED)
@@@ -592,18 -592,30 +592,30 @@@ static ssize_t tsl2563_calib1_store(str
   * once I understand what they mean */
  static DEVICE_ATTR(adc0, S_IRUGO, tsl2563_adc0_show, NULL);
  static DEVICE_ATTR(adc1, S_IRUGO, tsl2563_adc1_show, NULL);
- static DEVICE_ATTR(lux, S_IRUGO, tsl2563_lux_show, NULL);
+ static DEVICE_ATTR(illuminance0_input, S_IRUGO, tsl2563_lux_show, NULL);
  static DEVICE_ATTR(calib0, S_IRUGO | S_IWUSR,
                   tsl2563_calib0_show, tsl2563_calib0_store);
  static DEVICE_ATTR(calib1, S_IRUGO | S_IWUSR,
                   tsl2563_calib1_show, tsl2563_calib1_store);
  
+ static ssize_t tsl2563_show_name(struct device *dev,
+                               struct device_attribute *attr,
+                               char *buf)
+ {
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2563_chip *chip = indio_dev->dev_data;
+       return sprintf(buf, "%s\n", chip->client->name);
+ }
+ static DEVICE_ATTR(name, S_IRUGO, tsl2563_show_name, NULL);
  static struct attribute *tsl2563_attributes[] = {
        &dev_attr_adc0.attr,
        &dev_attr_adc1.attr,
-       &dev_attr_lux.attr,
+       &dev_attr_illuminance0_input.attr,
        &dev_attr_calib0.attr,
        &dev_attr_calib1.attr,
+       &dev_attr_name.attr,
        NULL
  };
  
@@@ -634,7 -646,7 +646,7 @@@ static int __devinit tsl2563_probe(stru
  
        err = tsl2563_detect(chip);
        if (err) {
-               dev_err(&client->dev, "device not found, error %d \n", -err);
+               dev_err(&client->dev, "device not found, error %d\n", -err);
                goto fail1;
        }
  
  fail2:
        iio_device_unregister(chip->indio_dev);
  fail1:
 +      i2c_set_clientdata(client, NULL);
        kfree(chip);
        return err;
  }
@@@ -693,7 -704,6 +705,7 @@@ static int tsl2563_remove(struct i2c_cl
  
        iio_device_unregister(chip->indio_dev);
  
 +      i2c_set_clientdata(client, NULL);
        kfree(chip);
        return 0;
  }
@@@ -63,7 -63,6 +63,7 @@@ struct usb_device_id rtusb_usb_id[] = 
        {USB_DEVICE(0x07D1, 0x3C11)},   /* D-Link */
        {USB_DEVICE(0x14B2, 0x3C07)},   /* AL */
        {USB_DEVICE(0x050D, 0x8053)},   /* Belkin */
 +      {USB_DEVICE(0x050D, 0x825B)},   /* Belkin */
        {USB_DEVICE(0x14B2, 0x3C23)},   /* Airlink */
        {USB_DEVICE(0x14B2, 0x3C27)},   /* Airlink */
        {USB_DEVICE(0x07AA, 0x002F)},   /* Corega */
@@@ -98,6 -97,7 +98,7 @@@
        {USB_DEVICE(0x5A57, 0x0282)},   /* Zinwell */
        {USB_DEVICE(0x7392, 0x7718)},
        {USB_DEVICE(0x7392, 0x7717)},
+       {USB_DEVICE(0x0411, 0x016f)},   /* MelCo.,Inc. WLI-UC-G301N */
        {USB_DEVICE(0x1737, 0x0070)},   /* Linksys WUSB100 */
        {USB_DEVICE(0x1737, 0x0071)},   /* Linksys WUSB600N */
        {USB_DEVICE(0x0411, 0x00e8)},   /* Buffalo WLI-UC-G300N */
@@@ -154,7 -154,7 +155,7 @@@ static void rt2870_disconnect(struct us
  static int __devinit rt2870_probe(IN struct usb_interface *intf,
                                  IN struct usb_device *usb_dev,
                                  IN const struct usb_device_id *dev_id,
-                                 struct rt_rtmp_adapter ** ppAd);
+                                 struct rt_rtmp_adapter **ppAd);
  
  #ifndef PF_NOFREEZE
  #define PF_NOFREEZE  0
@@@ -802,7 -802,7 +803,7 @@@ static void rt2870_disconnect(struct us
  static int __devinit rt2870_probe(IN struct usb_interface *intf,
                                  IN struct usb_device *usb_dev,
                                  IN const struct usb_device_id *dev_id,
-                                 struct rt_rtmp_adapter ** ppAd)
+                                 struct rt_rtmp_adapter **ppAd)
  {
        struct net_device *net_dev = NULL;
        struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)NULL;
@@@ -26,6 -26,7 +26,7 @@@
  
  #include <linux/vmalloc.h>
  #include <linux/slab.h>
+ #include <linux/eeprom_93cx6.h>
  
  #undef LOOP_TEST
  #undef DUMP_RX
@@@ -54,7 -55,6 +55,6 @@@
  
  #include <asm/uaccess.h>
  #include "r8192U.h"
- #include "r8180_93cx6.h"   /* Card EEPROM */
  #include "r8192U_wx.h"
  
  #include "r8192S_rtl8225.h"
@@@ -113,17 -113,14 +113,17 @@@ u32 rt_global_debug_component = 
  
  static const struct usb_device_id rtl8192_usb_id_tbl[] = {
        /* Realtek */
 +      {USB_DEVICE(0x0bda, 0x8171)},
        {USB_DEVICE(0x0bda, 0x8192)},
        {USB_DEVICE(0x0bda, 0x8709)},
        /* Corega */
        {USB_DEVICE(0x07aa, 0x0043)},
        /* Belkin */
        {USB_DEVICE(0x050d, 0x805E)},
 +      {USB_DEVICE(0x050d, 0x815F)}, /* Belkin F5D8053 v6 */
        /* Sitecom */
        {USB_DEVICE(0x0df6, 0x0031)},
 +      {USB_DEVICE(0x0df6, 0x004b)},   /* WL-349 */
        /* EnGenius */
        {USB_DEVICE(0x1740, 0x9201)},
        /* Dlink */
@@@ -217,6 -214,36 +217,36 @@@ static CHANNEL_LIST ChannelPlan[] = 
        {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14}                                 //For Global Domain. 1-11:active scan, 12-14 passive scan. //+YJ, 080626
  };
  
+ static void rtl819x_eeprom_register_read(struct eeprom_93cx6 *eeprom)
+ {
+       struct net_device *dev = eeprom->data;
+       u8 reg = read_nic_byte(dev, EPROM_CMD);
+       eeprom->reg_data_in = reg & RTL819X_EEPROM_CMD_WRITE;
+       eeprom->reg_data_out = reg & RTL819X_EEPROM_CMD_READ;
+       eeprom->reg_data_clock = reg & RTL819X_EEPROM_CMD_CK;
+       eeprom->reg_chip_select = reg & RTL819X_EEPROM_CMD_CS;
+ }
+ static void rtl819x_eeprom_register_write(struct eeprom_93cx6 *eeprom)
+ {
+       struct net_device *dev = eeprom->data;
+       u8 reg = 2 << 6;
+       if (eeprom->reg_data_in)
+               reg |= RTL819X_EEPROM_CMD_WRITE;
+       if (eeprom->reg_data_out)
+               reg |= RTL819X_EEPROM_CMD_READ;
+       if (eeprom->reg_data_clock)
+               reg |= RTL819X_EEPROM_CMD_CK;
+       if (eeprom->reg_chip_select)
+               reg |= RTL819X_EEPROM_CMD_CS;
+       write_nic_byte(dev, EPROM_CMD, reg);
+       read_nic_byte(dev, EPROM_CMD);
+       udelay(10);
+ }
  static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv)
  {
        int i, max_chan=-1, min_chan=-1;
@@@ -1155,15 -1182,6 +1185,6 @@@ void tx_timeout(struct net_device *dev
        //DMESG("TXTIMEOUT");
  }
  
- /* this is only for debug */
- void dump_eprom(struct net_device *dev)
- {
-       int i;
-       for(i=0; i<63; i++)
-               RT_TRACE(COMP_EPROM, "EEPROM addr %x : %x", i, eprom_read(dev,i));
- }
  /* this is only for debug */
  void rtl8192_dump_reg(struct net_device *dev)
  {
@@@ -1201,6 -1219,7 +1222,7 @@@ void rtl8192_set_mode(struct net_devic
  void rtl8192_update_msr(struct net_device *dev)
  {
        struct r8192_priv *priv = ieee80211_priv(dev);
+       LED_CTL_MODE LedAction = LED_CTL_NO_LINK;
        u8 msr;
  
        msr  = read_nic_byte(dev, MSR);
         * this is intentional and make sense for ad-hoc and
         * master (see the create BSS/IBSS func)
         */
-       if (priv->ieee80211->state == IEEE80211_LINKED){
+       if (priv->ieee80211->state == IEEE80211_LINKED) {
  
-               if (priv->ieee80211->iw_mode == IW_MODE_INFRA)
+               if (priv->ieee80211->iw_mode == IW_MODE_INFRA) {
                        msr |= (MSR_LINK_MANAGED<<MSR_LINK_SHIFT);
-               else if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
+                       LedAction = LED_CTL_LINK;
+               } else if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
                        msr |= (MSR_LINK_ADHOC<<MSR_LINK_SHIFT);
                else if (priv->ieee80211->iw_mode == IW_MODE_MASTER)
                        msr |= (MSR_LINK_MASTER<<MSR_LINK_SHIFT);
  
-       }else
+       } else
                msr |= (MSR_LINK_NONE<<MSR_LINK_SHIFT);
  
        write_nic_byte(dev, MSR, msr);
+       if(priv->ieee80211->LedControlHandler != NULL)
+               priv->ieee80211->LedControlHandler(dev, LedAction);
  }
  
  void rtl8192_set_chan(struct net_device *dev,short ch)
@@@ -1278,7 -1301,6 +1304,6 @@@ static int rtl8192_rx_initiate(struct n
                          kfree_skb(skb);
                          break;
                  }
- //            printk("nomal packet IN request!\n");
                  usb_fill_bulk_urb(entry, priv->udev,
                                    usb_rcvbulkpipe(priv->udev, 3), skb_tail_pointer(skb),
                                    RX_URB_SIZE, rtl8192_rx_isr, skb);
  
        /* command packet rx procedure */
          while (skb_queue_len(&priv->rx_queue) < MAX_RX_URB + 3) {
- //            printk("command packet IN request!\n");
                  skb = __dev_alloc_skb(RX_URB_SIZE ,GFP_KERNEL);
                  if (!skb)
                          break;
@@@ -2138,15 -2159,13 +2162,13 @@@ short rtl8192SU_tx(struct net_device *d
        struct r8192_priv *priv = ieee80211_priv(dev);
        cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
        tx_desc_819x_usb *tx_desc = (tx_desc_819x_usb *)skb->data;
-       //tx_fwinfo_819x_usb *tx_fwinfo = (tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);//92su del
        struct usb_device *udev = priv->udev;
        int pend;
        int status;
        struct urb *tx_urb = NULL, *tx_urb_zero = NULL;
-       //int urb_len;
        unsigned int idx_pipe;
-       u16             MPDUOverhead = 0;
-       //RT_DEBUG_DATA(COMP_SEND, tcb_desc, sizeof(cb_desc));
+       u16 MPDUOverhead = 0;
+       u16 type = 0;
  
        pend = atomic_read(&priv->tx_pending[tcb_desc->queue_index]);
        /* we are locked here so the two atomic_read and inc are executed
                                    skb->data,
                                    skb->len, rtl8192_tx_isr, skb);
  
+       if (type == IEEE80211_FTYPE_DATA) {
+               if (priv->ieee80211->LedControlHandler != NULL)
+                       priv->ieee80211->LedControlHandler(dev, LED_CTL_TX);
+         }
        status = usb_submit_urb(tx_urb, GFP_ATOMIC);
        if (!status) {
                /*
@@@ -2577,30 -2601,20 +2604,20 @@@ void rtl8192SU_update_ratr_table(struc
  void rtl8192SU_link_change(struct net_device *dev)
  {
        struct r8192_priv *priv = ieee80211_priv(dev);
-       struct ieee80211_device* ieee = priv->ieee80211;
-       //unsigned long flags;
+       struct ieee80211_device *ieee = priv->ieee80211;
        u32 reg = 0;
  
-       printk("=====>%s 1\n", __func__);
        reg = read_nic_dword(dev, RCR);
-       if (ieee->state == IEEE80211_LINKED)
-       {
+       if (ieee->state == IEEE80211_LINKED) {
                rtl8192SU_net_update(dev);
                rtl8192SU_update_ratr_table(dev);
                ieee->SetFwCmdHandler(dev, FW_CMD_HIGH_PWR_ENABLE);
                priv->ReceiveConfig = reg |= RCR_CBSSID;
  
-       }else{
+       } else
                priv->ReceiveConfig = reg &= ~RCR_CBSSID;
-       }
        write_nic_dword(dev, RCR, reg);
        rtl8192_update_msr(dev);
-       printk("<=====%s 2\n", __func__);
  }
  
  static struct ieee80211_qos_parameters def_qos_parameters = {
@@@ -3303,18 -3317,6 +3320,6 @@@ static void rtl8192_init_priv_task(stru
             (unsigned long)priv);
  }
  
- static void rtl8192_get_eeprom_size(struct net_device* dev)
- {
-       u16 curCR = 0;
-       struct r8192_priv *priv = ieee80211_priv(dev);
-       RT_TRACE(COMP_EPROM, "===========>%s()\n", __FUNCTION__);
-       curCR = read_nic_word_E(dev,EPROM_CMD);
-       RT_TRACE(COMP_EPROM, "read from Reg EPROM_CMD(%x):%x\n", EPROM_CMD, curCR);
-       //whether need I consider BIT5?
-       priv->epromtype = (curCR & Cmd9346CR_9356SEL) ? EPROM_93c56 : EPROM_93c46;
-       RT_TRACE(COMP_EPROM, "<===========%s(), epromtype:%d\n", __FUNCTION__, priv->epromtype);
- }
  //used to swap endian. as ntohl & htonl are not neccessary to swap endian, so use this instead.
  static inline u16 endian_swap(u16* data)
  {
@@@ -3409,34 -3411,28 +3414,28 @@@ void update_hal_variables(struct r8192_
        }
  }
  
- //
- //    Description:
- //            Config HW adapter information into initial value.
- //
- //    Assumption:
- //            1. After Auto load fail(i.e, check CR9346 fail)
- //
- //    Created by Roger, 2008.10.21.
- //
- void
- rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device* dev)
+ /*
+  * Description:
+  *    Config HW adapter information into initial value.
+  *
+  *    Assumption:
+  *            1. After Auto load fail(i.e, check CR9346 fail)
+  *
+  */
+ void rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device *dev)
  {
-       struct r8192_priv       *priv = ieee80211_priv(dev);
-       //u16                   i,usValue;
-       //u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x92, 0x00};
-       u8              rf_path;        // For EEPROM/EFUSE After V0.6_1117
-       int     i;
+       struct r8192_priv *priv = ieee80211_priv(dev);
+       u8 rf_path;     /* For EEPROM/EFUSE After V0.6_1117 */
+       int i;
  
        RT_TRACE(COMP_INIT, "====> ConfigAdapterInfo8192SForAutoLoadFail\n");
  
-       write_nic_byte(dev, SYS_ISO_CTRL+1, 0xE8); // Isolation signals from Loader
-       //PlatformStallExecution(10000);
+       /* Isolation signals from Loader */
+       write_nic_byte(dev, SYS_ISO_CTRL+1, 0xE8);
        mdelay(10);
-       write_nic_byte(dev, PMC_FSM, 0x02); // Enable Loader Data Keep
-       //RT_ASSERT(priv->AutoloadFailFlag==TRUE, ("ReadAdapterInfo8192SEEPROM(): AutoloadFailFlag !=TRUE\n"));
+       write_nic_byte(dev, PMC_FSM, 0x02); /* Enable Loader Data Keep */
  
-       // Initialize IC Version && Channel Plan
+       /* Initialize IC Version && Channel Plan */
        priv->eeprom_vid = 0;
        priv->eeprom_pid = 0;
        priv->card_8192_version = 0;
  
        RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid);
        RT_TRACE(COMP_INIT, "EEPROM PID = 0x%4x\n", priv->eeprom_pid);
-       RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID);
-       RT_TRACE(COMP_INIT, "EEPROM SubCustomer ID: 0x%2x\n", priv->eeprom_SubCustomerID);
-       RT_TRACE(COMP_INIT, "EEPROM ChannelPlan = 0x%4x\n", priv->eeprom_ChannelPlan);
-       RT_TRACE(COMP_INIT, "IgnoreDiffRateTxPowerOffset = %d\n", priv->bIgnoreDiffRateTxPowerOffset);
+       RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n",
+                                       priv->eeprom_CustomerID);
+       RT_TRACE(COMP_INIT, "EEPROM SubCustomer ID: 0x%2x\n",
+                                       priv->eeprom_SubCustomerID);
+       RT_TRACE(COMP_INIT, "EEPROM ChannelPlan = 0x%4x\n",
+                                       priv->eeprom_ChannelPlan);
+       RT_TRACE(COMP_INIT, "IgnoreDiffRateTxPowerOffset = %d\n",
+                                       priv->bIgnoreDiffRateTxPowerOffset);
  
        priv->EEPROMUsbOption = EEPROM_USB_Default_OPTIONAL_FUNC;
        RT_TRACE(COMP_INIT, "USB Option = %#x\n", priv->EEPROMUsbOption);
        for(i=0; i<5; i++)
                priv->EEPROMUsbPhyParam[i] = EEPROM_USB_Default_PHY_PARAM;
  
-       //RT_PRINT_DATA(COMP_INIT|COMP_EFUSE, DBG_LOUD, ("EFUSE USB PHY Param: \n"), priv->EEPROMUsbPhyParam, 5);
        {
-       //<Roger_Notes> In this case, we random assigh MAC address here. 2008.10.15.
+       /*
+        * In this case, we randomly assign a MAC address here.
+        */
                static u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x92, 0x00};
-               u8      i;
-               //sMacAddr[5] = (u8)GetRandomNumber(1, 254);
                for(i = 0; i < 6; i++)
                        dev->dev_addr[i] = sMacAddr[i];
        }
-       //NicIFSetMacAddress(Adapter, Adapter->PermanentAddress);
+       /* NicIFSetMacAddress(Adapter, Adapter->PermanentAddress); */
        write_nic_dword(dev, IDR0, ((u32*)dev->dev_addr)[0]);
        write_nic_word(dev, IDR4, ((u16*)(dev->dev_addr + 4))[0]);
  
                dev->dev_addr);
  
        priv->EEPROMBoardType = EEPROM_Default_BoardType;
-       priv->rf_type = RF_1T2R; //RF_2T2R
+       priv->rf_type = RF_1T2R; /* RF_2T2R */
        priv->EEPROMTxPowerDiff = EEPROM_Default_PwDiff;
        priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
        priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap;
        priv->EEPROMTSSI_B = EEPROM_Default_TSSI;
        priv->EEPROMTxPwrTkMode = EEPROM_Default_TxPwrTkMode;
  
        for (rf_path = 0; rf_path < 2; rf_path++)
        {
                for (i = 0; i < 3; i++)
                {
-                       // Read CCK RF A & B Tx power
+                       /* Read CCK RF A & B Tx power */
                        priv->RfCckChnlAreaTxPwr[rf_path][i] =
                        priv->RfOfdmChnlAreaTxPwr1T[rf_path][i] =
                        priv->RfOfdmChnlAreaTxPwr2T[rf_path][i] =
  
        update_hal_variables(priv);
  
-       //
-       // Update remained HAL variables.
-       //
+       /*
+        * Update remaining HAL variables.
+        */
        priv->TSSI_13dBm = priv->EEPROMThermalMeter *100;
-       priv->LegacyHTTxPowerDiff = priv->EEPROMTxPowerDiff;//new
+       priv->LegacyHTTxPowerDiff = priv->EEPROMTxPowerDiff; /* new */
        priv->TxPowerDiff = priv->EEPROMTxPowerDiff;
-       //priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);// Antenna B gain offset to antenna A, bit0~3
-       //priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4);// Antenna C gain offset to antenna A, bit4~7
-       priv->CrystalCap = priv->EEPROMCrystalCap;      // CrystalCap, bit12~15
-       priv->ThermalMeter[0] = priv->EEPROMThermalMeter;// ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
+       /* Antenna B gain offset to antenna A, bit0~3 */
+       /* priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf); */
+       /* Antenna C gain offset to antenna A, bit4~7 */
+       /* priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4); */
+       /* CrystalCap, bit12~15 */
+       priv->CrystalCap = priv->EEPROMCrystalCap;
+       /* ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 */
+       priv->ThermalMeter[0] = priv->EEPROMThermalMeter;
        priv->LedStrategy = SW_LED_MODE0;
  
        init_rate_adaptive(dev);
  
        RT_TRACE(COMP_INIT, "<==== ConfigAdapterInfo8192SForAutoLoadFail\n");
  }
  
- //
- //    Description:
- //            Read HW adapter information by E-Fuse or EEPROM according CR9346 reported.
- //
- //    Assumption:
- //            1. CR9346 regiser has verified.
- //            2. PASSIVE_LEVEL (USB interface)
- //
- //    Created by Roger, 2008.10.21.
- //
- void
- rtl8192SU_ReadAdapterInfo8192SUsb(struct net_device* dev)
+ /*
+  *    Description:
+  *            Read HW adapter information by E-Fuse
+  *            or EEPROM according CR9346 reported.
+  *
+  *    Assumption:
+  *            1. CR9346 regiser has verified.
+  *            2. PASSIVE_LEVEL (USB interface)
+  */
+ void rtl8192SU_ReadAdapterInfo8192SUsb(struct net_device *dev)
  {
-       struct r8192_priv       *priv = ieee80211_priv(dev);
-       u16                     i,usValue;
-       u8                      tmpU1b, tempval;
-       u16                     EEPROMId;
-       u8                      hwinfo[HWSET_MAX_SIZE_92S];
-       u8                      rf_path, index; // For EEPROM/EFUSE After V0.6_1117
-       RT_TRACE(COMP_INIT, "====> ReadAdapterInfo8192SUsb\n");
+       struct r8192_priv *priv = ieee80211_priv(dev);
+       u16 i;
+       u8 tmpU1b, tempval;
+       u16 EEPROMId;
+       u8 hwinfo[HWSET_MAX_SIZE_92S];
+       u8 rf_path, index; /* For EEPROM/EFUSE After V0.6_1117 */
+       struct eeprom_93cx6 eeprom;
+       u16 eeprom_val;
+       eeprom.data = dev;
+       eeprom.register_read = rtl819x_eeprom_register_read;
+       eeprom.register_write = rtl819x_eeprom_register_write;
+       eeprom.width = PCI_EEPROM_WIDTH_93C46;
  
-       //
-       // <Roger_Note> The following operation are prevent Efuse leakage by turn on 2.5V.
-       // 2008.11.25.
-       //
+       /*
+        * The following operation are prevent Efuse leakage by turn on 2.5V.
+        */
        tmpU1b = read_nic_byte(dev, EFUSE_TEST+3);
        write_nic_byte(dev, EFUSE_TEST+3, tmpU1b|0x80);
-       //PlatformStallExecution(1000);
        mdelay(10);
        write_nic_byte(dev, EFUSE_TEST+3, (tmpU1b&(~BIT7)));
  
-       // Retrieve Chip version.
+       /* Retrieve Chip version. */
        priv->card_8192_version = (VERSION_8192S)((read_nic_dword(dev, PMC_FSM)>>16)&0xF);
        RT_TRACE(COMP_INIT, "Chip Version ID: 0x%2x\n", priv->card_8192_version);
  
-       switch(priv->card_8192_version)
-       {
-               case 0:
-                       RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_ACUT.\n");
-                       break;
-               case 1:
-                       RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_BCUT.\n");
-                       break;
-               case 2:
-                       RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_CCUT.\n");
-                       break;
-               default:
-                       RT_TRACE(COMP_INIT, "Unknown Chip Version!!\n");
-                       priv->card_8192_version = VERSION_8192S_BCUT;
-                       break;
+       switch (priv->card_8192_version) {
+       case 0:
+               RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_ACUT.\n");
+               break;
+       case 1:
+               RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_BCUT.\n");
+               break;
+       case 2:
+               RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_CCUT.\n");
+               break;
+       default:
+               RT_TRACE(COMP_INIT, "Unknown Chip Version!!\n");
+               priv->card_8192_version = VERSION_8192S_BCUT;
+               break;
        }
  
-       //if (IS_BOOT_FROM_EEPROM(Adapter))
-       if(priv->EepromOrEfuse)
-       {       // Read frin EEPROM
-               write_nic_byte(dev, SYS_ISO_CTRL+1, 0xE8); // Isolation signals from Loader
-               //PlatformStallExecution(10000);
+       if (priv->EepromOrEfuse) { /* Read from EEPROM */
+               /* Isolation signals from Loader */
+               write_nic_byte(dev, SYS_ISO_CTRL+1, 0xE8);
                mdelay(10);
-               write_nic_byte(dev, PMC_FSM, 0x02); // Enable Loader Data Keep
-               // Read all Content from EEPROM or EFUSE.
-               for(i = 0; i < HWSET_MAX_SIZE_92S; i += 2)
-               {
-                       usValue = eprom_read(dev, (u16) (i>>1));
-                       *((u16*)(&hwinfo[i])) = usValue;
+               /* Enable Loader Data Keep */
+               write_nic_byte(dev, PMC_FSM, 0x02);
+               /* Read all Content from EEPROM or EFUSE. */
+               for (i = 0; i < HWSET_MAX_SIZE_92S; i += 2) {
+                       eeprom_93cx6_read(&eeprom, (u16) (i>>1), &eeprom_val);
+                       *((u16 *)(&hwinfo[i])) = eeprom_val;
                }
-       }
-       else if (!(priv->EepromOrEfuse))
-       {       // Read from EFUSE
-               //
-               // <Roger_Notes> We set Isolation signals from Loader and reset EEPROM after system resuming
-               // from suspend mode.
-               // 2008.10.21.
-               //
-               //PlatformEFIOWrite1Byte(Adapter, SYS_ISO_CTRL+1, 0xE8); // Isolation signals from Loader
-               //PlatformStallExecution(10000);
-               //PlatformEFIOWrite1Byte(Adapter, SYS_FUNC_EN+1, 0x40);
-               //PlatformEFIOWrite1Byte(Adapter, SYS_FUNC_EN+1, 0x50);
-               //tmpU1b = PlatformEFIORead1Byte(Adapter, EFUSE_TEST+3);
-               //PlatformEFIOWrite1Byte(Adapter, EFUSE_TEST+3, (tmpU1b | 0x80));
-               //PlatformEFIOWrite1Byte(Adapter, EFUSE_TEST+3, 0x72);
-               //PlatformEFIOWrite1Byte(Adapter, EFUSE_CLK, 0x03);
-               // Read EFUSE real map to shadow.
+       } else if (!(priv->EepromOrEfuse)) { /* Read from EFUSE */
+               /* Read EFUSE real map to shadow. */
                EFUSE_ShadowMapUpdate(dev);
                memcpy(hwinfo, &priv->EfuseMap[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE_92S);
+       } else {
+               RT_TRACE(COMP_INIT, "%s(): Invalid boot type", __func__);
        }
-       else
-       {
-               RT_TRACE(COMP_INIT, "ReadAdapterInfo8192SUsb(): Invalid boot type!!\n");
-       }
-       //YJ,test,090106
-       //dump_buf(hwinfo,HWSET_MAX_SIZE_92S);
-       //
-       // <Roger_Notes> The following are EFUSE/EEPROM independent operations!!
-       //
-       //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("MAP: \n"), hwinfo, HWSET_MAX_SIZE_92S);
  
-       //
-       // <Roger_Notes> Event though CR9346 regiser can verify whether Autoload is success or not, but we still
-       // double check ID codes for 92S here(e.g., due to HW GPIO polling fail issue).
-       // 2008.10.21.
-       //
+       /*
+        * Even though CR9346 regiser can verify whether Autoload
+        * is success or not, but we still double check ID codes for 92S here
+        * (e.g., due to HW GPIO polling fail issue)
+        */
        EEPROMId = *((u16 *)&hwinfo[0]);
-       if( EEPROMId != RTL8190_EEPROM_ID )
-       {
+       if (EEPROMId != RTL8190_EEPROM_ID) {
                RT_TRACE(COMP_INIT, "ID(%#x) is invalid!!\n", EEPROMId);
                priv->bTXPowerDataReadFromEEPORM = FALSE;
                priv->AutoloadFailFlag=TRUE;
-       }
-       else
-       {
+       } else {
                priv->AutoloadFailFlag=FALSE;
                priv->bTXPowerDataReadFromEEPORM = TRUE;
        }
-        // Read IC Version && Channel Plan
-       if(!priv->AutoloadFailFlag)
-       {
-               // VID, PID
+       /* Read IC Version && Channel Plan */
+       if (!priv->AutoloadFailFlag) {
+               /* VID, PID */
                priv->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID];
                priv->eeprom_pid = *(u16 *)&hwinfo[EEPROM_PID];
                priv->bIgnoreDiffRateTxPowerOffset = false;     //cosa for test
  
  
-               // EEPROM Version ID, Channel plan
+               /* EEPROM Version ID, Channel plan */
                priv->EEPROMVersion = *(u8 *)&hwinfo[EEPROM_Version];
                priv->eeprom_ChannelPlan = *(u8 *)&hwinfo[EEPROM_ChannelPlan];
  
-               // Customer ID, 0x00 and 0xff are reserved for Realtek.
+               /* Customer ID, 0x00 and 0xff are reserved for Realtek. */
                priv->eeprom_CustomerID = *(u8 *)&hwinfo[EEPROM_CustomID];
                priv->eeprom_SubCustomerID = *(u8 *)&hwinfo[EEPROM_SubCustomID];
-       }
-       else
-       {
-               //priv->eeprom_vid = 0;
-               //priv->eeprom_pid = 0;
-               //priv->EEPROMVersion = 0;
-               //priv->eeprom_ChannelPlan = 0;
-               //priv->eeprom_CustomerID = 0;
-               //priv->eeprom_SubCustomerID = 0;
+       } else {
                rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(dev);
                return;
        }
  
        RT_TRACE(COMP_INIT, "EEPROM Id = 0x%4x\n", EEPROMId);
        RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid);
        RT_TRACE(COMP_INIT, "EEPROM PID = 0x%4x\n", priv->eeprom_pid);
        RT_TRACE(COMP_INIT, "EEPROM ChannelPlan = 0x%4x\n", priv->eeprom_ChannelPlan);
        RT_TRACE(COMP_INIT, "bIgnoreDiffRateTxPowerOffset = %d\n", priv->bIgnoreDiffRateTxPowerOffset);
  
-       // Read USB optional function.
-       if(!priv->AutoloadFailFlag)
-       {
+       /* Read USB optional function. */
+       if (!priv->AutoloadFailFlag) {
                priv->EEPROMUsbOption = *(u8 *)&hwinfo[EEPROM_USB_OPTIONAL];
-       }
-       else
-       {
+       } else {
                priv->EEPROMUsbOption = EEPROM_USB_Default_OPTIONAL_FUNC;
        }
  
        priv->EEPROMUsbEndPointNumber = rtl8192SU_UsbOptionToEndPointNumber((priv->EEPROMUsbOption&EEPROM_EP_NUMBER)>>3);
  
        RT_TRACE(COMP_INIT, "USB Option = %#x\n", priv->EEPROMUsbOption);
@@@ -4134,18 -4079,12 +4082,12 @@@ short rtl8192_init(struct net_device *d
        rtl8192_init_priv_variable(dev);
        rtl8192_init_priv_lock(priv);
        rtl8192_init_priv_task(dev);
-       rtl8192_get_eeprom_size(dev);
        priv->ops->rtl819x_read_eeprom_info(dev);
        rtl8192_get_channel_map(dev);
        init_hal_dm(dev);
        init_timer(&priv->watch_dog_timer);
        priv->watch_dog_timer.data = (unsigned long)dev;
        priv->watch_dog_timer.function = watch_dog_timer_callback;
-       //rtl8192_adapter_start(dev);
- #ifdef DEBUG_EPROM
-       dump_eprom(dev);
- #endif
        return 0;
  }
  
@@@ -5513,85 -5452,88 +5455,88 @@@ void rtl819x_update_rxcounts
        }
  }
  
extern        void    rtl819x_watchdog_wqcallback(struct work_struct *work)
void rtl819x_watchdog_wqcallback(struct work_struct *work)
  {
-       struct delayed_work *dwork = container_of(work,struct delayed_work,work);
-        struct r8192_priv *priv = container_of(dwork,struct r8192_priv,watch_dog_wq);
-        struct net_device *dev = priv->ieee80211->dev;
+       struct delayed_work *dwork = container_of(work,
+                                               struct delayed_work,
+                                               work);
+       struct r8192_priv *priv = container_of(dwork,
+                                               struct r8192_priv,
+                                               watch_dog_wq);
+       struct net_device *dev = priv->ieee80211->dev;
        struct ieee80211_device* ieee = priv->ieee80211;
-       RESET_TYPE      ResetType = RESET_TYPE_NORESET;
-               static u8       check_reset_cnt=0;
+       RESET_TYPE ResetType = RESET_TYPE_NORESET;
+       static u8 check_reset_cnt;
+       u32 TotalRxBcnNum = 0;
+       u32 TotalRxDataNum = 0;
        bool bBusyTraffic = false;
  
        if(!priv->up)
                return;
        hal_dm_watchdog(dev);
-       {//to get busy traffic condition
-               if(ieee->state == IEEE80211_LINKED)
-               {
-                       //windows mod 666 to 100.
-                       //if(   ieee->LinkDetectInfo.NumRxOkInPeriod> 666 ||
-                       //      ieee->LinkDetectInfo.NumTxOkInPeriod> 666 ) {
-                       if(     ieee->LinkDetectInfo.NumRxOkInPeriod> 100 ||
-                               ieee->LinkDetectInfo.NumTxOkInPeriod> 100 ) {
+       /* to get busy traffic condition */
+       if (ieee->state == IEEE80211_LINKED) {
+               if (ieee->LinkDetectInfo.NumRxOkInPeriod > 666 ||
+                       ieee->LinkDetectInfo.NumTxOkInPeriod > 666)
                                bBusyTraffic = true;
-                       }
-                       ieee->LinkDetectInfo.NumRxOkInPeriod = 0;
-                       ieee->LinkDetectInfo.NumTxOkInPeriod = 0;
-                       ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic;
-               }
-       }
-       //added by amy for AP roaming
-       {
-               if(priv->ieee80211->state == IEEE80211_LINKED && priv->ieee80211->iw_mode == IW_MODE_INFRA)
-               {
-                       u32     TotalRxBcnNum = 0;
-                       u32     TotalRxDataNum = 0;
  
-                       rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum);
-                       if((TotalRxBcnNum+TotalRxDataNum) == 0)
-                       {
-                               #ifdef TODO
-                               if(rfState == eRfOff)
-                                       RT_TRACE(COMP_ERR,"========>%s()\n",__FUNCTION__);
-                               #endif
-                               printk("===>%s(): AP is power off,connect another one\n",__FUNCTION__);
-                       //      Dot11d_Reset(dev);
-                               priv->ieee80211->state = IEEE80211_ASSOCIATING;
-                               notify_wx_assoc_event(priv->ieee80211);
-                               RemovePeerTS(priv->ieee80211,priv->ieee80211->current_network.bssid);
-                               ieee->is_roaming = true;
-                               priv->ieee80211->link_change(dev);
-                                 queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq);
-                       }
+               ieee->LinkDetectInfo.NumRxOkInPeriod = 0;
+               ieee->LinkDetectInfo.NumTxOkInPeriod = 0;
+               ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic;
+       }
+       if (priv->ieee80211->state == IEEE80211_LINKED &&
+                               priv->ieee80211->iw_mode == IW_MODE_INFRA) {
+               rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum);
+               if ((TotalRxBcnNum + TotalRxDataNum) == 0) {
+                       RT_TRACE(COMP_ERR, "%s(): AP is powered off,"
+                                       "connect another one\n", __func__);
+                       /* Dot11d_Reset(dev); */
+                       priv->ieee80211->state = IEEE80211_ASSOCIATING;
+                       notify_wx_assoc_event(priv->ieee80211);
+                       RemovePeerTS(priv->ieee80211,
+                                       priv->ieee80211->current_network.bssid);
+                       ieee->is_roaming = true;
+                       priv->ieee80211->link_change(dev);
+                       if(ieee->LedControlHandler != NULL)
+                               ieee->LedControlHandler(ieee->dev,
+                                                       LED_CTL_START_TO_LINK);
+                       queue_work(priv->ieee80211->wq,
+                               &priv->ieee80211->associate_procedure_wq);
                }
-               priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod=0;
-               priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod=0;
        }
- //    CAM_read_entry(dev,4);
-       //check if reset the driver
-       if(check_reset_cnt++ >= 3 && !ieee->is_roaming)
-       {
-               ResetType = rtl819x_ifcheck_resetornot(dev);
+       priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod = 0;
+       priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod = 0;
+       /*
+        * CAM_read_entry(dev,4);
+        * check if reset the driver
+        */
+       if (check_reset_cnt++ >= 3 && !ieee->is_roaming) {
+               ResetType = rtl819x_ifcheck_resetornot(dev);
                check_reset_cnt = 3;
-               //DbgPrint("Start to check silent reset\n");
        }
-       //      RT_TRACE(COMP_RESET,"%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",__FUNCTION__,priv->force_reset,priv->ResetProgress,priv->bForcedSilentReset,priv->bDisableNormalResetCheck,ResetType);
- #if 1
-       if( (priv->force_reset) || (priv->ResetProgress==RESET_TYPE_NORESET &&
+       if ((priv->force_reset) || (priv->ResetProgress == RESET_TYPE_NORESET &&
                (priv->bForcedSilentReset ||
-               (!priv->bDisableNormalResetCheck && ResetType==RESET_TYPE_SILENT)))) // This is control by OID set in Pomelo
-       {
-               RT_TRACE(COMP_RESET,"%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",__FUNCTION__,priv->force_reset,priv->ResetProgress,priv->bForcedSilentReset,priv->bDisableNormalResetCheck,ResetType);
+               (!priv->bDisableNormalResetCheck &&
+                /* This is control by OID set in Pomelo */
+               ResetType == RESET_TYPE_SILENT)))) {
+               RT_TRACE(COMP_RESET, "%s(): priv->force_reset is %d,"
+                       "priv->ResetProgress is %d, "
+                       "priv->bForcedSilentReset is %d, "
+                       "priv->bDisableNormalResetCheck is %d, "
+                       "ResetType is %d",
+                                       __func__,
+                                       priv->force_reset,
+                                       priv->ResetProgress,
+                                       priv->bForcedSilentReset,
+                                       priv->bDisableNormalResetCheck,
+                                       ResetType);
                rtl819x_ifsilentreset(dev);
        }
- #endif
        priv->force_reset = false;
        priv->bForcedSilentReset = false;
        priv->bResetInProgress = false;
-       RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n");
  }
  
  void watch_dog_timer_callback(unsigned long data)
@@@ -5816,7 -5758,7 +5761,7 @@@ int rtl8192_ioctl(struct net_device *de
               goto out;
        }
  
-      ipw = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL);
+      ipw = kmalloc(p->length, GFP_KERNEL);
       if (ipw == NULL){
               ret = -ENOMEM;
               goto out;
@@@ -7593,96 -7535,113 +7538,113 @@@ void rtl8192_try_wake_queue(struct net_
  
  void EnableHWSecurityConfig8192(struct net_device *dev)
  {
-         u8 SECR_value = 0x0;
+       u8 SECR_value = 0x0;
        struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-        struct ieee80211_device* ieee = priv->ieee80211;
+       struct ieee80211_device *ieee = priv->ieee80211;
  
        SECR_value = SCR_TxEncEnable | SCR_RxDecEnable;
- #if 1
-       if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->ieee80211->auth_mode != 2))
-       {
-               SECR_value |= SCR_RxUseDK;
-               SECR_value |= SCR_TxUseDK;
-       }
-       else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP)))
-       {
-               SECR_value |= SCR_RxUseDK;
-               SECR_value |= SCR_TxUseDK;
+       switch (ieee->pairwise_key_type) {
+       case KEY_TYPE_WEP40:
+       case KEY_TYPE_WEP104:
+               if (priv->ieee80211->auth_mode != 2) {
+                       SECR_value |= SCR_RxUseDK;
+                       SECR_value |= SCR_TxUseDK;
+               }
+               break;
+       case KEY_TYPE_TKIP:
+       case KEY_TYPE_CCMP:
+               if (ieee->iw_mode == IW_MODE_ADHOC) {
+                       SECR_value |= SCR_RxUseDK;
+                       SECR_value |= SCR_TxUseDK;
+               }
+               break;
+       default:
+               break;
        }
- #endif
-         //add HWSec active enable here.
- //default using hwsec. when peer AP is in N mode only and pairwise_key_type is none_aes(which HT_IOT_ACT_PURE_N_MODE indicates it), use software security. when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes, use g mode hw security. WB on 2008.7.4
  
+       /*
+        * add HWSec active enable here.
+        * default using hwsec.
+        * when peer AP is in N mode only and pairwise_key_type is none_aes
+        * (which HT_IOT_ACT_PURE_N_MODE indicates it),
+        * use software security.
+        * when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes
+        * use g mode hw security.
+       */
        ieee->hwsec_active = 1;
  
-       if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep)//!ieee->hwsec_support) //add hwsec_support flag to totol control hw_sec on/off
-       {
+       /* add hwsec_support flag to totol control hw_sec on/off */
+       if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep) {
                ieee->hwsec_active = 0;
                SECR_value &= ~SCR_RxDecEnable;
        }
  
-       RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __FUNCTION__, \
-                       ieee->hwsec_active, ieee->pairwise_key_type, SECR_value);
-       {
-                 write_nic_byte(dev, SECR,  SECR_value);//SECR_value |  SCR_UseDK );
-         }
+       RT_TRACE(COMP_SEC, "%s(): hwsec: %d, pairwise_key: %d, "
+                                       "SECR_value: %x",
+                                       __func__, ieee->hwsec_active,
+                                       ieee->pairwise_key_type, SECR_value);
+       write_nic_byte(dev, SECR,  SECR_value); /* SECR_value |  SCR_UseDK ); */
  }
  
  
- void setKey(  struct net_device *dev,
+ void setKey(struct net_device *dev,
                u8 EntryNo,
                u8 KeyIndex,
                u16 KeyType,
                u8 *MacAddr,
                u8 DefaultKey,
-               u32 *KeyContent )
+               u32 *KeyContent)
  {
        u32 TargetCommand = 0;
        u32 TargetContent = 0;
        u16 usConfig = 0;
        u8 i;
        if (EntryNo >= TOTAL_CAM_ENTRY)
-               RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n");
+               RT_TRACE(COMP_ERR, "%s(): cam entry exceeds TOTAL_CAM_ENTRY",
+                                                               __func__);
  
-       RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n", dev,EntryNo, KeyIndex, KeyType, MacAddr);
+       RT_TRACE(COMP_SEC, "%s(): dev: %p, EntryNo: %d, "
+                               "KeyIndex: %d, KeyType: %d, MacAddr: %pM",
+                               __func__, dev, EntryNo,
+                               KeyIndex, KeyType, MacAddr);
  
        if (DefaultKey)
-               usConfig |= BIT15 | (KeyType<<2);
+               usConfig |= BIT15 | (KeyType << 2);
        else
-               usConfig |= BIT15 | (KeyType<<2) | KeyIndex;
- //    usConfig |= BIT15 | (KeyType<<2) | (DefaultKey<<5) | KeyIndex;
+               usConfig |= BIT15 | (KeyType << 2) | KeyIndex;
  
-       for(i=0 ; i<CAM_CONTENT_COUNT; i++){
-               TargetCommand  = i+CAM_CONTENT_COUNT*EntryNo;
+       for (i = 0 ; i < CAM_CONTENT_COUNT; i++) {
+               TargetCommand  = i + CAM_CONTENT_COUNT * EntryNo;
                TargetCommand |= BIT31|BIT16;
-               if(i==0){//MAC|Config
-                       TargetContent = (u32)(*(MacAddr+0)) << 16|
-                                       (u32)(*(MacAddr+1)) << 24|
+               switch (i) {
+               case 0: /* MAC|Config */
+                       TargetContent = (u32)(*(MacAddr + 0)) << 16|
+                                       (u32)(*(MacAddr + 1)) << 24|
                                        (u32)usConfig;
  
                        write_nic_dword(dev, WCAMI, TargetContent);
                        write_nic_dword(dev, RWCAM, TargetCommand);
-       //              printk("setkey cam =%8x\n", read_cam(dev, i+6*EntryNo));
-               }
-               else if(i==1){//MAC
-                         TargetContent = (u32)(*(MacAddr+2))    |
-                                         (u32)(*(MacAddr+3)) <<  8|
-                                         (u32)(*(MacAddr+4)) << 16|
-                                         (u32)(*(MacAddr+5)) << 24;
+                       continue;
+               case 1: /* MAC */
+                                       TargetContent = (u32)(*(MacAddr + 2))|
+                                       (u32)(*(MacAddr + 3)) <<  8|
+                                       (u32)(*(MacAddr + 4)) << 16|
+                                       (u32)(*(MacAddr + 5)) << 24;
                        write_nic_dword(dev, WCAMI, TargetContent);
                        write_nic_dword(dev, RWCAM, TargetCommand);
+                       continue;
+               default: /* Key Material */
+                       if (KeyContent != NULL) {
+                               write_nic_dword(dev, WCAMI,
+                                               (u32)(*(KeyContent+i-2)));
+                               write_nic_dword(dev, RWCAM,
+                                               TargetCommand);
+                       }
+                       continue;
                }
-               else {
-                       //Key Material
-                       if(KeyContent !=NULL){
-                       write_nic_dword(dev, WCAMI, (u32)(*(KeyContent+i-2)) );
-                       write_nic_dword(dev, RWCAM, TargetCommand);
-               }
-       }
        }
  }
  
  /***************************************************************************
@@@ -58,17 -58,17 +58,17 @@@ static struct usb_device_id id_table[] 
  MODULE_DEVICE_TABLE(usb, id_table);
  
  #ifndef CONFIG_FB_DEFERRED_IO
- #warning message "kernel FB_DEFFERRED_IO option to support generic fbdev apps"
+ #warning Please set CONFIG_FB_DEFFERRED_IO option to support generic fbdev apps
  #endif
  
  #ifndef CONFIG_FB_SYS_IMAGEBLIT
  #ifndef CONFIG_FB_SYS_IMAGEBLIT_MODULE
- #warning message "FB_SYS_* in kernel or module option to support fb console"
+ #warning Please set CONFIG_FB_SYS_IMAGEBLIT option to support fb console
  #endif
  #endif
  
  #ifndef CONFIG_FB_MODE_HELPERS
- #warning message "kernel FB_MODE_HELPERS required. Expect build break"
+ #warning CONFIG_FB_MODE_HELPERS required. Expect build break
  #endif
  
  /* dlfb keeps a list of urbs for efficient bulk transfers */
@@@ -366,32 -366,32 +366,32 @@@ static int dlfb_trim_hline(const u8 *bb
  }
  
  /*
- Render a command stream for an encoded horizontal line segment of pixels.
- A command buffer holds several commands.
- It always begins with a fresh command header
- (the protocol doesn't require this, but we enforce it to allow
- multiple buffers to be potentially encoded and sent in parallel).
- A single command encodes one contiguous horizontal line of pixels
- The function relies on the client to do all allocation, so that
- rendering can be done directly to output buffers (e.g. USB URBs).
- The function fills the supplied command buffer, providing information
- on where it left off, so the client may call in again with additional
- buffers if the line will take several buffers to complete.
- A single command can transmit a maximum of 256 pixels,
- regardless of the compression ratio (protocol design limit).
- To the hardware, 0 for a size byte means 256
- Rather than 256 pixel commands which are either rl or raw encoded,
- the rlx command simply assumes alternating raw and rl spans within one cmd.
- This has a slightly larger header overhead, but produces more even results.
- It also processes all data (read and write) in a single pass.
- Performance benchmarks of common cases show it having just slightly better
- compression than 256 pixel raw -or- rle commands, with similar CPU consumpion.
- But for very rl friendly data, will compress not quite as well.
- */
 * Render a command stream for an encoded horizontal line segment of pixels.
+  *
 * A command buffer holds several commands.
 * It always begins with a fresh command header
 * (the protocol doesn't require this, but we enforce it to allow
 * multiple buffers to be potentially encoded and sent in parallel).
 * A single command encodes one contiguous horizontal line of pixels
+  *
 * The function relies on the client to do all allocation, so that
 * rendering can be done directly to output buffers (e.g. USB URBs).
 * The function fills the supplied command buffer, providing information
 * on where it left off, so the client may call in again with additional
 * buffers if the line will take several buffers to complete.
+  *
 * A single command can transmit a maximum of 256 pixels,
 * regardless of the compression ratio (protocol design limit).
 * To the hardware, 0 for a size byte means 256
+  * 
 * Rather than 256 pixel commands which are either rl or raw encoded,
 * the rlx command simply assumes alternating raw and rl spans within one cmd.
 * This has a slightly larger header overhead, but produces more even results.
 * It also processes all data (read and write) in a single pass.
 * Performance benchmarks of common cases show it having just slightly better
 * compression than 256 pixel raw -or- rle commands, with similar CPU consumpion.
 * But for very rl friendly data, will compress not quite as well.
 */
  static void dlfb_compress_hline(
        const uint16_t **pixel_start_ptr,
        const uint16_t *const pixel_end,
@@@ -1438,7 -1438,7 +1438,7 @@@ static int __init dlfb_module_init(void
        if (res)
                err("usb_register failed. Error number %d", res);
  
-       printk("VMODES initialized\n");
+       printk(KERN_INFO "VMODES initialized\n");
  
        return res;
  }
@@@ -1508,8 -1508,8 +1508,8 @@@ static void dlfb_free_urb_list(struct d
                urb = unode->urb;
  
                /* Free each separately allocated piece */
 -              usb_buffer_free(urb->dev, dev->urbs.size,
 -                      urb->transfer_buffer, urb->transfer_dma);
 +              usb_free_coherent(urb->dev, dev->urbs.size,
 +                                urb->transfer_buffer, urb->transfer_dma);
                usb_free_urb(urb);
                kfree(node);
        }
@@@ -1543,8 -1543,8 +1543,8 @@@ static int dlfb_alloc_urb_list(struct d
                }
                unode->urb = urb;
  
 -              buf = usb_buffer_alloc(dev->udev, MAX_TRANSFER, GFP_KERNEL,
 -                                      &urb->transfer_dma);
 +              buf = usb_alloc_coherent(dev->udev, MAX_TRANSFER, GFP_KERNEL,
 +                                       &urb->transfer_dma);
                if (!buf) {
                        kfree(unode);
                        usb_free_urb(urb);
  
        kref_get(&dev->kref); /* released in free_render_urbs() */
  
-       dl_notice("allocated %d %d byte urbs \n", i, (int) size);
+       dl_notice("allocated %d %d byte urbs\n", i, (int) size);
  
        return i;
  }
@@@ -21,7 -21,7 +21,7 @@@
  
  #include "usbip_common.h"
  #include "stub.h"
 -#include "../../usb/core/hcd.h"
 +#include <linux/usb/hcd.h>
  
  
  static int is_clear_halt_cmd(struct urb *urb)
@@@ -502,13 -502,13 +502,13 @@@ static void stub_recv_cmd_submit(struc
        }
  
        /* set priv->urb->setup_packet */
-       priv->urb->setup_packet = kzalloc(8, GFP_KERNEL);
+       priv->urb->setup_packet = kmemdup(&pdu->u.cmd_submit.setup, 8,
+                                         GFP_KERNEL);
        if (!priv->urb->setup_packet) {
                dev_err(&sdev->interface->dev, "allocate setup_packet\n");
                usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC);
                return;
        }
-       memcpy(priv->urb->setup_packet, &pdu->u.cmd_submit.setup, 8);
  
        /* set other members from the base header of pdu */
        priv->urb->context                = (void *) priv;
@@@ -26,9 -26,9 +26,9 @@@
  #include <linux/spinlock.h>
  #include <linux/sched.h>
  #include <linux/slab.h>
- #include <asm/time.h>
- #include <asm/io.h>
- #include <asm/uaccess.h>
+ #include <linux/time.h>
+ #include <linux/io.h>
+ #include <linux/uaccess.h>
  
  #include "../vme.h"
  #include "../vme_bridge.h"
@@@ -40,27 -40,6 +40,6 @@@ static void tsi148_remove(struct pci_de
  static void __exit tsi148_exit(void);
  
  
- int tsi148_slave_set(struct vme_slave_resource *, int, unsigned long long,
-       unsigned long long, dma_addr_t, vme_address_t, vme_cycle_t);
- int tsi148_slave_get(struct vme_slave_resource *, int *, unsigned long long *,
-       unsigned long long *, dma_addr_t *, vme_address_t *, vme_cycle_t *);
- int tsi148_master_get(struct vme_master_resource *, int *, unsigned long long *,
-         unsigned long long *, vme_address_t *, vme_cycle_t *, vme_width_t *);
- int tsi148_master_set(struct vme_master_resource *, int, unsigned long long,
-       unsigned long long, vme_address_t, vme_cycle_t, vme_width_t);
- ssize_t tsi148_master_read(struct vme_master_resource *, void *, size_t,
-       loff_t);
- ssize_t tsi148_master_write(struct vme_master_resource *, void *, size_t,
-       loff_t);
- unsigned int tsi148_master_rmw(struct vme_master_resource *, unsigned int,
-       unsigned int, unsigned int, loff_t);
- int tsi148_dma_list_add (struct vme_dma_list *, struct vme_dma_attr *,
-       struct vme_dma_attr *, size_t);
- int tsi148_dma_list_exec(struct vme_dma_list *);
- int tsi148_dma_list_empty(struct vme_dma_list *);
- int tsi148_generate_irq(int, int);
  /* Module parameter */
  static int err_chk;
  static int geoid;
@@@ -122,7 -101,7 +101,7 @@@ static u32 tsi148_LM_irqhandler(struct 
        u32 serviced = 0;
  
        for (i = 0; i < 4; i++) {
-               if(stat & TSI148_LCSR_INTS_LMS[i]) {
+               if (stat & TSI148_LCSR_INTS_LMS[i]) {
                        /* We only enable interrupts if the callback is set */
                        bridge->lm_callback[i](i);
                        serviced |= TSI148_LCSR_INTC_LMC[i];
   *
   * XXX This functionality is not exposed up though API.
   */
- static u32 tsi148_MB_irqhandler(struct tsi148_driver *bridge, u32 stat)
+ static u32 tsi148_MB_irqhandler(struct vme_bridge *tsi148_bridge, u32 stat)
  {
        int i;
        u32 val;
        u32 serviced = 0;
+       struct tsi148_driver *bridge;
+       bridge = tsi148_bridge->driver_priv;
  
        for (i = 0; i < 4; i++) {
-               if(stat & TSI148_LCSR_INTS_MBS[i]) {
+               if (stat & TSI148_LCSR_INTS_MBS[i]) {
                        val = ioread32be(bridge->base + TSI148_GCSR_MBOX[i]);
-                       printk("VME Mailbox %d received: 0x%x\n", i, val);
+                       dev_err(tsi148_bridge->parent, "VME Mailbox %d received"
+                               ": 0x%x\n", i, val);
                        serviced |= TSI148_LCSR_INTC_MBC[i];
                }
        }
  /*
   * Display error & status message when PERR (PCI) exception interrupt occurs.
   */
- static u32 tsi148_PERR_irqhandler(struct tsi148_driver *bridge)
+ static u32 tsi148_PERR_irqhandler(struct vme_bridge *tsi148_bridge)
  {
-       printk(KERN_ERR
-               "PCI Exception at address: 0x%08x:%08x, attributes: %08x\n",
+       struct tsi148_driver *bridge;
+       bridge = tsi148_bridge->driver_priv;
+       dev_err(tsi148_bridge->parent, "PCI Exception at address: 0x%08x:%08x, "
+               "attributes: %08x\n",
                ioread32be(bridge->base + TSI148_LCSR_EDPAU),
                ioread32be(bridge->base + TSI148_LCSR_EDPAL),
-               ioread32be(bridge->base + TSI148_LCSR_EDPAT)
-               );
-       printk(KERN_ERR
-               "PCI-X attribute reg: %08x, PCI-X split completion reg: %08x\n",
+               ioread32be(bridge->base + TSI148_LCSR_EDPAT));
+       dev_err(tsi148_bridge->parent, "PCI-X attribute reg: %08x, PCI-X split "
+               "completion reg: %08x\n",
                ioread32be(bridge->base + TSI148_LCSR_EDPXA),
-               ioread32be(bridge->base + TSI148_LCSR_EDPXS)
-               );
+               ioread32be(bridge->base + TSI148_LCSR_EDPXS));
  
        iowrite32be(TSI148_LCSR_EDPAT_EDPCL, bridge->base + TSI148_LCSR_EDPAT);
  
@@@ -196,22 -182,21 +182,21 @@@ static u32 tsi148_VERR_irqhandler(struc
        reg_join(error_addr_high, error_addr_low, &error_addr);
  
        /* Check for exception register overflow (we have lost error data) */
-       if(error_attrib & TSI148_LCSR_VEAT_VEOF) {
-               printk(KERN_ERR "VME Bus Exception Overflow Occurred\n");
+       if (error_attrib & TSI148_LCSR_VEAT_VEOF) {
+               dev_err(tsi148_bridge->parent, "VME Bus Exception Overflow "
+                       "Occurred\n");
        }
  
-       error = (struct vme_bus_error *)kmalloc(sizeof (struct vme_bus_error),
-               GFP_ATOMIC);
+       error = kmalloc(sizeof(struct vme_bus_error), GFP_ATOMIC);
        if (error) {
                error->address = error_addr;
                error->attributes = error_attrib;
                list_add_tail(&(error->list), &(tsi148_bridge->vme_errors));
        } else {
-               printk(KERN_ERR
-                       "Unable to alloc memory for VMEbus Error reporting\n");
-               printk(KERN_ERR
-                       "VME Bus Error at address: 0x%llx, attributes: %08x\n",
-                       error_addr, error_attrib);
+               dev_err(tsi148_bridge->parent, "Unable to alloc memory for "
+                       "VMEbus Error reporting\n");
+               dev_err(tsi148_bridge->parent, "VME Bus Error at address: "
+                       "0x%llx, attributes: %08x\n", error_addr, error_attrib);
        }
  
        /* Clear Status */
@@@ -244,10 -229,9 +229,9 @@@ static u32 tsi148_VIRQ_irqhandler(struc
        for (i = 7; i > 0; i--) {
                if (stat & (1 << i)) {
                        /*
-                        *      Note:   Even though the registers are defined
-                        *      as 32-bits in the spec, we only want to issue
-                        *      8-bit IACK cycles on the bus, read from offset
-                        *      3.
+                        * Note: Even though the registers are defined as
+                        * 32-bits in the spec, we only want to issue 8-bit
+                        * IACK cycles on the bus, read from offset 3.
                         */
                        vec = ioread8(bridge->base + TSI148_LCSR_VIACK[i] + 3);
  
@@@ -281,9 -265,8 +265,8 @@@ static irqreturn_t tsi148_irqhandler(in
        /* Only look at unmasked interrupts */
        stat &= enable;
  
-       if (unlikely(!stat)) {
+       if (unlikely(!stat))
                return IRQ_NONE;
-       }
  
        /* Call subhandlers as appropriate */
        /* DMA irqs */
        /* Mail box irqs */
        if (stat & (TSI148_LCSR_INTS_MB3S | TSI148_LCSR_INTS_MB2S |
                        TSI148_LCSR_INTS_MB1S | TSI148_LCSR_INTS_MB0S))
-               serviced |= tsi148_MB_irqhandler(bridge, stat);
+               serviced |= tsi148_MB_irqhandler(tsi148_bridge, stat);
  
        /* PCI bus error */
        if (stat & TSI148_LCSR_INTS_PERRS)
-               serviced |= tsi148_PERR_irqhandler(bridge);
+               serviced |= tsi148_PERR_irqhandler(tsi148_bridge);
  
        /* VME bus error */
        if (stat & TSI148_LCSR_INTS_VERRS)
@@@ -346,8 -329,8 +329,8 @@@ static int tsi148_irq_init(struct vme_b
                             IRQF_SHARED,
                             driver_name, tsi148_bridge);
        if (result) {
-               dev_err(&pdev->dev, "Can't get assigned pci irq vector %02X\n",
-                       pdev->irq);
+               dev_err(tsi148_bridge->parent, "Can't get assigned pci irq "
+                       "vector %02X\n", pdev->irq);
                return result;
        }
  
@@@ -515,7 -498,9 +498,9 @@@ static struct vme_bus_error *tsi148_fin
        /* Iterate through errors */
        list_for_each(err_pos, &(tsi148_bridge->vme_errors)) {
                vme_err = list_entry(err_pos, struct vme_bus_error, list);
-               if((vme_err->address >= address) && (vme_err->address < bound)){
+               if ((vme_err->address >= address) &&
+                       (vme_err->address < bound)) {
                        valid = vme_err;
                        break;
                }
@@@ -548,7 -533,9 +533,9 @@@ static void tsi148_clear_errors(struct 
        list_for_each_safe(err_pos, temp, &(tsi148_bridge->vme_errors)) {
                vme_err = list_entry(err_pos, struct vme_bus_error, list);
  
-               if((vme_err->address >= address) && (vme_err->address < bound)){
+               if ((vme_err->address >= address) &&
+                       (vme_err->address < bound)) {
                        list_del(err_pos);
                        kfree(vme_err);
                }
@@@ -568,9 -555,11 +555,11 @@@ int tsi148_slave_set(struct vme_slave_r
        unsigned int vme_bound_low, vme_bound_high;
        unsigned int pci_offset_low, pci_offset_high;
        unsigned long long vme_bound, pci_offset;
+       struct vme_bridge *tsi148_bridge;
        struct tsi148_driver *bridge;
  
-       bridge = image->parent->driver_priv;
+       tsi148_bridge = image->parent;
+       bridge = tsi148_bridge->driver_priv;
  
        i = image->number;
  
        case VME_USER3:
        case VME_USER4:
        default:
-               printk("Invalid address space\n");
+               dev_err(tsi148_bridge->parent, "Invalid address space\n");
                return -EINVAL;
                break;
        }
        reg_split(pci_offset, &pci_offset_high, &pci_offset_low);
  
        if (vme_base_low & (granularity - 1)) {
-               printk("Invalid VME base alignment\n");
+               dev_err(tsi148_bridge->parent, "Invalid VME base alignment\n");
                return -EINVAL;
        }
        if (vme_bound_low & (granularity - 1)) {
-               printk("Invalid VME bound alignment\n");
+               dev_err(tsi148_bridge->parent, "Invalid VME bound alignment\n");
                return -EINVAL;
        }
        if (pci_offset_low & (granularity - 1)) {
-               printk("Invalid PCI Offset alignment\n");
+               dev_err(tsi148_bridge->parent, "Invalid PCI Offset "
+                       "alignment\n");
                return -EINVAL;
        }
  
@@@ -815,12 -805,7 +805,7 @@@ static int tsi148_alloc_resource(struc
  
        tsi148_bridge = image->parent;
  
-       /* Find pci_dev container of dev */
-         if (tsi148_bridge->parent == NULL) {
-                 printk("Dev entry NULL\n");
-                 return -EINVAL;
-         }
-         pdev = container_of(tsi148_bridge->parent, struct pci_dev, dev);
+       pdev = container_of(tsi148_bridge->parent, struct pci_dev, dev);
  
        existing_size = (unsigned long long)(image->bus_resource.end -
                image->bus_resource.start);
        }
  
        /* Exit here if size is zero */
-       if (size == 0) {
+       if (size == 0)
                return 0;
-       }
  
        if (image->bus_resource.name == NULL) {
                image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_KERNEL);
                if (image->bus_resource.name == NULL) {
-                       printk(KERN_ERR "Unable to allocate memory for resource"
-                               " name\n");
+                       dev_err(tsi148_bridge->parent, "Unable to allocate "
+                               "memory for resource name\n");
                        retval = -ENOMEM;
                        goto err_name;
                }
                &(image->bus_resource), size, size, PCIBIOS_MIN_MEM,
                0, NULL, NULL);
        if (retval) {
-               printk(KERN_ERR "Failed to allocate mem resource for "
-                       "window %d size 0x%lx start 0x%lx\n",
+               dev_err(tsi148_bridge->parent, "Failed to allocate mem "
+                       "resource for window %d size 0x%lx start 0x%lx\n",
                        image->number, (unsigned long)size,
                        (unsigned long)image->bus_resource.start);
                goto err_resource;
        image->kern_base = ioremap_nocache(
                image->bus_resource.start, size);
        if (image->kern_base == NULL) {
-               printk(KERN_ERR "Failed to remap resource\n");
+               dev_err(tsi148_bridge->parent, "Failed to remap resource\n");
                retval = -ENOMEM;
                goto err_remap;
        }
@@@ -907,7 -891,7 +891,7 @@@ static void tsi148_free_resource(struc
  /*
   * Set the attributes of an outbound window.
   */
- int tsi148_master_set( struct vme_master_resource *image, int enabled,
+ int tsi148_master_set(struct vme_master_resource *image, int enabled,
        unsigned long long vme_base, unsigned long long size,
        vme_address_t aspace, vme_cycle_t cycle, vme_width_t dwidth)
  {
        unsigned int pci_bound_low, pci_bound_high;
        unsigned int vme_offset_low, vme_offset_high;
        unsigned long long pci_bound, vme_offset, pci_base;
+       struct vme_bridge *tsi148_bridge;
        struct tsi148_driver *bridge;
  
-       bridge = image->parent->driver_priv;
+       tsi148_bridge = image->parent;
+       bridge = tsi148_bridge->driver_priv;
  
        /* Verify input data */
        if (vme_base & 0xFFFF) {
-               printk(KERN_ERR "Invalid VME Window alignment\n");
+               dev_err(tsi148_bridge->parent, "Invalid VME Window "
+                       "alignment\n");
                retval = -EINVAL;
                goto err_window;
        }
  
        if ((size == 0) && (enabled != 0)) {
-               printk(KERN_ERR "Size must be non-zero for enabled windows\n");
+               dev_err(tsi148_bridge->parent, "Size must be non-zero for "
+                       "enabled windows\n");
                retval = -EINVAL;
                goto err_window;
        }
        retval = tsi148_alloc_resource(image, size);
        if (retval) {
                spin_unlock(&(image->lock));
-               printk(KERN_ERR "Unable to allocate memory for "
+               dev_err(tsi148_bridge->parent, "Unable to allocate memory for "
                        "resource\n");
                goto err_res;
        }
  
        if (pci_base_low & 0xFFFF) {
                spin_unlock(&(image->lock));
-               printk(KERN_ERR "Invalid PCI base alignment\n");
+               dev_err(tsi148_bridge->parent, "Invalid PCI base alignment\n");
                retval = -EINVAL;
                goto err_gran;
        }
        if (pci_bound_low & 0xFFFF) {
                spin_unlock(&(image->lock));
-               printk(KERN_ERR "Invalid PCI bound alignment\n");
+               dev_err(tsi148_bridge->parent, "Invalid PCI bound alignment\n");
                retval = -EINVAL;
                goto err_gran;
        }
        if (vme_offset_low & 0xFFFF) {
                spin_unlock(&(image->lock));
-               printk(KERN_ERR "Invalid VME Offset alignment\n");
+               dev_err(tsi148_bridge->parent, "Invalid VME Offset "
+                       "alignment\n");
                retval = -EINVAL;
                goto err_gran;
        }
                temp_ctl |= TSI148_LCSR_OTAT_TM_2eSST;
        }
        if (cycle & VME_2eSSTB) {
-               printk(KERN_WARNING "Currently not setting Broadcast Select "
-                       "Registers\n");
+               dev_warn(tsi148_bridge->parent, "Currently not setting "
+                       "Broadcast Select Registers\n");
                temp_ctl &= ~TSI148_LCSR_OTAT_TM_M;
                temp_ctl |= TSI148_LCSR_OTAT_TM_2eSSTB;
        }
                break;
        default:
                spin_unlock(&(image->lock));
-               printk(KERN_ERR "Invalid data width\n");
+               dev_err(tsi148_bridge->parent, "Invalid data width\n");
                retval = -EINVAL;
                goto err_dwidth;
        }
                break;
        default:
                spin_unlock(&(image->lock));
-               printk(KERN_ERR "Invalid address space\n");
+               dev_err(tsi148_bridge->parent, "Invalid address space\n");
                retval = -EINVAL;
                goto err_aspace;
                break;
@@@ -1137,7 -1127,7 +1127,7 @@@ err_window
   *
   * XXX Not parsing prefetch information.
   */
- int __tsi148_master_get( struct vme_master_resource *image, int *enabled,
+ int __tsi148_master_get(struct vme_master_resource *image, int *enabled,
        unsigned long long *vme_base, unsigned long long *size,
        vme_address_t *aspace, vme_cycle_t *cycle, vme_width_t *dwidth)
  {
                *cycle |= VME_2eSST320;
  
        /* Setup cycle types */
-       if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_SCT)
+       if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_SCT)
                *cycle |= VME_SCT;
-       if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_BLT)
+       if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_BLT)
                *cycle |= VME_BLT;
-       if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_MBLT)
+       if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_MBLT)
                *cycle |= VME_MBLT;
-       if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_2eVME)
+       if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_2eVME)
                *cycle |= VME_2eVME;
-       if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_2eSST)
+       if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_2eSST)
                *cycle |= VME_2eSST;
-       if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_2eSSTB)
+       if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_2eSSTB)
                *cycle |= VME_2eSSTB;
  
        if (ctl & TSI148_LCSR_OTAT_SUP)
  }
  
  
- int tsi148_master_get( struct vme_master_resource *image, int *enabled,
+ int tsi148_master_get(struct vme_master_resource *image, int *enabled,
        unsigned long long *vme_base, unsigned long long *size,
        vme_address_t *aspace, vme_cycle_t *cycle, vme_width_t *dwidth)
  {
@@@ -1289,7 -1279,7 +1279,7 @@@ ssize_t tsi148_master_read(struct vme_m
  
        vme_err = tsi148_find_error(tsi148_bridge, aspace, vme_base + offset,
                count);
-       if(vme_err != NULL) {
+       if (vme_err != NULL) {
                dev_err(image->parent->parent, "First VME read error detected "
                        "an at address 0x%llx\n", vme_err->address);
                retval = vme_err->address - (vme_base + offset);
@@@ -1352,9 -1342,9 +1342,9 @@@ ssize_t tsi148_master_write(struct vme_
  
        vme_err = tsi148_find_error(tsi148_bridge, aspace, vme_base + offset,
                count);
-       if(vme_err != NULL) {
-               printk("First VME write error detected an at address 0x%llx\n",
-                       vme_err->address);
+       if (vme_err != NULL) {
+               dev_warn(tsi148_bridge->parent, "First VME write error detected"
+                       " an at address 0x%llx\n", vme_err->address);
                retval = vme_err->address - (vme_base + offset);
                /* Clear down save errors in this address range */
                tsi148_clear_errors(tsi148_bridge, aspace, vme_base + offset,
@@@ -1428,8 -1418,8 +1418,8 @@@ unsigned int tsi148_master_rmw(struct v
        return result;
  }
  
- static int tsi148_dma_set_vme_src_attributes (u32 *attr, vme_address_t aspace,
-       vme_cycle_t cycle, vme_width_t dwidth)
+ static int tsi148_dma_set_vme_src_attributes(struct device *dev, u32 *attr,
+       vme_address_t aspace, vme_cycle_t cycle, vme_width_t dwidth)
  {
        /* Setup 2eSST speeds */
        switch (cycle & (VME_2eSST160 | VME_2eSST267 | VME_2eSST320)) {
        }
  
        /* Setup cycle types */
-       if (cycle & VME_SCT) {
+       if (cycle & VME_SCT)
                *attr |= TSI148_LCSR_DSAT_TM_SCT;
-       }
-       if (cycle & VME_BLT) {
+       if (cycle & VME_BLT)
                *attr |= TSI148_LCSR_DSAT_TM_BLT;
-       }
-       if (cycle & VME_MBLT) {
+       if (cycle & VME_MBLT)
                *attr |= TSI148_LCSR_DSAT_TM_MBLT;
-       }
-       if (cycle & VME_2eVME) {
+       if (cycle & VME_2eVME)
                *attr |= TSI148_LCSR_DSAT_TM_2eVME;
-       }
-       if (cycle & VME_2eSST) {
+       if (cycle & VME_2eSST)
                *attr |= TSI148_LCSR_DSAT_TM_2eSST;
-       }
        if (cycle & VME_2eSSTB) {
-               printk("Currently not setting Broadcast Select Registers\n");
+               dev_err(dev, "Currently not setting Broadcast Select "
+                       "Registers\n");
                *attr |= TSI148_LCSR_DSAT_TM_2eSSTB;
        }
  
                *attr |= TSI148_LCSR_DSAT_DBW_32;
                break;
        default:
-               printk("Invalid data width\n");
+               dev_err(dev, "Invalid data width\n");
                return -EINVAL;
        }
  
                *attr |= TSI148_LCSR_DSAT_AMODE_USER4;
                break;
        default:
-               printk("Invalid address space\n");
+               dev_err(dev, "Invalid address space\n");
                return -EINVAL;
                break;
        }
        return 0;
  }
  
- static int tsi148_dma_set_vme_dest_attributes(u32 *attr, vme_address_t aspace,
-       vme_cycle_t cycle, vme_width_t dwidth)
+ static int tsi148_dma_set_vme_dest_attributes(struct device *dev, u32 *attr,
+       vme_address_t aspace, vme_cycle_t cycle, vme_width_t dwidth)
  {
        /* Setup 2eSST speeds */
        switch (cycle & (VME_2eSST160 | VME_2eSST267 | VME_2eSST320)) {
        }
  
        /* Setup cycle types */
-       if (cycle & VME_SCT) {
+       if (cycle & VME_SCT)
                *attr |= TSI148_LCSR_DDAT_TM_SCT;
-       }
-       if (cycle & VME_BLT) {
+       if (cycle & VME_BLT)
                *attr |= TSI148_LCSR_DDAT_TM_BLT;
-       }
-       if (cycle & VME_MBLT) {
+       if (cycle & VME_MBLT)
                *attr |= TSI148_LCSR_DDAT_TM_MBLT;
-       }
-       if (cycle & VME_2eVME) {
+       if (cycle & VME_2eVME)
                *attr |= TSI148_LCSR_DDAT_TM_2eVME;
-       }
-       if (cycle & VME_2eSST) {
+       if (cycle & VME_2eSST)
                *attr |= TSI148_LCSR_DDAT_TM_2eSST;
-       }
        if (cycle & VME_2eSSTB) {
-               printk("Currently not setting Broadcast Select Registers\n");
+               dev_err(dev, "Currently not setting Broadcast Select "
+                       "Registers\n");
                *attr |= TSI148_LCSR_DDAT_TM_2eSSTB;
        }
  
                *attr |= TSI148_LCSR_DDAT_DBW_32;
                break;
        default:
-               printk("Invalid data width\n");
+               dev_err(dev, "Invalid data width\n");
                return -EINVAL;
        }
  
                *attr |= TSI148_LCSR_DDAT_AMODE_USER4;
                break;
        default:
-               printk("Invalid address space\n");
+               dev_err(dev, "Invalid address space\n");
                return -EINVAL;
                break;
        }
  /*
   * Add a link list descriptor to the list
   */
- int tsi148_dma_list_add (struct vme_dma_list *list, struct vme_dma_attr *src,
+ int tsi148_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src,
        struct vme_dma_attr *dest, size_t count)
  {
        struct tsi148_dma_entry *entry, *prev;
        struct vme_dma_vme *vme_attr;
        dma_addr_t desc_ptr;
        int retval = 0;
+       struct vme_bridge *tsi148_bridge;
+       tsi148_bridge = list->parent->parent;
  
        /* Descriptor must be aligned on 64-bit boundaries */
-       entry = (struct tsi148_dma_entry *)kmalloc(
-               sizeof(struct tsi148_dma_entry), GFP_KERNEL);
+       entry = kmalloc(sizeof(struct tsi148_dma_entry), GFP_KERNEL);
        if (entry == NULL) {
-               printk("Failed to allocate memory for dma resource "
-                       "structure\n");
+               dev_err(tsi148_bridge->parent, "Failed to allocate memory for "
+                       "dma resource structure\n");
                retval = -ENOMEM;
                goto err_mem;
        }
  
        /* Test descriptor alignment */
        if ((unsigned long)&(entry->descriptor) & 0x7) {
-               printk("Descriptor not aligned to 8 byte boundary as "
-                       "required: %p\n", &(entry->descriptor));
+               dev_err(tsi148_bridge->parent, "Descriptor not aligned to 8 "
+                       "byte boundary as required: %p\n",
+                       &(entry->descriptor));
                retval = -EINVAL;
                goto err_align;
        }
                entry->descriptor.dsal = pattern_attr->pattern;
                entry->descriptor.dsat = TSI148_LCSR_DSAT_TYP_PAT;
                /* Default behaviour is 32 bit pattern */
-               if (pattern_attr->type & VME_DMA_PATTERN_BYTE) {
+               if (pattern_attr->type & VME_DMA_PATTERN_BYTE)
                        entry->descriptor.dsat |= TSI148_LCSR_DSAT_PSZ;
-               }
                /* It seems that the default behaviour is to increment */
-               if ((pattern_attr->type & VME_DMA_PATTERN_INCREMENT) == 0) {
+               if ((pattern_attr->type & VME_DMA_PATTERN_INCREMENT) == 0)
                        entry->descriptor.dsat |= TSI148_LCSR_DSAT_NIN;
-               }
                break;
        case VME_DMA_PCI:
                pci_attr = (struct vme_dma_pci *)src->private;
                entry->descriptor.dsat = TSI148_LCSR_DSAT_TYP_VME;
  
                retval = tsi148_dma_set_vme_src_attributes(
-                       &(entry->descriptor.dsat), vme_attr->aspace,
-                       vme_attr->cycle, vme_attr->dwidth);
-               if(retval < 0 )
+                       tsi148_bridge->parent, &(entry->descriptor.dsat),
+                       vme_attr->aspace, vme_attr->cycle, vme_attr->dwidth);
+               if (retval < 0)
                        goto err_source;
                break;
        default:
-               printk("Invalid source type\n");
+               dev_err(tsi148_bridge->parent, "Invalid source type\n");
                retval = -EINVAL;
                goto err_source;
                break;
                entry->descriptor.ddat = TSI148_LCSR_DDAT_TYP_VME;
  
                retval = tsi148_dma_set_vme_dest_attributes(
-                       &(entry->descriptor.ddat), vme_attr->aspace,
-                       vme_attr->cycle, vme_attr->dwidth);
-               if(retval < 0 )
+                       tsi148_bridge->parent, &(entry->descriptor.ddat),
+                       vme_attr->aspace, vme_attr->cycle, vme_attr->dwidth);
+               if (retval < 0)
                        goto err_dest;
                break;
        default:
-               printk("Invalid destination type\n");
+               dev_err(tsi148_bridge->parent, "Invalid destination type\n");
                retval = -EINVAL;
                goto err_dest;
                break;
        list_add_tail(&(entry->list), &(list->entries));
  
        /* Fill out previous descriptors "Next Address" */
-       if(entry->list.prev != &(list->entries)){
+       if (entry->list.prev != &(list->entries)) {
                prev = list_entry(entry->list.prev, struct tsi148_dma_entry,
                        list);
                /* We need the bus address for the pointer */
@@@ -1795,17 -1790,20 +1790,20 @@@ int tsi148_dma_list_exec(struct vme_dma
        dma_addr_t bus_addr;
        u32 bus_addr_high, bus_addr_low;
        u32 val, dctlreg = 0;
+       struct vme_bridge *tsi148_bridge;
        struct tsi148_driver *bridge;
  
        ctrlr = list->parent;
  
-       bridge = ctrlr->parent->driver_priv;
+       tsi148_bridge = ctrlr->parent;
+       bridge = tsi148_bridge->driver_priv;
  
        mutex_lock(&(ctrlr->mtx));
  
        channel = ctrlr->number;
  
-       if (! list_empty(&(ctrlr->running))) {
+       if (!list_empty(&(ctrlr->running))) {
                /*
                 * XXX We have an active DMA transfer and currently haven't
                 *     sorted out the mechanism for "pending" DMA transfers.
                TSI148_LCSR_OFFSET_DSTA);
  
        if (val & TSI148_LCSR_DSTA_VBE) {
-               printk(KERN_ERR "tsi148: DMA Error. DSTA=%08X\n", val);
+               dev_err(tsi148_bridge->parent, "DMA Error. DSTA=%08X\n", val);
                retval = -EIO;
        }
  
  int tsi148_dma_list_empty(struct vme_dma_list *list)
  {
        struct list_head *pos, *temp;
-         struct tsi148_dma_entry *entry;
+       struct tsi148_dma_entry *entry;
  
        /* detach and free each entry */
        list_for_each_safe(pos, temp, &(list->entries)) {
                kfree(entry);
        }
  
-       return (0);
+       return 0;
  }
  
  /*
@@@ -1891,9 -1889,12 +1889,12 @@@ int tsi148_lm_set(struct vme_lm_resourc
  {
        u32 lm_base_high, lm_base_low, lm_ctl = 0;
        int i;
+       struct vme_bridge *tsi148_bridge;
        struct tsi148_driver *bridge;
  
-       bridge = lm->parent->driver_priv;
+       tsi148_bridge = lm->parent;
+       bridge = tsi148_bridge->driver_priv;
  
        mutex_lock(&(lm->mtx));
  
        for (i = 0; i < lm->monitors; i++) {
                if (bridge->lm_callback[i] != NULL) {
                        mutex_unlock(&(lm->mtx));
-                       printk("Location monitor callback attached, can't "
-                               "reset\n");
+                       dev_err(tsi148_bridge->parent, "Location monitor "
+                               "callback attached, can't reset\n");
                        return -EBUSY;
                }
        }
                break;
        default:
                mutex_unlock(&(lm->mtx));
-               printk("Invalid address space\n");
+               dev_err(tsi148_bridge->parent, "Invalid address space\n");
                return -EINVAL;
                break;
        }
@@@ -1969,18 -1970,18 +1970,18 @@@ int tsi148_lm_get(struct vme_lm_resourc
        if (lm_ctl & TSI148_LCSR_LMAT_EN)
                enabled = 1;
  
-       if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A16) {
+       if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A16)
                *aspace |= VME_A16;
-       }
-       if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A24) {
+       if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A24)
                *aspace |= VME_A24;
-       }
-       if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A32) {
+       if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A32)
                *aspace |= VME_A32;
-       }
-       if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A64) {
+       if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A64)
                *aspace |= VME_A64;
-       }
  
        if (lm_ctl & TSI148_LCSR_LMAT_SUPR)
                *cycle |= VME_SUPER;
@@@ -2005,9 -2006,12 +2006,12 @@@ int tsi148_lm_attach(struct vme_lm_reso
        void (*callback)(int))
  {
        u32 lm_ctl, tmp;
+       struct vme_bridge *tsi148_bridge;
        struct tsi148_driver *bridge;
  
-       bridge = lm->parent->driver_priv;
+       tsi148_bridge = lm->parent;
+       bridge = tsi148_bridge->driver_priv;
  
        mutex_lock(&(lm->mtx));
  
        lm_ctl = ioread32be(bridge->base + TSI148_LCSR_LMAT);
        if ((lm_ctl & (TSI148_LCSR_LMAT_PGM | TSI148_LCSR_LMAT_DATA)) == 0) {
                mutex_unlock(&(lm->mtx));
-               printk("Location monitor not properly configured\n");
+               dev_err(tsi148_bridge->parent, "Location monitor not properly "
+                       "configured\n");
                return -EINVAL;
        }
  
        /* Check that a callback isn't already attached */
        if (bridge->lm_callback[monitor] != NULL) {
                mutex_unlock(&(lm->mtx));
-               printk("Existing callback attached\n");
+               dev_err(tsi148_bridge->parent, "Existing callback attached\n");
                return -EBUSY;
        }
  
@@@ -2094,7 -2099,7 +2099,7 @@@ int tsi148_lm_detach(struct vme_lm_reso
   */
  int tsi148_slot_get(struct vme_bridge *tsi148_bridge)
  {
-         u32 slot = 0;
+       u32 slot = 0;
        struct tsi148_driver *bridge;
  
        bridge = tsi148_bridge->driver_priv;
@@@ -2139,8 -2144,8 +2144,8 @@@ static int tsi148_crcsr_init(struct vme
        bridge->crcsr_kernel = pci_alloc_consistent(pdev, VME_CRCSR_BUF_SIZE,
                &(bridge->crcsr_bus));
        if (bridge->crcsr_kernel == NULL) {
-               dev_err(&pdev->dev, "Failed to allocate memory for CR/CSR "
-                       "image\n");
+               dev_err(tsi148_bridge->parent, "Failed to allocate memory for "
+                       "CR/CSR image\n");
                return -ENOMEM;
        }
  
  
        if (cbar != vstat) {
                cbar = vstat;
-               dev_info(&pdev->dev, "Setting CR/CSR offset\n");
+               dev_info(tsi148_bridge->parent, "Setting CR/CSR offset\n");
                iowrite32be(cbar<<3, bridge->base + TSI148_CBAR);
        }
-       dev_info(&pdev->dev, "CR/CSR Offset: %d\n", cbar);
+       dev_info(tsi148_bridge->parent, "CR/CSR Offset: %d\n", cbar);
  
        crat = ioread32be(bridge->base + TSI148_LCSR_CRAT);
        if (crat & TSI148_LCSR_CRAT_EN) {
-               dev_info(&pdev->dev, "Enabling CR/CSR space\n");
+               dev_info(tsi148_bridge->parent, "Enabling CR/CSR space\n");
                iowrite32be(crat | TSI148_LCSR_CRAT_EN,
                        bridge->base + TSI148_LCSR_CRAT);
        } else
-               dev_info(&pdev->dev, "CR/CSR already enabled\n");
+               dev_info(tsi148_bridge->parent, "CR/CSR already enabled\n");
  
        /* If we want flushed, error-checked writes, set up a window
         * over the CR/CSR registers. We read from here to safely flush
         * through VME writes.
         */
-       if(err_chk) {
+       if (err_chk) {
                retval = tsi148_master_set(bridge->flush_image, 1,
                        (vstat * 0x80000), 0x80000, VME_CRCSR, VME_SCT,
                        VME_D16);
                if (retval)
-                       dev_err(&pdev->dev, "Configuring flush image failed\n");
+                       dev_err(tsi148_bridge->parent, "Configuring flush image"
+                               " failed\n");
        }
  
        return 0;
@@@ -2224,8 -2230,7 +2230,7 @@@ static int tsi148_probe(struct pci_dev 
        /* If we want to support more than one of each bridge, we need to
         * dynamically generate this so we get one per device
         */
-       tsi148_bridge = (struct vme_bridge *)kmalloc(sizeof(struct vme_bridge),
-               GFP_KERNEL);
+       tsi148_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL);
        if (tsi148_bridge == NULL) {
                dev_err(&pdev->dev, "Failed to allocate memory for device "
                        "structure\n");
                goto err_struct;
        }
  
-       memset(tsi148_bridge, 0, sizeof(struct vme_bridge));
-       tsi148_device = kmalloc(sizeof(struct tsi148_driver), GFP_KERNEL);
+       tsi148_device = kzalloc(sizeof(struct tsi148_driver), GFP_KERNEL);
        if (tsi148_device == NULL) {
                dev_err(&pdev->dev, "Failed to allocate memory for device "
                        "structure\n");
                goto err_driver;
        }
  
-       memset(tsi148_device, 0, sizeof(struct tsi148_driver));
        tsi148_bridge->driver_priv = tsi148_device;
  
        /* Enable the device */
         * hence have one less master window resource available.
         */
        master_num = TSI148_MAX_MASTER;
-       if(err_chk){
+       if (err_chk) {
                master_num--;
  
-               tsi148_device->flush_image = (struct vme_master_resource *)
+               tsi148_device->flush_image =
                        kmalloc(sizeof(struct vme_master_resource), GFP_KERNEL);
                if (tsi148_device->flush_image == NULL) {
                        dev_err(&pdev->dev, "Failed to allocate memory for "
        /* Add master windows to list */
        INIT_LIST_HEAD(&(tsi148_bridge->master_resources));
        for (i = 0; i < master_num; i++) {
-               master_image = (struct vme_master_resource *)kmalloc(
-                       sizeof(struct vme_master_resource), GFP_KERNEL);
+               master_image = kmalloc(sizeof(struct vme_master_resource),
+                       GFP_KERNEL);
                if (master_image == NULL) {
                        dev_err(&pdev->dev, "Failed to allocate memory for "
                        "master resource structure\n");
        /* Add slave windows to list */
        INIT_LIST_HEAD(&(tsi148_bridge->slave_resources));
        for (i = 0; i < TSI148_MAX_SLAVE; i++) {
-               slave_image = (struct vme_slave_resource *)kmalloc(
-                       sizeof(struct vme_slave_resource), GFP_KERNEL);
+               slave_image = kmalloc(sizeof(struct vme_slave_resource),
+                       GFP_KERNEL);
                if (slave_image == NULL) {
                        dev_err(&pdev->dev, "Failed to allocate memory for "
                        "slave resource structure\n");
        /* Add dma engines to list */
        INIT_LIST_HEAD(&(tsi148_bridge->dma_resources));
        for (i = 0; i < TSI148_MAX_DMA; i++) {
-               dma_ctrlr = (struct vme_dma_resource *)kmalloc(
-                       sizeof(struct vme_dma_resource), GFP_KERNEL);
+               dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource),
+                       GFP_KERNEL);
                if (dma_ctrlr == NULL) {
                        dev_err(&pdev->dev, "Failed to allocate memory for "
                        "dma resource structure\n");
  
        data = ioread32be(tsi148_device->base + TSI148_LCSR_VSTAT);
        dev_info(&pdev->dev, "Board is%s the VME system controller\n",
-               (data & TSI148_LCSR_VSTAT_SCONS)? "" : " not");
+               (data & TSI148_LCSR_VSTAT_SCONS) ? "" : " not");
        if (!geoid)
                dev_info(&pdev->dev, "VME geographical address is %d\n",
                        data & TSI148_LCSR_VSTAT_GA_M);
        dev_info(&pdev->dev, "VME Write and flush and error check is %s\n",
                err_chk ? "enabled" : "disabled");
  
 -      if (tsi148_crcsr_init(tsi148_bridge, pdev))
 +      if (tsi148_crcsr_init(tsi148_bridge, pdev)) {
                dev_err(&pdev->dev, "CR/CSR configuration failed.\n");
                goto err_crcsr;
 +      }
  
        retval = vme_register_bridge(tsi148_bridge);
        if (retval != 0) {
@@@ -2504,7 -2504,8 +2505,8 @@@ err_slave
  err_master:
        /* resources are stored in link list */
        list_for_each(pos, &(tsi148_bridge->master_resources)) {
-               master_image = list_entry(pos, struct vme_master_resource,                              list);
+               master_image = list_entry(pos, struct vme_master_resource,
+                       list);
                list_del(pos);
                kfree(master_image);
        }
@@@ -2624,8 -2625,6 +2626,6 @@@ static void tsi148_remove(struct pci_de
  static void __exit tsi148_exit(void)
  {
        pci_unregister_driver(&tsi148_driver);
-       printk(KERN_DEBUG "Driver removed.\n");
  }
  
  MODULE_PARM_DESC(err_chk, "Check for VME errors on reads and writes");
@@@ -429,14 -429,14 +429,14 @@@ pOpts->flags|=DEVICE_FLAGS_DiversityANT
  static void
  device_set_options(PSDevice pDevice) {
  
-     BYTE    abyBroadcastAddr[U_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-     BYTE    abySNAP_RFC1042[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
-     BYTE    abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
+     BYTE    abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+     BYTE    abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
+     BYTE    abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
  
  
-     memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, U_ETHER_ADDR_LEN);
-     memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, U_ETHER_ADDR_LEN);
-     memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, U_ETHER_ADDR_LEN);
+     memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN);
+     memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN);
+     memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN);
  
      pDevice->uChannel = pDevice->sOpts.channel_num;
      pDevice->wRTSThreshold = pDevice->sOpts.rts_thresh;
@@@ -478,7 -478,7 +478,7 @@@ pDevice->bUpdateBBVGA = TRUE
      DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->bDiversityRegCtlON= %d\n",(INT)pDevice->bDiversityRegCtlON);
  }
  
- static VOID s_vCompleteCurrentMeasure (IN PSDevice pDevice, IN BYTE byResult)
+ static void s_vCompleteCurrentMeasure (PSDevice pDevice, BYTE byResult)
  {
      UINT    ii;
      DWORD   dwDuration = 0;
@@@ -638,7 -638,8 +638,8 @@@ byValue1 = SROMbyReadEmbedded(pDevice->
  //2008-8-4 <add> by chester
  //zonetype initial
   pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
-  if((zonetype=Config_FileOperation(pDevice,FALSE,NULL)) >= 0) {         //read zonetype file ok!
+  zonetype = Config_FileOperation(pDevice,FALSE,NULL);
+  if (zonetype >= 0) {         //read zonetype file ok!
    if ((zonetype == 0)&&
          (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] !=0x00)){          //for USA
      pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0;
@@@ -728,7 -729,7 +729,7 @@@ els
              pDevice->abyOFDMPwrTbl[ii+CB_MAX_CHANNEL_24G+1] = SROMbyReadEmbedded(pDevice->PortOffset, (BYTE)(ii + EEP_OFS_OFDMA_PWR_TBL));
              pDevice->abyOFDMDefaultPwr[ii+CB_MAX_CHANNEL_24G+1] = SROMbyReadEmbedded(pDevice->PortOffset, (BYTE)(ii + EEP_OFS_OFDMA_PWR_dBm));
          }
-         CARDvInitChannelTable((PVOID)pDevice);
+         CARDvInitChannelTable((void *)pDevice);
  
  
          if (pDevice->byLocalID > REV_ID_VT3253_B1) {
@@@ -846,7 -847,7 +847,7 @@@ else  CARDbRadioPowerOn(pDevice)
  
  
  
- static VOID device_init_diversity_timer(PSDevice pDevice) {
+ static void device_init_diversity_timer(PSDevice pDevice) {
  
      init_timer(&pDevice->TimerSQ3Tmax1);
      pDevice->TimerSQ3Tmax1.data = (ULONG)pDevice;
@@@ -1073,7 -1074,7 +1074,7 @@@ device_found1(struct pci_dev *pcid, con
      //Enable the chip specified capbilities
      pDevice->flags = pDevice->sOpts.flags | (pChip_info->flags & 0xFF000000UL);
      pDevice->tx_80211 = device_dma0_tx_80211;
-     pDevice->sMgmtObj.pAdapter = (PVOID)pDevice;
+     pDevice->sMgmtObj.pAdapter = (void *)pDevice;
      pDevice->pMgmt = &(pDevice->sMgmtObj);
  
      dev->irq                = pcid->irq;
      }
  //2008-07-21-01<Add>by MikeLiu
  //register wpadev
+ #if 0
     if(wpa_set_wpadev(pDevice, 1)!=0) {
       printk("Fail to Register WPADEV?\n");
          unregister_netdev(pDevice->dev);
          free_netdev(dev);
     }
+ #endif
      device_print_info(pDevice);
      pci_set_drvdata(pcid, pDevice);
      return 0;
@@@ -1242,13 -1245,13 +1245,13 @@@ device_release_WPADEV(pDevice)
      }
  #ifdef HOSTAP
      if (dev)
-         hostap_set_hostapd(pDevice, 0, 0);
+         vt6655_hostap_set_hostapd(pDevice, 0, 0);
  #endif
      if (dev)
          unregister_netdev(dev);
  
      if (pDevice->PortOffset)
-         iounmap((PVOID)pDevice->PortOffset);
+         iounmap((void *)pDevice->PortOffset);
  
      if (pDevice->pcid)
          pci_release_regions(pDevice->pcid);
@@@ -1460,7 -1463,7 +1463,7 @@@ static void device_free_rd0_ring(PSDevi
  
          dev_kfree_skb(pRDInfo->skb);
  
-         kfree((PVOID)pDesc->pRDInfo);
+         kfree((void *)pDesc->pRDInfo);
      }
  
  }
@@@ -1478,7 -1481,7 +1481,7 @@@ static void device_free_rd1_ring(PSDevi
  
          dev_kfree_skb(pRDInfo->skb);
  
-         kfree((PVOID)pDesc->pRDInfo);
+         kfree((void *)pDesc->pRDInfo);
      }
  
  }
@@@ -1563,7 -1566,7 +1566,7 @@@ static void device_free_td0_ring(PSDevi
          if (pTDInfo->skb)
              dev_kfree_skb(pTDInfo->skb);
  
-         kfree((PVOID)pDesc->pTDInfo);
+         kfree((void *)pDesc->pTDInfo);
      }
  }
  
@@@ -1581,7 -1584,7 +1584,7 @@@ static void device_free_td1_ring(PSDevi
          if (pTDInfo->skb)
              dev_kfree_skb(pTDInfo->skb);
  
-         kfree((PVOID)pDesc->pTDInfo);
+         kfree((void *)pDesc->pTDInfo);
      }
  
  }
@@@ -1829,7 -1832,7 +1832,7 @@@ static void device_free_tx_buf(PSDevic
  
  
  //PLICE_DEBUG ->
VOID  InitRxManagementQueue(PSDevice  pDevice)
void  InitRxManagementQueue(PSDevice  pDevice)
  {
        pDevice->rxManeQueue.packet_num = 0;
        pDevice->rxManeQueue.head = pDevice->rxManeQueue.tail = 0;
@@@ -1968,7 -1971,7 +1971,7 @@@ device_init_rd0_ring(pDevice)
  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "call device_init_registers\n");
        device_init_registers(pDevice, DEVICE_INIT_COLD);
      MACvReadEtherAddress(pDevice->PortOffset, pDevice->abyCurrentNetAddr);
-     memcpy(pDevice->pMgmt->abyMACAddr, pDevice->abyCurrentNetAddr, U_ETHER_ADDR_LEN);
+     memcpy(pDevice->pMgmt->abyMACAddr, pDevice->abyCurrentNetAddr, ETH_ALEN);
      device_set_multi(pDevice->dev);
  
      // Init for Key Management
@@@ -2008,11 -2011,11 +2011,11 @@@ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "cal
        MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
  
      if (pDevice->pMgmt->eConfigMode == WMAC_CONFIG_AP) {
-         bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);
+         bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL);
        }
        else {
-         bScheduleCommand((HANDLE)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
-         bScheduleCommand((HANDLE)pDevice, WLAN_CMD_SSID, NULL);
+         bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
+         bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL);
      }
      pDevice->flags |=DEVICE_FLAGS_OPENED;
  
@@@ -2031,7 -2034,7 +2034,7 @@@ static int  device_close(struct net_dev
  //PLICE_DEBUG<-
  //2007-1121-02<Add>by EinsnLiu
      if (pDevice->bLinkPass) {
-       bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
+       bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
          mdelay(30);
      }
  #ifdef TxInSleep
@@@ -2149,11 -2152,11 +2152,11 @@@ BOOL device_dma0_xmit(PSDevice pDevice
  
      pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP);
  
-     memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(skb->data), U_HEADER_LEN);
-     cbFrameBodySize = skb->len - U_HEADER_LEN;
+     memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(skb->data), ETH_HLEN);
+     cbFrameBodySize = skb->len - ETH_HLEN;
  
      // 802.1H
-     if (ntohs(pDevice->sTxEthHeader.wType) > MAX_DATA_LEN) {
+     if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN) {
          cbFrameBodySize += 8;
      }
      uMACfragNum = cbGetFragCount(pDevice, pTransmitKey, cbFrameBodySize, &pDevice->sTxEthHeader);
@@@ -2353,10 -2356,10 +2356,10 @@@ static int  device_xmit(struct sk_buff 
      pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP);
  
  
-     memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(skb->data), U_HEADER_LEN);
-     cbFrameBodySize = skb->len - U_HEADER_LEN;
+     memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(skb->data), ETH_HLEN);
+     cbFrameBodySize = skb->len - ETH_HLEN;
      // 802.1H
-     if (ntohs(pDevice->sTxEthHeader.wType) > MAX_DATA_LEN) {
+     if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN) {
          cbFrameBodySize += 8;
      }
  
@@@ -2633,10 -2636,10 +2636,10 @@@ pDevice->byTopCCKBasicRate,pDevice->byT
      BYTE  Descriptor_type;
      WORD Key_info;
  BOOL            bTxeapol_key = FALSE;
-     Protocol_Version = skb->data[U_HEADER_LEN];
-     Packet_Type = skb->data[U_HEADER_LEN+1];
-     Descriptor_type = skb->data[U_HEADER_LEN+1+1+2];
-     Key_info = (skb->data[U_HEADER_LEN+1+1+2+1] << 8)|(skb->data[U_HEADER_LEN+1+1+2+2]);
+     Protocol_Version = skb->data[ETH_HLEN];
+     Packet_Type = skb->data[ETH_HLEN+1];
+     Descriptor_type = skb->data[ETH_HLEN+1+1+2];
+     Key_info = (skb->data[ETH_HLEN+1+1+2+1] << 8)|(skb->data[ETH_HLEN+1+1+2+2]);
     if (pDevice->sTxEthHeader.wType == TYPE_PKT_802_1x) {
             if(((Protocol_Version==1) ||(Protocol_Version==2)) &&
                (Packet_Type==3)) {  //802.1x OR eapol-key challenge frame transfer
@@@ -2857,7 -2860,7 +2860,7 @@@ static  irqreturn_t  device_intr(int ir
  
              pDevice->bBeaconSent = FALSE;
              if (pDevice->bEnablePSMode) {
-                 PSbIsNextTBTTWakeUp((HANDLE)pDevice);
+                 PSbIsNextTBTTWakeUp((void *)pDevice);
              };
  
              if ((pDevice->eOPMode == OP_MODE_AP) ||
                          // check if mutltcast tx bufferring
                          pMgmt->byDTIMCount = pMgmt->byDTIMPeriod - 1;
                          pMgmt->sNodeDBTable[0].bRxPSPoll = TRUE;
-                         bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
+                         bScheduleCommand((void *)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
                      }
                  }
              }
@@@ -3022,7 -3025,7 +3025,7 @@@ int Config_FileOperation(PSDevice pDevi
          goto error1;
        }
  
- buffer = (UCHAR *)kmalloc(1024, GFP_KERNEL);
+ buffer = kmalloc(1024, GFP_KERNEL);
  if(buffer==NULL) {
    printk("alllocate mem for file fail?\n");
    result = -1;
@@@ -3080,7 -3083,7 +3083,7 @@@ static void device_set_multi(struct net
  
      PSMgmtObject     pMgmt = pDevice->pMgmt;
      u32              mc_filter[2];
 -    struct dev_mc_list *mclist;
 +    struct netdev_hw_addr *ha;
  
  
      VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byRxMode));
      }
      else {
          memset(mc_filter, 0, sizeof(mc_filter));
 -      netdev_for_each_mc_addr(mclist, dev) {
 -            int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
 +      netdev_for_each_mc_addr(ha, dev) {
 +            int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
              mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
          }
          MACvSelectPage1(pDevice->PortOffset);
@@@ -3328,7 -3331,7 +3331,7 @@@ static int  device_ioctl(struct net_dev
                break;
  
        case SIOCSIWTXPOW:
-         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWTXPOW \n");
+         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWTXPOW \n");
          rc = -EOPNOTSUPP;
                break;
  
                // Get the spy list
        case SIOCGIWSPY:
  
-         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSPY \n");
+         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSPY \n");
                rc = -EOPNOTSUPP;
                break;
  
      case IOCTL_CMD_HOSTAPD:
  
  
-       rc = hostap_ioctl(pDevice, &wrq->u.data);
+       rc = vt6655_hostap_ioctl(pDevice, &wrq->u.data);
          break;
  
      case IOCTL_CMD_WPA:
         if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
             netif_stop_queue(pDevice->dev);
             spin_lock_irq(&pDevice->lock);
-            bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);
+            bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL);
             spin_unlock_irq(&pDevice->lock);
         }
         else {
              pMgmt->eScanType = WMAC_SCAN_ACTIVE;
         if(pDevice->bWPASuppWextEnabled !=TRUE)
         #endif
-            bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
-            bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL);
+            bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
+            bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL);
             spin_unlock_irq(&pDevice->lock);
        }
        pDevice->bCommit = FALSE;
@@@ -3716,9 -3719,9 +3719,9 @@@ viawget_resume(struct pci_dev *pcid
          init_timer(&pMgmt->sTimerSecondCallback);
          init_timer(&pDevice->sTimerCommand);
          MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
-         BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
-         bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
-         bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL);
+         BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
+         bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
+         bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL);
          spin_unlock_irq(&pDevice->lock);
      }
      return 0;
   * Date: May 20, 2003
   *
   * Functions:
 - *      s_vGenerateTxParameter - Generate tx dma requried parameter.
 + *      s_vGenerateTxParameter - Generate tx dma required parameter.
   *      vGenerateMACHeader - Translate 802.3 to 802.11 header
 - *      cbGetFragCount - Caculate fragement number count
 + *      cbGetFragCount - Caculate fragment number count
   *      csBeacon_xmit - beacon tx function
   *      csMgmt_xmit - management tx function
   *      s_cbFillTxBufHead - fulfill tx dma buffer header
   *      s_uGetDataDuration - get tx data required duration
   *      s_uFillDataHead- fulfill tx data duration header
 - *      s_uGetRTSCTSDuration- get rtx/cts requried duration
 + *      s_uGetRTSCTSDuration- get rtx/cts required duration
   *      s_uGetRTSCTSRsvTime- get rts/cts reserved time
   *      s_uGetTxRsvTime- get frame reserved time
   *      s_vFillCTSHead- fulfill CTS ctl header
 - *      s_vFillFragParameter- Set fragement ctl parameter.
 + *      s_vFillFragParameter- Set fragment ctl parameter.
   *      s_vFillRTSHead- fulfill RTS ctl header
   *      s_vFillTxKey- fulfill tx encrypt key
   *      s_vSWencryption- Software encrypt header
@@@ -115,93 -115,93 +115,93 @@@ const WORD wFB_Opt1[2][5] = 
  
  
  static
- VOID
+ void
  s_vFillTxKey(
-     IN  PSDevice   pDevice,
-     IN  PBYTE      pbyBuf,
-     IN  PBYTE      pbyIVHead,
-     IN  PSKeyItem  pTransmitKey,
-     IN  PBYTE      pbyHdrBuf,
-     IN  WORD       wPayloadLen,
-     OUT PBYTE      pMICHDR
+     PSDevice   pDevice,
+     PBYTE      pbyBuf,
+     PBYTE      pbyIVHead,
+     PSKeyItem  pTransmitKey,
+     PBYTE      pbyHdrBuf,
+     WORD       wPayloadLen,
+     PBYTE      pMICHDR
      );
  
  
  
  static
- VOID
+ void
  s_vFillRTSHead(
-     IN PSDevice         pDevice,
-     IN BYTE             byPktType,
-     IN PVOID            pvRTS,
-     IN UINT             cbFrameLength,
-     IN BOOL             bNeedAck,
-     IN BOOL             bDisCRC,
-     IN PSEthernetHeader psEthHeader,
-     IN WORD             wCurrentRate,
-     IN BYTE             byFBOption
+     PSDevice         pDevice,
+     BYTE             byPktType,
+     void *           pvRTS,
+     UINT             cbFrameLength,
+     BOOL             bNeedAck,
+     BOOL             bDisCRC,
+     PSEthernetHeader psEthHeader,
+     WORD             wCurrentRate,
+     BYTE             byFBOption
      );
  
  static
- VOID
+ void
  s_vGenerateTxParameter(
-     IN PSDevice         pDevice,
-     IN  BYTE            byPktType,
-     IN PVOID            pTxBufHead,
-     IN PVOID            pvRrvTime,
-     IN PVOID            pvRTS,
-     IN PVOID            pvCTS,
-     IN UINT             cbFrameSize,
-     IN BOOL             bNeedACK,
-     IN UINT             uDMAIdx,
-     IN PSEthernetHeader psEthHeader,
-     IN WORD             wCurrentRate
+     PSDevice         pDevice,
+     BYTE            byPktType,
+     void *           pTxBufHead,
+     void *           pvRrvTime,
+     void *           pvRTS,
+     void *           pvCTS,
+     UINT             cbFrameSize,
+     BOOL             bNeedACK,
+     UINT             uDMAIdx,
+     PSEthernetHeader psEthHeader,
+     WORD             wCurrentRate
      );
  
  
  
  static void s_vFillFragParameter(
-     IN PSDevice pDevice,
-     IN PBYTE    pbyBuffer,
-     IN UINT     uTxType,
-     IN PVOID    pvtdCurr,
-     IN WORD     wFragType,
-     IN UINT     cbReqCount
+     PSDevice pDevice,
+     PBYTE    pbyBuffer,
+     UINT     uTxType,
+     void *   pvtdCurr,
+     WORD     wFragType,
+     UINT     cbReqCount
      );
  
  
  static
  UINT
  s_cbFillTxBufHead (
-     IN  PSDevice         pDevice,
-     IN  BYTE             byPktType,
-     IN  PBYTE            pbyTxBufferAddr,
-     IN  UINT             cbFrameBodySize,
-     IN  UINT             uDMAIdx,
-     IN  PSTxDesc         pHeadTD,
-     IN  PSEthernetHeader psEthHeader,
-     IN  PBYTE            pPacket,
-     IN  BOOL             bNeedEncrypt,
-     IN  PSKeyItem        pTransmitKey,
-     IN  UINT             uNodeIndex,
-     OUT PUINT            puMACfragNum
+     PSDevice         pDevice,
+     BYTE             byPktType,
+     PBYTE            pbyTxBufferAddr,
+     UINT             cbFrameBodySize,
+     UINT             uDMAIdx,
+     PSTxDesc         pHeadTD,
+     PSEthernetHeader psEthHeader,
+     PBYTE            pPacket,
+     BOOL             bNeedEncrypt,
+     PSKeyItem        pTransmitKey,
+     UINT             uNodeIndex,
+     PUINT            puMACfragNum
      );
  
  
  static
  UINT
  s_uFillDataHead (
-     IN PSDevice pDevice,
-     IN BYTE     byPktType,
-     IN PVOID    pTxDataHead,
-     IN UINT     cbFrameLength,
-     IN UINT     uDMAIdx,
-     IN BOOL     bNeedAck,
-     IN UINT     uFragIdx,
-     IN UINT     cbLastFragmentSize,
-     IN UINT     uMACfragNum,
-     IN BYTE     byFBOption,
-     IN WORD     wCurrentRate
+     PSDevice pDevice,
+     BYTE     byPktType,
+     void *   pTxDataHead,
+     UINT     cbFrameLength,
+     UINT     uDMAIdx,
+     BOOL     bNeedAck,
+     UINT     uFragIdx,
+     UINT     cbLastFragmentSize,
+     UINT     uMACfragNum,
+     BYTE     byFBOption,
+     WORD     wCurrentRate
      );
  
  
  
  
  static
- VOID
+ void
  s_vFillTxKey (
-     IN  PSDevice   pDevice,
-     IN  PBYTE      pbyBuf,
-     IN  PBYTE      pbyIVHead,
-     IN  PSKeyItem  pTransmitKey,
-     IN  PBYTE      pbyHdrBuf,
-     IN  WORD       wPayloadLen,
-     OUT PBYTE      pMICHDR
+     PSDevice   pDevice,
+     PBYTE      pbyBuf,
+     PBYTE      pbyIVHead,
+     PSKeyItem  pTransmitKey,
+     PBYTE      pbyHdrBuf,
+     WORD       wPayloadLen,
+     PBYTE      pMICHDR
      )
  {
      PDWORD          pdwIV = (PDWORD) pbyIVHead;
  
  
  static
- VOID
+ void
  s_vSWencryption (
-     IN  PSDevice            pDevice,
-     IN  PSKeyItem           pTransmitKey,
-     IN  PBYTE               pbyPayloadHead,
-     IN  WORD                wPayloadSize
+     PSDevice            pDevice,
+     PSKeyItem           pTransmitKey,
+     PBYTE               pbyPayloadHead,
+     WORD                wPayloadSize
      )
  {
      UINT   cbICVlen = 4;
  static
  UINT
  s_uGetTxRsvTime (
-     IN PSDevice pDevice,
-     IN BYTE     byPktType,
-     IN UINT     cbFrameLength,
-     IN WORD     wRate,
-     IN BOOL     bNeedAck
+     PSDevice pDevice,
+     BYTE     byPktType,
+     UINT     cbFrameLength,
+     WORD     wRate,
+     BOOL     bNeedAck
      )
  {
      UINT uDataTime, uAckTime;
  static
  UINT
  s_uGetRTSCTSRsvTime (
-     IN PSDevice pDevice,
-     IN BYTE byRTSRsvType,
-     IN BYTE byPktType,
-     IN UINT cbFrameLength,
-     IN WORD wCurrentRate
+     PSDevice pDevice,
+     BYTE byRTSRsvType,
+     BYTE byPktType,
+     UINT cbFrameLength,
+     WORD wCurrentRate
      )
  {
      UINT uRrvTime  , uRTSTime, uCTSTime, uAckTime, uDataTime;
  static
  UINT
  s_uGetDataDuration (
-     IN PSDevice pDevice,
-     IN BYTE     byDurType,
-     IN UINT     cbFrameLength,
-     IN BYTE     byPktType,
-     IN WORD     wRate,
-     IN BOOL     bNeedAck,
-     IN UINT     uFragIdx,
-     IN UINT     cbLastFragmentSize,
-     IN UINT     uMACfragNum,
-     IN BYTE     byFBOption
+     PSDevice pDevice,
+     BYTE     byDurType,
+     UINT     cbFrameLength,
+     BYTE     byPktType,
+     WORD     wRate,
+     BOOL     bNeedAck,
+     UINT     uFragIdx,
+     UINT     cbLastFragmentSize,
+     UINT     uMACfragNum,
+     BYTE     byFBOption
      )
  {
      BOOL bLastFrag = 0;
  static
  UINT
  s_uGetRTSCTSDuration (
-     IN PSDevice pDevice,
-     IN BYTE byDurType,
-     IN UINT cbFrameLength,
-     IN BYTE byPktType,
-     IN WORD wRate,
-     IN BOOL bNeedAck,
-     IN BYTE byFBOption
+     PSDevice pDevice,
+     BYTE byDurType,
+     UINT cbFrameLength,
+     BYTE byPktType,
+     WORD wRate,
+     BOOL bNeedAck,
+     BYTE byFBOption
      )
  {
      UINT uCTSTime = 0, uDurTime = 0;
  static
  UINT
  s_uFillDataHead (
-     IN PSDevice pDevice,
-     IN BYTE     byPktType,
-     IN PVOID    pTxDataHead,
-     IN UINT     cbFrameLength,
-     IN UINT     uDMAIdx,
-     IN BOOL     bNeedAck,
-     IN UINT     uFragIdx,
-     IN UINT     cbLastFragmentSize,
-     IN UINT     uMACfragNum,
-     IN BYTE     byFBOption,
-     IN WORD     wCurrentRate
+     PSDevice pDevice,
+     BYTE     byPktType,
+     void *   pTxDataHead,
+     UINT     cbFrameLength,
+     UINT     uDMAIdx,
+     BOOL     bNeedAck,
+     UINT     uFragIdx,
+     UINT     cbLastFragmentSize,
+     UINT     uMACfragNum,
+     BYTE     byFBOption,
+     WORD     wCurrentRate
      )
  {
      WORD  wLen = 0x0000;
  
  
  static
- VOID
+ void
  s_vFillRTSHead (
-     IN PSDevice         pDevice,
-     IN BYTE             byPktType,
-     IN PVOID            pvRTS,
-     IN UINT             cbFrameLength,
-     IN BOOL             bNeedAck,
-     IN BOOL             bDisCRC,
-     IN PSEthernetHeader psEthHeader,
-     IN WORD             wCurrentRate,
-     IN BYTE             byFBOption
+     PSDevice         pDevice,
+     BYTE             byPktType,
+     void *           pvRTS,
+     UINT             cbFrameLength,
+     BOOL             bNeedAck,
+     BOOL             bDisCRC,
+     PSEthernetHeader psEthHeader,
+     WORD             wCurrentRate,
+     BYTE             byFBOption
      )
  {
      UINT uRTSFrameLen = 20;
      }
  
      // Note: So far RTSHead dosen't appear in ATIM & Beacom DMA, so we don't need to take them into account.
 -    //       Otherwise, we need to modified codes for them.
 +    //       Otherwise, we need to modify codes for them.
      if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {
          if (byFBOption == AUTO_FB_NONE) {
              PSRTS_g pBuf = (PSRTS_g)pvRTS;
              pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4
              if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
                  (pDevice->eOPMode == OP_MODE_AP)) {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN);
              }
              else {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
              }
              if (pDevice->eOPMode == OP_MODE_AP) {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
              }
              else {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN);
              }
          }
          else {
  
              if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
                  (pDevice->eOPMode == OP_MODE_AP)) {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN);
              }
              else {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
              }
  
              if (pDevice->eOPMode == OP_MODE_AP) {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
              }
              else {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN);
              }
  
          } // if (byFBOption == AUTO_FB_NONE)
  
              if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
                  (pDevice->eOPMode == OP_MODE_AP)) {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN);
              }
              else {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
              }
  
              if (pDevice->eOPMode == OP_MODE_AP) {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
              }
              else {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN);
              }
  
          }
  
              if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
                  (pDevice->eOPMode == OP_MODE_AP)) {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN);
              }
              else {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
              }
              if (pDevice->eOPMode == OP_MODE_AP) {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
              }
              else {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+                 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN);
              }
          }
      }
  
          if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
              (pDevice->eOPMode == OP_MODE_AP)) {
-             memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+             memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN);
          }
          else {
-             memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+             memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
          }
  
          if (pDevice->eOPMode == OP_MODE_AP) {
-             memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+             memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
          }
          else {
-             memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+             memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN);
          }
      }
  }
  
  static
- VOID
+ void
  s_vFillCTSHead (
-     IN PSDevice pDevice,
-     IN UINT     uDMAIdx,
-     IN BYTE     byPktType,
-     IN PVOID    pvCTS,
-     IN UINT     cbFrameLength,
-     IN BOOL     bNeedAck,
-     IN BOOL     bDisCRC,
-     IN WORD     wCurrentRate,
-     IN BYTE     byFBOption
+     PSDevice pDevice,
+     UINT     uDMAIdx,
+     BYTE     byPktType,
+     void *   pvCTS,
+     UINT     cbFrameLength,
+     BOOL     bNeedAck,
+     BOOL     bDisCRC,
+     WORD     wCurrentRate,
+     BYTE     byFBOption
      )
  {
      UINT uCTSFrameLen = 14;
              pBuf->Data.wDurationID = pBuf->wDuration_ba;
              pBuf->Data.wFrameControl = TYPE_CTL_CTS;//0x00C4
              pBuf->Data.wReserved = 0x0000;
-             memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyCurrentNetAddr[0]), U_ETHER_ADDR_LEN);
+             memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyCurrentNetAddr[0]), ETH_ALEN);
  
          } else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA)
              PSCTS pBuf = (PSCTS)pvCTS;
              pBuf->Data.wDurationID = pBuf->wDuration_ba;
              pBuf->Data.wFrameControl = TYPE_CTL_CTS;//0x00C4
              pBuf->Data.wReserved = 0x0000;
-             memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyCurrentNetAddr[0]), U_ETHER_ADDR_LEN);
+             memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyCurrentNetAddr[0]), ETH_ALEN);
          }
      }
  }
   *
   * Parameters:
   *  In:
 - *      pDevice         - Pointer to adpater
 + *      pDevice         - Pointer to adapter
   *      pTxDataHead     - Transmit Data Buffer
   *      pTxBufHead      - pTxBufHead
   *      pvRrvTime        - pvRrvTime
  -*/
  // UINT            cbFrameSize,//Hdr+Payload+FCS
  static
- VOID
+ void
  s_vGenerateTxParameter (
-     IN PSDevice         pDevice,
-     IN BYTE             byPktType,
-     IN PVOID            pTxBufHead,
-     IN PVOID            pvRrvTime,
-     IN PVOID            pvRTS,
-     IN PVOID            pvCTS,
-     IN UINT             cbFrameSize,
-     IN BOOL             bNeedACK,
-     IN UINT             uDMAIdx,
-     IN PSEthernetHeader psEthHeader,
-     IN WORD             wCurrentRate
+     PSDevice         pDevice,
+     BYTE             byPktType,
+     void *           pTxBufHead,
+     void *           pvRrvTime,
+     void *           pvRTS,
+     void *           pvCTS,
+     UINT             cbFrameSize,
+     BOOL             bNeedACK,
+     UINT             uDMAIdx,
+     PSEthernetHeader psEthHeader,
+     WORD             wCurrentRate
      )
  {
      UINT cbMACHdLen = WLAN_HDR_ADDR3_LEN; //24
      UINT  cbFragmentSize,//Hdr+payoad+FCS
  */
  static
- VOID
+ void
  s_vFillFragParameter(
-     IN PSDevice pDevice,
-     IN PBYTE    pbyBuffer,
-     IN UINT     uTxType,
-     IN PVOID    pvtdCurr,
-     IN WORD     wFragType,
-     IN UINT     cbReqCount
+     PSDevice pDevice,
+     PBYTE    pbyBuffer,
+     UINT     uTxType,
+     void *   pvtdCurr,
+     WORD     wFragType,
+     UINT     cbReqCount
      )
  {
      PSTxBufHead pTxBufHead = (PSTxBufHead) pbyBuffer;
  static
  UINT
  s_cbFillTxBufHead (
-     IN  PSDevice         pDevice,
-     IN  BYTE             byPktType,
-     IN  PBYTE            pbyTxBufferAddr,
-     IN  UINT             cbFrameBodySize,
-     IN  UINT             uDMAIdx,
-     IN  PSTxDesc         pHeadTD,
-     IN  PSEthernetHeader psEthHeader,
-     IN  PBYTE            pPacket,
-     IN  BOOL             bNeedEncrypt,
-     IN  PSKeyItem        pTransmitKey,
-     IN  UINT             uNodeIndex,
-     OUT PUINT            puMACfragNum
+     PSDevice         pDevice,
+     BYTE             byPktType,
+     PBYTE            pbyTxBufferAddr,
+     UINT             cbFrameBodySize,
+     UINT             uDMAIdx,
+     PSTxDesc         pHeadTD,
+     PSEthernetHeader psEthHeader,
+     PBYTE            pPacket,
+     BOOL             bNeedEncrypt,
+     PSKeyItem        pTransmitKey,
+     UINT             uNodeIndex,
+     PUINT            puMACfragNum
      )
  {
      UINT           cbMACHdLen;
      PSTxBufHead    psTxBufHd = (PSTxBufHead) pbyTxBufferAddr;
  //    UINT           tmpDescIdx;
      UINT           cbHeaderLength = 0;
-     PVOID          pvRrvTime;
+     void *         pvRrvTime;
      PSMICHDRHead   pMICHDR;
-     PVOID          pvRTS;
-     PVOID          pvCTS;
-     PVOID          pvTxDataHd;
+     void *         pvRTS;
+     void *         pvCTS;
+     void *         pvTxDataHd;
      WORD           wTxBufSize;   // FFinfo size
      UINT           uTotalCopyLength = 0;
      BYTE           byFBOption = AUTO_FB_NONE;
              }
          } // Auto Fall Back
      }
-     memset((PVOID)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderLength - wTxBufSize));
+     memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderLength - wTxBufSize));
  
  //////////////////////////////////////////////////////////////////
      if ((bNeedEncrypt == TRUE) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) {
  
  
                  //Fill FIFO,RrvTime,RTS,and CTS
-                 s_vGenerateTxParameter(pDevice, byPktType, (PVOID)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
+                 s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
                                         cbFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate);
                  //Fill DataHead
                  uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFragmentSize, uDMAIdx, bNeedACK,
  
  
                  // 802.1H
-                 if (ntohs(psEthHeader->wType) > MAX_DATA_LEN) {
+                 if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) {
                      if ((psEthHeader->wType == TYPE_PKT_IPX) ||
                          (psEthHeader->wType == cpu_to_le16(0xF380))) {
                          memcpy((PBYTE) (pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6);
                  //if (pDevice->bAES) {
                  //    s_vFillMICHDR(pDevice, (PBYTE)pMICHDR, pbyMacHdr, (WORD)cbFragPayloadSize);
                  //}
-                 //cbReqCount += s_uDoEncryption(pDevice, psEthHeader, (PVOID)psTxBufHd, byKeySel,
+                 //cbReqCount += s_uDoEncryption(pDevice, psEthHeader, (void *)psTxBufHd, byKeySel,
                  //                                pbyPayloadHead, (WORD)cbFragPayloadSize, uDMAIdx);
  
  
  
                  uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len;
                  //copy TxBufferHeader + MacHeader to desc
-                 memcpy(pbyBuffer, (PVOID)psTxBufHd, uLength);
+                 memcpy(pbyBuffer, (void *)psTxBufHd, uLength);
  
                  // Copy the Packet into a tx Buffer
                  memcpy((pbyBuffer + uLength), (pPacket + 14), (cbFragPayloadSize - cb802_1_H_len));
                  //4.Set Sequence Control
                  //5.Get S/W generate FCS
                  //--------------------
-                 s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (PVOID)ptdCurr, wFragType, cbReqCount);
+                 s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (void *)ptdCurr, wFragType, cbReqCount);
  
                  ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding;
                  ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength;
                  wFragType = FRAGCTL_ENDFRAG;
  
                  //Fill FIFO,RrvTime,RTS,and CTS
-                 s_vGenerateTxParameter(pDevice, byPktType, (PVOID)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
+                 s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
                                         cbLastFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate);
                  //Fill DataHead
                  uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbLastFragmentSize, uDMAIdx, bNeedACK,
                  uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen;
  
                  //copy TxBufferHeader + MacHeader to desc
-                 memcpy(pbyBuffer, (PVOID)psTxBufHd, uLength);
+                 memcpy(pbyBuffer, (void *)psTxBufHd, uLength);
  
                  // Copy the Packet into a tx Buffer
                  if (bMIC2Frag == FALSE) {
                  //--------------------
  
  
-                 s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (PVOID)ptdCurr, wFragType, cbReqCount);
+                 s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (void *)ptdCurr, wFragType, cbReqCount);
  
                  ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding;
                  ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength;
                  wFragType = FRAGCTL_MIDFRAG;
  
                  //Fill FIFO,RrvTime,RTS,and CTS
-                 s_vGenerateTxParameter(pDevice, byPktType, (PVOID)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
+                 s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
                                         cbFragmentSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate);
                  //Fill DataHead
                  uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFragmentSize, uDMAIdx, bNeedACK,
                  //if (pDevice->bAES) {
                  //    s_vFillMICHDR(pDevice, (PBYTE)pMICHDR, pbyMacHdr, (WORD)cbFragPayloadSize);
                  //}
-                 //cbReqCount += s_uDoEncryption(pDevice, psEthHeader, (PVOID)psTxBufHd, byKeySel,
+                 //cbReqCount += s_uDoEncryption(pDevice, psEthHeader, (void *)psTxBufHd, byKeySel,
                  //                              pbyPayloadHead, (WORD)cbFragPayloadSize, uDMAIdx);
  
  
                  uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen;
  
                  //copy TxBufferHeader + MacHeader to desc
-                 memcpy(pbyBuffer, (PVOID)psTxBufHd, uLength);
+                 memcpy(pbyBuffer, (void *)psTxBufHd, uLength);
  
                  // Copy the Packet into a tx Buffer
                  memcpy((pbyBuffer + uLength),
                  //5.Get S/W generate FCS
                  //--------------------
  
-                 s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (PVOID)ptdCurr, wFragType, cbReqCount);
+                 s_vFillFragParameter(pDevice, pbyBuffer, uDMAIdx, (void *)ptdCurr, wFragType, cbReqCount);
  
                  ptdCurr->pTDInfo->dwReqCount = cbReqCount - uPadding;
                  ptdCurr->pTDInfo->dwHeaderLength = cbHeaderLength;
          psTxBufHd->wFragCtl |= (WORD)wFragType;
  
          //Fill FIFO,RrvTime,RTS,and CTS
-         s_vGenerateTxParameter(pDevice, byPktType, (PVOID)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
+         s_vGenerateTxParameter(pDevice, byPktType, (void *)psTxBufHd, pvRrvTime, pvRTS, pvCTS,
                                 cbFrameSize, bNeedACK, uDMAIdx, psEthHeader, pDevice->wCurrentRate);
          //Fill DataHead
          uDuration = s_uFillDataHead(pDevice, byPktType, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK,
          }
  
          // 802.1H
-         if (ntohs(psEthHeader->wType) > MAX_DATA_LEN) {
+         if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) {
              if ((psEthHeader->wType == TYPE_PKT_IPX) ||
                  (psEthHeader->wType == cpu_to_le16(0xF380))) {
                  memcpy((PBYTE) (pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6);
          uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len;
  
          //copy TxBufferHeader + MacHeader to desc
-         memcpy(pbyBuffer, (PVOID)psTxBufHd, uLength);
+         memcpy(pbyBuffer, (void *)psTxBufHd, uLength);
  
          // Copy the Packet into a tx Buffer
          memcpy((pbyBuffer + uLength),
  }
  
  
- VOID
+ void
  vGenerateFIFOHeader (
-     IN  PSDevice         pDevice,
-     IN  BYTE             byPktType,
-     IN  PBYTE            pbyTxBufferAddr,
-     IN  BOOL             bNeedEncrypt,
-     IN  UINT             cbPayloadSize,
-     IN  UINT             uDMAIdx,
-     IN  PSTxDesc         pHeadTD,
-     IN  PSEthernetHeader psEthHeader,
-     IN  PBYTE            pPacket,
-     IN  PSKeyItem        pTransmitKey,
-     IN  UINT             uNodeIndex,
-     OUT PUINT            puMACfragNum,
-     OUT PUINT            pcbHeaderSize
+     PSDevice         pDevice,
+     BYTE             byPktType,
+     PBYTE            pbyTxBufferAddr,
+     BOOL             bNeedEncrypt,
+     UINT             cbPayloadSize,
+     UINT             uDMAIdx,
+     PSTxDesc         pHeadTD,
+     PSEthernetHeader psEthHeader,
+     PBYTE            pPacket,
+     PSKeyItem        pTransmitKey,
+     UINT             uNodeIndex,
+     PUINT            puMACfragNum,
+     PUINT            pcbHeaderSize
      )
  {
      UINT            wTxBufSize;       // FFinfo size
   *
   * Parameters:
   *  In:
 - *      pDevice         - Pointer to adpater
 + *      pDevice         - Pointer to adapter
   *      dwTxBufferAddr  - Transmit Buffer
   *      pPacket         - Packet from upper layer
   *      cbPacketSize    - Transmit Data Length
   *
  -*/
  
- VOID
+ void
  vGenerateMACHeader (
-     IN PSDevice         pDevice,
-     IN PBYTE            pbyBufferAddr,
-     IN WORD             wDuration,
-     IN PSEthernetHeader psEthHeader,
-     IN BOOL             bNeedEncrypt,
-     IN WORD             wFragType,
-     IN UINT             uDMAIdx,
-     IN UINT             uFragIdx
+     PSDevice         pDevice,
+     PBYTE            pbyBufferAddr,
+     WORD             wDuration,
+     PSEthernetHeader psEthHeader,
+     BOOL             bNeedEncrypt,
+     WORD             wFragType,
+     UINT             uDMAIdx,
+     UINT             uFragIdx
      )
  {
      PS802_11Header  pMACHeader = (PS802_11Header)pbyBufferAddr;
      }
  
      if (pDevice->eOPMode == OP_MODE_AP) {
-         memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
-         memcpy(&(pMACHeader->abyAddr2[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
-         memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+         memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN);
+         memcpy(&(pMACHeader->abyAddr2[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
+         memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN);
          pMACHeader->wFrameCtl |= FC_FROMDS;
      }
      else {
          if (pDevice->eOPMode == OP_MODE_ADHOC) {
-             memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
-             memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
-             memcpy(&(pMACHeader->abyAddr3[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+             memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN);
+             memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN);
+             memcpy(&(pMACHeader->abyAddr3[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
          }
          else {
-             memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
-             memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
-             memcpy(&(pMACHeader->abyAddr1[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+             memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN);
+             memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN);
+             memcpy(&(pMACHeader->abyAddr1[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
              pMACHeader->wFrameCtl |= FC_TODS;
          }
      }
@@@ -2342,9 -2342,9 +2342,9 @@@ CMD_STATUS csMgmt_xmit(PSDevice pDevice
      PSTxDesc        pFrstTD;
      BYTE            byPktType;
      PBYTE           pbyTxBufferAddr;
-     PVOID           pvRTS;
+     void *          pvRTS;
      PSCTS           pCTS;
-     PVOID           pvTxDataHd;
+     void *          pvTxDataHd;
      UINT            uDuration;
      UINT            cbReqCount;
      PS802_11Header  pMACHeader;
      WORD            wTxBufSize;
      UINT            cbMacHdLen;
      SEthernetHeader sEthHeader;
-     PVOID           pvRrvTime;
-     PVOID           pMICHDR;
+     void *          pvRrvTime;
+     void *          pMICHDR;
      PSMgmtObject    pMgmt = pDevice->pMgmt;
      WORD            wCurrentRate = RATE_1M;
  
          cbHeaderSize = wTxBufSize + sizeof(SRrvTime_ab) + sizeof(STxDataHead_ab);
      }
  
-     memset((PVOID)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize));
+     memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize));
  
-     memcpy(&(sEthHeader.abyDstAddr[0]), &(pPacket->p80211Header->sA3.abyAddr1[0]), U_ETHER_ADDR_LEN);
-     memcpy(&(sEthHeader.abySrcAddr[0]), &(pPacket->p80211Header->sA3.abyAddr2[0]), U_ETHER_ADDR_LEN);
+     memcpy(&(sEthHeader.abyDstAddr[0]), &(pPacket->p80211Header->sA3.abyAddr1[0]), ETH_ALEN);
+     memcpy(&(sEthHeader.abySrcAddr[0]), &(pPacket->p80211Header->sA3.abyAddr2[0]), ETH_ALEN);
      //=========================
      //    No Fragmentation
      //=========================
@@@ -2738,10 -2738,10 +2738,10 @@@ CMD_STATUS csBeacon_xmit(PSDevice pDevi
  
  UINT
  cbGetFragCount (
-     IN  PSDevice         pDevice,
-     IN  PSKeyItem        pTransmitKey,
-     IN  UINT             cbFrameBodySize,
-     IN  PSEthernetHeader psEthHeader
+     PSDevice         pDevice,
+     PSKeyItem        pTransmitKey,
+     UINT             cbFrameBodySize,
+     PSEthernetHeader psEthHeader
      )
  {
      UINT           cbMACHdLen;
  }
  
  
- VOID
+ void
  vDMA0_tx_80211(PSDevice  pDevice, struct sk_buff *skb, PBYTE pbMPDU, UINT cbMPDULen) {
  
      PSTxDesc        pFrstTD;
      BYTE            byPktType;
      PBYTE           pbyTxBufferAddr;
-     PVOID           pvRTS;
-     PVOID           pvCTS;
-     PVOID           pvTxDataHd;
+     void *          pvRTS;
+     void *          pvCTS;
+     void *          pvTxDataHd;
      UINT            uDuration;
      UINT            cbReqCount;
      PS802_11Header  pMACHeader;
      WORD            wTxBufSize;
      UINT            cbMacHdLen;
      SEthernetHeader sEthHeader;
-     PVOID           pvRrvTime;
-     PVOID           pMICHDR;
+     void *          pvRrvTime;
+     void *          pMICHDR;
      PSMgmtObject    pMgmt = pDevice->pMgmt;
      WORD            wCurrentRate = RATE_1M;
      PUWLAN_80211HDR  p80211Header;
  
      }
  
-     memset((PVOID)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize));
-     memcpy(&(sEthHeader.abyDstAddr[0]), &(p80211Header->sA3.abyAddr1[0]), U_ETHER_ADDR_LEN);
-     memcpy(&(sEthHeader.abySrcAddr[0]), &(p80211Header->sA3.abyAddr2[0]), U_ETHER_ADDR_LEN);
+     memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize));
+     memcpy(&(sEthHeader.abyDstAddr[0]), &(p80211Header->sA3.abyAddr1[0]), ETH_ALEN);
+     memcpy(&(sEthHeader.abySrcAddr[0]), &(p80211Header->sA3.abyAddr2[0]), ETH_ALEN);
      //=========================
      //    No Fragmentation
      //=========================
@@@ -26,7 -26,7 +26,7 @@@
   *
   * Functions:
   *
-  *   vntwusb_found1 - module initial (insmod) driver entry
+  *   vt6656_probe - module initial (insmod) driver entry
   *   device_remove1 - module remove entry
   *   device_open - allocate dma/descripter resource & initial mac/bbp function
   *   device_xmit - asynchrous data tx function
@@@ -222,15 -222,11 +222,11 @@@ DEVICE_PARAM(b80211hEnable, "802.11h mo
  // Static vars definitions
  //
  
- static struct usb_device_id vntwusb_table[] = {
+ static struct usb_device_id vt6656_table[] __devinitdata = {
        {USB_DEVICE(VNT_USB_VENDOR_ID, VNT_USB_PRODUCT_ID)},
        {}
  };
  
  // Frequency list (map channels to frequencies)
  /*
  static const long frequency_list[] = {
  static const struct iw_handler_def    iwctl_handler_def;
  */
  
+ /*---------------------  Static Functions  --------------------------*/
  
+ static int vt6656_probe(struct usb_interface *intf,
+                       const struct usb_device_id *id);
+ static void vt6656_disconnect(struct usb_interface *intf);
  
- /*---------------------  Static Functions  --------------------------*/
- static int vntwusb_found1(struct usb_interface *intf, const struct usb_device_id *id);
- static void vntwusb_disconnect(struct usb_interface *intf);
  #ifdef CONFIG_PM      /* Minimal support for suspend and resume */
- static int vntwusb_suspend(struct usb_interface *intf, pm_message_t message);
- static int vntwusb_resume(struct usb_interface *intf);
- #endif
+ static int vt6656_suspend(struct usb_interface *intf, pm_message_t message);
+ static int vt6656_resume(struct usb_interface *intf);
+ #endif /* CONFIG_PM */
  static struct net_device_stats *device_get_stats(struct net_device *dev);
  static int  device_open(struct net_device *dev);
  static int  device_xmit(struct sk_buff *skb, struct net_device *dev);
@@@ -279,8 -277,10 +277,10 @@@ static void device_free_frag_bufs(PSDev
  static BOOL device_alloc_bufs(PSDevice pDevice);
  
  static int Read_config_file(PSDevice pDevice);
- static UCHAR *Config_FileOperation(PSDevice pDevice);
- static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source);
+ static unsigned char *Config_FileOperation(PSDevice pDevice);
+ static int Config_FileGetParameter(unsigned char *string,
+                                  unsigned char *dest,
+                                  unsigned char *source);
  
  //2008-0714<Add>by Mike Liu
  static BOOL device_release_WPADEV(PSDevice pDevice);
@@@ -297,14 -297,13 +297,13 @@@ static void usb_device_reset(PSDevice p
  static void
  device_set_options(PSDevice pDevice) {
  
-     BYTE    abyBroadcastAddr[U_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-     BYTE    abySNAP_RFC1042[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
-     BYTE    abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
+     BYTE    abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+     BYTE    abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
+     u8 abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
  
-     memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, U_ETHER_ADDR_LEN);
-     memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, U_ETHER_ADDR_LEN);
-     memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, U_ETHER_ADDR_LEN);
+     memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN);
+     memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN);
+     memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN);
  
      pDevice->cbTD = TX_DESC_DEF0;
      pDevice->cbRD = RX_DESC_DEF0;
  }
  
  
- static VOID device_init_diversity_timer(PSDevice pDevice) {
+ static void device_init_diversity_timer(PSDevice pDevice)
+ {
      init_timer(&pDevice->TimerSQ3Tmax1);
-     pDevice->TimerSQ3Tmax1.data = (ULONG)pDevice;
+     pDevice->TimerSQ3Tmax1.data = (unsigned long)pDevice;
      pDevice->TimerSQ3Tmax1.function = (TimerFunction)TimerSQ3CallBack;
      pDevice->TimerSQ3Tmax1.expires = RUN_AT(HZ);
  
      init_timer(&pDevice->TimerSQ3Tmax2);
-     pDevice->TimerSQ3Tmax2.data = (ULONG)pDevice;
+     pDevice->TimerSQ3Tmax2.data = (unsigned long)pDevice;
      pDevice->TimerSQ3Tmax2.function = (TimerFunction)TimerSQ3CallBack;
      pDevice->TimerSQ3Tmax2.expires = RUN_AT(HZ);
  
      init_timer(&pDevice->TimerSQ3Tmax3);
-     pDevice->TimerSQ3Tmax3.data = (ULONG)pDevice;
+     pDevice->TimerSQ3Tmax3.data = (unsigned long)pDevice;
      pDevice->TimerSQ3Tmax3.function = (TimerFunction)TimerSQ3Tmax3CallBack;
      pDevice->TimerSQ3Tmax3.expires = RUN_AT(HZ);
  
  
  static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType)
  {
-     BYTE            abyBroadcastAddr[U_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-     BYTE            abySNAP_RFC1042[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
-     BYTE            abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
+     u8 abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+     u8 abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
+     u8 abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
      BYTE            byAntenna;
-     UINT            ii;
+     unsigned int            ii;
      CMD_CARD_INIT   sInitCmd;
      NTSTATUS        ntStatus = STATUS_SUCCESS;
      RSP_CARD_INIT   sInitRsp;
  
      DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n", InitType, pDevice->byPacketType);
        spin_lock_irq(&pDevice->lock);
-     if (InitType == DEVICE_INIT_COLD) {
-         memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, U_ETHER_ADDR_LEN);
-         memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, U_ETHER_ADDR_LEN);
-         memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, U_ETHER_ADDR_LEN);
+       if (InitType == DEVICE_INIT_COLD) {
+               memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN);
+               memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN);
+               memcpy(pDevice->abySNAP_Bridgetunnel,
+                      abySNAP_Bridgetunnel,
+                      ETH_ALEN);
  
          if ( !FIRMWAREbCheckVersion(pDevice) ) {
              if (FIRMWAREbDownload(pDevice) == TRUE) {
  
          // get Permanent network address
          memcpy(pDevice->abyPermanentNetAddr,&(sInitRsp.byNetAddr[0]),6);
-         memcpy(pDevice->abyCurrentNetAddr, pDevice->abyPermanentNetAddr, U_ETHER_ADDR_LEN);
+       memcpy(pDevice->abyCurrentNetAddr,
+              pDevice->abyPermanentNetAddr,
+              ETH_ALEN);
  
          // if exist SW network address, use SW network address.
  
@@@ -712,7 -715,8 +715,8 @@@ static BOOL device_release_WPADEV(PSDev
  }
  
  #ifdef CONFIG_PM      /* Minimal support for suspend and resume */
- static int vntwusb_suspend(struct usb_interface *intf, pm_message_t message)
+ static int vt6656_suspend(struct usb_interface *intf, pm_message_t message)
  {
   PSDevice  pDevice = usb_get_intfdata(intf);
   struct net_device *dev = pDevice->dev;
@@@ -727,7 -731,7 +731,7 @@@ if(dev != NULL) 
   return 0;
  }
  
- static int vntwusb_resume(struct usb_interface *intf)
+ static int vt6656_resume(struct usb_interface *intf)
  {
   PSDevice  pDevice = usb_get_intfdata(intf);
   struct net_device *dev = pDevice->dev;
   }
   return 0;
  }
- #endif
  
+ #endif /* CONFIG_PM */
  
  static const struct net_device_ops device_netdev_ops = {
      .ndo_open               = device_open,
  };
  
  
- static int
- vntwusb_found1(struct usb_interface *intf, const struct usb_device_id *id)
+ static int __devinit
+ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
  {
-    BYTE            fake_mac[U_ETHER_ADDR_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01};//fake MAC address
+       u8 fake_mac[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
        struct usb_device *udev = interface_to_usbdev(intf);
      int         rc = 0;
      struct net_device *netdev = NULL;
      spin_lock_init(&pDevice->lock);
  
      pDevice->tx_80211 = device_dma0_tx_80211;
-     pDevice->sMgmtObj.pAdapter = (PVOID)pDevice;
+     pDevice->sMgmtObj.pAdapter = (void *)pDevice;
  
      netdev->netdev_ops         = &device_netdev_ops;
  
    //2007-0821-01<Add>by MikeLiu
           usb_set_intfdata(intf, pDevice);
        SET_NETDEV_DEV(netdev, &intf->dev);
-     memcpy(pDevice->dev->dev_addr, fake_mac, U_ETHER_ADDR_LEN); //use fake mac address
+     memcpy(pDevice->dev->dev_addr, fake_mac, ETH_ALEN);
      rc = register_netdev(netdev);
      if (rc != 0) {
          printk(KERN_ERR DEVICE_NAME " Failed to register netdev\n");
@@@ -841,7 -845,8 +845,8 @@@ err_nomem
  }
  
  
- static VOID device_free_tx_bufs(PSDevice pDevice) {
+ static void device_free_tx_bufs(PSDevice pDevice)
+ {
      PUSB_SEND_CONTEXT pTxContext;
      int ii;
  
  }
  
  
- static VOID device_free_rx_bufs(PSDevice pDevice) {
+ static void device_free_rx_bufs(PSDevice pDevice)
+ {
      PRCB pRCB;
      int ii;
  
@@@ -892,8 -898,8 +898,8 @@@ static void usb_device_reset(PSDevice p
        return ;
  }
  
- static VOID device_free_int_bufs(PSDevice pDevice) {
+ static void device_free_int_bufs(PSDevice pDevice)
+ {
      if (pDevice->intBuf.pDataBuf != NULL)
          kfree(pDevice->intBuf.pDataBuf);
      return;
@@@ -915,7 -921,7 +921,7 @@@ static BOOL device_alloc_bufs(PSDevice 
              goto free_tx;
          }
          pDevice->apTD[ii] = pTxContext;
-         pTxContext->pDevice = (PVOID) pDevice;
+       pTxContext->pDevice = (void *) pDevice;
          //allocate URBs
          pTxContext->pUrb = usb_alloc_urb(0, GFP_ATOMIC);
          if (pTxContext->pUrb == NULL) {
      for (ii = 0; ii < pDevice->cbRD; ii++) {
  
          pDevice->apRCB[ii] = pRCB;
-         pRCB->pDevice = (PVOID) pDevice;
+       pRCB->pDevice = (void *) pDevice;
          //allocate URBs
          pRCB->pUrb = usb_alloc_urb(0, GFP_ATOMIC);
  
@@@ -1102,8 -1108,8 +1108,8 @@@ static int  device_open(struct net_devi
      // Init for Key Management
  
      KeyvInitTable(pDevice,&pDevice->sKey);
-     memcpy(pDevice->sMgmtObj.abyMACAddr, pDevice->abyCurrentNetAddr, U_ETHER_ADDR_LEN);
-     memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, U_ETHER_ADDR_LEN);
+     memcpy(pDevice->sMgmtObj.abyMACAddr, pDevice->abyCurrentNetAddr, ETH_ALEN);
+     memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, ETH_ALEN);
      pDevice->bStopTx0Pkt = FALSE;
      pDevice->bStopDataPkt = FALSE;
      pDevice->bRoaming = FALSE;  //DavidWang
      }
  
      if (pDevice->sMgmtObj.eConfigMode == WMAC_CONFIG_AP) {
-         bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);
+               bScheduleCommand((void *) pDevice, WLAN_CMD_RUN_AP, NULL);
        }
        else {
        //mike:mark@2008-11-10
-             bScheduleCommand((HANDLE)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
-         //bScheduleCommand((HANDLE)pDevice, WLAN_CMD_SSID, NULL);
+         bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
+         /* bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); */
      }
  
  
@@@ -1216,7 -1222,7 +1222,7 @@@ static int  device_close(struct net_dev
  
  //2007-1121-02<Add>by EinsnLiu
      if (pDevice->bLinkPass) {
-       bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
+       bScheduleCommand((void *) pDevice, WLAN_CMD_DISASSOCIATE, NULL);
          mdelay(30);
      }
  //End Add
@@@ -1285,8 -1291,7 +1291,7 @@@ device_release_WPADEV(pDevice)
  }
  
  
- static void vntwusb_disconnect(struct usb_interface *intf)
+ static void __devexit vt6656_disconnect(struct usb_interface *intf)
  {
  
        PSDevice  pDevice = usb_get_intfdata(intf);
@@@ -1333,7 -1338,7 +1338,7 @@@ device_release_WPADEV(pDevice)
  static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) {
      PSDevice        pDevice=netdev_priv(dev);
      PBYTE           pbMPDU;
-     UINT            cbMPDULen = 0;
+     unsigned int            cbMPDULen = 0;
  
  
      DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_dma0_tx_80211\n");
@@@ -1408,24 -1413,27 +1413,27 @@@ static inline u32 ether_crc(int length
  }
  
  //find out  the start  position of str2 from str1
- static UCHAR *kstrstr(const UCHAR *str1,const UCHAR *str2) {
-   int str1_len=strlen(str1);
-   int str2_len=strlen(str2);
+ static unsigned char *kstrstr(const unsigned char *str1,
+                             const unsigned char *str2) {
+   int str1_len = strlen(str1);
+   int str2_len = strlen(str2);
  
    while (str1_len >= str2_len) {
         str1_len--;
        if(memcmp(str1,str2,str2_len)==0)
-          return (UCHAR *)str1;
+       return (unsigned char *) str1;
          str1++;
    }
    return NULL;
  }
  
- static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source)
+ static int Config_FileGetParameter(unsigned char *string,
+                                  unsigned char *dest,
+                                  unsigned char *source)
  {
-   UCHAR buf1[100];
-   UCHAR buf2[100];
-   UCHAR *start_p=NULL,*end_p=NULL,*tmp_p=NULL;
+   unsigned char buf1[100];
+   unsigned char buf2[100];
+   unsigned char *start_p = NULL, *end_p = NULL, *tmp_p = NULL;
    int ii;
  
      memset(buf1,0,100);
      source+=strlen(buf1);
  
  //find target string start point
-     if((start_p = kstrstr(source,buf1))==NULL)
+     start_p = kstrstr(source,buf1);
+     if (start_p == NULL)
        return FALSE;
  
  //check if current config line is marked by "#" ??
@@@ -1446,7 -1455,8 +1455,8 @@@ for(ii=1;;ii++) 
  }
  
  //find target string end point
-      if((end_p = kstrstr(start_p,"\n"))==NULL) {       //cann't find "\n",but don't care
+      end_p = kstrstr(start_p,"\n");
+      if (end_p == NULL) {       //can't find "\n",but don't care
            end_p=start_p+strlen(start_p);   //no include "\n"
         }
  
     buf2[end_p-start_p]='\0';
  
     //find value
-    if((start_p = kstrstr(buf2,"="))==NULL)
+    start_p = kstrstr(buf2,"=");
+    if (start_p == NULL)
        return FALSE;
     memset(buf1,0,100);
     strcpy(buf1,start_p+1);
  }
  
  //if read fail,return NULL,or return data pointer;
- static UCHAR *Config_FileOperation(PSDevice pDevice) {
-     UCHAR    *config_path=CONFIG_PATH;
-     UCHAR    *buffer=NULL;
+ static unsigned char *Config_FileOperation(PSDevice pDevice)
+ {
+     unsigned char *config_path = CONFIG_PATH;
+     unsigned char *buffer = NULL;
      struct file   *filp=NULL;
      mm_segment_t old_fs = get_fs();
      //int oldfsuid=0,oldfsgid=0;
-     int result=0;
+     int result = 0;
  
      set_fs (KERNEL_DS);
      /* Can't do this anymore, so we rely on correct filesystem permissions:
          goto error1;
        }
  
-     buffer = (UCHAR *)kmalloc(1024, GFP_KERNEL);
+     buffer = kmalloc(1024, GFP_KERNEL);
      if(buffer==NULL) {
        printk("alllocate mem for file fail?\n");
        result = -1;
@@@ -1539,16 -1551,17 +1551,17 @@@ if(result!=0) 
  
  //return --->-1:fail;  >=0:successful
  static int Read_config_file(PSDevice pDevice) {
-   int result=0;
-   UCHAR      tmpbuffer[100];
-   UCHAR *buffer=NULL;
+   int result = 0;
+   unsigned char tmpbuffer[100];
+   unsigned char *buffer = NULL;
  
    //init config setting
   pDevice->config_file.ZoneType = -1;
   pDevice->config_file.eAuthenMode = -1;
   pDevice->config_file.eEncryptionStatus = -1;
  
-   if((buffer=Config_FileOperation(pDevice)) ==NULL) {
+   buffer = Config_FileOperation(pDevice);
+   if (buffer == NULL) {
       result =-1;
       return result;
    }
@@@ -1596,7 -1609,7 +1609,7 @@@ static void device_set_multi(struct net
      PSMgmtObject     pMgmt = &(pDevice->sMgmtObj);
      u32              mc_filter[2];
      int              ii;
 -    struct dev_mc_list *mclist;
 +    struct netdev_hw_addr *ha;
      BYTE             pbyData[8] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
      BYTE             byTmpMode = 0;
      int              rc;
      }
      else {
          memset(mc_filter, 0, sizeof(mc_filter));
 -      netdev_for_each_mc_addr(mclist, dev) {
 -            int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
 +      netdev_for_each_mc_addr(ha, dev) {
 +            int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
              mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
          }
          for (ii = 0; ii < 4; ii++) {
@@@ -2064,7 -2077,7 +2077,7 @@@ static int  device_ioctl(struct net_dev
                    rc = 0;
                }
  
-               rc = hostap_ioctl(pDevice, &wrq->u.data);
+               rc = vt6656_hostap_ioctl(pDevice, &wrq->u.data);
          break;
  
      case IOCTL_CMD_WPA:
         if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
             netif_stop_queue(pDevice->dev);
             spin_lock_irq(&pDevice->lock);
-            bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);
+       bScheduleCommand((void *) pDevice, WLAN_CMD_RUN_AP, NULL);
             spin_unlock_irq(&pDevice->lock);
         }
         else {
             DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Commit the settings\n");
             spin_lock_irq(&pDevice->lock);
  //2007-1121-01<Modify>by EinsnLiu
-           if (pDevice->bLinkPass&&
+           if (pDevice->bLinkPass &&
                  memcmp(pMgmt->abyCurrSSID,pMgmt->abyDesireSSID,WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN)) {
-                         bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
+               bScheduleCommand((void *) pDevice, WLAN_CMD_DISASSOCIATE, NULL);
             } else {
             pDevice->bLinkPass = FALSE;
           pMgmt->eCurrState = WMAC_STATE_IDLE;
             netif_stop_queue(pDevice->dev);
  #ifdef  WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
             pMgmt->eScanType = WMAC_SCAN_ACTIVE;
-            if(pDevice->bWPASuppWextEnabled !=TRUE)
+          if (!pDevice->bWPASuppWextEnabled)
  #endif
-            bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
-            bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL);
+               bScheduleCommand((void *) pDevice,
+                                WLAN_CMD_BSSID_SCAN,
+                                pMgmt->abyDesireSSID);
+               bScheduleCommand((void *) pDevice,
+                                WLAN_CMD_SSID,
+                                NULL);
             spin_unlock_irq(&pDevice->lock);
        }
        pDevice->bCommit = FALSE;
@@@ -2153,35 -2170,29 +2170,29 @@@ static int ethtool_ioctl(struct net_dev
  
  /*------------------------------------------------------------------*/
  
+ MODULE_DEVICE_TABLE(usb, vt6656_table);
  
- MODULE_DEVICE_TABLE(usb, vntwusb_table);
- static struct usb_driver vntwusb_driver = {
-           .name =             DEVICE_NAME,
-           .probe =    vntwusb_found1,
-           .disconnect =       vntwusb_disconnect,
-           .id_table = vntwusb_table,
- //2008-0920-01<Add>by MikeLiu
- //for supporting S3 & S4 function
+ static struct usb_driver vt6656_driver = {
+       .name =         DEVICE_NAME,
+       .probe =        vt6656_probe,
+       .disconnect =   vt6656_disconnect,
+       .id_table =     vt6656_table,
  #ifdef CONFIG_PM
-          .suspend = vntwusb_suspend,
-          .resume = vntwusb_resume,
- #endif
+       .suspend = vt6656_suspend,
+       .resume = vt6656_resume,
+ #endif /* CONFIG_PM */
  };
  
- static int __init vntwusb_init_module(void)
+ static int __init vt6656_init_module(void)
  {
      printk(KERN_NOTICE DEVICE_FULL_DRV_NAM " " DEVICE_VERSION);
-     return usb_register(&vntwusb_driver);
+     return usb_register(&vt6656_driver);
  }
  
- static void __exit vntwusb_cleanup_module(void)
+ static void __exit vt6656_cleanup_module(void)
  {
-       usb_deregister(&vntwusb_driver);
+       usb_deregister(&vt6656_driver);
  }
  
- module_init(vntwusb_init_module);
- module_exit(vntwusb_cleanup_module);
+ module_init(vt6656_init_module);
+ module_exit(vt6656_cleanup_module);
   * Date: May 20, 2003
   *
   * Functions:
 - *      s_vGenerateTxParameter - Generate tx dma requried parameter.
 + *      s_vGenerateTxParameter - Generate tx dma required parameter.
   *      s_vGenerateMACHeader - Translate 802.3 to 802.11 header
   *      csBeacon_xmit - beacon tx function
   *      csMgmt_xmit - management tx function
   *      s_uGetDataDuration - get tx data required duration
   *      s_uFillDataHead- fulfill tx data duration header
 - *      s_uGetRTSCTSDuration- get rtx/cts requried duration
 + *      s_uGetRTSCTSDuration- get rtx/cts required duration
   *      s_uGetRTSCTSRsvTime- get rts/cts reserved time
   *      s_uGetTxRsvTime- get frame reserved time
   *      s_vFillCTSHead- fulfill CTS ctl header
 - *      s_vFillFragParameter- Set fragement ctl parameter.
 + *      s_vFillFragParameter- Set fragment ctl parameter.
   *      s_vFillRTSHead- fulfill RTS ctl header
   *      s_vFillTxKey- fulfill tx encrypt key
   *      s_vSWencryption- Software encrypt header
@@@ -113,181 -113,173 +113,173 @@@ const WORD wFB_Opt1[2][5] = 
  /*---------------------  Static Functions  --------------------------*/
  
  static
- VOID
+ void
  s_vSaveTxPktInfo(
-     IN PSDevice pDevice,
-     IN BYTE byPktNum,
-     IN PBYTE pbyDestAddr,
-     IN WORD wPktLength,
-     IN WORD wFIFOCtl
+      PSDevice pDevice,
+      BYTE byPktNum,
+      PBYTE pbyDestAddr,
+      WORD wPktLength,
+      WORD wFIFOCtl
  );
  
  static
- PVOID
+ void *
  s_vGetFreeContext(
      PSDevice pDevice
      );
  
  
  static
- VOID
+ void
  s_vGenerateTxParameter(
-     IN PSDevice         pDevice,
-     IN BYTE             byPktType,
-     IN WORD             wCurrentRate,
-     IN PVOID            pTxBufHead,
-     IN PVOID            pvRrvTime,
-     IN PVOID            pvRTS,
-     IN PVOID            pvCTS,
-     IN UINT             cbFrameSize,
-     IN BOOL             bNeedACK,
-     IN UINT             uDMAIdx,
-     IN PSEthernetHeader psEthHeader
+      PSDevice         pDevice,
+      BYTE             byPktType,
+      WORD             wCurrentRate,
+      void *pTxBufHead,
+      void *pvRrvTime,
+      void *pvRTS,
+      void *pvCTS,
+      unsigned int             cbFrameSize,
+      BOOL             bNeedACK,
+      unsigned int             uDMAIdx,
+      PSEthernetHeader psEthHeader
      );
  
  
- static
- UINT
- s_uFillDataHead (
-     IN PSDevice pDevice,
-     IN BYTE     byPktType,
-     IN WORD     wCurrentRate,
-     IN PVOID    pTxDataHead,
-     IN UINT     cbFrameLength,
-     IN UINT     uDMAIdx,
-     IN BOOL     bNeedAck,
-     IN UINT     uFragIdx,
-     IN UINT     cbLastFragmentSize,
-     IN UINT     uMACfragNum,
-     IN BYTE     byFBOption
+ static unsigned int s_uFillDataHead(
+      PSDevice pDevice,
+      BYTE     byPktType,
+      WORD     wCurrentRate,
+      void *pTxDataHead,
+      unsigned int     cbFrameLength,
+      unsigned int     uDMAIdx,
+      BOOL     bNeedAck,
+      unsigned int     uFragIdx,
+      unsigned int     cbLastFragmentSize,
+      unsigned int     uMACfragNum,
+      BYTE     byFBOption
      );
  
  
  
  
  static
- VOID
+ void
  s_vGenerateMACHeader (
-     IN PSDevice         pDevice,
-     IN PBYTE            pbyBufferAddr,
-     IN WORD             wDuration,
-     IN PSEthernetHeader psEthHeader,
-     IN BOOL             bNeedEncrypt,
-     IN WORD             wFragType,
-     IN UINT             uDMAIdx,
-     IN UINT             uFragIdx
+      PSDevice         pDevice,
+      PBYTE            pbyBufferAddr,
+      WORD             wDuration,
+      PSEthernetHeader psEthHeader,
+      BOOL             bNeedEncrypt,
+      WORD             wFragType,
+      unsigned int             uDMAIdx,
+      unsigned int             uFragIdx
      );
  
  static
- VOID
+ void
  s_vFillTxKey(
-     IN  PSDevice   pDevice,
-     IN  PBYTE      pbyBuf,
-     IN  PBYTE      pbyIVHead,
-     IN  PSKeyItem  pTransmitKey,
-     IN  PBYTE      pbyHdrBuf,
-     IN  WORD       wPayloadLen,
-     OUT PBYTE      pMICHDR
+       PSDevice   pDevice,
+       PBYTE      pbyBuf,
+       PBYTE      pbyIVHead,
+       PSKeyItem  pTransmitKey,
+       PBYTE      pbyHdrBuf,
+       WORD       wPayloadLen,
+      PBYTE      pMICHDR
      );
  
  static
- VOID
+ void
  s_vSWencryption (
-     IN  PSDevice         pDevice,
-     IN  PSKeyItem        pTransmitKey,
-     IN  PBYTE            pbyPayloadHead,
-     IN  WORD             wPayloadSize
+       PSDevice         pDevice,
+       PSKeyItem        pTransmitKey,
+       PBYTE            pbyPayloadHead,
+       WORD             wPayloadSize
      );
  
- static
- UINT
- s_uGetTxRsvTime (
-     IN PSDevice pDevice,
-     IN BYTE     byPktType,
-     IN UINT     cbFrameLength,
-     IN WORD     wRate,
-     IN BOOL     bNeedAck
+ static unsigned int s_uGetTxRsvTime(
+      PSDevice pDevice,
+      BYTE     byPktType,
+      unsigned int     cbFrameLength,
+      WORD     wRate,
+      BOOL     bNeedAck
      );
  
  
- static
- UINT
- s_uGetRTSCTSRsvTime (
-     IN PSDevice pDevice,
-     IN BYTE byRTSRsvType,
-     IN BYTE byPktType,
-     IN UINT cbFrameLength,
-     IN WORD wCurrentRate
+ static unsigned int s_uGetRTSCTSRsvTime(
+      PSDevice pDevice,
+      BYTE byRTSRsvType,
+      BYTE byPktType,
+      unsigned int cbFrameLength,
+      WORD wCurrentRate
      );
  
  static
- VOID
+ void
  s_vFillCTSHead (
-     IN PSDevice pDevice,
-     IN UINT     uDMAIdx,
-     IN BYTE     byPktType,
-     IN PVOID    pvCTS,
-     IN UINT     cbFrameLength,
-     IN BOOL     bNeedAck,
-     IN BOOL     bDisCRC,
-     IN WORD     wCurrentRate,
-     IN BYTE     byFBOption
+      PSDevice pDevice,
+      unsigned int     uDMAIdx,
+      BYTE     byPktType,
+      void *pvCTS,
+      unsigned int     cbFrameLength,
+      BOOL     bNeedAck,
+      BOOL     bDisCRC,
+      WORD     wCurrentRate,
+      BYTE     byFBOption
      );
  
  static
- VOID
+ void
  s_vFillRTSHead(
-     IN PSDevice         pDevice,
-     IN BYTE             byPktType,
-     IN PVOID            pvRTS,
-     IN UINT             cbFrameLength,
-     IN BOOL             bNeedAck,
-     IN BOOL             bDisCRC,
-     IN PSEthernetHeader psEthHeader,
-     IN WORD             wCurrentRate,
-     IN BYTE             byFBOption
+      PSDevice         pDevice,
+      BYTE             byPktType,
+      void *pvRTS,
+      unsigned int             cbFrameLength,
+      BOOL             bNeedAck,
+      BOOL             bDisCRC,
+      PSEthernetHeader psEthHeader,
+      WORD             wCurrentRate,
+      BYTE             byFBOption
      );
  
- static
- UINT
- s_uGetDataDuration (
-     IN PSDevice pDevice,
-     IN BYTE     byDurType,
-     IN UINT     cbFrameLength,
-     IN BYTE     byPktType,
-     IN WORD     wRate,
-     IN BOOL     bNeedAck,
-     IN UINT     uFragIdx,
-     IN UINT     cbLastFragmentSize,
-     IN UINT     uMACfragNum,
-     IN BYTE     byFBOption
+ static unsigned int s_uGetDataDuration(
+      PSDevice pDevice,
+      BYTE     byDurType,
+      unsigned int     cbFrameLength,
+      BYTE     byPktType,
+      WORD     wRate,
+      BOOL     bNeedAck,
+      unsigned int     uFragIdx,
+      unsigned int     cbLastFragmentSize,
+      unsigned int     uMACfragNum,
+      BYTE     byFBOption
      );
  
  
  static
- UINT
+ unsigned int
  s_uGetRTSCTSDuration (
-     IN PSDevice pDevice,
-     IN BYTE byDurType,
-     IN UINT cbFrameLength,
-     IN BYTE byPktType,
-     IN WORD wRate,
-     IN BOOL bNeedAck,
-     IN BYTE byFBOption
+      PSDevice pDevice,
+      BYTE byDurType,
+      unsigned int cbFrameLength,
+      BYTE byPktType,
+      WORD wRate,
+      BOOL bNeedAck,
+      BYTE byFBOption
      );
  
  
  /*---------------------  Export Variables  --------------------------*/
  
  static
- PVOID
+ void *
  s_vGetFreeContext(
      PSDevice pDevice
      )
  {
      PUSB_SEND_CONTEXT   pContext = NULL;
      PUSB_SEND_CONTEXT   pReturnContext = NULL;
-     UINT                ii;
+     unsigned int                ii;
  
      DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GetFreeContext()\n");
  
      if ( ii == pDevice->cbTD ) {
          DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No Free Tx Context\n");
      }
-     return ((PVOID) pReturnContext);
+     return (void *) pReturnContext;
  }
  
  
  static
- VOID
+ void
  s_vSaveTxPktInfo(PSDevice pDevice, BYTE byPktNum, PBYTE pbyDestAddr, WORD wPktLength, WORD wFIFOCtl)
  {
      PSStatCounter           pStatistic=&(pDevice->scStatistic);
  
      pStatistic->abyTxPktInfo[byPktNum].wLength = wPktLength;
      pStatistic->abyTxPktInfo[byPktNum].wFIFOCtl = wFIFOCtl;
-     memcpy(pStatistic->abyTxPktInfo[byPktNum].abyDestAddr, pbyDestAddr, U_ETHER_ADDR_LEN);
+     memcpy(pStatistic->abyTxPktInfo[byPktNum].abyDestAddr,
+          pbyDestAddr,
+          ETH_ALEN);
  }
  
  
  
  
  static
- VOID
+ void
  s_vFillTxKey (
-     IN  PSDevice   pDevice,
-     IN  PBYTE      pbyBuf,
-     IN  PBYTE      pbyIVHead,
-     IN  PSKeyItem  pTransmitKey,
-     IN  PBYTE      pbyHdrBuf,
-     IN  WORD       wPayloadLen,
-     OUT PBYTE      pMICHDR
+       PSDevice   pDevice,
+       PBYTE      pbyBuf,
+       PBYTE      pbyIVHead,
+       PSKeyItem  pTransmitKey,
+       PBYTE      pbyHdrBuf,
+       WORD       wPayloadLen,
+      PBYTE      pMICHDR
      )
  {
      PDWORD          pdwIV = (PDWORD) pbyIVHead;
  
  
  static
- VOID
+ void
  s_vSWencryption (
-     IN  PSDevice            pDevice,
-     IN  PSKeyItem           pTransmitKey,
-     IN  PBYTE               pbyPayloadHead,
-     IN  WORD                wPayloadSize
+       PSDevice            pDevice,
+       PSKeyItem           pTransmitKey,
+       PBYTE               pbyPayloadHead,
+       WORD                wPayloadSize
      )
  {
-     UINT   cbICVlen = 4;
+     unsigned int   cbICVlen = 4;
      DWORD  dwICV = 0xFFFFFFFFL;
      PDWORD pdwICV;
  
               PK_TYPE_11GA    3
  */
  static
- UINT
+ unsigned int
  s_uGetTxRsvTime (
-     IN PSDevice pDevice,
-     IN BYTE     byPktType,
-     IN UINT     cbFrameLength,
-     IN WORD     wRate,
-     IN BOOL     bNeedAck
+      PSDevice pDevice,
+      BYTE     byPktType,
+      unsigned int     cbFrameLength,
+      WORD     wRate,
+      BOOL     bNeedAck
      )
  {
-     UINT uDataTime, uAckTime;
+     unsigned int uDataTime, uAckTime;
  
      uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wRate);
      if (byPktType == PK_TYPE_11B) {//llb,CCK mode
  
  //byFreqType: 0=>5GHZ 1=>2.4GHZ
  static
- UINT
+ unsigned int
  s_uGetRTSCTSRsvTime (
-     IN PSDevice pDevice,
-     IN BYTE byRTSRsvType,
-     IN BYTE byPktType,
-     IN UINT cbFrameLength,
-     IN WORD wCurrentRate
+      PSDevice pDevice,
+      BYTE byRTSRsvType,
+      BYTE byPktType,
+      unsigned int cbFrameLength,
+      WORD wCurrentRate
      )
  {
-     UINT uRrvTime  , uRTSTime, uCTSTime, uAckTime, uDataTime;
+     unsigned int uRrvTime  , uRTSTime, uCTSTime, uAckTime, uDataTime;
  
      uRrvTime = uRTSTime = uCTSTime = uAckTime = uDataTime = 0;
  
  
  //byFreqType 0: 5GHz, 1:2.4Ghz
  static
- UINT
+ unsigned int
  s_uGetDataDuration (
-     IN PSDevice pDevice,
-     IN BYTE     byDurType,
-     IN UINT     cbFrameLength,
-     IN BYTE     byPktType,
-     IN WORD     wRate,
-     IN BOOL     bNeedAck,
-     IN UINT     uFragIdx,
-     IN UINT     cbLastFragmentSize,
-     IN UINT     uMACfragNum,
-     IN BYTE     byFBOption
+      PSDevice pDevice,
+      BYTE     byDurType,
+      unsigned int     cbFrameLength,
+      BYTE     byPktType,
+      WORD     wRate,
+      BOOL     bNeedAck,
+      unsigned int     uFragIdx,
+      unsigned int     cbLastFragmentSize,
+      unsigned int     uMACfragNum,
+      BYTE     byFBOption
      )
  {
      BOOL bLastFrag = 0;
-     UINT uAckTime =0, uNextPktTime = 0;
+     unsigned int uAckTime = 0, uNextPktTime = 0;
  
      if (uFragIdx == (uMACfragNum-1)) {
          bLastFrag = 1;
  
  //byFreqType: 0=>5GHZ 1=>2.4GHZ
  static
- UINT
+ unsigned int
  s_uGetRTSCTSDuration (
-     IN PSDevice pDevice,
-     IN BYTE byDurType,
-     IN UINT cbFrameLength,
-     IN BYTE byPktType,
-     IN WORD wRate,
-     IN BOOL bNeedAck,
-     IN BYTE byFBOption
+      PSDevice pDevice,
+      BYTE byDurType,
+      unsigned int cbFrameLength,
+      BYTE byPktType,
+      WORD wRate,
+      BOOL bNeedAck,
+      BYTE byFBOption
      )
  {
-     UINT uCTSTime = 0, uDurTime = 0;
+     unsigned int uCTSTime = 0, uDurTime = 0;
  
  
      switch (byDurType) {
  
  
  static
- UINT
+ unsigned int
  s_uFillDataHead (
-     IN PSDevice pDevice,
-     IN BYTE     byPktType,
-     IN WORD     wCurrentRate,
-     IN PVOID    pTxDataHead,
-     IN UINT     cbFrameLength,
-     IN UINT     uDMAIdx,
-     IN BOOL     bNeedAck,
-     IN UINT     uFragIdx,
-     IN UINT     cbLastFragmentSize,
-     IN UINT     uMACfragNum,
-     IN BYTE     byFBOption
+      PSDevice pDevice,
+      BYTE     byPktType,
+      WORD     wCurrentRate,
+      void *pTxDataHead,
+      unsigned int     cbFrameLength,
+      unsigned int     uDMAIdx,
+      BOOL     bNeedAck,
+      unsigned int     uFragIdx,
+      unsigned int     cbLastFragmentSize,
+      unsigned int     uMACfragNum,
+      BYTE     byFBOption
      )
  {
  
  
  
  static
- VOID
+ void
  s_vFillRTSHead (
-     IN PSDevice         pDevice,
-     IN BYTE             byPktType,
-     IN PVOID            pvRTS,
-     IN UINT             cbFrameLength,
-     IN BOOL             bNeedAck,
-     IN BOOL             bDisCRC,
-     IN PSEthernetHeader psEthHeader,
-     IN WORD             wCurrentRate,
-     IN BYTE             byFBOption
+      PSDevice         pDevice,
+      BYTE             byPktType,
+      void *pvRTS,
+      unsigned int             cbFrameLength,
+      BOOL             bNeedAck,
+      BOOL             bDisCRC,
+      PSEthernetHeader psEthHeader,
+      WORD             wCurrentRate,
+      BYTE             byFBOption
      )
  {
-     UINT uRTSFrameLen = 20;
+     unsigned int uRTSFrameLen = 20;
      WORD  wLen = 0x0000;
  
      if (pvRTS == NULL)
              pBuf->Data.wDurationID = pBuf->wDuration_aa;
              //Get RTS Frame body
              pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4
-             if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
-                 (pDevice->eOPMode == OP_MODE_AP)) {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
-             }
+       if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
+           (pDevice->eOPMode == OP_MODE_AP)) {
+               memcpy(&(pBuf->Data.abyRA[0]),
+                      &(psEthHeader->abyDstAddr[0]),
+                      ETH_ALEN);
+       }
              else {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
-             }
-             if (pDevice->eOPMode == OP_MODE_AP) {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
-             }
+                   memcpy(&(pBuf->Data.abyRA[0]),
+                          &(pDevice->abyBSSID[0]),
+                          ETH_ALEN);
+           }
+       if (pDevice->eOPMode == OP_MODE_AP) {
+               memcpy(&(pBuf->Data.abyTA[0]),
+                      &(pDevice->abyBSSID[0]),
+                      ETH_ALEN);
+       }
              else {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+                   memcpy(&(pBuf->Data.abyTA[0]),
+                          &(psEthHeader->abySrcAddr[0]),
+                          ETH_ALEN);
              }
          }
          else {
              //Get RTS Frame body
              pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4
  
-             if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
-                 (pDevice->eOPMode == OP_MODE_AP)) {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
-             }
+       if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
+           (pDevice->eOPMode == OP_MODE_AP)) {
+               memcpy(&(pBuf->Data.abyRA[0]),
+                      &(psEthHeader->abyDstAddr[0]),
+                      ETH_ALEN);
+       }
              else {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+               memcpy(&(pBuf->Data.abyRA[0]),
+                      &(pDevice->abyBSSID[0]),
+                      ETH_ALEN);
              }
  
-             if (pDevice->eOPMode == OP_MODE_AP) {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
-             }
+       if (pDevice->eOPMode == OP_MODE_AP) {
+               memcpy(&(pBuf->Data.abyTA[0]),
+                      &(pDevice->abyBSSID[0]),
+                      ETH_ALEN);
+       }
              else {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+                   memcpy(&(pBuf->Data.abyTA[0]),
+                          &(psEthHeader->abySrcAddr[0]),
+                          ETH_ALEN);
              }
  
          } // if (byFBOption == AUTO_FB_NONE)
              //Get RTS Frame body
              pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4
  
-             if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
-                 (pDevice->eOPMode == OP_MODE_AP)) {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
-             }
-             else {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
-             }
-             if (pDevice->eOPMode == OP_MODE_AP) {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
-             }
-             else {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
-             }
+       if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
+           (pDevice->eOPMode == OP_MODE_AP)) {
+               memcpy(&(pBuf->Data.abyRA[0]),
+                      &(psEthHeader->abyDstAddr[0]),
+                      ETH_ALEN);
+       } else {
+               memcpy(&(pBuf->Data.abyRA[0]),
+                      &(pDevice->abyBSSID[0]),
+                      ETH_ALEN);
+       }
+       if (pDevice->eOPMode == OP_MODE_AP) {
+               memcpy(&(pBuf->Data.abyTA[0]),
+                      &(pDevice->abyBSSID[0]),
+                      ETH_ALEN);
+       } else {
+               memcpy(&(pBuf->Data.abyTA[0]),
+                      &(psEthHeader->abySrcAddr[0]),
+                      ETH_ALEN);
+       }
  
          }
          else {
            //Get RTS Frame body
              pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4
  
-             if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
-                 (pDevice->eOPMode == OP_MODE_AP)) {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
-             }
-             else {
-                 memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
-             }
-             if (pDevice->eOPMode == OP_MODE_AP) {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
-             }
-             else {
-                 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
-             }
+       if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
+           (pDevice->eOPMode == OP_MODE_AP)) {
+               memcpy(&(pBuf->Data.abyRA[0]),
+                      &(psEthHeader->abyDstAddr[0]),
+                      ETH_ALEN);
+       } else {
+               memcpy(&(pBuf->Data.abyRA[0]),
+                      &(pDevice->abyBSSID[0]),
+                      ETH_ALEN);
+       }
+       if (pDevice->eOPMode == OP_MODE_AP) {
+               memcpy(&(pBuf->Data.abyTA[0]),
+                      &(pDevice->abyBSSID[0]),
+                      ETH_ALEN);
+       } else {
+               memcpy(&(pBuf->Data.abyTA[0]),
+                      &(psEthHeader->abySrcAddr[0]),
+                      ETH_ALEN);
+       }
          }
      }
      else if (byPktType == PK_TYPE_11B) {
          //Get RTS Frame body
          pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4
  
-         if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
+       if ((pDevice->eOPMode == OP_MODE_ADHOC) ||
              (pDevice->eOPMode == OP_MODE_AP)) {
-             memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
+               memcpy(&(pBuf->Data.abyRA[0]),
+                      &(psEthHeader->abyDstAddr[0]),
+                      ETH_ALEN);
          }
          else {
-             memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+               memcpy(&(pBuf->Data.abyRA[0]),
+                      &(pDevice->abyBSSID[0]),
+                      ETH_ALEN);
          }
  
          if (pDevice->eOPMode == OP_MODE_AP) {
-             memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
-         }
-         else {
-             memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+               memcpy(&(pBuf->Data.abyTA[0]),
+                      &(pDevice->abyBSSID[0]),
+                      ETH_ALEN);
+       } else {
+               memcpy(&(pBuf->Data.abyTA[0]),
+                      &(psEthHeader->abySrcAddr[0]),
+                      ETH_ALEN);
          }
      }
  }
  
  static
- VOID
+ void
  s_vFillCTSHead (
-     IN PSDevice pDevice,
-     IN UINT     uDMAIdx,
-     IN BYTE     byPktType,
-     IN PVOID    pvCTS,
-     IN UINT     cbFrameLength,
-     IN BOOL     bNeedAck,
-     IN BOOL     bDisCRC,
-     IN WORD     wCurrentRate,
-     IN BYTE     byFBOption
+      PSDevice pDevice,
+      unsigned int     uDMAIdx,
+      BYTE     byPktType,
+      void *pvCTS,
+      unsigned int     cbFrameLength,
+      BOOL     bNeedAck,
+      BOOL     bDisCRC,
+      WORD     wCurrentRate,
+      BYTE     byFBOption
      )
  {
-     UINT uCTSFrameLen = 14;
+     unsigned int uCTSFrameLen = 14;
      WORD  wLen = 0x0000;
  
      if (pvCTS == NULL) {
              pBuf->Data.wDurationID = pBuf->wDuration_ba;
              pBuf->Data.wFrameControl = TYPE_CTL_CTS;//0x00C4
              pBuf->Data.wReserved = 0x0000;
-             memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyCurrentNetAddr[0]), U_ETHER_ADDR_LEN);
+       memcpy(&(pBuf->Data.abyRA[0]),
+              &(pDevice->abyCurrentNetAddr[0]),
+              ETH_ALEN);
          } else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA)
              PSCTS pBuf = (PSCTS)pvCTS;
              //Get SignalField,ServiceField,Length
              pBuf->Data.wDurationID = pBuf->wDuration_ba;
              pBuf->Data.wFrameControl = TYPE_CTL_CTS;//0x00C4
              pBuf->Data.wReserved = 0x0000;
-             memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyCurrentNetAddr[0]), U_ETHER_ADDR_LEN);
+       memcpy(&(pBuf->Data.abyRA[0]),
+              &(pDevice->abyCurrentNetAddr[0]),
+              ETH_ALEN);
          }
      }
  }
  
  /*+
   *
   * Description:
   * Return Value: none
   *
  -*/
- // UINT            cbFrameSize,//Hdr+Payload+FCS
  static
- VOID
+ void
  s_vGenerateTxParameter (
-     IN PSDevice         pDevice,
-     IN BYTE             byPktType,
-     IN WORD             wCurrentRate,
-     IN PVOID            pTxBufHead,
-     IN PVOID            pvRrvTime,
-     IN PVOID            pvRTS,
-     IN PVOID            pvCTS,
-     IN UINT             cbFrameSize,
-     IN BOOL             bNeedACK,
-     IN UINT             uDMAIdx,
-     IN PSEthernetHeader psEthHeader
+      PSDevice         pDevice,
+      BYTE             byPktType,
+      WORD             wCurrentRate,
+      void *pTxBufHead,
+      void *pvRrvTime,
+      void *pvRTS,
+      void *pvCTS,
+      unsigned int             cbFrameSize,
+      BOOL             bNeedACK,
+      unsigned int             uDMAIdx,
+      PSEthernetHeader psEthHeader
      )
  {
-     UINT cbMACHdLen = WLAN_HDR_ADDR3_LEN; //24
+       unsigned int cbMACHdLen = WLAN_HDR_ADDR3_LEN; /* 24 */
      WORD wFifoCtl;
      BOOL bDisCRC = FALSE;
      BYTE byFBOption = AUTO_FB_NONE;
  /*
      PBYTE pbyBuffer,//point to pTxBufHead
      WORD  wFragType,//00:Non-Frag, 01:Start, 02:Mid, 03:Last
-     UINT  cbFragmentSize,//Hdr+payoad+FCS
+     unsigned int  cbFragmentSize,//Hdr+payoad+FCS
  */
  
  
  BOOL
  s_bPacketToWirelessUsb(
-     IN  PSDevice         pDevice,
-     IN  BYTE             byPktType,
-     IN  PBYTE            usbPacketBuf,
-     IN  BOOL             bNeedEncryption,
-     IN  UINT             uSkbPacketLen,
-     IN  UINT             uDMAIdx,
-     IN  PSEthernetHeader psEthHeader,
-     IN  PBYTE            pPacket,
-     IN  PSKeyItem        pTransmitKey,
-     IN  UINT             uNodeIndex,
-     IN  WORD             wCurrentRate,
-     OUT UINT             *pcbHeaderLen,
-     OUT UINT             *pcbTotalLen
+       PSDevice         pDevice,
+       BYTE             byPktType,
+       PBYTE            usbPacketBuf,
+       BOOL             bNeedEncryption,
+       unsigned int             uSkbPacketLen,
+       unsigned int             uDMAIdx,
+       PSEthernetHeader psEthHeader,
+       PBYTE            pPacket,
+       PSKeyItem        pTransmitKey,
+       unsigned int             uNodeIndex,
+       WORD             wCurrentRate,
+      unsigned int             *pcbHeaderLen,
+      unsigned int             *pcbTotalLen
      )
  {
      PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-     UINT                cbFrameSize,cbFrameBodySize;
+     unsigned int cbFrameSize, cbFrameBodySize;
      PTX_BUFFER          pTxBufHead;
-     UINT                cb802_1_H_len;
-     UINT                cbIVlen=0,cbICVlen=0,cbMIClen=0,cbMACHdLen=0,cbFCSlen=4;
-     UINT                cbMICHDR = 0;
+     unsigned int cb802_1_H_len;
+     unsigned int cbIVlen = 0, cbICVlen = 0, cbMIClen = 0,
+           cbMACHdLen = 0, cbFCSlen = 4;
+     unsigned int cbMICHDR = 0;
      BOOL                bNeedACK,bRTS;
      PBYTE               pbyType,pbyMacHdr,pbyIVHead,pbyPayloadHead,pbyTxBufferAddr;
-     BYTE                abySNAP_RFC1042[6] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
-     BYTE                abySNAP_Bridgetunnel[6] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
-     UINT                uDuration;
-     UINT                cbHeaderLength= 0,uPadding = 0;
-     PVOID               pvRrvTime;
+     BYTE abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
+     BYTE abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
+     unsigned int uDuration;
+     unsigned int cbHeaderLength = 0, uPadding = 0;
+     void *pvRrvTime;
      PSMICHDRHead        pMICHDR;
-     PVOID               pvRTS;
-     PVOID               pvCTS;
-     PVOID               pvTxDataHd;
+     void *pvRTS;
+     void *pvCTS;
+     void *pvTxDataHd;
      BYTE                byFBOption = AUTO_FB_NONE,byFragType;
      WORD                wTxBufSize;
      DWORD               dwMICKey0,dwMICKey1,dwMIC_Priority,dwCRC;
          cb802_1_H_len = 0;
      }
  
-     cbFrameBodySize = uSkbPacketLen - U_HEADER_LEN + cb802_1_H_len;
+     cbFrameBodySize = uSkbPacketLen - ETH_HLEN + cb802_1_H_len;
  
      //Set packet type
      pTxBufHead->wFIFOCtl |= (WORD)(byPktType<<8);
  
  
      //Fill FIFO,RrvTime,RTS,and CTS
-     s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, (PVOID)pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS,
+     s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate,
+                          (void *)pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS,
                                 cbFrameSize, bNeedACK, uDMAIdx, psEthHeader);
      //Fill DataHead
      uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK,
      if (pPacket != NULL) {
          // Copy the Packet into a tx Buffer
          memcpy((pbyPayloadHead + cb802_1_H_len),
-                  (pPacket + U_HEADER_LEN),
-                  uSkbPacketLen - U_HEADER_LEN
+                  (pPacket + ETH_HLEN),
+                  uSkbPacketLen - ETH_HLEN
                   );
  
      } else {
          // while bRelayPacketSend psEthHeader is point to header+payload
-         memcpy((pbyPayloadHead + cb802_1_H_len), ((PBYTE)psEthHeader)+U_HEADER_LEN, uSkbPacketLen - U_HEADER_LEN);
+         memcpy((pbyPayloadHead + cb802_1_H_len), ((PBYTE)psEthHeader) + ETH_HLEN, uSkbPacketLen - ETH_HLEN);
      }
  
      ASSERT(uLength == cbNdisBodySize);
      }
  
      if (pDevice->bSoftwareGenCrcErr == TRUE) {
-         UINT   cbLen;
+       unsigned int cbLen;
          PDWORD pdwCRC;
  
          dwCRC = 0xFFFFFFFFL;
   *
  -*/
  
- VOID
+ void
  s_vGenerateMACHeader (
-     IN PSDevice         pDevice,
-     IN PBYTE            pbyBufferAddr,
-     IN WORD             wDuration,
-     IN PSEthernetHeader psEthHeader,
-     IN BOOL             bNeedEncrypt,
-     IN WORD             wFragType,
-     IN UINT             uDMAIdx,
-     IN UINT             uFragIdx
+      PSDevice         pDevice,
+      PBYTE            pbyBufferAddr,
+      WORD             wDuration,
+      PSEthernetHeader psEthHeader,
+      BOOL             bNeedEncrypt,
+      WORD             wFragType,
+      unsigned int             uDMAIdx,
+      unsigned int             uFragIdx
      )
  {
      PS802_11Header  pMACHeader = (PS802_11Header)pbyBufferAddr;
      }
  
      if (pDevice->eOPMode == OP_MODE_AP) {
-         memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
-         memcpy(&(pMACHeader->abyAddr2[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
-         memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
+       memcpy(&(pMACHeader->abyAddr1[0]),
+              &(psEthHeader->abyDstAddr[0]),
+              ETH_ALEN);
+       memcpy(&(pMACHeader->abyAddr2[0]), &(pDevice->abyBSSID[0]), ETH_ALEN);
+       memcpy(&(pMACHeader->abyAddr3[0]),
+              &(psEthHeader->abySrcAddr[0]),
+              ETH_ALEN);
          pMACHeader->wFrameCtl |= FC_FROMDS;
-     }
-     else {
-         if (pDevice->eOPMode == OP_MODE_ADHOC) {
-             memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
-             memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
-             memcpy(&(pMACHeader->abyAddr3[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
-         }
-         else {
-             memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN);
-             memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN);
-             memcpy(&(pMACHeader->abyAddr1[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN);
+     } else {
+       if (pDevice->eOPMode == OP_MODE_ADHOC) {
+               memcpy(&(pMACHeader->abyAddr1[0]),
+                      &(psEthHeader->abyDstAddr[0]),
+                      ETH_ALEN);
+               memcpy(&(pMACHeader->abyAddr2[0]),
+                      &(psEthHeader->abySrcAddr[0]),
+                      ETH_ALEN);
+               memcpy(&(pMACHeader->abyAddr3[0]),
+                      &(pDevice->abyBSSID[0]),
+                      ETH_ALEN);
+       } else {
+               memcpy(&(pMACHeader->abyAddr3[0]),
+                      &(psEthHeader->abyDstAddr[0]),
+                      ETH_ALEN);
+               memcpy(&(pMACHeader->abyAddr2[0]),
+                      &(psEthHeader->abySrcAddr[0]),
+                      ETH_ALEN);
+               memcpy(&(pMACHeader->abyAddr1[0]),
+                      &(pDevice->abyBSSID[0]),
+                      ETH_ALEN);
              pMACHeader->wFrameCtl |= FC_TODS;
          }
      }
  -*/
  
  CMD_STATUS csMgmt_xmit(
-     IN  PSDevice pDevice,
-     IN  PSTxMgmtPacket pPacket
+       PSDevice pDevice,
+       PSTxMgmtPacket pPacket
      )
  {
      BYTE            byPktType;
      PBYTE           pbyTxBufferAddr;
-     PVOID           pvRTS;
+     void *pvRTS;
      PSCTS           pCTS;
-     PVOID           pvTxDataHd;
-     UINT            uDuration;
-     UINT            cbReqCount;
+     void *pvTxDataHd;
+     unsigned int            uDuration;
+     unsigned int            cbReqCount;
      PS802_11Header  pMACHeader;
-     UINT            cbHeaderSize;
-     UINT            cbFrameBodySize;
+     unsigned int            cbHeaderSize;
+     unsigned int            cbFrameBodySize;
      BOOL            bNeedACK;
      BOOL            bIsPSPOLL = FALSE;
      PSTxBufHead     pTxBufHead;
-     UINT            cbFrameSize;
-     UINT            cbIVlen = 0;
-     UINT            cbICVlen = 0;
-     UINT            cbMIClen = 0;
-     UINT            cbFCSlen = 4;
-     UINT            uPadding = 0;
+     unsigned int            cbFrameSize;
+     unsigned int            cbIVlen = 0;
+     unsigned int            cbICVlen = 0;
+     unsigned int            cbMIClen = 0;
+     unsigned int            cbFCSlen = 4;
+     unsigned int            uPadding = 0;
      WORD            wTxBufSize;
-     UINT            cbMacHdLen;
+     unsigned int            cbMacHdLen;
      SEthernetHeader sEthHeader;
-     PVOID           pvRrvTime;
-     PVOID           pMICHDR;
+     void *pvRrvTime;
+     void *pMICHDR;
      PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
      WORD            wCurrentRate = RATE_1M;
      PTX_BUFFER          pTX_Buffer;
          cbHeaderSize = wTxBufSize + sizeof(SRrvTime_ab) + sizeof(STxDataHead_ab);
      }
  
-     memset((PVOID)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize));
+     memset((void *)(pbyTxBufferAddr + wTxBufSize), 0,
+          (cbHeaderSize - wTxBufSize));
  
-     memcpy(&(sEthHeader.abyDstAddr[0]), &(pPacket->p80211Header->sA3.abyAddr1[0]), U_ETHER_ADDR_LEN);
-     memcpy(&(sEthHeader.abySrcAddr[0]), &(pPacket->p80211Header->sA3.abyAddr2[0]), U_ETHER_ADDR_LEN);
+     memcpy(&(sEthHeader.abyDstAddr[0]),
+          &(pPacket->p80211Header->sA3.abyAddr1[0]),
+          ETH_ALEN);
+     memcpy(&(sEthHeader.abySrcAddr[0]),
+          &(pPacket->p80211Header->sA3.abyAddr2[0]),
+          ETH_ALEN);
      //=========================
      //    No Fragmentation
      //=========================
  
  CMD_STATUS
  csBeacon_xmit(
-     IN  PSDevice pDevice,
-     IN  PSTxMgmtPacket pPacket
+       PSDevice pDevice,
+       PSTxMgmtPacket pPacket
      )
  {
  
-     UINT                cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN;
-     UINT                cbHeaderSize = 0;
+     unsigned int                cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN;
+     unsigned int                cbHeaderSize = 0;
      WORD                wTxBufSize = sizeof(STxShortBufHead);
      PSTxShortBufHead    pTxBufHead;
      PS802_11Header      pMACHeader;
      PSTxDataHead_ab     pTxDataHead;
      WORD                wCurrentRate;
-     UINT                cbFrameBodySize;
-     UINT                cbReqCount;
+     unsigned int                cbFrameBodySize;
+     unsigned int                cbReqCount;
      PBEACON_BUFFER      pTX_Buffer;
      PBYTE               pbyTxBufferAddr;
      PUSB_SEND_CONTEXT   pContext;
  
  
  
- VOID
+ void
  vDMA0_tx_80211(PSDevice  pDevice, struct sk_buff *skb) {
  
      PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
      BYTE            byPktType;
      PBYTE           pbyTxBufferAddr;
-     PVOID           pvRTS;
-     PVOID           pvCTS;
-     PVOID           pvTxDataHd;
-     UINT            uDuration;
-     UINT            cbReqCount;
+     void *pvRTS;
+     void *pvCTS;
+     void *pvTxDataHd;
+     unsigned int            uDuration;
+     unsigned int            cbReqCount;
      PS802_11Header  pMACHeader;
-     UINT            cbHeaderSize;
-     UINT            cbFrameBodySize;
+     unsigned int            cbHeaderSize;
+     unsigned int            cbFrameBodySize;
      BOOL            bNeedACK;
      BOOL            bIsPSPOLL = FALSE;
      PSTxBufHead     pTxBufHead;
-     UINT            cbFrameSize;
-     UINT            cbIVlen = 0;
-     UINT            cbICVlen = 0;
-     UINT            cbMIClen = 0;
-     UINT            cbFCSlen = 4;
-     UINT            uPadding = 0;
-     UINT            cbMICHDR = 0;
-     UINT            uLength = 0;
+     unsigned int            cbFrameSize;
+     unsigned int            cbIVlen = 0;
+     unsigned int            cbICVlen = 0;
+     unsigned int            cbMIClen = 0;
+     unsigned int            cbFCSlen = 4;
+     unsigned int            uPadding = 0;
+     unsigned int            cbMICHDR = 0;
+     unsigned int            uLength = 0;
      DWORD           dwMICKey0, dwMICKey1;
      DWORD           dwMIC_Priority;
      PDWORD          pdwMIC_L;
      PDWORD          pdwMIC_R;
      WORD            wTxBufSize;
-     UINT            cbMacHdLen;
+     unsigned int            cbMacHdLen;
      SEthernetHeader sEthHeader;
-     PVOID           pvRrvTime;
-     PVOID           pMICHDR;
+     void *pvRrvTime;
+     void *pMICHDR;
      WORD            wCurrentRate = RATE_1M;
      PUWLAN_80211HDR  p80211Header;
-     UINT             uNodeIndex = 0;
+     unsigned int             uNodeIndex = 0;
      BOOL            bNodeExist = FALSE;
      SKeyItem        STempKey;
      PSKeyItem       pTransmitKey = NULL;
      PBYTE           pbyIVHead;
      PBYTE           pbyPayloadHead;
      PBYTE           pbyMacHdr;
-     UINT            cbExtSuppRate = 0;
+     unsigned int            cbExtSuppRate = 0;
      PTX_BUFFER          pTX_Buffer;
      PUSB_SEND_CONTEXT   pContext;
  //    PWLAN_IE        pItem;
          pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR);
          cbHeaderSize = wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(STxDataHead_ab);
      }
-     memset((PVOID)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize));
-     memcpy(&(sEthHeader.abyDstAddr[0]), &(p80211Header->sA3.abyAddr1[0]), U_ETHER_ADDR_LEN);
-     memcpy(&(sEthHeader.abySrcAddr[0]), &(p80211Header->sA3.abyAddr2[0]), U_ETHER_ADDR_LEN);
+     memset((void *)(pbyTxBufferAddr + wTxBufSize), 0,
+          (cbHeaderSize - wTxBufSize));
+     memcpy(&(sEthHeader.abyDstAddr[0]),
+          &(p80211Header->sA3.abyAddr1[0]),
+          ETH_ALEN);
+     memcpy(&(sEthHeader.abySrcAddr[0]),
+          &(p80211Header->sA3.abyAddr2[0]),
+          ETH_ALEN);
      //=========================
      //    No Fragmentation
      //=========================
  
  NTSTATUS
  nsDMA_tx_packet(
-     IN  PSDevice pDevice,
-     IN  UINT    uDMAIdx,
-     IN  struct sk_buff *skb
+       PSDevice pDevice,
+       unsigned int    uDMAIdx,
+       struct sk_buff *skb
      )
  {
      PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-     UINT            BytesToWrite =0,uHeaderLen = 0;
-     UINT            uNodeIndex = 0;
+     unsigned int BytesToWrite = 0, uHeaderLen = 0;
+     unsigned int            uNodeIndex = 0;
      BYTE            byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
      WORD            wAID;
      BYTE            byPktType;
      BOOL            bNeedEncryption = FALSE;
      PSKeyItem       pTransmitKey = NULL;
      SKeyItem        STempKey;
-     UINT            ii;
+     unsigned int            ii;
      BOOL            bTKIP_UseGTK = FALSE;
      BOOL            bNeedDeAuth = FALSE;
      PBYTE           pbyBSSID;
      PUSB_SEND_CONTEXT pContext;
      BOOL            fConvertedPacket;
      PTX_BUFFER      pTX_Buffer;
-     UINT            status;
+     unsigned int            status;
      WORD            wKeepRate = pDevice->wCurrentRate;
      struct net_device_stats* pStats = &pDevice->stats;
  //#ifdef WPA_SM_Transtatus
          return STATUS_RESOURCES;
      }
  
-     memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(skb->data), U_HEADER_LEN);
+     memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(skb->data), ETH_HLEN);
  
  //mike add:station mode check eapol-key challenge--->
  {
      BYTE  Descriptor_type;
      WORD Key_info;
  
-     Protocol_Version = skb->data[U_HEADER_LEN];
-     Packet_Type = skb->data[U_HEADER_LEN+1];
-     Descriptor_type = skb->data[U_HEADER_LEN+1+1+2];
-     Key_info = (skb->data[U_HEADER_LEN+1+1+2+1] << 8)|(skb->data[U_HEADER_LEN+1+1+2+2]);
+     Protocol_Version = skb->data[ETH_HLEN];
+     Packet_Type = skb->data[ETH_HLEN+1];
+     Descriptor_type = skb->data[ETH_HLEN+1+1+2];
+     Key_info = (skb->data[ETH_HLEN+1+1+2+1] << 8)|(skb->data[ETH_HLEN+1+1+2+2]);
     if (pDevice->sTxEthHeader.wType == TYPE_PKT_802_1x) {
             if(((Protocol_Version==1) ||(Protocol_Version==2)) &&
                (Packet_Type==3)) {  //802.1x OR eapol-key challenge frame transfer
          }
      }
  
-     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dma_tx: pDevice->wCurrentRate = %d \n", pDevice->wCurrentRate);
+     DBG_PRT(MSG_LEVEL_DEBUG,
+           KERN_INFO "dma_tx: pDevice->wCurrentRate = %d\n",
+           pDevice->wCurrentRate);
  
      if (wKeepRate != pDevice->wCurrentRate) {
-         bScheduleCommand((HANDLE)pDevice, WLAN_CMD_SETPOWER, NULL);
+       bScheduleCommand((void *) pDevice, WLAN_CMD_SETPOWER, NULL);
      }
  
      if (pDevice->wCurrentRate <= RATE_11M) {
  
      if ( pDevice->bEnablePSMode == TRUE ) {
          if ( !pDevice->bPSModeTxBurst ) {
-             bScheduleCommand((HANDLE) pDevice, WLAN_CMD_MAC_DISPOWERSAVING, NULL);
+               bScheduleCommand((void *) pDevice,
+                                WLAN_CMD_MAC_DISPOWERSAVING,
+                                NULL);
              pDevice->bPSModeTxBurst = TRUE;
          }
      }
      if (bNeedDeAuth == TRUE) {
          WORD wReason = WLAN_MGMT_REASON_MIC_FAILURE;
  
-         bScheduleCommand((HANDLE) pDevice, WLAN_CMD_DEAUTH, (PBYTE)&wReason);
+       bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (PBYTE) &wReason);
      }
  
    if(status!=STATUS_PENDING) {
  
  BOOL
  bRelayPacketSend (
-     IN  PSDevice pDevice,
-     IN  PBYTE    pbySkbData,
-     IN  UINT     uDataLen,
-     IN  UINT     uNodeIndex
+       PSDevice pDevice,
+       PBYTE    pbySkbData,
+       unsigned int     uDataLen,
+       unsigned int     uNodeIndex
      )
  {
      PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-     UINT            BytesToWrite =0,uHeaderLen = 0;
+     unsigned int BytesToWrite = 0, uHeaderLen = 0;
      BYTE            byPktType = PK_TYPE_11B;
      BOOL            bNeedEncryption = FALSE;
      SKeyItem        STempKey;
      BYTE            byPktTyp;
      BOOL            fConvertedPacket;
      PTX_BUFFER      pTX_Buffer;
-     UINT            status;
+     unsigned int            status;
      WORD            wKeepRate = pDevice->wCurrentRate;
  
  
          return FALSE;
      }
  
-     memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)pbySkbData, U_HEADER_LEN);
+     memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)pbySkbData, ETH_HLEN);
  
      if (pDevice->bEncryptionEnable == TRUE) {
          bNeedEncryption = TRUE;
          pDevice->wCurrentRate = pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate;
      }
  
      if (wKeepRate != pDevice->wCurrentRate) {
-         bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SETPOWER, NULL);
+       bScheduleCommand((void *) pDevice, WLAN_CMD_SETPOWER, NULL);
      }
  
      if (pDevice->wCurrentRate <= RATE_11M)
@@@ -92,10 -92,10 +92,10 @@@ static int wbsoft_get_stats(struct ieee
        return 0;
  }
  
 -static u64 wbsoft_prepare_multicast(struct ieee80211_hw *hw, int mc_count,
 -                                  struct dev_addr_list *mc_list)
 +static u64 wbsoft_prepare_multicast(struct ieee80211_hw *hw,
 +                                  struct netdev_hw_addr_list *mc_list)
  {
 -      return mc_count;
 +      return netdev_hw_addr_list_count(mc_list);
  }
  
  static void wbsoft_configure_filter(struct ieee80211_hw *dev,
@@@ -142,19 -142,17 +142,17 @@@ static void hal_set_radio_mode(struct h
        if (pHwData->SurpriseRemove)
                return;
  
-       if (radio_off)          //disable Baseband receive off
-       {
-               pHwData->CurrentRadioSw = 1;    // off
+       if (radio_off) {        /* disable Baseband receive off */
+               pHwData->CurrentRadioSw = 1;    /* off */
                reg->M24_MacControl &= 0xffffffbf;
        } else {
-               pHwData->CurrentRadioSw = 0;    // on
+               pHwData->CurrentRadioSw = 0;    /* on */
                reg->M24_MacControl |= 0x00000040;
        }
        Wb35Reg_Write(pHwData, 0x0824, reg->M24_MacControl);
  }
  
- static void
- hal_set_current_channel_ex(struct hw_data *pHwData, struct chan_info channel)
+ static void hal_set_current_channel_ex(struct hw_data *pHwData, struct chan_info channel)
  {
        struct wb35_reg *reg = &pHwData->reg;
  
  
        printk("Going to channel: %d/%d\n", channel.band, channel.ChanNo);
  
-       RFSynthesizer_SwitchingChannel(pHwData, channel);       // Switch channel
+       RFSynthesizer_SwitchingChannel(pHwData, channel); /* Switch channel */
        pHwData->Channel = channel.ChanNo;
        pHwData->band = channel.band;
  #ifdef _PE_STATE_DUMP_
        printk("Set channel is %d, band =%d\n", pHwData->Channel,
               pHwData->band);
  #endif
-       reg->M28_MacControl &= ~0xff;   // Clean channel information field
+       reg->M28_MacControl &= ~0xff;   /* Clean channel information field */
        reg->M28_MacControl |= channel.ChanNo;
        Wb35Reg_WriteWithCallbackValue(pHwData, 0x0828, reg->M28_MacControl,
-                                      (s8 *) & channel, sizeof(struct chan_info));
+                                      (s8 *) &channel,
+                                      sizeof(struct chan_info));
  }
  
  static void hal_set_current_channel(struct hw_data *pHwData, struct chan_info channel)
@@@ -188,21 -187,22 +187,22 @@@ static void hal_set_accept_broadcast(st
        if (pHwData->SurpriseRemove)
                return;
  
-       reg->M00_MacControl &= ~0x02000000;     //The HW value
+       reg->M00_MacControl &= ~0x02000000;     /* The HW value */
  
        if (enable)
-               reg->M00_MacControl |= 0x02000000;      //The HW value
+               reg->M00_MacControl |= 0x02000000;      /* The HW value */
  
        Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl);
  }
  
- //for wep key error detection, we need to accept broadcast packets to be received temporary.
+ /* For wep key error detection, we need to accept broadcast packets to be received temporary. */
  static void hal_set_accept_promiscuous(struct hw_data *pHwData, u8 enable)
  {
        struct wb35_reg *reg = &pHwData->reg;
  
        if (pHwData->SurpriseRemove)
                return;
        if (enable) {
                reg->M00_MacControl |= 0x00400000;
                Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl);
@@@ -219,9 -219,9 +219,9 @@@ static void hal_set_accept_multicast(st
        if (pHwData->SurpriseRemove)
                return;
  
-       reg->M00_MacControl &= ~0x01000000;     //The HW value
+       reg->M00_MacControl &= ~0x01000000;     /* The HW value */
        if (enable)
-               reg->M00_MacControl |= 0x01000000;      //The HW value
+               reg->M00_MacControl |= 0x01000000;      /* The HW value */
        Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl);
  }
  
@@@ -232,13 -232,12 +232,12 @@@ static void hal_set_accept_beacon(struc
        if (pHwData->SurpriseRemove)
                return;
  
-       // 20040108 debug
-       if (!enable)            //Due to SME and MLME are not suitable for 35
+       if (!enable)    /* Due to SME and MLME are not suitable for 35 */
                return;
  
-       reg->M00_MacControl &= ~0x04000000;     //The HW value
+       reg->M00_MacControl &= ~0x04000000;     /* The HW value */
        if (enable)
-               reg->M00_MacControl |= 0x04000000;      //The HW value
+               reg->M00_MacControl |= 0x04000000;      /* The HW value */
  
        Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl);
  }
@@@ -283,8 -282,7 +282,7 @@@ static const struct ieee80211_ops wbsof
        .get_tsf                = wbsoft_get_tsf,
  };
  
- static void
- hal_set_ethernet_address(struct hw_data *pHwData, u8 * current_address)
+ static void hal_set_ethernet_address(struct hw_data *pHwData, u8 *current_address)
  {
        u32 ltmp[2];
  
        memcpy(pHwData->CurrentMacAddress, current_address, ETH_ALEN);
  
        ltmp[0] = cpu_to_le32(*(u32 *) pHwData->CurrentMacAddress);
-       ltmp[1] =
-           cpu_to_le32(*(u32 *) (pHwData->CurrentMacAddress + 4)) & 0xffff;
+       ltmp[1] = cpu_to_le32(*(u32 *) (pHwData->CurrentMacAddress + 4)) & 0xffff;
  
        Wb35Reg_BurstWrite(pHwData, 0x03e8, ltmp, 2, AUTO_INCREMENT);
  }
  
- static void
- hal_get_permanent_address(struct hw_data *pHwData, u8 * pethernet_address)
+ static void hal_get_permanent_address(struct hw_data *pHwData, u8 *pethernet_address)
  {
        if (pHwData->SurpriseRemove)
                return;
@@@ -319,7 -315,7 +315,7 @@@ static void hal_stop(struct hw_data *pH
        pHwData->Wb35Tx.tx_halt = 1;
        Wb35Tx_stop(pHwData);
  
-       reg->D00_DmaControl &= ~0xc0000000;     //Tx Off, Rx Off
+       reg->D00_DmaControl &= ~0xc0000000;     /* Tx Off, Rx Off */
        Wb35Reg_Write(pHwData, 0x0400, reg->D00_DmaControl);
  }
  
@@@ -346,14 -342,14 +342,14 @@@ u8 hal_get_antenna_number(struct hw_dat
  }
  
  /* 0 : radio on; 1: radio off */
- static u8 hal_get_hw_radio_off(struct hw_data * pHwData)
+ static u8 hal_get_hw_radio_off(struct hw_data *pHwData)
  {
        struct wb35_reg *reg = &pHwData->reg;
  
        if (pHwData->SurpriseRemove)
                return 1;
  
-       //read the bit16 of register U1B0
+       /* read the bit16 of register U1B0 */
        Wb35Reg_Read(pHwData, 0x3b0, &reg->U1B0);
        if ((reg->U1B0 & 0x00010000)) {
                pHwData->CurrentRadioHw = 1;
@@@ -387,104 -383,98 +383,98 @@@ static void hal_led_control(unsigned lo
  
        if (pHwData->LED_control) {
                ltmp2 = pHwData->LED_control & 0xff;
-               if (ltmp2 == 5) // 5 is WPS mode
-               {
+               if (ltmp2 == 5) { /* 5 is WPS mode */
                        TimeInterval = 100;
                        ltmp2 = (pHwData->LED_control >> 8) & 0xff;
                        switch (ltmp2) {
-                       case 1: // [0.2 On][0.1 Off]...
+                       case 1: /* [0.2 On][0.1 Off]... */
                                pHwData->LED_Blinking %= 3;
-                               ltmp = 0x1010;  // Led 1 & 0 Green and Red
-                               if (pHwData->LED_Blinking == 2) // Turn off
+                               ltmp = 0x1010;  /* Led 1 & 0 Green and Red */
+                               if (pHwData->LED_Blinking == 2) /* Turn off */
                                        ltmp = 0;
                                break;
-                       case 2: // [0.1 On][0.1 Off]...
+                       case 2: /* [0.1 On][0.1 Off]... */
                                pHwData->LED_Blinking %= 2;
-                               ltmp = 0x0010;  // Led 0 red color
-                               if (pHwData->LED_Blinking)      // Turn off
+                               ltmp = 0x0010;  /* Led 0 red color */
+                               if (pHwData->LED_Blinking) /* Turn off */
                                        ltmp = 0;
                                break;
-                       case 3: // [0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.5 Off]...
+                       case 3: /* [0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.5 Off]... */
                                pHwData->LED_Blinking %= 15;
-                               ltmp = 0x0010;  // Led 0 red color
-                               if ((pHwData->LED_Blinking >= 9) || (pHwData->LED_Blinking % 2))        // Turn off 0.6 sec
+                               ltmp = 0x0010;  /* Led 0 red color */
+                               if ((pHwData->LED_Blinking >= 9) || (pHwData->LED_Blinking % 2)) /* Turn off 0.6 sec */
                                        ltmp = 0;
                                break;
-                       case 4: // [300 On][ off ]
-                               ltmp = 0x1000;  // Led 1 Green color
+                       case 4: /* [300 On][ off ] */
+                               ltmp = 0x1000;  /* Led 1 Green color */
                                if (pHwData->LED_Blinking >= 3000)
-                                       ltmp = 0;       // led maybe on after 300sec * 32bit counter overlap.
+                                       ltmp = 0; /* led maybe on after 300sec * 32bit counter overlap. */
                                break;
                        }
                        pHwData->LED_Blinking++;
  
                        reg->U1BC_LEDConfigure = ltmp;
-                       if (LEDSet != 7)        // Only 111 mode has 2 LEDs on PCB.
-                       {
-                               reg->U1BC_LEDConfigure |= (ltmp & 0xff) << 8;   // Copy LED result to each LED control register
+                       if (LEDSet != 7) { /* Only 111 mode has 2 LEDs on PCB. */
+                               reg->U1BC_LEDConfigure |= (ltmp & 0xff) << 8; /* Copy LED result to each LED control register */
                                reg->U1BC_LEDConfigure |= (ltmp & 0xff00) >> 8;
                        }
                        Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure);
                }
-       } else if (pHwData->CurrentRadioSw || pHwData->CurrentRadioHw)  // If radio off
-       {
+       } else if (pHwData->CurrentRadioSw || pHwData->CurrentRadioHw) { /* If radio off */
                if (reg->U1BC_LEDConfigure & 0x1010) {
                        reg->U1BC_LEDConfigure &= ~0x1010;
                        Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure);
                }
        } else {
                switch (LEDSet) {
-               case 4: // [100] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
-                       if (!pHwData->LED_LinkOn)       // Blink only if not Link On
-                       {
-                               // Blinking if scanning is on progress
+               case 4: /* [100] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing */
+                       if (!pHwData->LED_LinkOn) { /* Blink only if not Link On */
+                               /* Blinking if scanning is on progress */
                                if (pHwData->LED_Scanning) {
                                        if (pHwData->LED_Blinking == 0) {
                                                reg->U1BC_LEDConfigure |= 0x10;
-                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 On
+                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 On */
                                                pHwData->LED_Blinking = 1;
                                                TimeInterval = 300;
                                        } else {
                                                reg->U1BC_LEDConfigure &= ~0x10;
-                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
+                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */
                                                pHwData->LED_Blinking = 0;
                                                TimeInterval = 300;
                                        }
                                } else {
-                                       //Turn Off LED_0
+                                       /* Turn Off LED_0 */
                                        if (reg->U1BC_LEDConfigure & 0x10) {
                                                reg->U1BC_LEDConfigure &= ~0x10;
-                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
+                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */
                                        }
                                }
                        } else {
-                               // Turn On LED_0
+                               /* Turn On LED_0 */
                                if ((reg->U1BC_LEDConfigure & 0x10) == 0) {
                                        reg->U1BC_LEDConfigure |= 0x10;
-                                       Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
+                                       Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */
                                }
                        }
                        break;
-               case 6: // [110] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
-                       if (!pHwData->LED_LinkOn)       // Blink only if not Link On
-                       {
-                               // Blinking if scanning is on progress
+               case 6: /* [110] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing */
+                       if (!pHwData->LED_LinkOn) { /* Blink only if not Link On */
+                               /* Blinking if scanning is on progress */
                                if (pHwData->LED_Scanning) {
                                        if (pHwData->LED_Blinking == 0) {
                                                reg->U1BC_LEDConfigure &= ~0xf;
                                                reg->U1BC_LEDConfigure |= 0x10;
-                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 On
+                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 On */
                                                pHwData->LED_Blinking = 1;
                                                TimeInterval = 300;
                                        } else {
                                                reg->U1BC_LEDConfigure &= ~0x1f;
-                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
+                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */
                                                pHwData->LED_Blinking = 0;
                                                TimeInterval = 300;
                                        }
                                } else {
-                                       // 20060901 Gray blinking if in disconnect state and not scanning
+                                       /* Gray blinking if in disconnect state and not scanning */
                                        ltmp = reg->U1BC_LEDConfigure;
                                        reg->U1BC_LEDConfigure &= ~0x1f;
                                        if (LED_GRAY2[(pHwData->LED_Blinking % 30)]) {
                                        }
                                        pHwData->LED_Blinking++;
                                        if (reg->U1BC_LEDConfigure != ltmp)
-                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
+                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */
                                        TimeInterval = 100;
                                }
                        } else {
-                               // Turn On LED_0
+                               /* Turn On LED_0 */
                                if ((reg->U1BC_LEDConfigure & 0x10) == 0) {
                                        reg->U1BC_LEDConfigure |= 0x10;
-                                       Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off
+                                       Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */
                                }
                        }
                        break;
-               case 5: // [101] Only 1 Led be placed on PCB and use LED_1 for showing
-                       if (!pHwData->LED_LinkOn)       // Blink only if not Link On
-                       {
-                               // Blinking if scanning is on progress
+               case 5: /* [101] Only 1 Led be placed on PCB and use LED_1 for showing */
+                       if (!pHwData->LED_LinkOn) { /* Blink only if not Link On */
+                               /* Blinking if scanning is on progress */
                                if (pHwData->LED_Scanning) {
                                        if (pHwData->LED_Blinking == 0) {
-                                               reg->U1BC_LEDConfigure |=
-                                                   0x1000;
-                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 On
+                                               reg->U1BC_LEDConfigure |= 0x1000;
+                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 On */
                                                pHwData->LED_Blinking = 1;
                                                TimeInterval = 300;
                                        } else {
-                                               reg->U1BC_LEDConfigure &=
-                                                   ~0x1000;
-                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 Off
+                                               reg->U1BC_LEDConfigure &= ~0x1000;
+                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 Off */
                                                pHwData->LED_Blinking = 0;
                                                TimeInterval = 300;
                                        }
                                } else {
-                                       //Turn Off LED_1
+                                       /* Turn Off LED_1 */
                                        if (reg->U1BC_LEDConfigure & 0x1000) {
-                                               reg->U1BC_LEDConfigure &=
-                                                   ~0x1000;
-                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 Off
+                                               reg->U1BC_LEDConfigure &= ~0x1000;
+                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 Off */
                                        }
                                }
                        } else {
-                               // Is transmitting/receiving ??
+                               /* Is transmitting/receiving ?? */
                                if ((adapter->RxByteCount !=
                                     pHwData->RxByteCountLast)
                                    || (adapter->TxByteCount !=
                                        pHwData->TxByteCountLast)) {
                                        if ((reg->U1BC_LEDConfigure & 0x3000) !=
                                            0x3000) {
-                                               reg->U1BC_LEDConfigure |=
-                                                   0x3000;
-                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 On
+                                               reg->U1BC_LEDConfigure |= 0x3000;
+                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 On */
                                        }
-                                       // Update variable
+                                       /* Update variable */
                                        pHwData->RxByteCountLast =
                                            adapter->RxByteCount;
                                        pHwData->TxByteCountLast =
                                            adapter->TxByteCount;
                                        TimeInterval = 200;
                                } else {
-                                       // Turn On LED_1 and blinking if transmitting/receiving
+                                       /* Turn On LED_1 and blinking if transmitting/receiving */
                                        if ((reg->U1BC_LEDConfigure & 0x3000) !=
                                            0x1000) {
                                                reg->U1BC_LEDConfigure &=
                                                    ~0x3000;
                                                reg->U1BC_LEDConfigure |=
                                                    0x1000;
-                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 On
+                                               Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 On */
                                        }
                                }
                        }
                        break;
-               default:        // Default setting. 2 LED be placed on PCB. LED_0: Link On LED_1 Active
+               default: /* Default setting. 2 LED be placed on PCB. LED_0: Link On LED_1 Active */
                        if ((reg->U1BC_LEDConfigure & 0x3000) != 0x3000) {
-                               reg->U1BC_LEDConfigure |= 0x3000;       // LED_1 is always on and event enable
+                               reg->U1BC_LEDConfigure |= 0x3000;       /* LED_1 is always on and event enable */
                                Wb35Reg_Write(pHwData, 0x03bc,
                                              reg->U1BC_LEDConfigure);
                        }
  
                        if (pHwData->LED_Blinking) {
-                               // Gray blinking
+                               /* Gray blinking */
                                reg->U1BC_LEDConfigure &= ~0x0f;
                                reg->U1BC_LEDConfigure |= 0x10;
                                reg->U1BC_LEDConfigure |=
                                if (pHwData->LED_Blinking < 40)
                                        TimeInterval = 100;
                                else {
-                                       pHwData->LED_Blinking = 0;      // Stop blinking
+                                       pHwData->LED_Blinking = 0; /* Stop blinking */
                                        reg->U1BC_LEDConfigure &= ~0x0f;
                                        Wb35Reg_Write(pHwData, 0x03bc,
                                                      reg->U1BC_LEDConfigure);
                        }
  
                        if (pHwData->LED_LinkOn) {
-                               if (!(reg->U1BC_LEDConfigure & 0x10))   // Check the LED_0
-                               {
-                                       //Try to turn ON LED_0 after gray blinking
+                               if (!(reg->U1BC_LEDConfigure & 0x10)) { /* Check the LED_0 */
+                                       /* Try to turn ON LED_0 after gray blinking */
                                        reg->U1BC_LEDConfigure |= 0x10;
-                                       pHwData->LED_Blinking = 1;      //Start blinking
+                                       pHwData->LED_Blinking = 1; /* Start blinking */
                                        TimeInterval = 50;
                                }
                        } else {
-                               if (reg->U1BC_LEDConfigure & 0x10)      // Check the LED_0
-                               {
+                               if (reg->U1BC_LEDConfigure & 0x10) { /* Check the LED_0 */
                                        reg->U1BC_LEDConfigure &= ~0x10;
                                        Wb35Reg_Write(pHwData, 0x03bc,
                                                      reg->U1BC_LEDConfigure);
                        break;
                }
  
-               //20060828.1 Active send null packet to avoid AP disconnect
+               /* Active send null packet to avoid AP disconnect */
                if (pHwData->LED_LinkOn) {
                        pHwData->NullPacketCount += TimeInterval;
                        if (pHwData->NullPacketCount >=
        }
  
        pHwData->time_count += TimeInterval;
-       Wb35Tx_CurrentTime(adapter, pHwData->time_count);       // 20060928 add
+       Wb35Tx_CurrentTime(adapter, pHwData->time_count);
        pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(TimeInterval);
        add_timer(&pHwData->LEDTimer);
  }
@@@ -654,7 -635,7 +635,7 @@@ static int hal_init_hardware(struct iee
        SoftwareSet = hal_software_set(pHwData);
  
  #ifdef Vendor2
-       // Try to make sure the EEPROM contain
+       /* Try to make sure the EEPROM contain */
        SoftwareSet >>= 8;
        if (SoftwareSet != 0x82)
                return false;
  #include <wl_sysfs.h>
  
  
- /*******************************************************************************
-  *  macro definitions
-  ******************************************************************************/
- #define CS_CHECK(fn, ret) do { \
-                     last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \
-             } while (0)
  /*******************************************************************************
   *  global definitions
   ******************************************************************************/
@@@ -156,6 -149,9 +149,6 @@@ static int wl_adapter_attach(struct pcm
      link->io.NumPorts1      = HCF_NUM_IO_PORTS;
      link->io.Attributes1    = IO_DATA_PATH_WIDTH_16;
      link->io.IOAddrLines    = 6;
 -    link->irq.Attributes    = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT;
 -//    link->irq.IRQInfo1      = IRQ_INFO2_VALID | IRQ_LEVEL_ID;
 -    link->irq.Handler       = &wl_isr;
      link->conf.Attributes   = CONF_ENABLE_IRQ;
      link->conf.IntType      = INT_MEMORY_AND_IO;
      link->conf.ConfigIndex  = 5;
@@@ -302,7 -298,7 +295,7 @@@ void wl_adapter_insert( struct pcmcia_d
  {
      struct net_device       *dev;
      int i;
-     int                     last_fn, last_ret;
+     int                     ret;
      /*------------------------------------------------------------------------*/
  
      DBG_FUNC( "wl_adapter_insert" );
      /* Do we need to allocate an interrupt? */
      link->conf.Attributes |= CONF_ENABLE_IRQ;
  
-     CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
-     CS_CHECK(RequestIRQ, pcmcia_request_irq(link, wl_isr));
-     CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
+     ret = pcmcia_request_io(link, &link->io);
+     if (ret != 0)
+         goto failed;
+     ret = pcmcia_request_irq(link, (void *) wl_isr);
+     if (ret != 0)
+         goto failed;
  
+     ret = pcmcia_request_configuration(link, &link->conf);
+     if (ret != 0)
+         goto failed;
  
 -    dev->irq        = link->irq.AssignedIRQ;
 +    dev->irq        = link->irq;
      dev->base_addr  = link->io.BasePort1;
  
-     SET_NETDEV_DEV(dev, &handle_to_dev(link));
+     SET_NETDEV_DEV(dev, &link->dev);
      if (register_netdev(dev) != 0) {
        printk("%s: register_netdev() failed\n", MODULE_NAME);
        goto failed;
      }
-     link->dev_node = &( wl_priv(dev) )->node;
-     strcpy(( wl_priv(dev) )->node.dev_name, dev->name);
      register_wlags_sysfs(dev);
  
      printk(KERN_INFO "%s: Wireless, io_addr %#03lx, irq %d, ""mac_address ",
      DBG_LEAVE( DbgInfo );
      return;
  
- cs_failed:
-     cs_error( link, last_fn, last_ret );
  failed:
      wl_adapter_release( link );
  
@@@ -463,15 -463,10 +463,10 @@@ static void wl_get_drvinfo(struct net_d
  //    strncpy(info.fw_version, priv->fw_name,
  //    sizeof(info.fw_version) - 1);
  
- #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20))
      if (dev->dev.parent) {
        dev_set_name(dev->dev.parent, "%s", info->bus_info);
        //strncpy(info->bus_info, dev->dev.parent->bus_id,
        //      sizeof(info->bus_info) - 1);
- #else
-           if (dev->class_dev.parent) {
-               sizeof(info->bus_info) - 1);
- #endif
      } else {
        snprintf(info->bus_info, sizeof(info->bus_info) - 1,
                "PCMCIA FIXME");
@@@ -930,8 -925,10 +925,10 @@@ int wl_rx(struct net_device *dev
          port = ( hfs_stat >> 8 ) & 0x0007;
          DBG_RX( DbgInfo, "Rx frame for port %d\n", port );
  
-         if(( pktlen = lp->hcfCtx.IFB_RxLen ) != 0 ) {
-             if(( skb = ALLOC_SKB( pktlen )) != NULL ) {
+         pktlen = lp->hcfCtx.IFB_RxLen;
+         if (pktlen != 0) {
+             skb = ALLOC_SKB(pktlen);
+             if (skb != NULL) {
                  /* Set the netdev based on the port */
                  switch( port ) {
  #ifdef USE_WDS
@@@ -1050,7 -1047,7 +1047,7 @@@ void wl_multicast( struct net_device *d
  //;?seems reasonable that even an AP-only driver could afford this small additional footprint
  
      int                 x;
 -    struct dev_mc_list *mclist;
 +    struct netdev_hw_addr *ha;
      struct wl_private   *lp = wl_priv(dev);
      unsigned long       flags;
      /*------------------------------------------------------------------------*/
  
          DBG_PRINT( "  mc_count: %d\n", netdev_mc_count(dev));
  
 -      netdev_for_each_mc_addr(mclist, dev)
 -            DBG_PRINT( "    %s (%d)\n", DbgHwAddr(mclist->dmi_addr),
 -                       mclist->dmi_addrlen );
 +      netdev_for_each_mc_addr(ha, dev)
 +            DBG_PRINT("    %s (%d)\n", DbgHwAddr(ha->addr),
 +                    dev->addr_len);
      }
  #endif /* DBG */
  
                  lp->ltvRecord.typ = CFG_GROUP_ADDR;
  
                x = 0;
 -              netdev_for_each_mc_addr(mclist, dev)
 +              netdev_for_each_mc_addr(ha, dev)
                      memcpy(&(lp->ltvRecord.u.u8[x++ * ETH_ALEN]),
 -                           mclist->dmi_addr, ETH_ALEN);
 +                         ha->addr, ETH_ALEN);
                  DBG_PRINT( "Setting multicast list\n" );
                  hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
              } else {
@@@ -1177,7 -1174,6 +1174,6 @@@ void wl_multicast( struct net_device *d
  
  #endif /* NEW_MULTICAST */
  
- #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
  static const struct net_device_ops wl_netdev_ops =
  {
      .ndo_start_xmit         = &wl_tx_port0,
      .ndo_poll_controller    = wl_poll,
  #endif
  };
- #endif // (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
  
  /*******************************************************************************
   *    wl_device_alloc()
@@@ -1251,27 -1246,7 +1246,7 @@@ struct net_device * wl_device_alloc( vo
      lp->wireless_data.spy_data = &lp->spy_data;
      dev->wireless_data = &lp->wireless_data;
  
- #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
      dev->netdev_ops = &wl_netdev_ops;
- #else
-     dev->hard_start_xmit    = &wl_tx_port0;
-     dev->set_config         = &wl_config;
-     dev->get_stats          = &wl_stats;
-     dev->set_multicast_list = &wl_multicast;
-     dev->init               = &wl_insert;
-     dev->open               = &wl_adapter_open;
-     dev->stop               = &wl_adapter_close;
-     dev->do_ioctl           = &wl_ioctl;
-     dev->tx_timeout         = &wl_tx_timeout;
- #ifdef CONFIG_NET_POLL_CONTROLLER
-     dev->poll_controller = wl_poll;
- #endif
- #endif // (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
  
      dev->watchdog_timeo     = TX_TIMEOUT;
  
@@@ -1995,8 -1970,10 +1970,10 @@@ int wl_rx_dma( struct net_device *dev 
                  port = ( hfs_stat >> 8 ) & 0x0007;
                  DBG_RX( DbgInfo, "Rx frame for port %d\n", port );
  
-                 if(( pktlen = GET_BUF_CNT( desc_next )) != 0 ) {
-                     if(( skb = ALLOC_SKB( pktlen )) != NULL ) {
+                 pktlen = GET_BUF_CNT(desc_next);
+                 if (pktlen != 0) {
+                     skb = ALLOC_SKB(pktlen);
+                     if (skb != NULL) {
                          switch( port ) {
  #ifdef USE_WDS
                          case 1: