^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2001-2005 Edouard TISSERANT <edouard.tisserant@wanadoo.fr>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2004-2005 Stephane VOLTZ <svoltz@numericable.fr>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * USB Acecad "Acecad Flair" tablet support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Changelog:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * v3.2 - Added sysfs support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/usb/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) MODULE_AUTHOR("Edouard TISSERANT <edouard.tisserant@wanadoo.fr>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) MODULE_DESCRIPTION("USB Acecad Flair tablet driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define USB_VENDOR_ID_ACECAD 0x0460
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define USB_DEVICE_ID_FLAIR 0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define USB_DEVICE_ID_302 0x0008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct usb_acecad {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) char name[128];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) char phys[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct usb_interface *intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct input_dev *input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct urb *irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) unsigned char *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) dma_addr_t data_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static void usb_acecad_irq(struct urb *urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct usb_acecad *acecad = urb->context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) unsigned char *data = acecad->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct input_dev *dev = acecad->input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct usb_interface *intf = acecad->intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct usb_device *udev = interface_to_usbdev(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) int prox, status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) switch (urb->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /* success */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) case -ECONNRESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) case -ENOENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) case -ESHUTDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /* this urb is terminated, clean up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) dev_dbg(&intf->dev, "%s - urb shutting down with status: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) __func__, urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) dev_dbg(&intf->dev, "%s - nonzero urb status received: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) __func__, urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) goto resubmit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) prox = (data[0] & 0x04) >> 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) input_report_key(dev, BTN_TOOL_PEN, prox);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) if (prox) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int x = data[1] | (data[2] << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) int y = data[3] | (data[4] << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /* Pressure should compute the same way for flair and 302 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int pressure = data[5] | (data[6] << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) int touch = data[0] & 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) int stylus = (data[0] & 0x10) >> 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) int stylus2 = (data[0] & 0x20) >> 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) input_report_abs(dev, ABS_X, x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) input_report_abs(dev, ABS_Y, y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) input_report_abs(dev, ABS_PRESSURE, pressure);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) input_report_key(dev, BTN_TOUCH, touch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) input_report_key(dev, BTN_STYLUS, stylus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) input_report_key(dev, BTN_STYLUS2, stylus2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /* event termination */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) input_sync(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) resubmit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) status = usb_submit_urb(urb, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) dev_err(&intf->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) "can't resubmit intr, %s-%s/input0, status %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) udev->bus->bus_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) udev->devpath, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) static int usb_acecad_open(struct input_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct usb_acecad *acecad = input_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) acecad->irq->dev = interface_to_usbdev(acecad->intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if (usb_submit_urb(acecad->irq, GFP_KERNEL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static void usb_acecad_close(struct input_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct usb_acecad *acecad = input_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) usb_kill_urb(acecad->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct usb_device *dev = interface_to_usbdev(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct usb_host_interface *interface = intf->cur_altsetting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct usb_endpoint_descriptor *endpoint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct usb_acecad *acecad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) int pipe, maxp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) if (interface->desc.bNumEndpoints != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) endpoint = &interface->endpoint[0].desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if (!usb_endpoint_is_int_in(endpoint))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) input_dev = input_allocate_device();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) if (!acecad || !input_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) goto fail1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) acecad->data = usb_alloc_coherent(dev, 8, GFP_KERNEL, &acecad->data_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) if (!acecad->data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) err= -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) goto fail1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) acecad->irq = usb_alloc_urb(0, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) if (!acecad->irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) goto fail2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) acecad->intf = intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) acecad->input = input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) if (dev->manufacturer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (dev->product) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) if (dev->manufacturer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) strlcat(acecad->name, " ", sizeof(acecad->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) strlcat(acecad->name, dev->product, sizeof(acecad->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) usb_make_path(dev, acecad->phys, sizeof(acecad->phys));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) strlcat(acecad->phys, "/input0", sizeof(acecad->phys));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) input_dev->name = acecad->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) input_dev->phys = acecad->phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) usb_to_input_id(dev, &input_dev->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) input_dev->dev.parent = &intf->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) input_set_drvdata(input_dev, acecad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) input_dev->open = usb_acecad_open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) input_dev->close = usb_acecad_close;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) input_dev->keybit[BIT_WORD(BTN_DIGI)] = BIT_MASK(BTN_TOOL_PEN) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) BIT_MASK(BTN_TOUCH) | BIT_MASK(BTN_STYLUS) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) BIT_MASK(BTN_STYLUS2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) switch (id->driver_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) input_set_abs_params(input_dev, ABS_X, 0, 5000, 4, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) input_set_abs_params(input_dev, ABS_Y, 0, 3750, 4, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) input_set_abs_params(input_dev, ABS_PRESSURE, 0, 512, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) if (!strlen(acecad->name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) snprintf(acecad->name, sizeof(acecad->name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) "USB Acecad Flair Tablet %04x:%04x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) le16_to_cpu(dev->descriptor.idVendor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) le16_to_cpu(dev->descriptor.idProduct));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) input_set_abs_params(input_dev, ABS_X, 0, 53000, 4, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) input_set_abs_params(input_dev, ABS_Y, 0, 2250, 4, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) input_set_abs_params(input_dev, ABS_PRESSURE, 0, 1024, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) if (!strlen(acecad->name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) snprintf(acecad->name, sizeof(acecad->name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) "USB Acecad 302 Tablet %04x:%04x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) le16_to_cpu(dev->descriptor.idVendor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) le16_to_cpu(dev->descriptor.idProduct));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) usb_fill_int_urb(acecad->irq, dev, pipe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) acecad->data, maxp > 8 ? 8 : maxp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) usb_acecad_irq, acecad, endpoint->bInterval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) acecad->irq->transfer_dma = acecad->data_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) err = input_register_device(acecad->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) goto fail3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) usb_set_intfdata(intf, acecad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) fail3: usb_free_urb(acecad->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) fail2: usb_free_coherent(dev, 8, acecad->data, acecad->data_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) fail1: input_free_device(input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) kfree(acecad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) static void usb_acecad_disconnect(struct usb_interface *intf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct usb_acecad *acecad = usb_get_intfdata(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) struct usb_device *udev = interface_to_usbdev(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) usb_set_intfdata(intf, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) input_unregister_device(acecad->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) usb_free_urb(acecad->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) usb_free_coherent(udev, 8, acecad->data, acecad->data_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) kfree(acecad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) static const struct usb_device_id usb_acecad_id_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) { USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_FLAIR), .driver_info = 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) { USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_302), .driver_info = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) MODULE_DEVICE_TABLE(usb, usb_acecad_id_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) static struct usb_driver usb_acecad_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) .name = "usb_acecad",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) .probe = usb_acecad_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) .disconnect = usb_acecad_disconnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) .id_table = usb_acecad_id_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) module_usb_driver(usb_acecad_driver);