31 #include <linux/kernel.h>
32 #include <linux/input.h>
34 #include <linux/slab.h>
35 #include <linux/module.h>
44 #define ONETOUCH_PKT_LEN 0x02
45 #define ONETOUCH_BUTTON KEY_PROG1
47 static int onetouch_connect_input(
struct us_data *
ss);
48 static void onetouch_release_input(
void *onetouch_);
53 struct input_dev *
dev;
66 #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
67 vendorName, productName, useProtocol, useTransport, \
68 initFunction, flags) \
69 { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
70 .driver_info = (flags) }
83 #define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
84 vendor_name, product_name, use_protocol, use_transport, \
85 init_function, Flags) \
87 .vendorName = vendor_name, \
88 .productName = product_name, \
89 .useProtocol = use_protocol, \
90 .useTransport = use_transport, \
91 .initFunction = init_function, \
102 static void usb_onetouch_irq(
struct urb *
urb)
106 struct input_dev *
dev = onetouch->
dev;
128 dev_err(&dev->dev,
"can't resubmit intr, %s-%s/input0, "
129 "retval %d\n", onetouch->
udev->bus->bus_name,
130 onetouch->
udev->devpath, retval);
133 static int usb_onetouch_open(
struct input_dev *dev)
138 onetouch->
irq->dev = onetouch->
udev;
140 dev_err(&dev->dev,
"usb_submit_urb failed\n");
147 static void usb_onetouch_close(
struct input_dev *dev)
156 static void usb_onetouch_pm_hook(
struct us_data *us,
int action)
168 "usb_submit_urb failed\n");
177 static int onetouch_connect_input(
struct us_data *
ss)
183 struct input_dev *input_dev;
187 interface = ss->pusb_intf->cur_altsetting;
189 if (interface->desc.bNumEndpoints != 3)
192 endpoint = &interface->endpoint[2].desc;
193 if (!usb_endpoint_is_int_in(endpoint))
197 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
200 input_dev = input_allocate_device();
201 if (!onetouch || !input_dev)
214 onetouch->
dev = input_dev;
216 if (udev->manufacturer)
218 sizeof(onetouch->
name));
220 if (udev->manufacturer)
227 "Maxtor Onetouch %04x:%04x",
231 usb_make_path(udev, onetouch->
phys,
sizeof(onetouch->
phys));
234 input_dev->name = onetouch->
name;
235 input_dev->phys = onetouch->
phys;
236 usb_to_input_id(udev, &input_dev->id);
237 input_dev->dev.parent = &udev->dev;
243 input_set_drvdata(input_dev, onetouch);
245 input_dev->open = usb_onetouch_open;
246 input_dev->close = usb_onetouch_close;
248 usb_fill_int_urb(onetouch->
irq, udev, pipe, onetouch->
data,
249 (maxp > 8 ? 8 : maxp),
250 usb_onetouch_irq, onetouch, endpoint->
bInterval);
252 onetouch->
irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
255 ss->
extra = onetouch;
257 ss->suspend_resume_hook = usb_onetouch_pm_hook;
260 error = input_register_device(onetouch->
dev);
269 fail1:
kfree(onetouch);
270 input_free_device(input_dev);
274 static void onetouch_release_input(
void *onetouch_)
280 input_unregister_device(onetouch->
dev);
294 (
id - onetouch_usb_ids) + onetouch_unusual_dev_list);
304 static struct usb_driver onetouch_driver = {
305 .name =
"ums-onetouch",
306 .probe = onetouch_probe,
313 .id_table = onetouch_usb_ids,