Merge master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
authorDmitry Torokhov <dtor@insightbb.com>
Tue, 1 May 2007 04:24:54 +0000 (00:24 -0400)
committerDmitry Torokhov <dtor@insightbb.com>
Tue, 1 May 2007 04:24:54 +0000 (00:24 -0400)
Conflicts:

drivers/usb/input/Makefile
drivers/usb/input/gtco.c

1  2 
arch/mips/cobalt/Makefile
drivers/input/keyboard/Kconfig
drivers/input/keyboard/gpio_keys.c
drivers/input/serio/i8042.c
drivers/input/touchscreen/ucb1400_ts.c
drivers/usb/input/Makefile
drivers/usb/input/gtco.c

@@@ -2,8 -2,8 +2,8 @@@
  # Makefile for the Cobalt micro systems family specific parts of the kernel
  #
  
 -obj-y  := irq.o reset.o setup.o
 +obj-y  := irq.o reset.o setup.o buttons.o
  
+ obj-$(CONFIG_PCI)             += pci.o
  obj-$(CONFIG_EARLY_PRINTK)    += console.o
- EXTRA_AFLAGS := $(CFLAGS)
+ obj-$(CONFIG_MTD_PHYSMAP)     += mtd.o
@@@ -203,15 -203,6 +203,15 @@@ config KEYBOARD_OMA
          To compile this driver as a module, choose M here: the
          module will be called omap-keypad.
  
 +config KEYBOARD_PXA27x
 +      tristate "PXA27x keyboard support"
 +      depends on PXA27x
 +      help
 +        Enable support for PXA27x matrix keyboard controller
 +
 +        To compile this driver as a module, choose M here: the
 +        module will be called pxa27x_keyboard.
 +
  config KEYBOARD_AAED2000
        tristate "AAED-2000 keyboard"
        depends on MACH_AAED2000
          module will be called aaed2000_kbd.
  
  config KEYBOARD_GPIO
-       tristate "Buttons on CPU GPIOs (PXA)"
-       depends on (ARCH_SA1100 || ARCH_PXA || ARCH_S3C2410)
+       tristate "GPIO Buttons"
+       depends on GENERIC_GPIO
        help
          This driver implements support for buttons connected
-         directly to GPIO pins of SA1100, PXA or S3C24xx CPUs.
+         to GPIO pins of various CPUs (and some other chips).
  
          Say Y here if your device has buttons connected
-         directly to GPIO pins of the CPU.
+         directly to such GPIO pins.  Your board-specific
+         setup logic must also provide a platform device,
+         with configuration data saying which GPIOs are used.
  
          To compile this driver as a module, choose M here: the
          module will be called gpio-keys.
  #include <linux/platform_device.h>
  #include <linux/input.h>
  #include <linux/irq.h>
+ #include <linux/gpio_keys.h>
  
  #include <asm/gpio.h>
- #include <asm/arch/hardware.h>
- #include <asm/hardware/gpio_keys.h>
  
  static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
  {
@@@ -65,7 -63,8 +63,7 @@@ static int __devinit gpio_keys_probe(st
  
        input->name = pdev->name;
        input->phys = "gpio-keys/input0";
 -      input->cdev.dev = &pdev->dev;
 -      input->private = pdata;
 +      input->dev.parent = &pdev->dev;
  
        input->id.bustype = BUS_HOST;
        input->id.vendor = 0x0001;
@@@ -553,7 -553,8 +553,8 @@@ static int __devinit i8042_check_aux(vo
   */
  
        param = 0x5a;
-       if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != 0x5a) {
+       retval = i8042_command(&param, I8042_CMD_AUX_LOOP);
+       if (retval || param != 0x5a) {
  
  /*
   * External connection test - filters out AT-soldered PS/2 i8042's
                    (param && param != 0xfa && param != 0xff))
                        return -1;
  
-               aux_loop_broken = 1;
+ /*
+  * If AUX_LOOP completed without error but returned unexpected data
+  * mark it as broken
+  */
+               if (!retval)
+                       aux_loop_broken = 1;
        }
  
  /*
@@@ -762,13 -768,6 +768,13 @@@ static void i8042_controller_reset(void
        i8042_flush();
  
  /*
 + * Disable both KBD and AUX interfaces so they don't get in the way
 + */
 +
 +      i8042_ctr |= I8042_CTR_KBDDIS | I8042_CTR_AUXDIS;
 +      i8042_ctr &= ~(I8042_CTR_KBDINT | I8042_CTR_AUXINT);
 +
 +/*
   * Disable MUX mode if present.
   */
  
@@@ -97,8 -97,6 +97,8 @@@ struct ucb1400 
  };
  
  static int adcsync;
 +static int ts_delay = 55; /* us */
 +static int ts_delay_pressure; /* us */
  
  static inline u16 ucb1400_reg_read(struct ucb1400 *ucb, u16 reg)
  {
@@@ -161,7 -159,6 +161,7 @@@ static inline unsigned int ucb1400_ts_r
                        UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW |
                        UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND |
                        UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
 +      udelay(ts_delay_pressure);
        return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPY);
  }
  
@@@ -183,7 -180,7 +183,7 @@@ static inline unsigned int ucb1400_ts_r
                        UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
                        UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA);
  
 -      udelay(55);
 +      udelay(ts_delay);
  
        return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPY);
  }
@@@ -206,7 -203,7 +206,7 @@@ static inline unsigned int ucb1400_ts_r
                        UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
                        UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA);
  
 -      udelay(55);
 +      udelay(ts_delay);
  
        return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPX);
  }
