]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/usb/input/aiptek.c
Input: drivers/usb/input - don't access dev->private directly
[linux-2.6-omap-h63xx.git] / drivers / usb / input / aiptek.c
index a6693b0d1c4cc92c20b04957c9630bac3a8224f5..8b33a8eae8a114757221e57160a9810c1b9d2f7a 100644 (file)
 #include <linux/jiffies.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
-#include <linux/input.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/usb.h>
-#include <linux/usb_input.h>
-#include <linux/sched.h>
+#include <linux/usb/input.h>
 #include <asm/uaccess.h>
 #include <asm/unaligned.h>
 
@@ -398,7 +395,7 @@ static int aiptek_convert_from_2s_complement(unsigned char c)
  * replaced with the input_sync() method (which emits EV_SYN.)
  */
 
-static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
+static void aiptek_irq(struct urb *urb)
 {
        struct aiptek *aiptek = urb->context;
        unsigned char *data = aiptek->data;
@@ -444,8 +441,6 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
                        aiptek->diagnostic =
                            AIPTEK_DIAGNOSTIC_SENDING_RELATIVE_IN_ABSOLUTE;
                } else {
-                       input_regs(inputdev, regs);
-
                        x = aiptek_convert_from_2s_complement(data[2]);
                        y = aiptek_convert_from_2s_complement(data[3]);
 
@@ -490,8 +485,6 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
                            (aiptek->curSetting.pointerMode)) {
                                aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED;
                } else {
-                       input_regs(inputdev, regs);
-
                        x = le16_to_cpu(get_unaligned((__le16 *) (data + 1)));
                        y = le16_to_cpu(get_unaligned((__le16 *) (data + 3)));
                        z = le16_to_cpu(get_unaligned((__le16 *) (data + 6)));
@@ -570,7 +563,6 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
                        (aiptek->curSetting.pointerMode)) {
                        aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED;
                } else {
-                       input_regs(inputdev, regs);
                        x = le16_to_cpu(get_unaligned((__le16 *) (data + 1)));
                        y = le16_to_cpu(get_unaligned((__le16 *) (data + 3)));
 
@@ -633,8 +625,6 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
                z = le16_to_cpu(get_unaligned((__le16 *) (data + 4)));
 
                if (dv != 0) {
-                       input_regs(inputdev, regs);
-
                        /* If we've not already sent a tool_button_?? code, do
                         * so now. Then set FIRED_BIT so it won't be resent unless
                         * the user forces FIRED_BIT off.
@@ -683,8 +673,6 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
                macro = data[3];
 
                if (dv != 0) {
-                       input_regs(inputdev, regs);
-
                        /* If we've not already sent a tool_button_?? code, do
                         * so now. Then set FIRED_BIT so it won't be resent unless
                         * the user forces FIRED_BIT off.
@@ -728,8 +716,6 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
         */
        else if (data[0] == 6) {
                macro = le16_to_cpu(get_unaligned((__le16 *) (data + 1)));
-               input_regs(inputdev, regs);
-
                if (macro > 0) {
                        input_report_key(inputdev, macroKeyEvents[macro - 1],
                                         0);
@@ -812,7 +798,7 @@ MODULE_DEVICE_TABLE(usb, aiptek_ids);
  */
 static int aiptek_open(struct input_dev *inputdev)
 {
-       struct aiptek *aiptek = inputdev->private;
+       struct aiptek *aiptek = input_get_drvdata(inputdev);
 
        aiptek->urb->dev = aiptek->usbdev;
        if (usb_submit_urb(aiptek->urb, GFP_KERNEL) != 0)
@@ -826,7 +812,7 @@ static int aiptek_open(struct input_dev *inputdev)
  */
 static void aiptek_close(struct input_dev *inputdev)
 {
-       struct aiptek *aiptek = inputdev->private;
+       struct aiptek *aiptek = input_get_drvdata(inputdev);
 
        usb_kill_urb(aiptek->urb);
 }
@@ -1986,6 +1972,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
                AIPTEK_PROGRAMMABLE_DELAY_200,
                AIPTEK_PROGRAMMABLE_DELAY_300
        };
+       int err = -ENOMEM;
 
        /* programmableDelay is where the command-line specified
         * delay is kept. We make it the first element of speeds[],
@@ -2001,7 +1988,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
                goto fail1;
 
        aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH,
-                                       SLAB_ATOMIC, &aiptek->data_dma);
+                                       GFP_ATOMIC, &aiptek->data_dma);
        if (!aiptek->data)
                goto fail1;
 
@@ -2058,7 +2045,9 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
        inputdev->phys = aiptek->features.usbPath;
        usb_to_input_id(usbdev, &inputdev->id);
        inputdev->cdev.dev = &intf->dev;
-       inputdev->private = aiptek;
+
+       input_set_drvdata(inputdev, aiptek);
+
        inputdev->open = aiptek_open;
        inputdev->close = aiptek_close;
 
@@ -2147,7 +2136,9 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
 
        /* Register the tablet as an Input Device
         */
-       input_register_device(aiptek->inputdev);
+       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
@@ -2179,23 +2170,13 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
 
        return 0;
 
-fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data,
+ fail2:        usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data,
                        aiptek->data_dma);
-fail1: input_free_device(inputdev);
+ fail1:        input_free_device(inputdev);
        kfree(aiptek);
-       return -ENOMEM;
+       return err;
 }
 
-/* Forward declaration */
-static void aiptek_disconnect(struct usb_interface *intf);
-
-static struct usb_driver aiptek_driver = {
-       .name = "aiptek",
-       .probe = aiptek_probe,
-       .disconnect = aiptek_disconnect,
-       .id_table = aiptek_ids,
-};
-
 /***********************************************************************
  * Deal with tablet disconnecting from the system.
  */
@@ -2220,6 +2201,13 @@ static void aiptek_disconnect(struct usb_interface *intf)
        }
 }
 
+static struct usb_driver aiptek_driver = {
+       .name = "aiptek",
+       .probe = aiptek_probe,
+       .disconnect = aiptek_disconnect,
+       .id_table = aiptek_ids,
+};
+
 static int __init aiptek_init(void)
 {
        int result = usb_register(&aiptek_driver);