]> err.no Git - linux-2.6/blobdiff - drivers/input/tablet/aiptek.c
Input: aiptek - do not check for NULL in attribute methods
[linux-2.6] / drivers / input / tablet / aiptek.c
index cc0a498763d8db609e7dd03d5086f50010931765..274c12f4220bcae7b43976d258463250e64477cb 100644 (file)
@@ -294,7 +294,6 @@ struct aiptek_features {
        int modelCode;          /* Tablet model code (not unique) */
        int firmwareCode;       /* prom/eeprom version            */
        char usbPath[64 + 1];   /* device's physical usb path     */
-       char inputPath[64 + 1]; /* input device path              */
 };
 
 struct aiptek_settings {
@@ -1007,9 +1006,6 @@ static ssize_t show_tabletSize(struct device *dev, struct device_attribute *attr
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        return snprintf(buf, PAGE_SIZE, "%dx%d\n",
                        aiptek->inputdev->absmax[ABS_X] + 1,
                        aiptek->inputdev->absmax[ABS_Y] + 1);
@@ -1023,71 +1019,6 @@ static ssize_t show_tabletSize(struct device *dev, struct device_attribute *attr
  */
 static DEVICE_ATTR(size, S_IRUGO, show_tabletSize, NULL);
 
-/***********************************************************************
- * support routines for the 'product_id' file
- */
-static ssize_t show_tabletProductId(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct aiptek *aiptek = dev_get_drvdata(dev);
-
-       if (aiptek == NULL)
-               return 0;
-
-       return snprintf(buf, PAGE_SIZE, "0x%04x\n",
-                       aiptek->inputdev->id.product);
-}
-
-static DEVICE_ATTR(product_id, S_IRUGO, show_tabletProductId, NULL);
-
-/***********************************************************************
- * support routines for the 'vendor_id' file
- */
-static ssize_t show_tabletVendorId(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct aiptek *aiptek = dev_get_drvdata(dev);
-
-       if (aiptek == NULL)
-               return 0;
-
-       return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->inputdev->id.vendor);
-}
-
-static DEVICE_ATTR(vendor_id, S_IRUGO, show_tabletVendorId, NULL);
-
-/***********************************************************************
- * support routines for the 'vendor' file
- */
-static ssize_t show_tabletManufacturer(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct aiptek *aiptek = dev_get_drvdata(dev);
-       int retval;
-
-       if (aiptek == NULL)
-               return 0;
-
-       retval = snprintf(buf, PAGE_SIZE, "%s\n", aiptek->usbdev->manufacturer);
-       return retval;
-}
-
-static DEVICE_ATTR(vendor, S_IRUGO, show_tabletManufacturer, NULL);
-
-/***********************************************************************
- * support routines for the 'product' file
- */
-static ssize_t show_tabletProduct(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct aiptek *aiptek = dev_get_drvdata(dev);
-       int retval;
-
-       if (aiptek == NULL)
-               return 0;
-
-       retval = snprintf(buf, PAGE_SIZE, "%s\n", aiptek->usbdev->product);
-       return retval;
-}
-
-static DEVICE_ATTR(product, S_IRUGO, show_tabletProduct, NULL);
-
 /***********************************************************************
  * support routines for the 'pointer_mode' file. Note that this file
  * both displays current setting and allows reprogramming.
@@ -1097,9 +1028,6 @@ static ssize_t show_tabletPointerMode(struct device *dev, struct device_attribut
        struct aiptek *aiptek = dev_get_drvdata(dev);
        char *s;
 
-       if (aiptek == NULL)
-               return 0;
-
        switch (aiptek->curSetting.pointerMode) {
        case AIPTEK_POINTER_ONLY_STYLUS_MODE:
                s = "stylus";
@@ -1124,8 +1052,6 @@ static ssize_t
 store_tabletPointerMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
-       if (aiptek == NULL)
-               return 0;
 
        if (strcmp(buf, "stylus") == 0) {
                aiptek->newSetting.pointerMode =
@@ -1151,9 +1077,6 @@ static ssize_t show_tabletCoordinateMode(struct device *dev, struct device_attri
        struct aiptek *aiptek = dev_get_drvdata(dev);
        char *s;
 
-       if (aiptek == NULL)
-               return 0;
-
        switch (aiptek->curSetting.coordinateMode) {
        case AIPTEK_COORDINATE_ABSOLUTE_MODE:
                s = "absolute";
@@ -1174,8 +1097,6 @@ static ssize_t
 store_tabletCoordinateMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
-       if (aiptek == NULL)
-               return 0;
 
        if (strcmp(buf, "absolute") == 0) {
                aiptek->newSetting.pointerMode =
@@ -1200,9 +1121,6 @@ static ssize_t show_tabletToolMode(struct device *dev, struct device_attribute *
        struct aiptek *aiptek = dev_get_drvdata(dev);
        char *s;
 
-       if (aiptek == NULL)
-               return 0;
-
        switch (TOOL_BUTTON(aiptek->curSetting.toolMode)) {
        case AIPTEK_TOOL_BUTTON_MOUSE_MODE:
                s = "mouse";
@@ -1243,8 +1161,6 @@ static ssize_t
 store_tabletToolMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
-       if (aiptek == NULL)
-               return 0;
 
        if (strcmp(buf, "mouse") == 0) {
                aiptek->newSetting.toolMode = AIPTEK_TOOL_BUTTON_MOUSE_MODE;
@@ -1277,9 +1193,6 @@ static ssize_t show_tabletXtilt(struct device *dev, struct device_attribute *att
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        if (aiptek->curSetting.xTilt == AIPTEK_TILT_DISABLE) {
                return snprintf(buf, PAGE_SIZE, "disable\n");
        } else {
@@ -1294,9 +1207,6 @@ store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char
        struct aiptek *aiptek = dev_get_drvdata(dev);
        int x;
 
-       if (aiptek == NULL)
-               return 0;
-
        if (strcmp(buf, "disable") == 0) {
                aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE;
        } else {
@@ -1319,9 +1229,6 @@ static ssize_t show_tabletYtilt(struct device *dev, struct device_attribute *att
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        if (aiptek->curSetting.yTilt == AIPTEK_TILT_DISABLE) {
                return snprintf(buf, PAGE_SIZE, "disable\n");
        } else {
@@ -1336,9 +1243,6 @@ store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char
        struct aiptek *aiptek = dev_get_drvdata(dev);
        int y;
 
-       if (aiptek == NULL)
-               return 0;
-
        if (strcmp(buf, "disable") == 0) {
                aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE;
        } else {
@@ -1361,9 +1265,6 @@ static ssize_t show_tabletJitterDelay(struct device *dev, struct device_attribut
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        return snprintf(buf, PAGE_SIZE, "%d\n", aiptek->curSetting.jitterDelay);
 }
 
@@ -1372,9 +1273,6 @@ store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        aiptek->newSetting.jitterDelay = (int)simple_strtol(buf, NULL, 10);
        return count;
 }
@@ -1391,9 +1289,6 @@ static ssize_t show_tabletProgrammableDelay(struct device *dev, struct device_at
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        return snprintf(buf, PAGE_SIZE, "%d\n",
                        aiptek->curSetting.programmableDelay);
 }
@@ -1403,9 +1298,6 @@ store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr,
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        aiptek->newSetting.programmableDelay = (int)simple_strtol(buf, NULL, 10);
        return count;
 }
@@ -1414,23 +1306,6 @@ static DEVICE_ATTR(delay,
                   S_IRUGO | S_IWUGO,
                   show_tabletProgrammableDelay, store_tabletProgrammableDelay);
 
-/***********************************************************************
- * support routines for the 'input_path' file. Note that this file
- * only displays current setting.
- */
-static ssize_t show_tabletInputDevice(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct aiptek *aiptek = dev_get_drvdata(dev);
-
-       if (aiptek == NULL)
-               return 0;
-
-       return snprintf(buf, PAGE_SIZE, "/dev/input/%s\n",
-                       aiptek->features.inputPath);
-}
-
-static DEVICE_ATTR(input_path, S_IRUGO, show_tabletInputDevice, NULL);
-
 /***********************************************************************
  * support routines for the 'event_count' file. Note that this file
  * only displays current setting.
@@ -1439,9 +1314,6 @@ static ssize_t show_tabletEventsReceived(struct device *dev, struct device_attri
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        return snprintf(buf, PAGE_SIZE, "%ld\n", aiptek->eventCount);
 }
 
@@ -1456,9 +1328,6 @@ static ssize_t show_tabletDiagnosticMessage(struct device *dev, struct device_at
        struct aiptek *aiptek = dev_get_drvdata(dev);
        char *retMsg;
 
-       if (aiptek == NULL)
-               return 0;
-
        switch (aiptek->diagnostic) {
        case AIPTEK_DIAGNOSTIC_NA:
                retMsg = "no errors\n";
@@ -1498,9 +1367,6 @@ static ssize_t show_tabletStylusUpper(struct device *dev, struct device_attribut
        struct aiptek *aiptek = dev_get_drvdata(dev);
        char *s;
 
-       if (aiptek == NULL)
-               return 0;
-
        switch (aiptek->curSetting.stylusButtonUpper) {
        case AIPTEK_STYLUS_UPPER_BUTTON:
                s = "upper";
@@ -1522,9 +1388,6 @@ store_tabletStylusUpper(struct device *dev, struct device_attribute *attr, const
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        if (strcmp(buf, "upper") == 0) {
                aiptek->newSetting.stylusButtonUpper =
                    AIPTEK_STYLUS_UPPER_BUTTON;
@@ -1548,9 +1411,6 @@ static ssize_t show_tabletStylusLower(struct device *dev, struct device_attribut
        struct aiptek *aiptek = dev_get_drvdata(dev);
        char *s;
 
-       if (aiptek == NULL)
-               return 0;
-
        switch (aiptek->curSetting.stylusButtonLower) {
        case AIPTEK_STYLUS_UPPER_BUTTON:
                s = "upper";
@@ -1572,9 +1432,6 @@ store_tabletStylusLower(struct device *dev, struct device_attribute *attr, const
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        if (strcmp(buf, "upper") == 0) {
                aiptek->newSetting.stylusButtonLower =
                    AIPTEK_STYLUS_UPPER_BUTTON;
@@ -1598,9 +1455,6 @@ static ssize_t show_tabletMouseLeft(struct device *dev, struct device_attribute
        struct aiptek *aiptek = dev_get_drvdata(dev);
        char *s;
 
-       if (aiptek == NULL)
-               return 0;
-
        switch (aiptek->curSetting.mouseButtonLeft) {
        case AIPTEK_MOUSE_LEFT_BUTTON:
                s = "left";
@@ -1626,9 +1480,6 @@ store_tabletMouseLeft(struct device *dev, struct device_attribute *attr, const c
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        if (strcmp(buf, "left") == 0) {
                aiptek->newSetting.mouseButtonLeft = AIPTEK_MOUSE_LEFT_BUTTON;
        } else if (strcmp(buf, "middle") == 0) {
@@ -1652,9 +1503,6 @@ static ssize_t show_tabletMouseMiddle(struct device *dev, struct device_attribut
        struct aiptek *aiptek = dev_get_drvdata(dev);
        char *s;
 
-       if (aiptek == NULL)
-               return 0;
-
        switch (aiptek->curSetting.mouseButtonMiddle) {
        case AIPTEK_MOUSE_LEFT_BUTTON:
                s = "left";
@@ -1680,9 +1528,6 @@ store_tabletMouseMiddle(struct device *dev, struct device_attribute *attr, const
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        if (strcmp(buf, "left") == 0) {
                aiptek->newSetting.mouseButtonMiddle = AIPTEK_MOUSE_LEFT_BUTTON;
        } else if (strcmp(buf, "middle") == 0) {
@@ -1708,9 +1553,6 @@ static ssize_t show_tabletMouseRight(struct device *dev, struct device_attribute
        struct aiptek *aiptek = dev_get_drvdata(dev);
        char *s;
 
-       if (aiptek == NULL)
-               return 0;
-
        switch (aiptek->curSetting.mouseButtonRight) {
        case AIPTEK_MOUSE_LEFT_BUTTON:
                s = "left";
@@ -1736,9 +1578,6 @@ store_tabletMouseRight(struct device *dev, struct device_attribute *attr, const
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        if (strcmp(buf, "left") == 0) {
                aiptek->newSetting.mouseButtonRight = AIPTEK_MOUSE_LEFT_BUTTON;
        } else if (strcmp(buf, "middle") == 0) {
@@ -1762,9 +1601,6 @@ static ssize_t show_tabletWheel(struct device *dev, struct device_attribute *att
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        if (aiptek->curSetting.wheel == AIPTEK_WHEEL_DISABLE) {
                return snprintf(buf, PAGE_SIZE, "disable\n");
        } else {
@@ -1778,9 +1614,6 @@ store_tabletWheel(struct device *dev, struct device_attribute *attr, const char
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        aiptek->newSetting.wheel = (int)simple_strtol(buf, NULL, 10);
        return count;
 }
@@ -1794,11 +1627,6 @@ static DEVICE_ATTR(wheel,
  */
 static ssize_t show_tabletExecute(struct device *dev, struct device_attribute *attr, char *buf)
 {
-       struct aiptek *aiptek = dev_get_drvdata(dev);
-
-       if (aiptek == NULL)
-               return 0;
-
        /* There is nothing useful to display, so a one-line manual
         * is in order...
         */
@@ -1811,9 +1639,6 @@ store_tabletExecute(struct device *dev, struct device_attribute *attr, const cha
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        /* We do not care what you write to this file. Merely the action
         * of writing to this file triggers a tablet reprogramming.
         */
@@ -1837,9 +1662,6 @@ static ssize_t show_tabletODMCode(struct device *dev, struct device_attribute *a
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.odmCode);
 }
 
@@ -1853,9 +1675,6 @@ static ssize_t show_tabletModelCode(struct device *dev, struct device_attribute
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.modelCode);
 }
 
@@ -1869,86 +1688,39 @@ static ssize_t show_firmwareCode(struct device *dev, struct device_attribute *at
 {
        struct aiptek *aiptek = dev_get_drvdata(dev);
 
-       if (aiptek == NULL)
-               return 0;
-
        return snprintf(buf, PAGE_SIZE, "%04x\n",
                        aiptek->features.firmwareCode);
 }
 
 static DEVICE_ATTR(firmware_code, S_IRUGO, show_firmwareCode, NULL);
 
-/***********************************************************************
- * This routine removes all existing sysfs files managed by this device
- * driver.
- */
-static void aiptek_delete_files(struct device *dev)
-{
-       device_remove_file(dev, &dev_attr_size);
-       device_remove_file(dev, &dev_attr_product_id);
-       device_remove_file(dev, &dev_attr_vendor_id);
-       device_remove_file(dev, &dev_attr_vendor);
-       device_remove_file(dev, &dev_attr_product);
-       device_remove_file(dev, &dev_attr_pointer_mode);
-       device_remove_file(dev, &dev_attr_coordinate_mode);
-       device_remove_file(dev, &dev_attr_tool_mode);
-       device_remove_file(dev, &dev_attr_xtilt);
-       device_remove_file(dev, &dev_attr_ytilt);
-       device_remove_file(dev, &dev_attr_jitter);
-       device_remove_file(dev, &dev_attr_delay);
-       device_remove_file(dev, &dev_attr_input_path);
-       device_remove_file(dev, &dev_attr_event_count);
-       device_remove_file(dev, &dev_attr_diagnostic);
-       device_remove_file(dev, &dev_attr_odm_code);
-       device_remove_file(dev, &dev_attr_model_code);
-       device_remove_file(dev, &dev_attr_firmware_code);
-       device_remove_file(dev, &dev_attr_stylus_lower);
-       device_remove_file(dev, &dev_attr_stylus_upper);
-       device_remove_file(dev, &dev_attr_mouse_left);
-       device_remove_file(dev, &dev_attr_mouse_middle);
-       device_remove_file(dev, &dev_attr_mouse_right);
-       device_remove_file(dev, &dev_attr_wheel);
-       device_remove_file(dev, &dev_attr_execute);
-}
-
-/***********************************************************************
- * This routine creates the sysfs files managed by this device
- * driver.
- */
-static int aiptek_add_files(struct device *dev)
-{
-       int ret;
+static struct attribute *aiptek_attributes[] = {
+       &dev_attr_size.attr,
+       &dev_attr_pointer_mode.attr,
+       &dev_attr_coordinate_mode.attr,
+       &dev_attr_tool_mode.attr,
+       &dev_attr_xtilt.attr,
+       &dev_attr_ytilt.attr,
+       &dev_attr_jitter.attr,
+       &dev_attr_delay.attr,
+       &dev_attr_event_count.attr,
+       &dev_attr_diagnostic.attr,
+       &dev_attr_odm_code.attr,
+       &dev_attr_model_code.attr,
+       &dev_attr_firmware_code.attr,
+       &dev_attr_stylus_lower.attr,
+       &dev_attr_stylus_upper.attr,
+       &dev_attr_mouse_left.attr,
+       &dev_attr_mouse_middle.attr,
+       &dev_attr_mouse_right.attr,
+       &dev_attr_wheel.attr,
+       &dev_attr_execute.attr,
+       NULL
+};
 
-       if ((ret = device_create_file(dev, &dev_attr_size)) ||
-           (ret = device_create_file(dev, &dev_attr_product_id)) ||
-           (ret = device_create_file(dev, &dev_attr_vendor_id)) ||
-           (ret = device_create_file(dev, &dev_attr_vendor)) ||
-           (ret = device_create_file(dev, &dev_attr_product)) ||
-           (ret = device_create_file(dev, &dev_attr_pointer_mode)) ||
-           (ret = device_create_file(dev, &dev_attr_coordinate_mode)) ||
-           (ret = device_create_file(dev, &dev_attr_tool_mode)) ||
-           (ret = device_create_file(dev, &dev_attr_xtilt)) ||
-           (ret = device_create_file(dev, &dev_attr_ytilt)) ||
-           (ret = device_create_file(dev, &dev_attr_jitter)) ||
-           (ret = device_create_file(dev, &dev_attr_delay)) ||
-           (ret = device_create_file(dev, &dev_attr_input_path)) ||
-           (ret = device_create_file(dev, &dev_attr_event_count)) ||
-           (ret = device_create_file(dev, &dev_attr_diagnostic)) ||
-           (ret = device_create_file(dev, &dev_attr_odm_code)) ||
-           (ret = device_create_file(dev, &dev_attr_model_code)) ||
-           (ret = device_create_file(dev, &dev_attr_firmware_code)) ||
-           (ret = device_create_file(dev, &dev_attr_stylus_lower)) ||
-           (ret = device_create_file(dev, &dev_attr_stylus_upper)) ||
-           (ret = device_create_file(dev, &dev_attr_mouse_left)) ||
-           (ret = device_create_file(dev, &dev_attr_mouse_middle)) ||
-           (ret = device_create_file(dev, &dev_attr_mouse_right)) ||
-           (ret = device_create_file(dev, &dev_attr_wheel)) ||
-           (ret = device_create_file(dev, &dev_attr_execute))) {
-               err("aiptek: killing own sysfs device files\n");
-               aiptek_delete_files(dev);
-       }
-       return ret;
-}
+static struct attribute_group aiptek_attribute_group = {
+       .attrs  = aiptek_attributes,
+};
 
 /***********************************************************************
  * This routine is called when a tablet has been identified. It basically
@@ -1961,8 +1733,6 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
        struct usb_endpoint_descriptor *endpoint;
        struct aiptek *aiptek;
        struct input_dev *inputdev;
-       struct input_handle *inputhandle;
-       struct list_head *node, *next;
        int i;
        int speeds[] = { 0,
                AIPTEK_PROGRAMMABLE_DELAY_50,
@@ -2134,45 +1904,30 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
                }
        }
 
-       /* Register the tablet as an Input Device
-        */
-       err = input_register_device(aiptek->inputdev);
-       if (err)
-               goto fail2;
-
-       /* We now will look for the evdev device which is mapped to
-        * the tablet. The partial name is kept in the link list of
-        * input_handles associated with this input device.
-        * What identifies an evdev input_handler is that it begins
-        * with 'event', continues with a digit, and that in turn
-        * is mapped to input/eventN.
-        */
-       list_for_each_safe(node, next, &inputdev->h_list) {
-               inputhandle = to_handle(node);
-               if (strncmp(inputhandle->name, "event", 5) == 0) {
-                       strcpy(aiptek->features.inputPath, inputhandle->name);
-                       break;
-               }
-       }
-
        /* Associate this driver's struct with the usb interface.
         */
        usb_set_intfdata(intf, aiptek);
 
        /* Set up the sysfs files
         */
-       aiptek_add_files(&intf->dev);
+       err = sysfs_create_group(&intf->dev.kobj, &aiptek_attribute_group);
+       if (err)
+               goto fail3;
 
-       /* Make sure the evdev module is loaded. Assuming evdev IS a module :-)
+       /* Register the tablet as an Input Device
         */
-       if (request_module("evdev") != 0)
-               info("aiptek: error loading 'evdev' module");
+       err = input_register_device(aiptek->inputdev);
+       if (err)
+               goto fail4;
 
        return 0;
 
+ fail4:        sysfs_remove_group(&intf->dev.kobj, &aiptek_attribute_group);
+ fail3: usb_free_urb(aiptek->urb);
  fail2:        usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data,
                        aiptek->data_dma);
- fail1:        input_free_device(inputdev);
+ fail1: usb_set_intfdata(intf, NULL);
+       input_free_device(inputdev);
        kfree(aiptek);
        return err;
 }
@@ -2192,7 +1947,7 @@ static void aiptek_disconnect(struct usb_interface *intf)
                 */
                usb_kill_urb(aiptek->urb);
                input_unregister_device(aiptek->inputdev);
-               aiptek_delete_files(&intf->dev);
+               sysfs_remove_group(&intf->dev.kobj, &aiptek_attribute_group);
                usb_free_urb(aiptek->urb);
                usb_buffer_free(interface_to_usbdev(intf),
                                AIPTEK_PACKET_LENGTH,