diff options
| author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-09-15 03:01:47 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-10-28 12:52:52 -0400 |
| commit | c5b7c7c395a34f12cdf246d66c1feeff2933d584 (patch) | |
| tree | 8af335c30bb92991f4bfd8251de4fed9907b07bd /drivers/usb/input/touchkitusb.c | |
| parent | 3c42f0c3dde8feb59fc87df45cadb847d5511c0a (diff) | |
[PATCH] drivers/usb/input: convert to dynamic input_dev allocation
Input: convert drivers/iusb/input to dynamic input_dev allocation
This is required for input_dev sysfs integration
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/input/touchkitusb.c')
| -rw-r--r-- | drivers/usb/input/touchkitusb.c | 116 |
1 files changed, 55 insertions, 61 deletions
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c index 4276c24a5080..3766ccc271be 100644 --- a/drivers/usb/input/touchkitusb.c +++ b/drivers/usb/input/touchkitusb.c | |||
| @@ -68,7 +68,7 @@ struct touchkit_usb { | |||
| 68 | dma_addr_t data_dma; | 68 | dma_addr_t data_dma; |
| 69 | struct urb *irq; | 69 | struct urb *irq; |
| 70 | struct usb_device *udev; | 70 | struct usb_device *udev; |
| 71 | struct input_dev input; | 71 | struct input_dev *input; |
| 72 | char name[128]; | 72 | char name[128]; |
| 73 | char phys[64]; | 73 | char phys[64]; |
| 74 | }; | 74 | }; |
| @@ -115,12 +115,12 @@ static void touchkit_irq(struct urb *urb, struct pt_regs *regs) | |||
| 115 | y = TOUCHKIT_GET_Y(touchkit->data); | 115 | y = TOUCHKIT_GET_Y(touchkit->data); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | input_regs(&touchkit->input, regs); | 118 | input_regs(touchkit->input, regs); |
| 119 | input_report_key(&touchkit->input, BTN_TOUCH, | 119 | input_report_key(touchkit->input, BTN_TOUCH, |
| 120 | TOUCHKIT_GET_TOUCHED(touchkit->data)); | 120 | TOUCHKIT_GET_TOUCHED(touchkit->data)); |
| 121 | input_report_abs(&touchkit->input, ABS_X, x); | 121 | input_report_abs(touchkit->input, ABS_X, x); |
| 122 | input_report_abs(&touchkit->input, ABS_Y, y); | 122 | input_report_abs(touchkit->input, ABS_Y, y); |
| 123 | input_sync(&touchkit->input); | 123 | input_sync(touchkit->input); |
| 124 | 124 | ||
| 125 | exit: | 125 | exit: |
| 126 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 126 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
| @@ -171,87 +171,81 @@ static void touchkit_free_buffers(struct usb_device *udev, | |||
| 171 | static int touchkit_probe(struct usb_interface *intf, | 171 | static int touchkit_probe(struct usb_interface *intf, |
| 172 | const struct usb_device_id *id) | 172 | const struct usb_device_id *id) |
| 173 | { | 173 | { |
| 174 | int ret; | ||
| 175 | struct touchkit_usb *touchkit; | 174 | struct touchkit_usb *touchkit; |
| 175 | struct input_dev *input_dev; | ||
| 176 | struct usb_host_interface *interface; | 176 | struct usb_host_interface *interface; |
| 177 | struct usb_endpoint_descriptor *endpoint; | 177 | struct usb_endpoint_descriptor *endpoint; |
| 178 | struct usb_device *udev = interface_to_usbdev(intf); | 178 | struct usb_device *udev = interface_to_usbdev(intf); |
| 179 | char path[64]; | ||
| 180 | 179 | ||
| 181 | interface = intf->cur_altsetting; | 180 | interface = intf->cur_altsetting; |
| 182 | endpoint = &interface->endpoint[0].desc; | 181 | endpoint = &interface->endpoint[0].desc; |
| 183 | 182 | ||
| 184 | touchkit = kmalloc(sizeof(struct touchkit_usb), GFP_KERNEL); | 183 | touchkit = kzalloc(sizeof(struct touchkit_usb), GFP_KERNEL); |
| 185 | if (!touchkit) | 184 | input_dev = input_allocate_device(); |
| 186 | return -ENOMEM; | 185 | if (!touchkit || !input_dev) |
| 187 | |||
| 188 | memset(touchkit, 0, sizeof(struct touchkit_usb)); | ||
| 189 | touchkit->udev = udev; | ||
| 190 | |||
| 191 | if (touchkit_alloc_buffers(udev, touchkit)) { | ||
| 192 | ret = -ENOMEM; | ||
| 193 | goto out_free; | 186 | goto out_free; |
| 194 | } | ||
| 195 | |||
| 196 | touchkit->input.private = touchkit; | ||
| 197 | touchkit->input.open = touchkit_open; | ||
| 198 | touchkit->input.close = touchkit_close; | ||
| 199 | |||
| 200 | usb_make_path(udev, path, 64); | ||
| 201 | sprintf(touchkit->phys, "%s/input0", path); | ||
| 202 | |||
| 203 | touchkit->input.name = touchkit->name; | ||
| 204 | touchkit->input.phys = touchkit->phys; | ||
| 205 | usb_to_input_id(udev, &touchkit->input.id); | ||
| 206 | touchkit->input.dev = &intf->dev; | ||
| 207 | |||
| 208 | touchkit->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
| 209 | touchkit->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | ||
| 210 | touchkit->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
| 211 | |||
| 212 | /* Used to Scale Compensated Data */ | ||
| 213 | touchkit->input.absmin[ABS_X] = TOUCHKIT_MIN_XC; | ||
| 214 | touchkit->input.absmax[ABS_X] = TOUCHKIT_MAX_XC; | ||
| 215 | touchkit->input.absfuzz[ABS_X] = TOUCHKIT_XC_FUZZ; | ||
| 216 | touchkit->input.absflat[ABS_X] = TOUCHKIT_XC_FLAT; | ||
| 217 | touchkit->input.absmin[ABS_Y] = TOUCHKIT_MIN_YC; | ||
| 218 | touchkit->input.absmax[ABS_Y] = TOUCHKIT_MAX_YC; | ||
| 219 | touchkit->input.absfuzz[ABS_Y] = TOUCHKIT_YC_FUZZ; | ||
| 220 | touchkit->input.absflat[ABS_Y] = TOUCHKIT_YC_FLAT; | ||
| 221 | |||
| 222 | if (udev->manufacturer) | ||
| 223 | strcat(touchkit->name, udev->manufacturer); | ||
| 224 | if (udev->product) | ||
| 225 | sprintf(touchkit->name, "%s %s", touchkit->name, udev->product); | ||
| 226 | 187 | ||
| 227 | if (!strlen(touchkit->name)) | 188 | if (touchkit_alloc_buffers(udev, touchkit)) |
| 228 | sprintf(touchkit->name, "USB Touchscreen %04x:%04x", | 189 | goto out_free; |
| 229 | touchkit->input.id.vendor, touchkit->input.id.product); | ||
| 230 | 190 | ||
| 231 | touchkit->irq = usb_alloc_urb(0, GFP_KERNEL); | 191 | touchkit->irq = usb_alloc_urb(0, GFP_KERNEL); |
| 232 | if (!touchkit->irq) { | 192 | if (!touchkit->irq) { |
| 233 | dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__); | 193 | dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__); |
| 234 | ret = -ENOMEM; | ||
| 235 | goto out_free_buffers; | 194 | goto out_free_buffers; |
| 236 | } | 195 | } |
| 237 | 196 | ||
| 197 | touchkit->udev = udev; | ||
| 198 | touchkit->input = input_dev; | ||
| 199 | |||
| 200 | if (udev->manufacturer) | ||
| 201 | strlcpy(touchkit->name, udev->manufacturer, sizeof(touchkit->name)); | ||
| 202 | |||
| 203 | if (udev->product) { | ||
| 204 | if (udev->manufacturer) | ||
| 205 | strlcat(touchkit->name, " ", sizeof(touchkit->name)); | ||
| 206 | strlcat(touchkit->name, udev->product, sizeof(touchkit->name)); | ||
| 207 | } | ||
| 208 | |||
| 209 | if (!strlen(touchkit->name)) | ||
| 210 | snprintf(touchkit->name, sizeof(touchkit->name), | ||
| 211 | "USB Touchscreen %04x:%04x", | ||
| 212 | le16_to_cpu(udev->descriptor.idVendor), | ||
| 213 | le16_to_cpu(udev->descriptor.idProduct)); | ||
| 214 | |||
| 215 | usb_make_path(udev, touchkit->phys, sizeof(touchkit->phys)); | ||
| 216 | strlcpy(touchkit->phys, "/input0", sizeof(touchkit->phys)); | ||
| 217 | |||
| 218 | input_dev->name = touchkit->name; | ||
| 219 | input_dev->phys = touchkit->phys; | ||
| 220 | usb_to_input_id(udev, &input_dev->id); | ||
| 221 | input_dev->cdev.dev = &intf->dev; | ||
| 222 | input_dev->private = touchkit; | ||
| 223 | input_dev->open = touchkit_open; | ||
| 224 | input_dev->close = touchkit_close; | ||
| 225 | |||
| 226 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
| 227 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
| 228 | input_set_abs_params(input_dev, ABS_X, TOUCHKIT_MIN_XC, TOUCHKIT_MAX_XC, | ||
| 229 | TOUCHKIT_XC_FUZZ, TOUCHKIT_XC_FLAT); | ||
| 230 | input_set_abs_params(input_dev, ABS_Y, TOUCHKIT_MIN_YC, TOUCHKIT_MAX_YC, | ||
| 231 | TOUCHKIT_YC_FUZZ, TOUCHKIT_YC_FLAT); | ||
| 232 | |||
| 238 | usb_fill_int_urb(touchkit->irq, touchkit->udev, | 233 | usb_fill_int_urb(touchkit->irq, touchkit->udev, |
| 239 | usb_rcvintpipe(touchkit->udev, 0x81), | 234 | usb_rcvintpipe(touchkit->udev, 0x81), |
| 240 | touchkit->data, TOUCHKIT_REPORT_DATA_SIZE, | 235 | touchkit->data, TOUCHKIT_REPORT_DATA_SIZE, |
| 241 | touchkit_irq, touchkit, endpoint->bInterval); | 236 | touchkit_irq, touchkit, endpoint->bInterval); |
| 242 | 237 | ||
| 243 | input_register_device(&touchkit->input); | 238 | input_register_device(touchkit->input); |
| 244 | 239 | ||
| 245 | printk(KERN_INFO "input: %s on %s\n", touchkit->name, path); | ||
| 246 | usb_set_intfdata(intf, touchkit); | 240 | usb_set_intfdata(intf, touchkit); |
| 247 | |||
| 248 | return 0; | 241 | return 0; |
| 249 | 242 | ||
| 250 | out_free_buffers: | 243 | out_free_buffers: |
| 251 | touchkit_free_buffers(udev, touchkit); | 244 | touchkit_free_buffers(udev, touchkit); |
| 252 | out_free: | 245 | out_free: |
| 246 | input_free_device(input_dev); | ||
| 253 | kfree(touchkit); | 247 | kfree(touchkit); |
| 254 | return ret; | 248 | return -ENOMEM; |
| 255 | } | 249 | } |
| 256 | 250 | ||
| 257 | static void touchkit_disconnect(struct usb_interface *intf) | 251 | static void touchkit_disconnect(struct usb_interface *intf) |
| @@ -265,8 +259,8 @@ static void touchkit_disconnect(struct usb_interface *intf) | |||
| 265 | 259 | ||
| 266 | dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__); | 260 | dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__); |
| 267 | usb_set_intfdata(intf, NULL); | 261 | usb_set_intfdata(intf, NULL); |
| 268 | input_unregister_device(&touchkit->input); | ||
| 269 | usb_kill_urb(touchkit->irq); | 262 | usb_kill_urb(touchkit->irq); |
| 263 | input_unregister_device(touchkit->input); | ||
| 270 | usb_free_urb(touchkit->irq); | 264 | usb_free_urb(touchkit->irq); |
| 271 | touchkit_free_buffers(interface_to_usbdev(intf), touchkit); | 265 | touchkit_free_buffers(interface_to_usbdev(intf), touchkit); |
| 272 | kfree(touchkit); | 266 | kfree(touchkit); |