@@@ -372,7 -369,7 +372,7 @@@ static irqreturn_t ucb1400_hard_irq(in
  
  static int ucb1400_ts_open(struct input_dev *idev)
  {
 -      struct ucb1400 *ucb = idev->private;
 +      struct ucb1400 *ucb = input_get_drvdata(idev);
        int ret = 0;
  
        BUG_ON(ucb->ts_task);
  
  static void ucb1400_ts_close(struct input_dev *idev)
  {
 -      struct ucb1400 *ucb = idev->private;
 +      struct ucb1400 *ucb = input_get_drvdata(idev);
  
        if (ucb->ts_task)
                kthread_stop(ucb->ts_task);
@@@ -510,9 -507,8 +510,9 @@@ static int ucb1400_ts_probe(struct devi
        }
        printk(KERN_DEBUG "UCB1400: found IRQ %d\n", ucb->irq);
  
 -      idev->private           = ucb;
 -      idev->cdev.dev          = dev;
 +      input_set_drvdata(idev, ucb);
 +
 +      idev->dev.parent        = dev;
        idev->name              = "UCB1400 touchscreen interface";
        idev->id.vendor         = ucb1400_reg_read(ucb, AC97_VENDOR_ID1);
        idev->id.product        = id;
@@@ -557,6 -553,7 +557,7 @@@ static int ucb1400_ts_remove(struct dev
  }
  
  static struct device_driver ucb1400_ts_driver = {
+       .name           = "ucb1400_ts",
        .owner          = THIS_MODULE,
        .bus            = &ac97_bus_type,
        .probe          = ucb1400_ts_probe,
@@@ -574,15 -571,7 +575,15 @@@ static void __exit ucb1400_ts_exit(void
        driver_unregister(&ucb1400_ts_driver);
  }
  
 -module_param(adcsync, int, 0444);
 +module_param(adcsync, bool, 0444);
 +MODULE_PARM_DESC(adcsync, "Synchronize touch readings with ADCSYNC pin.");
 +
 +module_param(ts_delay, int, 0444);
 +MODULE_PARM_DESC(ts_delay, "Delay between panel setup and position read. Default = 55us.");
 +
 +module_param(ts_delay_pressure, int, 0444);
 +MODULE_PARM_DESC(ts_delay_pressure,
 +                "delay between panel setup and pressure read.  Default = 0us.");
  
  module_init(ucb1400_ts_init);
  module_exit(ucb1400_ts_exit);
@@@ -4,40 -4,15 +4,12 @@@
  
  # Multipart objects.
  wacom-objs    := wacom_wac.o wacom_sys.o
- usbhid-objs   := hid-core.o
- # Optional parts of multipart objects.
- ifeq ($(CONFIG_USB_HIDDEV),y)
-       usbhid-objs     += hiddev.o
- endif
- ifeq ($(CONFIG_HID_PID),y)
-       usbhid-objs     += hid-pidff.o
- endif
- ifeq ($(CONFIG_LOGITECH_FF),y)
-       usbhid-objs     += hid-lgff.o
- endif
- ifeq ($(CONFIG_PANTHERLORD_FF),y)
-       usbhid-objs     += hid-plff.o
- endif
- ifeq ($(CONFIG_THRUSTMASTER_FF),y)
-       usbhid-objs     += hid-tmff.o
- endif
- ifeq ($(CONFIG_ZEROPLUS_FF),y)
-       usbhid-objs     += hid-zpff.o
- endif
- ifeq ($(CONFIG_HID_FF),y)
-       usbhid-objs     += hid-ff.o
- endif
  
  obj-$(CONFIG_USB_AIPTEK)      += aiptek.o
  obj-$(CONFIG_USB_ATI_REMOTE)  += ati_remote.o
  obj-$(CONFIG_USB_ATI_REMOTE2) += ati_remote2.o
- obj-$(CONFIG_USB_HID)         += usbhid.o
- obj-$(CONFIG_USB_KBD)         += usbkbd.o
  obj-$(CONFIG_USB_KBTAB)               += kbtab.o
  obj-$(CONFIG_USB_KEYSPAN_REMOTE)      += keyspan_remote.o
- obj-$(CONFIG_USB_MOUSE)               += usbmouse.o
 -obj-$(CONFIG_USB_MTOUCH)      += mtouchusb.o
 -obj-$(CONFIG_USB_ITMTOUCH)    += itmtouch.o
 -obj-$(CONFIG_USB_EGALAX)      += touchkitusb.o
  obj-$(CONFIG_USB_TOUCHSCREEN) += usbtouchscreen.o
  obj-$(CONFIG_USB_POWERMATE)   += powermate.o
  obj-$(CONFIG_USB_WACOM)               += wacom.o
@@@ -45,7 -20,7 +17,7 @@@ obj-$(CONFIG_USB_ACECAD)      += acecad.
  obj-$(CONFIG_USB_YEALINK)     += yealink.o
  obj-$(CONFIG_USB_XPAD)                += xpad.o
  obj-$(CONFIG_USB_APPLETOUCH)  += appletouch.o
--obj-$(CONFIG_USB_GTCO)         += gtco.o
++obj-$(CONFIG_USB_GTCO)                += gtco.o
  
  ifeq ($(CONFIG_USB_DEBUG),y)
  EXTRA_CFLAGS += -DDEBUG
diff --combined drivers/usb/input/gtco.c
@@@ -187,6 -187,7 +187,6 @@@ struct hid_descripto
  
  
  /*
 - *
   *   This is an abbreviated parser for the HID Report Descriptor.  We
   *   know what devices we are talking to, so this is by no means meant
   *   to be generic.  We can make some safe assumptions:
  static void parse_hid_report_descriptor(struct gtco *device, char * report,
                                        int length)
  {
 -      int   x,i=0;
 +      int   x, i = 0;
  
        /* Tag primitive vars */
        __u8   prefix;
        __u16  data16 = 0;
        __u32  data32 = 0;
  
 -
        /* For parsing logic */
        int   inputnum = 0;
        __u32 usage = 0;
        __u32 oldval[TAG_GLOB_MAX];
  
        /* Debug stuff */
--      char  maintype='x';
++      char  maintype = 'x';
        char  globtype[12];
 -      int   indent=0;
 -      char  indentstr[10]="";
 -
 +      int   indent = 0;
 +      char  indentstr[10] = "";
  
  
        dbg("======>>>>>>PARSE<<<<<<======");
  
        /* Walk  this report and pull out the info we need */
 -      while (i<length){
 -              prefix=report[i];
 +      while (i < length) {
 +              prefix = report[i];
  
                /* Skip over prefix */
                i++;
  
                /* Determine data size and save the data in the proper variable */
                size = PREF_SIZE(prefix);
 -              switch(size){
 +              switch (size) {
                case 1:
                        data = report[i];
                        break;
                case 2:
 -                      data16 = le16_to_cpu(get_unaligned((__le16*)(&(report[i]))));
 +                      data16 = le16_to_cpu(get_unaligned((__le16 *)&report[i]));
                        break;
                case 3:
                        size = 4;
 -                      data32 = le32_to_cpu(get_unaligned((__le32*)(&(report[i]))));
 +                      data32 = le32_to_cpu(get_unaligned((__le32 *)&report[i]));
 +                      break;
                }
  
                /* Skip size of data */
 -              i+=size;
 +              i += size;
  
                /* What we do depends on the tag type */
                tag  = PREF_TAG(prefix);
                type = PREF_TYPE(prefix);
 -              switch(type){
 +              switch (type) {
                case TYPE_MAIN:
 -                      strcpy(globtype,"");
 -                      switch(tag){
 +                      strcpy(globtype, "");
 +                      switch (tag) {
  
                        case TAG_MAIN_INPUT:
                                /*
                                 * min/max values
                                 */
  
 -                              maintype='I';
 -                              if (data==2){
 -                                      strcpy(globtype,"Variable");
 -                              }
 -                              if (data==3){
 -                                      strcpy(globtype,"Var|Const");
 -                              }
 +                              maintype = 'I';
 +                              if (data == 2)
 +                                      strcpy(globtype, "Variable");
 +                              else if (data == 3)
 +                                      strcpy(globtype, "Var|Const");
  
                                dbg("::::: Saving Report: %d input #%d Max: 0x%X(%d) Min:0x%X(%d) of %d bits",
 -                                  globalval[TAG_GLOB_REPORT_ID],inputnum,
 -                                  globalval[TAG_GLOB_LOG_MAX],globalval[TAG_GLOB_LOG_MAX],
 -                                  globalval[TAG_GLOB_LOG_MIN],globalval[TAG_GLOB_LOG_MIN],
 -                                  (globalval[TAG_GLOB_REPORT_SZ] * globalval[TAG_GLOB_REPORT_CNT]));
 +                                  globalval[TAG_GLOB_REPORT_ID], inputnum,
 +                                  globalval[TAG_GLOB_LOG_MAX], globalval[TAG_GLOB_LOG_MAX],
 +                                  globalval[TAG_GLOB_LOG_MIN], globalval[TAG_GLOB_LOG_MIN],
 +                                  globalval[TAG_GLOB_REPORT_SZ] * globalval[TAG_GLOB_REPORT_CNT]);
  
  
                                /*
                                  that, we look for everything else by
                                  local usage value
                                 */
 -                              switch (inputnum){
 +                              switch (inputnum) {
                                case 0:  /* X coord */
 -                                      dbg("GER: X Usage: 0x%x",usage);
 -                                      if (device->max_X == 0){
 +                                      dbg("GER: X Usage: 0x%x", usage);
 +                                      if (device->max_X == 0) {
                                                device->max_X = globalval[TAG_GLOB_LOG_MAX];
                                                device->min_X = globalval[TAG_GLOB_LOG_MIN];
                                        }
 -
                                        break;
 +
                                case 1:  /* Y coord */
 -                                      dbg("GER: Y Usage: 0x%x",usage);
 -                                      if (device->max_Y == 0){
 +                                      dbg("GER: Y Usage: 0x%x", usage);
 +                                      if (device->max_Y == 0) {
                                                device->max_Y = globalval[TAG_GLOB_LOG_MAX];
                                                device->min_Y = globalval[TAG_GLOB_LOG_MIN];
                                        }
                                        break;
 +
                                default:
                                        /* Tilt X */
 -                                      if (usage == DIGITIZER_USAGE_TILT_X){
 -                                              if (device->maxtilt_X == 0){
 +                                      if (usage == DIGITIZER_USAGE_TILT_X) {
 +                                              if (device->maxtilt_X == 0) {
                                                        device->maxtilt_X = globalval[TAG_GLOB_LOG_MAX];
                                                        device->mintilt_X = globalval[TAG_GLOB_LOG_MIN];
                                                }
                                        }
  
                                        /* Tilt Y */
 -                                      if (usage == DIGITIZER_USAGE_TILT_Y){
 -                                              if (device->maxtilt_Y == 0){
 +                                      if (usage == DIGITIZER_USAGE_TILT_Y) {
 +                                              if (device->maxtilt_Y == 0) {
                                                        device->maxtilt_Y = globalval[TAG_GLOB_LOG_MAX];
                                                        device->mintilt_Y = globalval[TAG_GLOB_LOG_MIN];
                                                }
                                        }
  
 -
                                        /* Pressure */
 -                                      if (usage == DIGITIZER_USAGE_TIP_PRESSURE){
 -                                              if (device->maxpressure == 0){
 +                                      if (usage == DIGITIZER_USAGE_TIP_PRESSURE) {
 +                                              if (device->maxpressure == 0) {
                                                        device->maxpressure = globalval[TAG_GLOB_LOG_MAX];
                                                        device->minpressure = globalval[TAG_GLOB_LOG_MIN];
                                                }
                                }
  
                                inputnum++;
 -
 -
                                break;
 +
                        case TAG_MAIN_OUTPUT:
 -                              maintype='O';
 +                              maintype = 'O';
                                break;
 +
                        case TAG_MAIN_FEATURE:
 -                              maintype='F';
 +                              maintype = 'F';
                                break;
 +
                        case TAG_MAIN_COL_START:
 -                              maintype='S';
 +                              maintype = 'S';
  
 -                              if (data==0){
 +                              if (data == 0) {
                                        dbg("======>>>>>> Physical");
 -                                      strcpy(globtype,"Physical");
 -                              }else{
 +                                      strcpy(globtype, "Physical");
 +                              } else
                                        dbg("======>>>>>>");
 -                              }
  
                                /* Indent the debug output */
                                indent++;
 -                              for (x=0;x<indent;x++){
 -                                      indentstr[x]='-';
 -                              }
 -                              indentstr[x]=0;
 +                              for (x = 0; x < indent; x++)
 +                                      indentstr[x] = '-';
 +                              indentstr[x] = 0;
  
                                /* Save global tags */
 -                              for (x=0;x<TAG_GLOB_MAX;x++){
 +                              for (x = 0; x < TAG_GLOB_MAX; x++)
                                        oldval[x] = globalval[x];
 -                              }
  
                                break;
 +
                        case TAG_MAIN_COL_END:
                                dbg("<<<<<<======");
 -                              maintype='E';
 +                              maintype = 'E';
                                indent--;
 -                              for (x=0;x<indent;x++){
 -                                      indentstr[x]='-';
 -                              }
 -                              indentstr[x]=0;
 +                              for (x = 0; x < indent; x++)
 +                                      indentstr[x] = '-';
 +                              indentstr[x] = 0;
  
                                /* Copy global tags back */
 -                              for (x=0;x<TAG_GLOB_MAX;x++){
 +                              for (x = 0; x < TAG_GLOB_MAX; x++)
                                        globalval[x] = oldval[x];
 -                              }
  
                                break;
                        }
  
 -                      switch (size){
 +                      switch (size) {
                        case 1:
                                dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x",
 -                                  indentstr,tag,maintype,size,globtype,data);
 +                                  indentstr, tag, maintype, size, globtype, data);
                                break;
 +
                        case 2:
                                dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x",
 -                                  indentstr,tag,maintype,size,globtype, data16);
 +                                  indentstr, tag, maintype, size, globtype, data16);
                                break;
 +
                        case 4:
                                dbg("%sMAINTAG:(%d) %c SIZE: %d Data: %s 0x%x",
 -                                  indentstr,tag,maintype,size,globtype,data32);
 +                                  indentstr, tag, maintype, size, globtype, data32);
                                break;
                        }
                        break;
 +
                case TYPE_GLOBAL:
 -                      switch(tag){
 +                      switch (tag) {
                        case TAG_GLOB_USAGE:
                                /*
                                 * First time we hit the global usage tag,
                                 * it should tell us the type of device
                                 */
 -                              if (device->usage == 0){
 +                              if (device->usage == 0)
                                        device->usage = data;
 -                              }
 -                              strcpy(globtype,"USAGE");
 +
 +                              strcpy(globtype, "USAGE");
                                break;
 -                      case TAG_GLOB_LOG_MIN   :
 -                              strcpy(globtype,"LOG_MIN");
 +
 +                      case TAG_GLOB_LOG_MIN:
 +                              strcpy(globtype, "LOG_MIN");
                                break;
 -                      case TAG_GLOB_LOG_MAX   :
 -                              strcpy(globtype,"LOG_MAX");
 +
 +                      case TAG_GLOB_LOG_MAX:
 +                              strcpy(globtype, "LOG_MAX");
                                break;
 -                      case TAG_GLOB_PHYS_MIN  :
 -                              strcpy(globtype,"PHYS_MIN");
 +
 +                      case TAG_GLOB_PHYS_MIN:
 +                              strcpy(globtype, "PHYS_MIN");
                                break;
 -                      case TAG_GLOB_PHYS_MAX  :
 -                              strcpy(globtype,"PHYS_MAX");
 +
 +                      case TAG_GLOB_PHYS_MAX:
 +                              strcpy(globtype, "PHYS_MAX");
                                break;
 -                      case TAG_GLOB_UNIT_EXP  :
 -                              strcpy(globtype,"EXP");
 +
 +                      case TAG_GLOB_UNIT_EXP:
 +                              strcpy(globtype, "EXP");
                                break;
 -                      case TAG_GLOB_UNIT      :
 -                              strcpy(globtype,"UNIT");
 +
 +                      case TAG_GLOB_UNIT:
 +                              strcpy(globtype, "UNIT");
                                break;
 -                      case TAG_GLOB_REPORT_SZ :
 -                              strcpy(globtype,"REPORT_SZ");
 +
 +                      case TAG_GLOB_REPORT_SZ:
 +                              strcpy(globtype, "REPORT_SZ");
                                break;
 -                      case TAG_GLOB_REPORT_ID :
 -                              strcpy(globtype,"REPORT_ID");
 +
 +                      case TAG_GLOB_REPORT_ID:
 +                              strcpy(globtype, "REPORT_ID");
                                /* New report, restart numbering */
 -                              inputnum=0;
 +                              inputnum = 0;
                                break;
 +
                        case TAG_GLOB_REPORT_CNT:
 -                              strcpy(globtype,"REPORT_CNT");
 +                              strcpy(globtype, "REPORT_CNT");
                                break;
 -                      case TAG_GLOB_PUSH :
 -                              strcpy(globtype,"PUSH");
 +
 +                      case TAG_GLOB_PUSH:
 +                              strcpy(globtype, "PUSH");
                                break;
 +
                        case TAG_GLOB_POP:
 -                              strcpy(globtype,"POP");
 +                              strcpy(globtype, "POP");
                                break;
                        }
  
 -
                        /* Check to make sure we have a good tag number
                           so we don't overflow array */
 -                      if (tag < TAG_GLOB_MAX){
 -                              switch (size){
 +                      if (tag < TAG_GLOB_MAX) {
 +                              switch (size) {
                                case 1:
 -                                      dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",indentstr,globtype,tag,size,data);
 -                                      globalval[tag]=data;
 +                                      dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",
 +                                          indentstr, globtype, tag, size, data);
 +                                      globalval[tag] = data;
                                        break;
 +
                                case 2:
 -                                      dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",indentstr,globtype,tag,size,data16);
 -                                      globalval[tag]=data16;
 +                                      dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",
 +                                          indentstr, globtype, tag, size, data16);
 +                                      globalval[tag] = data16;
                                        break;
 +
                                case 4:
 -                                      dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",indentstr,globtype,tag,size,data32);
 -                                      globalval[tag]=data32;
 +                                      dbg("%sGLOBALTAG:%s(%d) SIZE: %d Data: 0x%x",
 +                                          indentstr, globtype, tag, size, data32);
 +                                      globalval[tag] = data32;
                                        break;
                                }
 -                      }else{
 +                      } else {
                                dbg("%sGLOBALTAG: ILLEGAL TAG:%d SIZE: %d ",
 -                                  indentstr,tag,size);
 +                                  indentstr, tag, size);
                        }
 -
 -
                        break;
  
                case TYPE_LOCAL:
 -                      switch(tag){
 +                      switch (tag) {
                        case TAG_GLOB_USAGE:
 -                              strcpy(globtype,"USAGE");
 +                              strcpy(globtype, "USAGE");
                                /* Always 1 byte */
                                usage = data;
                                break;
 -                      case TAG_GLOB_LOG_MIN   :
 -                              strcpy(globtype,"MIN");
 +
 +                      case TAG_GLOB_LOG_MIN:
 +                              strcpy(globtype, "MIN");
                                break;
 -                      case TAG_GLOB_LOG_MAX   :
 -                              strcpy(globtype,"MAX");
 +
 +                      case TAG_GLOB_LOG_MAX:
 +                              strcpy(globtype, "MAX");
                                break;
 +
                        default:
 -                              strcpy(globtype,"UNKNOWN");
 +                              strcpy(globtype, "UNKNOWN");
 +                              break;
                        }
  
 -                      switch (size){
 +                      switch (size) {
                        case 1:
                                dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x",
 -                                  indentstr,tag,globtype,size,data);
 +                                  indentstr, tag, globtype, size, data);
                                break;
 +
                        case 2:
                                dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x",
 -                                  indentstr,tag,globtype,size,data16);
 +                                  indentstr, tag, globtype, size, data16);
                                break;
 +
                        case 4:
                                dbg("%sLOCALTAG:(%d) %s SIZE: %d Data: 0x%x",
 -                                  indentstr,tag,globtype,size,data32);
 +                                  indentstr, tag, globtype, size, data32);
                                break;
                        }
  
                        break;
                }
 -
        }
 -
  }
  
 -
 -
  /*   INPUT DRIVER Routines                               */
  
 -
  /*
 - *    Called when opening the input device.  This will submit the URB to
 - *    the usb system so we start getting reports
 + * Called when opening the input device.  This will submit the URB to
 + * the usb system so we start getting reports
   */
  static int gtco_input_open(struct input_dev *inputdev)
  {
 -      struct gtco *device;
 -      device = inputdev->private;
 +      struct gtco *device = input_get_drvdata(inputdev);
  
        device->urbinfo->dev = device->usbdev;
 -      if (usb_submit_urb(device->urbinfo, GFP_KERNEL)) {
 +      if (usb_submit_urb(device->urbinfo, GFP_KERNEL))
                return -EIO;
 -      }
 +
        return 0;
  }
  
 -/**
 -    Called when closing the input device.  This will unlink the URB
 -*/
 +/*
 + * Called when closing the input device.  This will unlink the URB
 + */
  static void gtco_input_close(struct input_dev *inputdev)
  {
 -      struct gtco *device = inputdev->private;
 +      struct gtco *device = input_get_drvdata(inputdev);
  
        usb_kill_urb(device->urbinfo);
 -
  }
  
  
   *  placed in the struct gtco structure
   *
   */
 -static void  gtco_setup_caps(struct input_dev  *inputdev)
 +static void gtco_setup_caps(struct input_dev *inputdev)
  {
 -      struct gtco *device = inputdev->private;
 -
 +      struct gtco *device = input_get_drvdata(inputdev);
  
        /* Which events */
        inputdev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC);
  
 -
        /* Misc event menu block */
        inputdev->mscbit[0] = BIT(MSC_SCAN)|BIT(MSC_SERIAL)|BIT(MSC_RAW) ;
  
 -
        /* Absolute values based on HID report info */
        input_set_abs_params(inputdev, ABS_X, device->min_X, device->max_X,
                             0, 0);
        input_set_abs_params(inputdev, ABS_PRESSURE, device->minpressure,
                             device->maxpressure, 0, 0);
  
 -
        /* Transducer */
 -      input_set_abs_params(inputdev, ABS_MISC, 0,0xFF, 0, 0);
 -
 +      input_set_abs_params(inputdev, ABS_MISC, 0, 0xFF, 0, 0);
  }
  
 -
 -
  /*   USB Routines  */
  
 -
  /*
   * URB callback routine.  Called when we get IRQ reports from the
   *  digitizer.
   */
  static void gtco_urb_callback(struct urb *urbinfo)
  {
 -
 -
 -      struct gtco     *device = urbinfo->context;
 +      struct gtco *device = urbinfo->context;
        struct input_dev  *inputdev;
        int               rc;
        u32               val = 0;
  
        inputdev = device->inputdevice;
  
 -
        /* Was callback OK? */
 -      if ((urbinfo->status == -ECONNRESET ) ||
 -          (urbinfo->status == -ENOENT ) ||
 -          (urbinfo->status == -ESHUTDOWN )){
 +      if (urbinfo->status == -ECONNRESET ||
 +          urbinfo->status == -ENOENT ||
 +          urbinfo->status == -ESHUTDOWN) {
  
                /* Shutdown is occurring. Return and don't queue up any more */
                return;
        }
  
 -      if (urbinfo->status != 0 ) {
 -              /* Some unknown error.  Hopefully temporary.  Just go and */
 -              /* requeue an URB */
 +      if (urbinfo->status != 0) {
 +              /*
 +               * Some unknown error.  Hopefully temporary. Just go and
 +               * requeue an URB
 +               */
                goto resubmit;
        }
  
         */
  
        /* PID dependent when we interpret the report */
 -      if ((inputdev->id.product == PID_1000 )||
 -          (inputdev->id.product == PID_1001 )||
 -          (inputdev->id.product == PID_1002 ))
 -      {
 +      if (inputdev->id.product == PID_1000 ||
 +          inputdev->id.product == PID_1001 ||
 +          inputdev->id.product == PID_1002) {
  
                /*
                 * Switch on the report ID
                 * the report number.  We can just fall through the case
                 * statements if we start with the highest number report
                 */
 -              switch(device->buffer[0]){
 +              switch (device->buffer[0]) {
                case 5:
                        /* Pressure is 9 bits */
 -                      val =  ((u16)(device->buffer[8]) << 1);
 +                      val = ((u16)(device->buffer[8]) << 1);
                        val |= (u16)(device->buffer[7] >> 7);
                        input_report_abs(inputdev, ABS_PRESSURE,
                                         device->buffer[8]);
                        /* Mask out the Y tilt value used for pressure */
                        device->buffer[7] = (u8)((device->buffer[7]) & 0x7F);
  
 -
                        /* Fall thru */
                case 4:
                        /* Tilt */
                        input_report_abs(inputdev, ABS_TILT_Y, (s32)valsigned);
  
                        /* Fall thru */
 -
                case 2:
                case 3:
                        /* Convert buttons, only 5 bits possible */
 -                      val = (device->buffer[5])&MASK_BUTTON;
 +                      val = (device->buffer[5]) & MASK_BUTTON;
  
                        /* We don't apply any meaning to the bitmask,
                           just report */
  
                        /*  Fall thru */
                case 1:
 -
                        /* All reports have X and Y coords in the same place */
 -                      val = le16_to_cpu(get_unaligned((__le16 *) &(device->buffer[1])));
 +                      val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[1]));
                        input_report_abs(inputdev, ABS_X, val);
  
 -                      val = le16_to_cpu(get_unaligned((__le16 *) &(device->buffer[3])));
 +                      val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[3]));
                        input_report_abs(inputdev, ABS_Y, val);
  
 -
                        /* Ditto for proximity bit */
 -                      if (device->buffer[5]& MASK_INRANGE){
 -                              val = 1;
 -                      }else{
 -                              val=0;
 -                      }
 +                      val = device->buffer[5] & MASK_INRANGE ? 1 : 0;
                        input_report_abs(inputdev, ABS_DISTANCE, val);
  
 -
                        /* Report 1 is an exception to how we handle buttons */
                        /* Buttons are an index, not a bitmask */
 -                      if (device->buffer[0] == 1){
 +                      if (device->buffer[0] == 1) {
  
 -                              /* Convert buttons, 5 bit index */
 -                              /* Report value of index set as one,
 -                                 the rest as 0 */
 -                              val = device->buffer[5]& MASK_BUTTON;
 +                              /*
 +                               * Convert buttons, 5 bit index
 +                               * Report value of index set as one,
 +                               * the rest as 0
 +                               */
 +                              val = device->buffer[5] & MASK_BUTTON;
                                dbg("======>>>>>>REPORT 1: val 0x%X(%d)",
 -                                  val,val);
 +                                  val, val);
  
                                /*
                                 * We don't apply any meaning to the button
                                 * index, just report it
                                 */
                                input_event(inputdev, EV_MSC, MSC_SERIAL, val);
 -
 -
                        }
 -
                        break;
 +
                case 7:
                        /* Menu blocks */
                        input_event(inputdev, EV_MSC, MSC_SCAN,
                                    device->buffer[1]);
 -
 -
                        break;
 -
                }
 -
 -
        }
 +
        /* Other pid class */
 -      if ((inputdev->id.product == PID_400 )||
 -          (inputdev->id.product == PID_401 ))
 -      {
 +      if (inputdev->id.product == PID_400 ||
 +          inputdev->id.product == PID_401) {
  
                /* Report 2 */
 -              if (device->buffer[0] == 2){
 +              if (device->buffer[0] == 2) {
                        /* Menu blocks */
 -                      input_event(inputdev, EV_MSC, MSC_SCAN,
 -                                  device->buffer[1]);
 +                      input_event(inputdev, EV_MSC, MSC_SCAN, device->buffer[1]);
                }
  
                /*  Report 1 */
 -              if (device->buffer[0] == 1){
 +              if (device->buffer[0] == 1) {
                        char buttonbyte;
  
 -
                        /*  IF X max > 64K, we still a bit from the y report */
 -                      if (device->max_X > 0x10000){
 +                      if (device->max_X > 0x10000) {
  
 -                              val = (u16)(((u16)(device->buffer[2]<<8))|((u8)(device->buffer[1])));
 -                              val |= (u32)(((u8)device->buffer[3]&0x1)<< 16);
 +                              val = (u16)(((u16)(device->buffer[2] << 8)) | (u8)device->buffer[1]);
 +                              val |= (u32)(((u8)device->buffer[3] & 0x1) << 16);
  
                                input_report_abs(inputdev, ABS_X, val);
  
 -                              le_buffer[0]  = (u8)((u8)(device->buffer[3])>>1);
 -                              le_buffer[0] |= (u8)((device->buffer[3]&0x1)<<7);
 -
 -                              le_buffer[1]  = (u8)(device->buffer[4]>>1);
 -                              le_buffer[1] |= (u8)((device->buffer[5]&0x1)<<7);
 +                              le_buffer[0]  = (u8)((u8)(device->buffer[3]) >> 1);
 +                              le_buffer[0] |= (u8)((device->buffer[3] & 0x1) << 7);
  
 -                              val = le16_to_cpu(get_unaligned((__le16 *)(le_buffer)));
 +                              le_buffer[1]  = (u8)(device->buffer[4] >> 1);
 +                              le_buffer[1] |= (u8)((device->buffer[5] & 0x1) << 7);
  
 +                              val = le16_to_cpu(get_unaligned((__le16 *)le_buffer));
                                input_report_abs(inputdev, ABS_Y, val);
  
 -
                                /*
                                 * Shift the button byte right by one to
                                 * make it look like the standard report
                                 */
 -                              buttonbyte = (device->buffer[5])>>1;
 -                      }else{
 +                              buttonbyte = device->buffer[5] >> 1;
 +                      } else {
  
 -                              val = le16_to_cpu(get_unaligned((__le16 *) (&(device->buffer[1]))));
 +                              val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[1]));
                                input_report_abs(inputdev, ABS_X, val);
  
 -                              val = le16_to_cpu(get_unaligned((__le16 *) (&(device->buffer[3]))));
 +                              val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[3]));
                                input_report_abs(inputdev, ABS_Y, val);
  
                                buttonbyte = device->buffer[5];
 -
                        }
  
 -
                        /* BUTTONS and PROXIMITY */
 -                      if (buttonbyte& MASK_INRANGE){
 -                              val = 1;
 -                      }else{
 -                              val=0;
 -                      }
 +                      val = buttonbyte & MASK_INRANGE ? 1 : 0;
                        input_report_abs(inputdev, ABS_DISTANCE, val);
  
                        /* Convert buttons, only 4 bits possible */
 -                      val = buttonbyte&0x0F;
 +                      val = buttonbyte & 0x0F;
  #ifdef USE_BUTTONS
 -                      for ( i=0;i<5;i++){
 -                              input_report_key(inputdev, BTN_DIGI+i,val&(1<<i));
 -                      }
 +                      for (i = 0; i < 5; i++)
 +                              input_report_key(inputdev, BTN_DIGI + i, val & (1 << i));
  #else
                        /* We don't apply any meaning to the bitmask, just report */
                        input_event(inputdev, EV_MSC, MSC_SERIAL, val);
  #endif
 +
                        /* TRANSDUCER */
                        input_report_abs(inputdev, ABS_MISC, device->buffer[6]);
 -
                }
        }
  
  
   resubmit:
        rc = usb_submit_urb(urbinfo, GFP_ATOMIC);
 -      if (rc != 0) {
 -              err("usb_submit_urb failed rc=0x%x",rc);
 -      }
 -
 +      if (rc != 0)
 +              err("usb_submit_urb failed rc=0x%x", rc);
  }
  
  /*
@@@ -825,46 -854,58 +825,46 @@@ static int gtco_probe(struct usb_interf
                      const struct usb_device_id *id)
  {
  
 -      struct gtco             *device = NULL;
 -      char                    path[PATHLENGTH];
 -      struct input_dev        *inputdev;
 +      struct gtco             *gtco;
 +      struct input_dev        *input_dev;
        struct hid_descriptor   *hid_desc;
 -      char                    *report;
 -      int                     result=0, retry;
 +      char                    *report = NULL;
 +      int                     result = 0, retry;
 +      int                     error;
        struct usb_endpoint_descriptor *endpoint;
  
        /* Allocate memory for device structure */
 -      device = kzalloc(sizeof(struct gtco), GFP_KERNEL);
 -      if (device == NULL) {
 +      gtco = kzalloc(sizeof(struct gtco), GFP_KERNEL);
 +      input_dev = input_allocate_device();
 +      if (!gtco || !input_dev) {
                err("No more memory");
 -              return -ENOMEM;
 +              error = -ENOMEM;
 +              goto err_free_devs;
        }
  
 -
 -      device->inputdevice = input_allocate_device();
 -      if (!device->inputdevice){
 -              kfree(device);
 -              err("No more memory");
 -              return -ENOMEM;
 -      }
 -
 -      /* Get pointer to the input device */
 -      inputdev = device->inputdevice;
 +      /* Set pointer to the input device */
 +      gtco->inputdevice = input_dev;
  
        /* Save interface information */
 -      device->usbdev     = usb_get_dev(interface_to_usbdev(usbinterface));
 -
 +      gtco->usbdev = usb_get_dev(interface_to_usbdev(usbinterface));
  
        /* Allocate some data for incoming reports */
 -      device->buffer = usb_buffer_alloc(device->usbdev, REPORT_MAX_SIZE,
 -                                         GFP_KERNEL, &(device->buf_dma));
 -      if (!device->buffer){
 -              input_free_device(device->inputdevice);
 -              kfree(device);
 -              err("No more memory");
 -              return -ENOMEM;
 +      gtco->buffer = usb_buffer_alloc(gtco->usbdev, REPORT_MAX_SIZE,
 +                                      GFP_KERNEL, &gtco->buf_dma);
 +      if (!gtco->buffer) {
 +              err("No more memory for us buffers");
 +              error = -ENOMEM;
 +              goto err_free_devs;
        }
  
        /* Allocate URB for reports */
 -      device->urbinfo = usb_alloc_urb(0, GFP_KERNEL);
 -      if (!device->urbinfo) {
 -              usb_buffer_free(device->usbdev, REPORT_MAX_SIZE,
 -                              device->buffer, device->buf_dma);
 -              input_free_device(device->inputdevice);
 -              kfree(device);
 -              err("No more memory");
 +      gtco->urbinfo = usb_alloc_urb(0, GFP_KERNEL);
 +      if (!gtco->urbinfo) {
 +              err("Failed to allocate URB");
                return -ENOMEM;
 +              goto err_free_buf;
        }
  
 -
        /*
         * The endpoint is always altsetting 0, we know this since we know
         * this device only has one interrupt endpoint
        endpoint = &usbinterface->altsetting[0].endpoint[0].desc;
  
        /* Some debug */
 -      dbg("gtco # interfaces: %d",usbinterface->num_altsetting);
 -      dbg("num endpoints:     %d",usbinterface->cur_altsetting->desc.bNumEndpoints);
 -      dbg("interface class:   %d",usbinterface->cur_altsetting->desc.bInterfaceClass);
 -      dbg("endpoint: attribute:0x%x type:0x%x",endpoint->bmAttributes,endpoint->bDescriptorType);
 +      dbg("gtco # interfaces: %d", usbinterface->num_altsetting);
 +      dbg("num endpoints:     %d", usbinterface->cur_altsetting->desc.bNumEndpoints);
 +      dbg("interface class:   %d", usbinterface->cur_altsetting->desc.bInterfaceClass);
 +      dbg("endpoint: attribute:0x%x type:0x%x", endpoint->bmAttributes, endpoint->bDescriptorType);
        if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)
                dbg("endpoint: we have interrupt endpoint\n");
  
 -      dbg("endpoint extra len:%d ",usbinterface->altsetting[0].extralen);
 -
 -
 +      dbg("endpoint extra len:%d ", usbinterface->altsetting[0].extralen);
  
        /*
         * Find the HID descriptor so we can find out the size of the
         * HID report descriptor
         */
        if (usb_get_extra_descriptor(usbinterface->cur_altsetting,
 -                                   HID_DEVICE_TYPE,&hid_desc) != 0){
 +                                   HID_DEVICE_TYPE, &hid_desc) != 0){
                err("Can't retrieve exta USB descriptor to get hid report descriptor length");
 -              usb_buffer_free(device->usbdev, REPORT_MAX_SIZE,
 -                              device->buffer, device->buf_dma);
 -              input_free_device(device->inputdevice);
 -              kfree(device);
 -              return -EIO;
 +              error = -EIO;
 +              goto err_free_urb;
        }
  
        dbg("Extra descriptor success: type:%d  len:%d",
            hid_desc->bDescriptorType,  hid_desc->wDescriptorLength);
  
 -      if (!(report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL))) {
 -              usb_buffer_free(device->usbdev, REPORT_MAX_SIZE,
 -                              device->buffer, device->buf_dma);
 -
 -              input_free_device(device->inputdevice);
 -              kfree(device);
 -              err("No more memory");
 -              return -ENOMEM;
 +      report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL);
 +      if (!report) {
 +              err("No more memory for report");
 +              error = -ENOMEM;
 +              goto err_free_urb;
        }
  
        /* Couple of tries to get reply */
 -      for (retry=0;retry<3;retry++) {
 -              result = usb_control_msg(device->usbdev,
 -                                       usb_rcvctrlpipe(device->usbdev, 0),
 +      for (retry = 0; retry < 3; retry++) {
 +              result = usb_control_msg(gtco->usbdev,
 +                                       usb_rcvctrlpipe(gtco->usbdev, 0),
                                         USB_REQ_GET_DESCRIPTOR,
                                         USB_RECIP_INTERFACE | USB_DIR_IN,
 -                                       (REPORT_DEVICE_TYPE << 8),
 +                                       REPORT_DEVICE_TYPE << 8,
                                         0, /* interface */
                                         report,
                                         hid_desc->wDescriptorLength,
  
        /* If we didn't get the report, fail */
        dbg("usb_control_msg result: :%d", result);
 -      if (result != hid_desc->wDescriptorLength){
 -              kfree(report);
 -              usb_buffer_free(device->usbdev, REPORT_MAX_SIZE,
 -                              device->buffer, device->buf_dma);
 -              input_free_device(device->inputdevice);
 -              kfree(device);
 +      if (result != hid_desc->wDescriptorLength) {
                err("Failed to get HID Report Descriptor of size: %d",
                    hid_desc->wDescriptorLength);
 -              return -EIO;
 +              error = -EIO;
 +              goto err_free_urb;
        }
  
 -
        /* Now we parse the report */
 -      parse_hid_report_descriptor(device,report,result);
 +      parse_hid_report_descriptor(gtco, report, result);
  
        /* Now we delete it */
        kfree(report);
  
        /* Create a device file node */
 -      usb_make_path(device->usbdev, path, PATHLENGTH);
 -      sprintf(device->usbpath, "%s/input0", path);
 -
 +      usb_make_path(gtco->usbdev, gtco->usbpath, sizeof(gtco->usbpath));
 +      strlcat(gtco->usbpath, "/input0", sizeof(gtco->usbpath));
  
        /* Set Input device functions */
 -      inputdev->open     = gtco_input_open;
 -      inputdev->close    = gtco_input_close;
 +      input_dev->open = gtco_input_open;
 +      input_dev->close = gtco_input_close;
  
        /* Set input device information */
 -      inputdev->name     = "GTCO_CalComp";
 -      inputdev->phys     = device->usbpath;
 -      inputdev->private  = device;
 +      input_dev->name = "GTCO_CalComp";
 +      input_dev->phys = gtco->usbpath;
  
 +      input_set_drvdata(input_dev, gtco);
  
        /* Now set up all the input device capabilities */
 -      gtco_setup_caps(inputdev);
 +      gtco_setup_caps(input_dev);
  
        /* Set input device required ID information */
 -      usb_to_input_id(device->usbdev, &device->inputdevice->id);
 -      inputdev->cdev.dev = &usbinterface->dev;
 +      usb_to_input_id(gtco->usbdev, &input_dev->id);
 +      input_dev->dev.parent = &usbinterface->dev;
  
        /* Setup the URB, it will be posted later on open of input device */
        endpoint = &usbinterface->altsetting[0].endpoint[0].desc;
  
 -      usb_fill_int_urb(device->urbinfo,
 -                       device->usbdev,
 -                       usb_rcvintpipe(device->usbdev,
 +      usb_fill_int_urb(gtco->urbinfo,
 +                       gtco->usbdev,
 +                       usb_rcvintpipe(gtco->usbdev,
                                        endpoint->bEndpointAddress),
 -                       device->buffer,
 +                       gtco->buffer,
                         REPORT_MAX_SIZE,
                         gtco_urb_callback,
 -                       device,
 +                       gtco,
                         endpoint->bInterval);
  
 -      device->urbinfo->transfer_dma = device->buf_dma;
 -      device->urbinfo->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
 -
 +      gtco->urbinfo->transfer_dma = gtco->buf_dma;
 +      gtco->urbinfo->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  
 -      /* Save device pointer in USB interface device */
 -      usb_set_intfdata(usbinterface, device);
 +      /* Save gtco pointer in USB interface gtco */
 +      usb_set_intfdata(usbinterface, gtco);
  
        /* All done, now register the input device */
 -      input_register_device(inputdev);
 +      error = input_register_device(input_dev);
 +      if (error)
 +              goto err_free_urb;
  
 -      info( "gtco driver created usb:  %s\n",  path);
        return 0;
  
 + err_free_urb:
 +      usb_free_urb(gtco->urbinfo);
 + err_free_buf:
 +      usb_buffer_free(gtco->usbdev, REPORT_MAX_SIZE,
 +                      gtco->buffer, gtco->buf_dma);
 + err_free_devs:
 +      kfree(report);
 +      input_free_device(input_dev);
 +      kfree(gtco);
 +      return error;
  }
  
  /*
   */
  static void gtco_disconnect(struct usb_interface *interface)
  {
 -
        /* Grab private device ptr */
 -      struct gtco    *device = usb_get_intfdata (interface);
 +      struct gtco *gtco = usb_get_intfdata(interface);
  
        /* Now reverse all the registration stuff */
 -      if (device) {
 -              input_unregister_device(device->inputdevice);
 -              usb_kill_urb(device->urbinfo);
 -              usb_free_urb(device->urbinfo);
 -              usb_buffer_free(device->usbdev, REPORT_MAX_SIZE,
 -                              device->buffer, device->buf_dma);
 -              kfree(device);
 +      if (gtco) {
 +              input_unregister_device(gtco->inputdevice);
 +              usb_kill_urb(gtco->urbinfo);
 +              usb_free_urb(gtco->urbinfo);
 +              usb_buffer_free(gtco->usbdev, REPORT_MAX_SIZE,
 +                              gtco->buffer, gtco->buf_dma);
 +              kfree(gtco);
        }
  
        info("gtco driver disconnected");
  }
  
 -
  /*   STANDARD MODULE LOAD ROUTINES  */
  
  static struct usb_driver gtco_driverinfo_table = {
 -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16))
 -      .owner      = THIS_MODULE,
 -#endif
 -      .name       = "gtco",
 -      .id_table   = gtco_usbid_table,
 -      .probe      = gtco_probe,
 -      .disconnect = gtco_disconnect,
 +      .name           = "gtco",
 +      .id_table       = gtco_usbid_table,
 +      .probe          = gtco_probe,
 +      .disconnect     = gtco_disconnect,
  };
 +
  /*
   *  Register this module with the USB subsystem
   */
  static int __init gtco_init(void)
  {
 -      int rc;
 -      rc = usb_register(&gtco_driverinfo_table);
 -      if (rc) {
 -              err("usb_register() failed rc=0x%x", rc);
 +      int error;
 +
 +      error = usb_register(&gtco_driverinfo_table);
 +      if (error) {
 +              err("usb_register() failed rc=0x%x", error);
 +              return error;
        }
 -      printk("GTCO usb driver version: %s",GTCO_VERSION);
 -      return rc;
 +
 +      printk("GTCO usb driver version: %s", GTCO_VERSION);
 +      return 0;
  }
  
  /*
@@@ -1049,7 -1095,7 +1049,7 @@@ static void __exit gtco_exit(void
        usb_deregister(&gtco_driverinfo_table);
  }
  
 -module_init (gtco_init);
 -module_exit (gtco_exit);
 +module_init(gtco_init);
 +module_exit(gtco_exit);
  
  MODULE_LICENSE("GPL");