diff options
Diffstat (limited to 'drivers/usb')
63 files changed, 1205 insertions, 1245 deletions
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c index fc15b4acc8af..57e800ac3cee 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c | |||
| @@ -106,7 +106,7 @@ void hcd_buffer_destroy (struct usb_hcd *hcd) | |||
| 106 | void *hcd_buffer_alloc ( | 106 | void *hcd_buffer_alloc ( |
| 107 | struct usb_bus *bus, | 107 | struct usb_bus *bus, |
| 108 | size_t size, | 108 | size_t size, |
| 109 | unsigned mem_flags, | 109 | gfp_t mem_flags, |
| 110 | dma_addr_t *dma | 110 | dma_addr_t *dma |
| 111 | ) | 111 | ) |
| 112 | { | 112 | { |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 487ff672b104..befe0c7f63d1 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
| @@ -1509,7 +1509,7 @@ void usbdev_add(struct usb_device *dev) | |||
| 1509 | { | 1509 | { |
| 1510 | int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); | 1510 | int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); |
| 1511 | 1511 | ||
| 1512 | dev->class_dev = class_device_create(usb_device_class, | 1512 | dev->class_dev = class_device_create(usb_device_class, NULL, |
| 1513 | MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev, | 1513 | MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev, |
| 1514 | "usbdev%d.%d", dev->bus->busnum, dev->devnum); | 1514 | "usbdev%d.%d", dev->bus->busnum, dev->devnum); |
| 1515 | 1515 | ||
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 65ca131cc44c..78cb4be9529f 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c | |||
| @@ -172,7 +172,9 @@ int usb_register_dev(struct usb_interface *intf, | |||
| 172 | ++temp; | 172 | ++temp; |
| 173 | else | 173 | else |
| 174 | temp = name; | 174 | temp = name; |
| 175 | intf->class_dev = class_device_create(usb_class, MKDEV(USB_MAJOR, minor), &intf->dev, "%s", temp); | 175 | intf->class_dev = class_device_create(usb_class, NULL, |
| 176 | MKDEV(USB_MAJOR, minor), | ||
| 177 | &intf->dev, "%s", temp); | ||
| 176 | if (IS_ERR(intf->class_dev)) { | 178 | if (IS_ERR(intf->class_dev)) { |
| 177 | spin_lock (&minor_lock); | 179 | spin_lock (&minor_lock); |
| 178 | usb_minors[intf->minor] = NULL; | 180 | usb_minors[intf->minor] = NULL; |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 1017a97a418b..14c47a10da86 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
| @@ -782,7 +782,8 @@ static int usb_register_bus(struct usb_bus *bus) | |||
| 782 | return -E2BIG; | 782 | return -E2BIG; |
| 783 | } | 783 | } |
| 784 | 784 | ||
| 785 | bus->class_dev = class_device_create(usb_host_class, MKDEV(0,0), bus->controller, "usb_host%d", busnum); | 785 | bus->class_dev = class_device_create(usb_host_class, NULL, MKDEV(0,0), |
| 786 | bus->controller, "usb_host%d", busnum); | ||
| 786 | if (IS_ERR(bus->class_dev)) { | 787 | if (IS_ERR(bus->class_dev)) { |
| 787 | clear_bit(busnum, busmap.busmap); | 788 | clear_bit(busnum, busmap.busmap); |
| 788 | up(&usb_bus_list_lock); | 789 | up(&usb_bus_list_lock); |
| @@ -1112,7 +1113,7 @@ static void urb_unlink (struct urb *urb) | |||
| 1112 | * expects usb_submit_urb() to have sanity checked and conditioned all | 1113 | * expects usb_submit_urb() to have sanity checked and conditioned all |
| 1113 | * inputs in the urb | 1114 | * inputs in the urb |
| 1114 | */ | 1115 | */ |
| 1115 | static int hcd_submit_urb (struct urb *urb, unsigned mem_flags) | 1116 | static int hcd_submit_urb (struct urb *urb, gfp_t mem_flags) |
| 1116 | { | 1117 | { |
| 1117 | int status; | 1118 | int status; |
| 1118 | struct usb_hcd *hcd = urb->dev->bus->hcpriv; | 1119 | struct usb_hcd *hcd = urb->dev->bus->hcpriv; |
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index ac451fa7e4d2..1f1ed6211af8 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h | |||
| @@ -142,12 +142,12 @@ struct hcd_timeout { /* timeouts we allocate */ | |||
| 142 | 142 | ||
| 143 | struct usb_operations { | 143 | struct usb_operations { |
| 144 | int (*get_frame_number) (struct usb_device *usb_dev); | 144 | int (*get_frame_number) (struct usb_device *usb_dev); |
| 145 | int (*submit_urb) (struct urb *urb, unsigned mem_flags); | 145 | int (*submit_urb) (struct urb *urb, gfp_t mem_flags); |
| 146 | int (*unlink_urb) (struct urb *urb, int status); | 146 | int (*unlink_urb) (struct urb *urb, int status); |
| 147 | 147 | ||
| 148 | /* allocate dma-consistent buffer for URB_DMA_NOMAPPING */ | 148 | /* allocate dma-consistent buffer for URB_DMA_NOMAPPING */ |
| 149 | void *(*buffer_alloc)(struct usb_bus *bus, size_t size, | 149 | void *(*buffer_alloc)(struct usb_bus *bus, size_t size, |
| 150 | unsigned mem_flags, | 150 | gfp_t mem_flags, |
| 151 | dma_addr_t *dma); | 151 | dma_addr_t *dma); |
| 152 | void (*buffer_free)(struct usb_bus *bus, size_t size, | 152 | void (*buffer_free)(struct usb_bus *bus, size_t size, |
| 153 | void *addr, dma_addr_t dma); | 153 | void *addr, dma_addr_t dma); |
| @@ -200,7 +200,7 @@ struct hc_driver { | |||
| 200 | int (*urb_enqueue) (struct usb_hcd *hcd, | 200 | int (*urb_enqueue) (struct usb_hcd *hcd, |
| 201 | struct usb_host_endpoint *ep, | 201 | struct usb_host_endpoint *ep, |
| 202 | struct urb *urb, | 202 | struct urb *urb, |
| 203 | unsigned mem_flags); | 203 | gfp_t mem_flags); |
| 204 | int (*urb_dequeue) (struct usb_hcd *hcd, struct urb *urb); | 204 | int (*urb_dequeue) (struct usb_hcd *hcd, struct urb *urb); |
| 205 | 205 | ||
| 206 | /* hw synch, freeing endpoint resources that urb_dequeue can't */ | 206 | /* hw synch, freeing endpoint resources that urb_dequeue can't */ |
| @@ -247,7 +247,7 @@ int hcd_buffer_create (struct usb_hcd *hcd); | |||
| 247 | void hcd_buffer_destroy (struct usb_hcd *hcd); | 247 | void hcd_buffer_destroy (struct usb_hcd *hcd); |
| 248 | 248 | ||
| 249 | void *hcd_buffer_alloc (struct usb_bus *bus, size_t size, | 249 | void *hcd_buffer_alloc (struct usb_bus *bus, size_t size, |
| 250 | unsigned mem_flags, dma_addr_t *dma); | 250 | gfp_t mem_flags, dma_addr_t *dma); |
| 251 | void hcd_buffer_free (struct usb_bus *bus, size_t size, | 251 | void hcd_buffer_free (struct usb_bus *bus, size_t size, |
| 252 | void *addr, dma_addr_t dma); | 252 | void *addr, dma_addr_t dma); |
| 253 | 253 | ||
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index a12cab5314e9..c3e2024c4347 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
| @@ -1020,9 +1020,15 @@ void usb_set_device_state(struct usb_device *udev, | |||
| 1020 | spin_lock_irqsave(&device_state_lock, flags); | 1020 | spin_lock_irqsave(&device_state_lock, flags); |
| 1021 | if (udev->state == USB_STATE_NOTATTACHED) | 1021 | if (udev->state == USB_STATE_NOTATTACHED) |
| 1022 | ; /* do nothing */ | 1022 | ; /* do nothing */ |
| 1023 | else if (new_state != USB_STATE_NOTATTACHED) | 1023 | else if (new_state != USB_STATE_NOTATTACHED) { |
| 1024 | udev->state = new_state; | 1024 | udev->state = new_state; |
| 1025 | else | 1025 | if (new_state == USB_STATE_CONFIGURED) |
| 1026 | device_init_wakeup(&udev->dev, | ||
| 1027 | (udev->actconfig->desc.bmAttributes | ||
| 1028 | & USB_CONFIG_ATT_WAKEUP)); | ||
| 1029 | else if (new_state != USB_STATE_SUSPENDED) | ||
| 1030 | device_init_wakeup(&udev->dev, 0); | ||
| 1031 | } else | ||
| 1026 | recursively_mark_NOTATTACHED(udev); | 1032 | recursively_mark_NOTATTACHED(udev); |
| 1027 | spin_unlock_irqrestore(&device_state_lock, flags); | 1033 | spin_unlock_irqrestore(&device_state_lock, flags); |
| 1028 | } | 1034 | } |
| @@ -1546,11 +1552,7 @@ static int hub_port_suspend(struct usb_hub *hub, int port1, | |||
| 1546 | * NOTE: OTG devices may issue remote wakeup (or SRP) even when | 1552 | * NOTE: OTG devices may issue remote wakeup (or SRP) even when |
| 1547 | * we don't explicitly enable it here. | 1553 | * we don't explicitly enable it here. |
| 1548 | */ | 1554 | */ |
| 1549 | if (udev->actconfig | 1555 | if (device_may_wakeup(&udev->dev)) { |
| 1550 | // && FIXME (remote wakeup enabled on this bus) | ||
| 1551 | // ... currently assuming it's always appropriate | ||
| 1552 | && (udev->actconfig->desc.bmAttributes | ||
| 1553 | & USB_CONFIG_ATT_WAKEUP) != 0) { | ||
| 1554 | status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 1556 | status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
| 1555 | USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, | 1557 | USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, |
| 1556 | USB_DEVICE_REMOTE_WAKEUP, 0, | 1558 | USB_DEVICE_REMOTE_WAKEUP, 0, |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index f1fb67fe22a8..f9a81e84dbdf 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
| @@ -321,7 +321,7 @@ int usb_sg_init ( | |||
| 321 | struct scatterlist *sg, | 321 | struct scatterlist *sg, |
| 322 | int nents, | 322 | int nents, |
| 323 | size_t length, | 323 | size_t length, |
| 324 | unsigned mem_flags | 324 | gfp_t mem_flags |
| 325 | ) | 325 | ) |
| 326 | { | 326 | { |
| 327 | int i; | 327 | int i; |
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index c846fefb7386..b32898e0a27d 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
| @@ -60,7 +60,7 @@ void usb_init_urb(struct urb *urb) | |||
| 60 | * | 60 | * |
| 61 | * The driver must call usb_free_urb() when it is finished with the urb. | 61 | * The driver must call usb_free_urb() when it is finished with the urb. |
| 62 | */ | 62 | */ |
| 63 | struct urb *usb_alloc_urb(int iso_packets, unsigned mem_flags) | 63 | struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags) |
| 64 | { | 64 | { |
| 65 | struct urb *urb; | 65 | struct urb *urb; |
| 66 | 66 | ||
| @@ -224,7 +224,7 @@ struct urb * usb_get_urb(struct urb *urb) | |||
| 224 | * GFP_NOIO, unless b) or c) apply | 224 | * GFP_NOIO, unless b) or c) apply |
| 225 | * | 225 | * |
| 226 | */ | 226 | */ |
| 227 | int usb_submit_urb(struct urb *urb, unsigned mem_flags) | 227 | int usb_submit_urb(struct urb *urb, gfp_t mem_flags) |
| 228 | { | 228 | { |
| 229 | int pipe, temp, max; | 229 | int pipe, temp, max; |
| 230 | struct usb_device *dev; | 230 | struct usb_device *dev; |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 7d131509e419..4c57f3f649ed 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
| @@ -1147,7 +1147,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, | |||
| 1147 | void *usb_buffer_alloc ( | 1147 | void *usb_buffer_alloc ( |
| 1148 | struct usb_device *dev, | 1148 | struct usb_device *dev, |
| 1149 | size_t size, | 1149 | size_t size, |
| 1150 | unsigned mem_flags, | 1150 | gfp_t mem_flags, |
| 1151 | dma_addr_t *dma | 1151 | dma_addr_t *dma |
| 1152 | ) | 1152 | ) |
| 1153 | { | 1153 | { |
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 583db7c38cf1..503201764f6b 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
| @@ -470,7 +470,7 @@ static int dummy_disable (struct usb_ep *_ep) | |||
| 470 | } | 470 | } |
| 471 | 471 | ||
| 472 | static struct usb_request * | 472 | static struct usb_request * |
| 473 | dummy_alloc_request (struct usb_ep *_ep, unsigned mem_flags) | 473 | dummy_alloc_request (struct usb_ep *_ep, gfp_t mem_flags) |
| 474 | { | 474 | { |
| 475 | struct dummy_ep *ep; | 475 | struct dummy_ep *ep; |
| 476 | struct dummy_request *req; | 476 | struct dummy_request *req; |
| @@ -507,7 +507,7 @@ dummy_alloc_buffer ( | |||
| 507 | struct usb_ep *_ep, | 507 | struct usb_ep *_ep, |
| 508 | unsigned bytes, | 508 | unsigned bytes, |
| 509 | dma_addr_t *dma, | 509 | dma_addr_t *dma, |
| 510 | unsigned mem_flags | 510 | gfp_t mem_flags |
| 511 | ) { | 511 | ) { |
| 512 | char *retval; | 512 | char *retval; |
| 513 | struct dummy_ep *ep; | 513 | struct dummy_ep *ep; |
| @@ -541,7 +541,7 @@ fifo_complete (struct usb_ep *ep, struct usb_request *req) | |||
| 541 | 541 | ||
| 542 | static int | 542 | static int |
| 543 | dummy_queue (struct usb_ep *_ep, struct usb_request *_req, | 543 | dummy_queue (struct usb_ep *_ep, struct usb_request *_req, |
| 544 | unsigned mem_flags) | 544 | gfp_t mem_flags) |
| 545 | { | 545 | { |
| 546 | struct dummy_ep *ep; | 546 | struct dummy_ep *ep; |
| 547 | struct dummy_request *req; | 547 | struct dummy_request *req; |
| @@ -935,14 +935,10 @@ static int dummy_udc_remove (struct device *dev) | |||
| 935 | return 0; | 935 | return 0; |
| 936 | } | 936 | } |
| 937 | 937 | ||
| 938 | static int dummy_udc_suspend (struct device *dev, pm_message_t state, | 938 | static int dummy_udc_suspend (struct device *dev, pm_message_t state) |
| 939 | u32 level) | ||
| 940 | { | 939 | { |
| 941 | struct dummy *dum = dev_get_drvdata(dev); | 940 | struct dummy *dum = dev_get_drvdata(dev); |
| 942 | 941 | ||
| 943 | if (level != SUSPEND_DISABLE) | ||
| 944 | return 0; | ||
| 945 | |||
| 946 | dev_dbg (dev, "%s\n", __FUNCTION__); | 942 | dev_dbg (dev, "%s\n", __FUNCTION__); |
| 947 | spin_lock_irq (&dum->lock); | 943 | spin_lock_irq (&dum->lock); |
| 948 | dum->udc_suspended = 1; | 944 | dum->udc_suspended = 1; |
| @@ -954,13 +950,10 @@ static int dummy_udc_suspend (struct device *dev, pm_message_t state, | |||
| 954 | return 0; | 950 | return 0; |
| 955 | } | 951 | } |
| 956 | 952 | ||
| 957 | static int dummy_udc_resume (struct device *dev, u32 level) | 953 | static int dummy_udc_resume (struct device *dev) |
| 958 | { | 954 | { |
| 959 | struct dummy *dum = dev_get_drvdata(dev); | 955 | struct dummy *dum = dev_get_drvdata(dev); |
| 960 | 956 | ||
| 961 | if (level != RESUME_ENABLE) | ||
| 962 | return 0; | ||
| 963 | |||
| 964 | dev_dbg (dev, "%s\n", __FUNCTION__); | 957 | dev_dbg (dev, "%s\n", __FUNCTION__); |
| 965 | spin_lock_irq (&dum->lock); | 958 | spin_lock_irq (&dum->lock); |
| 966 | dum->udc_suspended = 0; | 959 | dum->udc_suspended = 0; |
| @@ -999,7 +992,7 @@ static int dummy_urb_enqueue ( | |||
| 999 | struct usb_hcd *hcd, | 992 | struct usb_hcd *hcd, |
| 1000 | struct usb_host_endpoint *ep, | 993 | struct usb_host_endpoint *ep, |
| 1001 | struct urb *urb, | 994 | struct urb *urb, |
| 1002 | unsigned mem_flags | 995 | gfp_t mem_flags |
| 1003 | ) { | 996 | ) { |
| 1004 | struct dummy *dum; | 997 | struct dummy *dum; |
| 1005 | struct urbp *urbp; | 998 | struct urbp *urbp; |
| @@ -1936,14 +1929,10 @@ static int dummy_hcd_remove (struct device *dev) | |||
| 1936 | return 0; | 1929 | return 0; |
| 1937 | } | 1930 | } |
| 1938 | 1931 | ||
| 1939 | static int dummy_hcd_suspend (struct device *dev, pm_message_t state, | 1932 | static int dummy_hcd_suspend (struct device *dev, pm_message_t state) |
| 1940 | u32 level) | ||
| 1941 | { | 1933 | { |
| 1942 | struct usb_hcd *hcd; | 1934 | struct usb_hcd *hcd; |
| 1943 | 1935 | ||
| 1944 | if (level != SUSPEND_DISABLE) | ||
| 1945 | return 0; | ||
| 1946 | |||
| 1947 | dev_dbg (dev, "%s\n", __FUNCTION__); | 1936 | dev_dbg (dev, "%s\n", __FUNCTION__); |
| 1948 | hcd = dev_get_drvdata (dev); | 1937 | hcd = dev_get_drvdata (dev); |
| 1949 | 1938 | ||
| @@ -1958,13 +1947,10 @@ static int dummy_hcd_suspend (struct device *dev, pm_message_t state, | |||
| 1958 | return 0; | 1947 | return 0; |
| 1959 | } | 1948 | } |
| 1960 | 1949 | ||
| 1961 | static int dummy_hcd_resume (struct device *dev, u32 level) | 1950 | static int dummy_hcd_resume (struct device *dev) |
| 1962 | { | 1951 | { |
| 1963 | struct usb_hcd *hcd; | 1952 | struct usb_hcd *hcd; |
| 1964 | 1953 | ||
| 1965 | if (level != RESUME_ENABLE) | ||
| 1966 | return 0; | ||
| 1967 | |||
| 1968 | dev_dbg (dev, "%s\n", __FUNCTION__); | 1954 | dev_dbg (dev, "%s\n", __FUNCTION__); |
| 1969 | hcd = dev_get_drvdata (dev); | 1955 | hcd = dev_get_drvdata (dev); |
| 1970 | hcd->state = HC_STATE_RUNNING; | 1956 | hcd->state = HC_STATE_RUNNING; |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 49459e33e952..f1024e804d5c 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
| @@ -945,11 +945,11 @@ config_buf (enum usb_device_speed speed, | |||
| 945 | 945 | ||
| 946 | /*-------------------------------------------------------------------------*/ | 946 | /*-------------------------------------------------------------------------*/ |
| 947 | 947 | ||
| 948 | static void eth_start (struct eth_dev *dev, unsigned gfp_flags); | 948 | static void eth_start (struct eth_dev *dev, gfp_t gfp_flags); |
| 949 | static int alloc_requests (struct eth_dev *dev, unsigned n, unsigned gfp_flags); | 949 | static int alloc_requests (struct eth_dev *dev, unsigned n, gfp_t gfp_flags); |
| 950 | 950 | ||
| 951 | static int | 951 | static int |
| 952 | set_ether_config (struct eth_dev *dev, unsigned gfp_flags) | 952 | set_ether_config (struct eth_dev *dev, gfp_t gfp_flags) |
| 953 | { | 953 | { |
| 954 | int result = 0; | 954 | int result = 0; |
| 955 | struct usb_gadget *gadget = dev->gadget; | 955 | struct usb_gadget *gadget = dev->gadget; |
| @@ -1081,7 +1081,7 @@ static void eth_reset_config (struct eth_dev *dev) | |||
| 1081 | * that returns config descriptors, and altsetting code. | 1081 | * that returns config descriptors, and altsetting code. |
| 1082 | */ | 1082 | */ |
| 1083 | static int | 1083 | static int |
| 1084 | eth_set_config (struct eth_dev *dev, unsigned number, unsigned gfp_flags) | 1084 | eth_set_config (struct eth_dev *dev, unsigned number, gfp_t gfp_flags) |
| 1085 | { | 1085 | { |
| 1086 | int result = 0; | 1086 | int result = 0; |
| 1087 | struct usb_gadget *gadget = dev->gadget; | 1087 | struct usb_gadget *gadget = dev->gadget; |
| @@ -1598,7 +1598,7 @@ static void defer_kevent (struct eth_dev *dev, int flag) | |||
| 1598 | static void rx_complete (struct usb_ep *ep, struct usb_request *req); | 1598 | static void rx_complete (struct usb_ep *ep, struct usb_request *req); |
| 1599 | 1599 | ||
| 1600 | static int | 1600 | static int |
| 1601 | rx_submit (struct eth_dev *dev, struct usb_request *req, unsigned gfp_flags) | 1601 | rx_submit (struct eth_dev *dev, struct usb_request *req, gfp_t gfp_flags) |
| 1602 | { | 1602 | { |
| 1603 | struct sk_buff *skb; | 1603 | struct sk_buff *skb; |
| 1604 | int retval = -ENOMEM; | 1604 | int retval = -ENOMEM; |
| @@ -1724,7 +1724,7 @@ clean: | |||
| 1724 | } | 1724 | } |
| 1725 | 1725 | ||
| 1726 | static int prealloc (struct list_head *list, struct usb_ep *ep, | 1726 | static int prealloc (struct list_head *list, struct usb_ep *ep, |
| 1727 | unsigned n, unsigned gfp_flags) | 1727 | unsigned n, gfp_t gfp_flags) |
| 1728 | { | 1728 | { |
| 1729 | unsigned i; | 1729 | unsigned i; |
| 1730 | struct usb_request *req; | 1730 | struct usb_request *req; |
| @@ -1763,7 +1763,7 @@ extra: | |||
| 1763 | return 0; | 1763 | return 0; |
| 1764 | } | 1764 | } |
| 1765 | 1765 | ||
| 1766 | static int alloc_requests (struct eth_dev *dev, unsigned n, unsigned gfp_flags) | 1766 | static int alloc_requests (struct eth_dev *dev, unsigned n, gfp_t gfp_flags) |
| 1767 | { | 1767 | { |
| 1768 | int status; | 1768 | int status; |
| 1769 | 1769 | ||
| @@ -1779,7 +1779,7 @@ fail: | |||
| 1779 | return status; | 1779 | return status; |
| 1780 | } | 1780 | } |
| 1781 | 1781 | ||
| 1782 | static void rx_fill (struct eth_dev *dev, unsigned gfp_flags) | 1782 | static void rx_fill (struct eth_dev *dev, gfp_t gfp_flags) |
| 1783 | { | 1783 | { |
| 1784 | struct usb_request *req; | 1784 | struct usb_request *req; |
| 1785 | unsigned long flags; | 1785 | unsigned long flags; |
| @@ -1962,7 +1962,7 @@ drop: | |||
| 1962 | * normally just one notification will be queued. | 1962 | * normally just one notification will be queued. |
| 1963 | */ | 1963 | */ |
| 1964 | 1964 | ||
| 1965 | static struct usb_request *eth_req_alloc (struct usb_ep *, unsigned, unsigned); | 1965 | static struct usb_request *eth_req_alloc (struct usb_ep *, unsigned, gfp_t); |
| 1966 | static void eth_req_free (struct usb_ep *ep, struct usb_request *req); | 1966 | static void eth_req_free (struct usb_ep *ep, struct usb_request *req); |
| 1967 | 1967 | ||
| 1968 | static void | 1968 | static void |
| @@ -2024,7 +2024,7 @@ static int rndis_control_ack (struct net_device *net) | |||
| 2024 | 2024 | ||
| 2025 | #endif /* RNDIS */ | 2025 | #endif /* RNDIS */ |
| 2026 | 2026 | ||
| 2027 | static void eth_start (struct eth_dev *dev, unsigned gfp_flags) | 2027 | static void eth_start (struct eth_dev *dev, gfp_t gfp_flags) |
| 2028 | { | 2028 | { |
| 2029 | DEBUG (dev, "%s\n", __FUNCTION__); | 2029 | DEBUG (dev, "%s\n", __FUNCTION__); |
| 2030 | 2030 | ||
| @@ -2092,7 +2092,7 @@ static int eth_stop (struct net_device *net) | |||
| 2092 | /*-------------------------------------------------------------------------*/ | 2092 | /*-------------------------------------------------------------------------*/ |
| 2093 | 2093 | ||
| 2094 | static struct usb_request * | 2094 | static struct usb_request * |
| 2095 | eth_req_alloc (struct usb_ep *ep, unsigned size, unsigned gfp_flags) | 2095 | eth_req_alloc (struct usb_ep *ep, unsigned size, gfp_t gfp_flags) |
| 2096 | { | 2096 | { |
| 2097 | struct usb_request *req; | 2097 | struct usb_request *req; |
| 2098 | 2098 | ||
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index eaab26f4ed37..b0f3cd63e3b9 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c | |||
| @@ -269,7 +269,7 @@ static int goku_ep_disable(struct usb_ep *_ep) | |||
| 269 | /*-------------------------------------------------------------------------*/ | 269 | /*-------------------------------------------------------------------------*/ |
| 270 | 270 | ||
| 271 | static struct usb_request * | 271 | static struct usb_request * |
| 272 | goku_alloc_request(struct usb_ep *_ep, unsigned gfp_flags) | 272 | goku_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags) |
| 273 | { | 273 | { |
| 274 | struct goku_request *req; | 274 | struct goku_request *req; |
| 275 | 275 | ||
| @@ -327,7 +327,7 @@ goku_free_request(struct usb_ep *_ep, struct usb_request *_req) | |||
| 327 | */ | 327 | */ |
| 328 | static void * | 328 | static void * |
| 329 | goku_alloc_buffer(struct usb_ep *_ep, unsigned bytes, | 329 | goku_alloc_buffer(struct usb_ep *_ep, unsigned bytes, |
| 330 | dma_addr_t *dma, unsigned gfp_flags) | 330 | dma_addr_t *dma, gfp_t gfp_flags) |
| 331 | { | 331 | { |
| 332 | void *retval; | 332 | void *retval; |
| 333 | struct goku_ep *ep; | 333 | struct goku_ep *ep; |
| @@ -789,7 +789,7 @@ finished: | |||
| 789 | /*-------------------------------------------------------------------------*/ | 789 | /*-------------------------------------------------------------------------*/ |
| 790 | 790 | ||
| 791 | static int | 791 | static int |
| 792 | goku_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags) | 792 | goku_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) |
| 793 | { | 793 | { |
| 794 | struct goku_request *req; | 794 | struct goku_request *req; |
| 795 | struct goku_ep *ep; | 795 | struct goku_ep *ep; |
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c index 4842577789c9..012d1e5f1524 100644 --- a/drivers/usb/gadget/lh7a40x_udc.c +++ b/drivers/usb/gadget/lh7a40x_udc.c | |||
| @@ -71,13 +71,13 @@ static char *state_names[] = { | |||
| 71 | static int lh7a40x_ep_enable(struct usb_ep *ep, | 71 | static int lh7a40x_ep_enable(struct usb_ep *ep, |
| 72 | const struct usb_endpoint_descriptor *); | 72 | const struct usb_endpoint_descriptor *); |
| 73 | static int lh7a40x_ep_disable(struct usb_ep *ep); | 73 | static int lh7a40x_ep_disable(struct usb_ep *ep); |
| 74 | static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, int); | 74 | static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, gfp_t); |
| 75 | static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *); | 75 | static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *); |
| 76 | static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned, dma_addr_t *, | 76 | static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned, dma_addr_t *, |
| 77 | int); | 77 | gfp_t); |
| 78 | static void lh7a40x_free_buffer(struct usb_ep *ep, void *, dma_addr_t, | 78 | static void lh7a40x_free_buffer(struct usb_ep *ep, void *, dma_addr_t, |
| 79 | unsigned); | 79 | unsigned); |
| 80 | static int lh7a40x_queue(struct usb_ep *ep, struct usb_request *, int); | 80 | static int lh7a40x_queue(struct usb_ep *ep, struct usb_request *, gfp_t); |
| 81 | static int lh7a40x_dequeue(struct usb_ep *ep, struct usb_request *); | 81 | static int lh7a40x_dequeue(struct usb_ep *ep, struct usb_request *); |
| 82 | static int lh7a40x_set_halt(struct usb_ep *ep, int); | 82 | static int lh7a40x_set_halt(struct usb_ep *ep, int); |
| 83 | static int lh7a40x_fifo_status(struct usb_ep *ep); | 83 | static int lh7a40x_fifo_status(struct usb_ep *ep); |
| @@ -1106,7 +1106,7 @@ static int lh7a40x_ep_disable(struct usb_ep *_ep) | |||
| 1106 | } | 1106 | } |
| 1107 | 1107 | ||
| 1108 | static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, | 1108 | static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, |
| 1109 | unsigned gfp_flags) | 1109 | gfp_t gfp_flags) |
| 1110 | { | 1110 | { |
| 1111 | struct lh7a40x_request *req; | 1111 | struct lh7a40x_request *req; |
| 1112 | 1112 | ||
| @@ -1134,7 +1134,7 @@ static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *_req) | |||
| 1134 | } | 1134 | } |
| 1135 | 1135 | ||
| 1136 | static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned bytes, | 1136 | static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned bytes, |
| 1137 | dma_addr_t * dma, unsigned gfp_flags) | 1137 | dma_addr_t * dma, gfp_t gfp_flags) |
| 1138 | { | 1138 | { |
| 1139 | char *retval; | 1139 | char *retval; |
| 1140 | 1140 | ||
| @@ -1158,7 +1158,7 @@ static void lh7a40x_free_buffer(struct usb_ep *ep, void *buf, dma_addr_t dma, | |||
| 1158 | * NOTE: Sets INDEX register | 1158 | * NOTE: Sets INDEX register |
| 1159 | */ | 1159 | */ |
| 1160 | static int lh7a40x_queue(struct usb_ep *_ep, struct usb_request *_req, | 1160 | static int lh7a40x_queue(struct usb_ep *_ep, struct usb_request *_req, |
| 1161 | unsigned gfp_flags) | 1161 | gfp_t gfp_flags) |
| 1162 | { | 1162 | { |
| 1163 | struct lh7a40x_request *req; | 1163 | struct lh7a40x_request *req; |
| 1164 | struct lh7a40x_ep *ep; | 1164 | struct lh7a40x_ep *ep; |
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index 477fab2e74d1..c32e1f7476da 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
| @@ -376,7 +376,7 @@ static int net2280_disable (struct usb_ep *_ep) | |||
| 376 | /*-------------------------------------------------------------------------*/ | 376 | /*-------------------------------------------------------------------------*/ |
| 377 | 377 | ||
| 378 | static struct usb_request * | 378 | static struct usb_request * |
| 379 | net2280_alloc_request (struct usb_ep *_ep, unsigned gfp_flags) | 379 | net2280_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags) |
| 380 | { | 380 | { |
| 381 | struct net2280_ep *ep; | 381 | struct net2280_ep *ep; |
| 382 | struct net2280_request *req; | 382 | struct net2280_request *req; |
| @@ -463,7 +463,7 @@ net2280_alloc_buffer ( | |||
| 463 | struct usb_ep *_ep, | 463 | struct usb_ep *_ep, |
| 464 | unsigned bytes, | 464 | unsigned bytes, |
| 465 | dma_addr_t *dma, | 465 | dma_addr_t *dma, |
| 466 | unsigned gfp_flags | 466 | gfp_t gfp_flags |
| 467 | ) | 467 | ) |
| 468 | { | 468 | { |
| 469 | void *retval; | 469 | void *retval; |
| @@ -897,7 +897,7 @@ done (struct net2280_ep *ep, struct net2280_request *req, int status) | |||
| 897 | /*-------------------------------------------------------------------------*/ | 897 | /*-------------------------------------------------------------------------*/ |
| 898 | 898 | ||
| 899 | static int | 899 | static int |
| 900 | net2280_queue (struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags) | 900 | net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) |
| 901 | { | 901 | { |
| 902 | struct net2280_request *req; | 902 | struct net2280_request *req; |
| 903 | struct net2280_ep *ep; | 903 | struct net2280_ep *ep; |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index ff5533e69560..b7885dc0f42f 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
| @@ -269,7 +269,7 @@ static int omap_ep_disable(struct usb_ep *_ep) | |||
| 269 | /*-------------------------------------------------------------------------*/ | 269 | /*-------------------------------------------------------------------------*/ |
| 270 | 270 | ||
| 271 | static struct usb_request * | 271 | static struct usb_request * |
| 272 | omap_alloc_request(struct usb_ep *ep, unsigned gfp_flags) | 272 | omap_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) |
| 273 | { | 273 | { |
| 274 | struct omap_req *req; | 274 | struct omap_req *req; |
| 275 | 275 | ||
| @@ -298,7 +298,7 @@ omap_alloc_buffer( | |||
| 298 | struct usb_ep *_ep, | 298 | struct usb_ep *_ep, |
| 299 | unsigned bytes, | 299 | unsigned bytes, |
| 300 | dma_addr_t *dma, | 300 | dma_addr_t *dma, |
| 301 | unsigned gfp_flags | 301 | gfp_t gfp_flags |
| 302 | ) | 302 | ) |
| 303 | { | 303 | { |
| 304 | void *retval; | 304 | void *retval; |
| @@ -937,7 +937,7 @@ static void dma_channel_release(struct omap_ep *ep) | |||
| 937 | /*-------------------------------------------------------------------------*/ | 937 | /*-------------------------------------------------------------------------*/ |
| 938 | 938 | ||
| 939 | static int | 939 | static int |
| 940 | omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags) | 940 | omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) |
| 941 | { | 941 | { |
| 942 | struct omap_ep *ep = container_of(_ep, struct omap_ep, ep); | 942 | struct omap_ep *ep = container_of(_ep, struct omap_ep, ep); |
| 943 | struct omap_req *req = container_of(_req, struct omap_req, req); | 943 | struct omap_req *req = container_of(_req, struct omap_req, req); |
| @@ -2909,12 +2909,10 @@ static int __exit omap_udc_remove(struct device *dev) | |||
| 2909 | * may involve talking to an external transceiver (e.g. isp1301). | 2909 | * may involve talking to an external transceiver (e.g. isp1301). |
| 2910 | */ | 2910 | */ |
| 2911 | 2911 | ||
| 2912 | static int omap_udc_suspend(struct device *dev, pm_message_t message, u32 level) | 2912 | static int omap_udc_suspend(struct device *dev, pm_message_t message) |
| 2913 | { | 2913 | { |
| 2914 | u32 devstat; | 2914 | u32 devstat; |
| 2915 | 2915 | ||
| 2916 | if (level != SUSPEND_POWER_DOWN) | ||
| 2917 | return 0; | ||
| 2918 | devstat = UDC_DEVSTAT_REG; | 2916 | devstat = UDC_DEVSTAT_REG; |
| 2919 | 2917 | ||
| 2920 | /* we're requesting 48 MHz clock if the pullup is enabled | 2918 | /* we're requesting 48 MHz clock if the pullup is enabled |
| @@ -2931,11 +2929,8 @@ static int omap_udc_suspend(struct device *dev, pm_message_t message, u32 level) | |||
| 2931 | return 0; | 2929 | return 0; |
| 2932 | } | 2930 | } |
| 2933 | 2931 | ||
| 2934 | static int omap_udc_resume(struct device *dev, u32 level) | 2932 | static int omap_udc_resume(struct device *dev) |
| 2935 | { | 2933 | { |
| 2936 | if (level != RESUME_POWER_ON) | ||
| 2937 | return 0; | ||
| 2938 | |||
| 2939 | DBG("resume + wakeup/SRP\n"); | 2934 | DBG("resume + wakeup/SRP\n"); |
| 2940 | omap_pullup(&udc->gadget, 1); | 2935 | omap_pullup(&udc->gadget, 1); |
| 2941 | 2936 | ||
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c index 73f8c9404156..647028590b23 100644 --- a/drivers/usb/gadget/pxa2xx_udc.c +++ b/drivers/usb/gadget/pxa2xx_udc.c | |||
| @@ -332,7 +332,7 @@ static int pxa2xx_ep_disable (struct usb_ep *_ep) | |||
| 332 | * pxa2xx_ep_alloc_request - allocate a request data structure | 332 | * pxa2xx_ep_alloc_request - allocate a request data structure |
| 333 | */ | 333 | */ |
| 334 | static struct usb_request * | 334 | static struct usb_request * |
| 335 | pxa2xx_ep_alloc_request (struct usb_ep *_ep, unsigned gfp_flags) | 335 | pxa2xx_ep_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags) |
| 336 | { | 336 | { |
| 337 | struct pxa2xx_request *req; | 337 | struct pxa2xx_request *req; |
| 338 | 338 | ||
| @@ -367,7 +367,7 @@ pxa2xx_ep_free_request (struct usb_ep *_ep, struct usb_request *_req) | |||
| 367 | */ | 367 | */ |
| 368 | static void * | 368 | static void * |
| 369 | pxa2xx_ep_alloc_buffer(struct usb_ep *_ep, unsigned bytes, | 369 | pxa2xx_ep_alloc_buffer(struct usb_ep *_ep, unsigned bytes, |
| 370 | dma_addr_t *dma, unsigned gfp_flags) | 370 | dma_addr_t *dma, gfp_t gfp_flags) |
| 371 | { | 371 | { |
| 372 | char *retval; | 372 | char *retval; |
| 373 | 373 | ||
| @@ -422,7 +422,7 @@ static inline void ep0_idle (struct pxa2xx_udc *dev) | |||
| 422 | } | 422 | } |
| 423 | 423 | ||
| 424 | static int | 424 | static int |
| 425 | write_packet(volatile unsigned long *uddr, struct pxa2xx_request *req, unsigned max) | 425 | write_packet(volatile u32 *uddr, struct pxa2xx_request *req, unsigned max) |
| 426 | { | 426 | { |
| 427 | u8 *buf; | 427 | u8 *buf; |
| 428 | unsigned length, count; | 428 | unsigned length, count; |
| @@ -874,7 +874,7 @@ done: | |||
| 874 | /*-------------------------------------------------------------------------*/ | 874 | /*-------------------------------------------------------------------------*/ |
| 875 | 875 | ||
| 876 | static int | 876 | static int |
| 877 | pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags) | 877 | pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) |
| 878 | { | 878 | { |
| 879 | struct pxa2xx_request *req; | 879 | struct pxa2xx_request *req; |
| 880 | struct pxa2xx_ep *ep; | 880 | struct pxa2xx_ep *ep; |
| @@ -2602,24 +2602,23 @@ static int __exit pxa2xx_udc_remove(struct device *_dev) | |||
| 2602 | * VBUS IRQs should probably be ignored so that the PXA device just acts | 2602 | * VBUS IRQs should probably be ignored so that the PXA device just acts |
| 2603 | * "dead" to USB hosts until system resume. | 2603 | * "dead" to USB hosts until system resume. |
| 2604 | */ | 2604 | */ |
| 2605 | static int pxa2xx_udc_suspend(struct device *dev, pm_message_t state, u32 level) | 2605 | static int pxa2xx_udc_suspend(struct device *dev, pm_message_t state) |
| 2606 | { | 2606 | { |
| 2607 | struct pxa2xx_udc *udc = dev_get_drvdata(dev); | 2607 | struct pxa2xx_udc *udc = dev_get_drvdata(dev); |
| 2608 | 2608 | ||
| 2609 | if (level == SUSPEND_POWER_DOWN) { | 2609 | if (!udc->mach->udc_command) |
| 2610 | if (!udc->mach->udc_command) | 2610 | WARN("USB host won't detect disconnect!\n"); |
| 2611 | WARN("USB host won't detect disconnect!\n"); | 2611 | pullup(udc, 0); |
| 2612 | pullup(udc, 0); | 2612 | |
| 2613 | } | ||
| 2614 | return 0; | 2613 | return 0; |
| 2615 | } | 2614 | } |
| 2616 | 2615 | ||
| 2617 | static int pxa2xx_udc_resume(struct device *dev, u32 level) | 2616 | static int pxa2xx_udc_resume(struct device *dev) |
| 2618 | { | 2617 | { |
| 2619 | struct pxa2xx_udc *udc = dev_get_drvdata(dev); | 2618 | struct pxa2xx_udc *udc = dev_get_drvdata(dev); |
| 2620 | 2619 | ||
| 2621 | if (level == RESUME_POWER_ON) | 2620 | pullup(udc, 1); |
| 2622 | pullup(udc, 1); | 2621 | |
| 2623 | return 0; | 2622 | return 0; |
| 2624 | } | 2623 | } |
| 2625 | 2624 | ||
diff --git a/drivers/usb/gadget/pxa2xx_udc.h b/drivers/usb/gadget/pxa2xx_udc.h index a58f3e6e71f1..19a883f7d1b8 100644 --- a/drivers/usb/gadget/pxa2xx_udc.h +++ b/drivers/usb/gadget/pxa2xx_udc.h | |||
| @@ -69,11 +69,11 @@ struct pxa2xx_ep { | |||
| 69 | * UDDR = UDC Endpoint Data Register (the fifo) | 69 | * UDDR = UDC Endpoint Data Register (the fifo) |
| 70 | * DRCM = DMA Request Channel Map | 70 | * DRCM = DMA Request Channel Map |
| 71 | */ | 71 | */ |
| 72 | volatile unsigned long *reg_udccs; | 72 | volatile u32 *reg_udccs; |
| 73 | volatile unsigned long *reg_ubcr; | 73 | volatile u32 *reg_ubcr; |
| 74 | volatile unsigned long *reg_uddr; | 74 | volatile u32 *reg_uddr; |
| 75 | #ifdef USE_DMA | 75 | #ifdef USE_DMA |
| 76 | volatile unsigned long *reg_drcmr; | 76 | volatile u32 *reg_drcmr; |
| 77 | #define drcmr(n) .reg_drcmr = & DRCMR ## n , | 77 | #define drcmr(n) .reg_drcmr = & DRCMR ## n , |
| 78 | #else | 78 | #else |
| 79 | #define drcmr(n) | 79 | #define drcmr(n) |
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index c925d9222f53..b35ac6d334f8 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
| @@ -300,18 +300,18 @@ static int gs_build_config_buf(u8 *buf, enum usb_device_speed speed, | |||
| 300 | u8 type, unsigned int index, int is_otg); | 300 | u8 type, unsigned int index, int is_otg); |
| 301 | 301 | ||
| 302 | static struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len, | 302 | static struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len, |
| 303 | unsigned kmalloc_flags); | 303 | gfp_t kmalloc_flags); |
| 304 | static void gs_free_req(struct usb_ep *ep, struct usb_request *req); | 304 | static void gs_free_req(struct usb_ep *ep, struct usb_request *req); |
| 305 | 305 | ||
| 306 | static struct gs_req_entry *gs_alloc_req_entry(struct usb_ep *ep, unsigned len, | 306 | static struct gs_req_entry *gs_alloc_req_entry(struct usb_ep *ep, unsigned len, |
| 307 | unsigned kmalloc_flags); | 307 | gfp_t kmalloc_flags); |
| 308 | static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req); | 308 | static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req); |
| 309 | 309 | ||
| 310 | static int gs_alloc_ports(struct gs_dev *dev, unsigned kmalloc_flags); | 310 | static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags); |
| 311 | static void gs_free_ports(struct gs_dev *dev); | 311 | static void gs_free_ports(struct gs_dev *dev); |
| 312 | 312 | ||
| 313 | /* circular buffer */ | 313 | /* circular buffer */ |
| 314 | static struct gs_buf *gs_buf_alloc(unsigned int size, unsigned kmalloc_flags); | 314 | static struct gs_buf *gs_buf_alloc(unsigned int size, gfp_t kmalloc_flags); |
| 315 | static void gs_buf_free(struct gs_buf *gb); | 315 | static void gs_buf_free(struct gs_buf *gb); |
| 316 | static void gs_buf_clear(struct gs_buf *gb); | 316 | static void gs_buf_clear(struct gs_buf *gb); |
| 317 | static unsigned int gs_buf_data_avail(struct gs_buf *gb); | 317 | static unsigned int gs_buf_data_avail(struct gs_buf *gb); |
| @@ -2091,7 +2091,7 @@ static int gs_build_config_buf(u8 *buf, enum usb_device_speed speed, | |||
| 2091 | * usb_request or NULL if there is an error. | 2091 | * usb_request or NULL if there is an error. |
| 2092 | */ | 2092 | */ |
| 2093 | static struct usb_request * | 2093 | static struct usb_request * |
| 2094 | gs_alloc_req(struct usb_ep *ep, unsigned int len, unsigned kmalloc_flags) | 2094 | gs_alloc_req(struct usb_ep *ep, unsigned int len, gfp_t kmalloc_flags) |
| 2095 | { | 2095 | { |
| 2096 | struct usb_request *req; | 2096 | struct usb_request *req; |
| 2097 | 2097 | ||
| @@ -2132,7 +2132,7 @@ static void gs_free_req(struct usb_ep *ep, struct usb_request *req) | |||
| 2132 | * endpoint, buffer len, and kmalloc flags. | 2132 | * endpoint, buffer len, and kmalloc flags. |
| 2133 | */ | 2133 | */ |
| 2134 | static struct gs_req_entry * | 2134 | static struct gs_req_entry * |
| 2135 | gs_alloc_req_entry(struct usb_ep *ep, unsigned len, unsigned kmalloc_flags) | 2135 | gs_alloc_req_entry(struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags) |
| 2136 | { | 2136 | { |
| 2137 | struct gs_req_entry *req; | 2137 | struct gs_req_entry *req; |
| 2138 | 2138 | ||
| @@ -2173,7 +2173,7 @@ static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req) | |||
| 2173 | * | 2173 | * |
| 2174 | * The device lock is normally held when calling this function. | 2174 | * The device lock is normally held when calling this function. |
| 2175 | */ | 2175 | */ |
| 2176 | static int gs_alloc_ports(struct gs_dev *dev, unsigned kmalloc_flags) | 2176 | static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags) |
| 2177 | { | 2177 | { |
| 2178 | int i; | 2178 | int i; |
| 2179 | struct gs_port *port; | 2179 | struct gs_port *port; |
| @@ -2255,7 +2255,7 @@ static void gs_free_ports(struct gs_dev *dev) | |||
| 2255 | * | 2255 | * |
| 2256 | * Allocate a circular buffer and all associated memory. | 2256 | * Allocate a circular buffer and all associated memory. |
| 2257 | */ | 2257 | */ |
| 2258 | static struct gs_buf *gs_buf_alloc(unsigned int size, unsigned kmalloc_flags) | 2258 | static struct gs_buf *gs_buf_alloc(unsigned int size, gfp_t kmalloc_flags) |
| 2259 | { | 2259 | { |
| 2260 | struct gs_buf *gb; | 2260 | struct gs_buf *gb; |
| 2261 | 2261 | ||
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 6890e773b2a2..ec9c424f1d97 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
| @@ -612,7 +612,7 @@ static void source_sink_complete (struct usb_ep *ep, struct usb_request *req) | |||
| 612 | } | 612 | } |
| 613 | 613 | ||
| 614 | static struct usb_request * | 614 | static struct usb_request * |
| 615 | source_sink_start_ep (struct usb_ep *ep, unsigned gfp_flags) | 615 | source_sink_start_ep (struct usb_ep *ep, gfp_t gfp_flags) |
| 616 | { | 616 | { |
| 617 | struct usb_request *req; | 617 | struct usb_request *req; |
| 618 | int status; | 618 | int status; |
| @@ -640,7 +640,7 @@ source_sink_start_ep (struct usb_ep *ep, unsigned gfp_flags) | |||
| 640 | } | 640 | } |
| 641 | 641 | ||
| 642 | static int | 642 | static int |
| 643 | set_source_sink_config (struct zero_dev *dev, unsigned gfp_flags) | 643 | set_source_sink_config (struct zero_dev *dev, gfp_t gfp_flags) |
| 644 | { | 644 | { |
| 645 | int result = 0; | 645 | int result = 0; |
| 646 | struct usb_ep *ep; | 646 | struct usb_ep *ep; |
| @@ -744,7 +744,7 @@ static void loopback_complete (struct usb_ep *ep, struct usb_request *req) | |||
| 744 | } | 744 | } |
| 745 | 745 | ||
| 746 | static int | 746 | static int |
| 747 | set_loopback_config (struct zero_dev *dev, unsigned gfp_flags) | 747 | set_loopback_config (struct zero_dev *dev, gfp_t gfp_flags) |
| 748 | { | 748 | { |
| 749 | int result = 0; | 749 | int result = 0; |
| 750 | struct usb_ep *ep; | 750 | struct usb_ep *ep; |
| @@ -845,7 +845,7 @@ static void zero_reset_config (struct zero_dev *dev) | |||
| 845 | * by limiting configuration choices (like the pxa2xx). | 845 | * by limiting configuration choices (like the pxa2xx). |
| 846 | */ | 846 | */ |
| 847 | static int | 847 | static int |
| 848 | zero_set_config (struct zero_dev *dev, unsigned number, unsigned gfp_flags) | 848 | zero_set_config (struct zero_dev *dev, unsigned number, gfp_t gfp_flags) |
| 849 | { | 849 | { |
| 850 | int result = 0; | 850 | int result = 0; |
| 851 | struct usb_gadget *gadget = dev->gadget; | 851 | struct usb_gadget *gadget = dev->gadget; |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index b948ffd94f45..f5eb9e7b5b18 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
| @@ -983,7 +983,7 @@ static int ehci_urb_enqueue ( | |||
| 983 | struct usb_hcd *hcd, | 983 | struct usb_hcd *hcd, |
| 984 | struct usb_host_endpoint *ep, | 984 | struct usb_host_endpoint *ep, |
| 985 | struct urb *urb, | 985 | struct urb *urb, |
| 986 | unsigned mem_flags | 986 | gfp_t mem_flags |
| 987 | ) { | 987 | ) { |
| 988 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 988 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
| 989 | struct list_head qtd_list; | 989 | struct list_head qtd_list; |
diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c index 5c38ad869485..91c2ab43cbcc 100644 --- a/drivers/usb/host/ehci-mem.c +++ b/drivers/usb/host/ehci-mem.c | |||
| @@ -45,7 +45,7 @@ static inline void ehci_qtd_init (struct ehci_qtd *qtd, dma_addr_t dma) | |||
| 45 | INIT_LIST_HEAD (&qtd->qtd_list); | 45 | INIT_LIST_HEAD (&qtd->qtd_list); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | static struct ehci_qtd *ehci_qtd_alloc (struct ehci_hcd *ehci, int flags) | 48 | static struct ehci_qtd *ehci_qtd_alloc (struct ehci_hcd *ehci, gfp_t flags) |
| 49 | { | 49 | { |
| 50 | struct ehci_qtd *qtd; | 50 | struct ehci_qtd *qtd; |
| 51 | dma_addr_t dma; | 51 | dma_addr_t dma; |
| @@ -79,7 +79,7 @@ static void qh_destroy (struct kref *kref) | |||
| 79 | dma_pool_free (ehci->qh_pool, qh, qh->qh_dma); | 79 | dma_pool_free (ehci->qh_pool, qh, qh->qh_dma); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, int flags) | 82 | static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, gfp_t flags) |
| 83 | { | 83 | { |
| 84 | struct ehci_qh *qh; | 84 | struct ehci_qh *qh; |
| 85 | dma_addr_t dma; | 85 | dma_addr_t dma; |
| @@ -161,7 +161,7 @@ static void ehci_mem_cleanup (struct ehci_hcd *ehci) | |||
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | /* remember to add cleanup code (above) if you add anything here */ | 163 | /* remember to add cleanup code (above) if you add anything here */ |
| 164 | static int ehci_mem_init (struct ehci_hcd *ehci, int flags) | 164 | static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags) |
| 165 | { | 165 | { |
| 166 | int i; | 166 | int i; |
| 167 | 167 | ||
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 940d38ca7d91..5bb872c3496d 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
| @@ -477,7 +477,7 @@ qh_urb_transaction ( | |||
| 477 | struct ehci_hcd *ehci, | 477 | struct ehci_hcd *ehci, |
| 478 | struct urb *urb, | 478 | struct urb *urb, |
| 479 | struct list_head *head, | 479 | struct list_head *head, |
| 480 | int flags | 480 | gfp_t flags |
| 481 | ) { | 481 | ) { |
| 482 | struct ehci_qtd *qtd, *qtd_prev; | 482 | struct ehci_qtd *qtd, *qtd_prev; |
| 483 | dma_addr_t buf; | 483 | dma_addr_t buf; |
| @@ -629,7 +629,7 @@ static struct ehci_qh * | |||
| 629 | qh_make ( | 629 | qh_make ( |
| 630 | struct ehci_hcd *ehci, | 630 | struct ehci_hcd *ehci, |
| 631 | struct urb *urb, | 631 | struct urb *urb, |
| 632 | int flags | 632 | gfp_t flags |
| 633 | ) { | 633 | ) { |
| 634 | struct ehci_qh *qh = ehci_qh_alloc (ehci, flags); | 634 | struct ehci_qh *qh = ehci_qh_alloc (ehci, flags); |
| 635 | u32 info1 = 0, info2 = 0; | 635 | u32 info1 = 0, info2 = 0; |
| @@ -906,7 +906,7 @@ submit_async ( | |||
| 906 | struct usb_host_endpoint *ep, | 906 | struct usb_host_endpoint *ep, |
| 907 | struct urb *urb, | 907 | struct urb *urb, |
| 908 | struct list_head *qtd_list, | 908 | struct list_head *qtd_list, |
| 909 | unsigned mem_flags | 909 | gfp_t mem_flags |
| 910 | ) { | 910 | ) { |
| 911 | struct ehci_qtd *qtd; | 911 | struct ehci_qtd *qtd; |
| 912 | int epnum; | 912 | int epnum; |
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index ccc7300baa6d..f0c8aa1ccd5d 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
| @@ -589,7 +589,7 @@ static int intr_submit ( | |||
| 589 | struct usb_host_endpoint *ep, | 589 | struct usb_host_endpoint *ep, |
| 590 | struct urb *urb, | 590 | struct urb *urb, |
| 591 | struct list_head *qtd_list, | 591 | struct list_head *qtd_list, |
| 592 | unsigned mem_flags | 592 | gfp_t mem_flags |
| 593 | ) { | 593 | ) { |
| 594 | unsigned epnum; | 594 | unsigned epnum; |
| 595 | unsigned long flags; | 595 | unsigned long flags; |
| @@ -634,7 +634,7 @@ done: | |||
| 634 | /* ehci_iso_stream ops work with both ITD and SITD */ | 634 | /* ehci_iso_stream ops work with both ITD and SITD */ |
| 635 | 635 | ||
| 636 | static struct ehci_iso_stream * | 636 | static struct ehci_iso_stream * |
| 637 | iso_stream_alloc (unsigned mem_flags) | 637 | iso_stream_alloc (gfp_t mem_flags) |
| 638 | { | 638 | { |
| 639 | struct ehci_iso_stream *stream; | 639 | struct ehci_iso_stream *stream; |
| 640 | 640 | ||
| @@ -851,7 +851,7 @@ iso_stream_find (struct ehci_hcd *ehci, struct urb *urb) | |||
| 851 | /* ehci_iso_sched ops can be ITD-only or SITD-only */ | 851 | /* ehci_iso_sched ops can be ITD-only or SITD-only */ |
| 852 | 852 | ||
| 853 | static struct ehci_iso_sched * | 853 | static struct ehci_iso_sched * |
| 854 | iso_sched_alloc (unsigned packets, unsigned mem_flags) | 854 | iso_sched_alloc (unsigned packets, gfp_t mem_flags) |
| 855 | { | 855 | { |
| 856 | struct ehci_iso_sched *iso_sched; | 856 | struct ehci_iso_sched *iso_sched; |
| 857 | int size = sizeof *iso_sched; | 857 | int size = sizeof *iso_sched; |
| @@ -924,7 +924,7 @@ itd_urb_transaction ( | |||
| 924 | struct ehci_iso_stream *stream, | 924 | struct ehci_iso_stream *stream, |
| 925 | struct ehci_hcd *ehci, | 925 | struct ehci_hcd *ehci, |
| 926 | struct urb *urb, | 926 | struct urb *urb, |
| 927 | unsigned mem_flags | 927 | gfp_t mem_flags |
| 928 | ) | 928 | ) |
| 929 | { | 929 | { |
| 930 | struct ehci_itd *itd; | 930 | struct ehci_itd *itd; |
| @@ -1418,7 +1418,7 @@ itd_complete ( | |||
| 1418 | /*-------------------------------------------------------------------------*/ | 1418 | /*-------------------------------------------------------------------------*/ |
| 1419 | 1419 | ||
| 1420 | static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, | 1420 | static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, |
| 1421 | unsigned mem_flags) | 1421 | gfp_t mem_flags) |
| 1422 | { | 1422 | { |
| 1423 | int status = -EINVAL; | 1423 | int status = -EINVAL; |
| 1424 | unsigned long flags; | 1424 | unsigned long flags; |
| @@ -1529,7 +1529,7 @@ sitd_urb_transaction ( | |||
| 1529 | struct ehci_iso_stream *stream, | 1529 | struct ehci_iso_stream *stream, |
| 1530 | struct ehci_hcd *ehci, | 1530 | struct ehci_hcd *ehci, |
| 1531 | struct urb *urb, | 1531 | struct urb *urb, |
| 1532 | unsigned mem_flags | 1532 | gfp_t mem_flags |
| 1533 | ) | 1533 | ) |
| 1534 | { | 1534 | { |
| 1535 | struct ehci_sitd *sitd; | 1535 | struct ehci_sitd *sitd; |
| @@ -1779,7 +1779,7 @@ sitd_complete ( | |||
| 1779 | 1779 | ||
| 1780 | 1780 | ||
| 1781 | static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb, | 1781 | static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb, |
| 1782 | unsigned mem_flags) | 1782 | gfp_t mem_flags) |
| 1783 | { | 1783 | { |
| 1784 | int status = -EINVAL; | 1784 | int status = -EINVAL; |
| 1785 | unsigned long flags; | 1785 | unsigned long flags; |
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index e142056b0d2c..642f35068ce2 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
| @@ -694,7 +694,7 @@ static int balance(struct isp116x *isp116x, u16 period, u16 load) | |||
| 694 | 694 | ||
| 695 | static int isp116x_urb_enqueue(struct usb_hcd *hcd, | 695 | static int isp116x_urb_enqueue(struct usb_hcd *hcd, |
| 696 | struct usb_host_endpoint *hep, struct urb *urb, | 696 | struct usb_host_endpoint *hep, struct urb *urb, |
| 697 | unsigned mem_flags) | 697 | gfp_t mem_flags) |
| 698 | { | 698 | { |
| 699 | struct isp116x *isp116x = hcd_to_isp116x(hcd); | 699 | struct isp116x *isp116x = hcd_to_isp116x(hcd); |
| 700 | struct usb_device *udev = urb->dev; | 700 | struct usb_device *udev = urb->dev; |
| @@ -1774,15 +1774,12 @@ static int __init isp116x_probe(struct device *dev) | |||
| 1774 | /* | 1774 | /* |
| 1775 | Suspend of platform device | 1775 | Suspend of platform device |
| 1776 | */ | 1776 | */ |
| 1777 | static int isp116x_suspend(struct device *dev, pm_message_t state, u32 phase) | 1777 | static int isp116x_suspend(struct device *dev, pm_message_t state) |
| 1778 | { | 1778 | { |
| 1779 | int ret = 0; | 1779 | int ret = 0; |
| 1780 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 1780 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 1781 | 1781 | ||
| 1782 | VDBG("%s: state %x, phase %x\n", __func__, state, phase); | 1782 | VDBG("%s: state %x\n", __func__, state); |
| 1783 | |||
| 1784 | if (phase != SUSPEND_DISABLE && phase != SUSPEND_POWER_DOWN) | ||
| 1785 | return 0; | ||
| 1786 | 1783 | ||
| 1787 | ret = usb_suspend_device(hcd->self.root_hub, state); | 1784 | ret = usb_suspend_device(hcd->self.root_hub, state); |
| 1788 | if (!ret) { | 1785 | if (!ret) { |
| @@ -1797,15 +1794,12 @@ static int isp116x_suspend(struct device *dev, pm_message_t state, u32 phase) | |||
| 1797 | /* | 1794 | /* |
| 1798 | Resume platform device | 1795 | Resume platform device |
| 1799 | */ | 1796 | */ |
| 1800 | static int isp116x_resume(struct device *dev, u32 phase) | 1797 | static int isp116x_resume(struct device *dev) |
| 1801 | { | 1798 | { |
| 1802 | int ret = 0; | 1799 | int ret = 0; |
| 1803 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 1800 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 1804 | 1801 | ||
| 1805 | VDBG("%s: state %x, phase %x\n", __func__, dev->power.power_state, | 1802 | VDBG("%s: state %x\n", __func__, dev->power.power_state); |
| 1806 | phase); | ||
| 1807 | if (phase != RESUME_POWER_ON) | ||
| 1808 | return 0; | ||
| 1809 | 1803 | ||
| 1810 | ret = usb_resume_device(hcd->self.root_hub); | 1804 | ret = usb_resume_device(hcd->self.root_hub); |
| 1811 | if (!ret) { | 1805 | if (!ret) { |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 67c1aa5eb1c1..f8da8c7af7c6 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
| @@ -180,7 +180,7 @@ static int ohci_urb_enqueue ( | |||
| 180 | struct usb_hcd *hcd, | 180 | struct usb_hcd *hcd, |
| 181 | struct usb_host_endpoint *ep, | 181 | struct usb_host_endpoint *ep, |
| 182 | struct urb *urb, | 182 | struct urb *urb, |
| 183 | unsigned mem_flags | 183 | gfp_t mem_flags |
| 184 | ) { | 184 | ) { |
| 185 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 185 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
| 186 | struct ed *ed; | 186 | struct ed *ed; |
diff --git a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c index fd3c4d3714bd..9fb83dfb1eb4 100644 --- a/drivers/usb/host/ohci-mem.c +++ b/drivers/usb/host/ohci-mem.c | |||
| @@ -84,7 +84,7 @@ dma_to_td (struct ohci_hcd *hc, dma_addr_t td_dma) | |||
| 84 | 84 | ||
| 85 | /* TDs ... */ | 85 | /* TDs ... */ |
| 86 | static struct td * | 86 | static struct td * |
| 87 | td_alloc (struct ohci_hcd *hc, unsigned mem_flags) | 87 | td_alloc (struct ohci_hcd *hc, gfp_t mem_flags) |
| 88 | { | 88 | { |
| 89 | dma_addr_t dma; | 89 | dma_addr_t dma; |
| 90 | struct td *td; | 90 | struct td *td; |
| @@ -118,7 +118,7 @@ td_free (struct ohci_hcd *hc, struct td *td) | |||
| 118 | 118 | ||
| 119 | /* EDs ... */ | 119 | /* EDs ... */ |
| 120 | static struct ed * | 120 | static struct ed * |
| 121 | ed_alloc (struct ohci_hcd *hc, unsigned mem_flags) | 121 | ed_alloc (struct ohci_hcd *hc, gfp_t mem_flags) |
| 122 | { | 122 | { |
| 123 | dma_addr_t dma; | 123 | dma_addr_t dma; |
| 124 | struct ed *ed; | 124 | struct ed *ed; |
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index d8f3ba7ad52e..a574216625a0 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
| @@ -455,14 +455,11 @@ static int ohci_hcd_omap_drv_remove(struct device *dev) | |||
| 455 | 455 | ||
| 456 | #ifdef CONFIG_PM | 456 | #ifdef CONFIG_PM |
| 457 | 457 | ||
| 458 | static int ohci_omap_suspend(struct device *dev, pm_message_t message, u32 level) | 458 | static int ohci_omap_suspend(struct device *dev, pm_message_t message) |
| 459 | { | 459 | { |
| 460 | struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); | 460 | struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); |
| 461 | int status = -EINVAL; | 461 | int status = -EINVAL; |
| 462 | 462 | ||
| 463 | if (level != SUSPEND_POWER_DOWN) | ||
| 464 | return 0; | ||
| 465 | |||
| 466 | down(&ohci_to_hcd(ohci)->self.root_hub->serialize); | 463 | down(&ohci_to_hcd(ohci)->self.root_hub->serialize); |
| 467 | status = ohci_hub_suspend(ohci_to_hcd(ohci)); | 464 | status = ohci_hub_suspend(ohci_to_hcd(ohci)); |
| 468 | if (status == 0) { | 465 | if (status == 0) { |
| @@ -476,14 +473,11 @@ static int ohci_omap_suspend(struct device *dev, pm_message_t message, u32 level | |||
| 476 | return status; | 473 | return status; |
| 477 | } | 474 | } |
| 478 | 475 | ||
| 479 | static int ohci_omap_resume(struct device *dev, u32 level) | 476 | static int ohci_omap_resume(struct device *dev) |
| 480 | { | 477 | { |
| 481 | struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); | 478 | struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); |
| 482 | int status = 0; | 479 | int status = 0; |
| 483 | 480 | ||
| 484 | if (level != RESUME_POWER_ON) | ||
| 485 | return 0; | ||
| 486 | |||
| 487 | if (time_before(jiffies, ohci->next_statechange)) | 481 | if (time_before(jiffies, ohci->next_statechange)) |
| 488 | msleep(5); | 482 | msleep(5); |
| 489 | ohci->next_statechange = jiffies; | 483 | ohci->next_statechange = jiffies; |
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 2fdb262d4726..f042261ecb8e 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
| @@ -309,7 +309,7 @@ static int ohci_hcd_pxa27x_drv_remove(struct device *dev) | |||
| 309 | return 0; | 309 | return 0; |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state, u32 level) | 312 | static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state) |
| 313 | { | 313 | { |
| 314 | // struct platform_device *pdev = to_platform_device(dev); | 314 | // struct platform_device *pdev = to_platform_device(dev); |
| 315 | // struct usb_hcd *hcd = dev_get_drvdata(dev); | 315 | // struct usb_hcd *hcd = dev_get_drvdata(dev); |
| @@ -318,7 +318,7 @@ static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state, u | |||
| 318 | return 0; | 318 | return 0; |
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | static int ohci_hcd_pxa27x_drv_resume(struct device *dev, u32 level) | 321 | static int ohci_hcd_pxa27x_drv_resume(struct device *dev) |
| 322 | { | 322 | { |
| 323 | // struct platform_device *pdev = to_platform_device(dev); | 323 | // struct platform_device *pdev = to_platform_device(dev); |
| 324 | // struct usb_hcd *hcd = dev_get_drvdata(dev); | 324 | // struct usb_hcd *hcd = dev_get_drvdata(dev); |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index d42a15d10a46..b5e7a478bc01 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
| @@ -818,7 +818,7 @@ static int sl811h_urb_enqueue( | |||
| 818 | struct usb_hcd *hcd, | 818 | struct usb_hcd *hcd, |
| 819 | struct usb_host_endpoint *hep, | 819 | struct usb_host_endpoint *hep, |
| 820 | struct urb *urb, | 820 | struct urb *urb, |
| 821 | unsigned mem_flags | 821 | gfp_t mem_flags |
| 822 | ) { | 822 | ) { |
| 823 | struct sl811 *sl811 = hcd_to_sl811(hcd); | 823 | struct sl811 *sl811 = hcd_to_sl811(hcd); |
| 824 | struct usb_device *udev = urb->dev; | 824 | struct usb_device *udev = urb->dev; |
| @@ -1784,15 +1784,12 @@ sl811h_probe(struct device *dev) | |||
| 1784 | */ | 1784 | */ |
| 1785 | 1785 | ||
| 1786 | static int | 1786 | static int |
| 1787 | sl811h_suspend(struct device *dev, pm_message_t state, u32 phase) | 1787 | sl811h_suspend(struct device *dev, pm_message_t state) |
| 1788 | { | 1788 | { |
| 1789 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 1789 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 1790 | struct sl811 *sl811 = hcd_to_sl811(hcd); | 1790 | struct sl811 *sl811 = hcd_to_sl811(hcd); |
| 1791 | int retval = 0; | 1791 | int retval = 0; |
| 1792 | 1792 | ||
| 1793 | if (phase != SUSPEND_POWER_DOWN) | ||
| 1794 | return retval; | ||
| 1795 | |||
| 1796 | if (state.event == PM_EVENT_FREEZE) | 1793 | if (state.event == PM_EVENT_FREEZE) |
| 1797 | retval = sl811h_hub_suspend(hcd); | 1794 | retval = sl811h_hub_suspend(hcd); |
| 1798 | else if (state.event == PM_EVENT_SUSPEND) | 1795 | else if (state.event == PM_EVENT_SUSPEND) |
| @@ -1803,14 +1800,11 @@ sl811h_suspend(struct device *dev, pm_message_t state, u32 phase) | |||
| 1803 | } | 1800 | } |
| 1804 | 1801 | ||
| 1805 | static int | 1802 | static int |
| 1806 | sl811h_resume(struct device *dev, u32 phase) | 1803 | sl811h_resume(struct device *dev) |
| 1807 | { | 1804 | { |
| 1808 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 1805 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 1809 | struct sl811 *sl811 = hcd_to_sl811(hcd); | 1806 | struct sl811 *sl811 = hcd_to_sl811(hcd); |
| 1810 | 1807 | ||
| 1811 | if (phase != RESUME_POWER_ON) | ||
| 1812 | return 0; | ||
| 1813 | |||
| 1814 | /* with no "check to see if VBUS is still powered" board hook, | 1808 | /* with no "check to see if VBUS is still powered" board hook, |
| 1815 | * let's assume it'd only be powered to enable remote wakeup. | 1809 | * let's assume it'd only be powered to enable remote wakeup. |
| 1816 | */ | 1810 | */ |
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index ea0d168a8c67..4e0fbe2c1a9a 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c | |||
| @@ -1164,7 +1164,7 @@ static struct urb *uhci_find_urb_ep(struct uhci_hcd *uhci, struct urb *urb) | |||
| 1164 | 1164 | ||
| 1165 | static int uhci_urb_enqueue(struct usb_hcd *hcd, | 1165 | static int uhci_urb_enqueue(struct usb_hcd *hcd, |
| 1166 | struct usb_host_endpoint *ep, | 1166 | struct usb_host_endpoint *ep, |
| 1167 | struct urb *urb, unsigned mem_flags) | 1167 | struct urb *urb, gfp_t mem_flags) |
| 1168 | { | 1168 | { |
| 1169 | int ret; | 1169 | int ret; |
| 1170 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); | 1170 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); |
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c index 74f8760d7c07..a32558b4048e 100644 --- a/drivers/usb/input/acecad.c +++ b/drivers/usb/input/acecad.c | |||
| @@ -53,7 +53,7 @@ struct usb_acecad { | |||
| 53 | char name[128]; | 53 | char name[128]; |
| 54 | char phys[64]; | 54 | char phys[64]; |
| 55 | struct usb_device *usbdev; | 55 | struct usb_device *usbdev; |
| 56 | struct input_dev dev; | 56 | struct input_dev *input; |
| 57 | struct urb *irq; | 57 | struct urb *irq; |
| 58 | 58 | ||
| 59 | signed char *data; | 59 | signed char *data; |
| @@ -64,7 +64,7 @@ static void usb_acecad_irq(struct urb *urb, struct pt_regs *regs) | |||
| 64 | { | 64 | { |
| 65 | struct usb_acecad *acecad = urb->context; | 65 | struct usb_acecad *acecad = urb->context; |
| 66 | unsigned char *data = acecad->data; | 66 | unsigned char *data = acecad->data; |
| 67 | struct input_dev *dev = &acecad->dev; | 67 | struct input_dev *dev = acecad->input; |
| 68 | int prox, status; | 68 | int prox, status; |
| 69 | 69 | ||
| 70 | switch (urb->status) { | 70 | switch (urb->status) { |
| @@ -135,8 +135,8 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
| 135 | struct usb_host_interface *interface = intf->cur_altsetting; | 135 | struct usb_host_interface *interface = intf->cur_altsetting; |
| 136 | struct usb_endpoint_descriptor *endpoint; | 136 | struct usb_endpoint_descriptor *endpoint; |
| 137 | struct usb_acecad *acecad; | 137 | struct usb_acecad *acecad; |
| 138 | struct input_dev *input_dev; | ||
| 138 | int pipe, maxp; | 139 | int pipe, maxp; |
| 139 | char path[64]; | ||
| 140 | 140 | ||
| 141 | if (interface->desc.bNumEndpoints != 1) | 141 | if (interface->desc.bNumEndpoints != 1) |
| 142 | return -ENODEV; | 142 | return -ENODEV; |
| @@ -153,8 +153,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
| 153 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | 153 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
| 154 | 154 | ||
| 155 | acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); | 155 | acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); |
| 156 | if (!acecad) | 156 | input_dev = input_allocate_device(); |
| 157 | return -ENOMEM; | 157 | if (!acecad || !input_dev) |
| 158 | goto fail1; | ||
| 158 | 159 | ||
| 159 | acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); | 160 | acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); |
| 160 | if (!acecad->data) | 161 | if (!acecad->data) |
| @@ -164,6 +165,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
| 164 | if (!acecad->irq) | 165 | if (!acecad->irq) |
| 165 | goto fail2; | 166 | goto fail2; |
| 166 | 167 | ||
| 168 | acecad->usbdev = dev; | ||
| 169 | acecad->input = input_dev; | ||
| 170 | |||
| 167 | if (dev->manufacturer) | 171 | if (dev->manufacturer) |
| 168 | strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); | 172 | strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); |
| 169 | 173 | ||
| @@ -173,48 +177,48 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
| 173 | strlcat(acecad->name, dev->product, sizeof(acecad->name)); | 177 | strlcat(acecad->name, dev->product, sizeof(acecad->name)); |
| 174 | } | 178 | } |
| 175 | 179 | ||
| 176 | usb_make_path(dev, path, sizeof(path)); | 180 | usb_make_path(dev, acecad->phys, sizeof(acecad->phys)); |
| 177 | snprintf(acecad->phys, sizeof(acecad->phys), "%s/input0", path); | 181 | strlcat(acecad->phys, "/input0", sizeof(acecad->phys)); |
| 178 | 182 | ||
| 179 | acecad->usbdev = dev; | 183 | input_dev->name = acecad->name; |
| 184 | input_dev->phys = acecad->phys; | ||
| 185 | usb_to_input_id(dev, &input_dev->id); | ||
| 186 | input_dev->cdev.dev = &intf->dev; | ||
| 187 | input_dev->private = acecad; | ||
| 180 | 188 | ||
| 181 | acecad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 189 | input_dev->open = usb_acecad_open; |
| 182 | acecad->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | 190 | input_dev->close = usb_acecad_close; |
| 183 | acecad->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 191 | |
| 184 | acecad->dev.keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2); | 192 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
| 193 | input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
| 194 | input_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | ||
| 195 | input_dev->keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2); | ||
| 185 | 196 | ||
| 186 | switch (id->driver_info) { | 197 | switch (id->driver_info) { |
| 187 | case 0: | 198 | case 0: |
| 188 | acecad->dev.absmax[ABS_X] = 5000; | 199 | input_dev->absmax[ABS_X] = 5000; |
| 189 | acecad->dev.absmax[ABS_Y] = 3750; | 200 | input_dev->absmax[ABS_Y] = 3750; |
| 190 | acecad->dev.absmax[ABS_PRESSURE] = 512; | 201 | input_dev->absmax[ABS_PRESSURE] = 512; |
| 191 | if (!strlen(acecad->name)) | 202 | if (!strlen(acecad->name)) |
| 192 | snprintf(acecad->name, sizeof(acecad->name), | 203 | snprintf(acecad->name, sizeof(acecad->name), |
| 193 | "USB Acecad Flair Tablet %04x:%04x", | 204 | "USB Acecad Flair Tablet %04x:%04x", |
| 194 | dev->descriptor.idVendor, dev->descriptor.idProduct); | 205 | le16_to_cpu(dev->descriptor.idVendor), |
| 206 | le16_to_cpu(dev->descriptor.idProduct)); | ||
| 195 | break; | 207 | break; |
| 196 | case 1: | 208 | case 1: |
| 197 | acecad->dev.absmax[ABS_X] = 3000; | 209 | input_dev->absmax[ABS_X] = 3000; |
| 198 | acecad->dev.absmax[ABS_Y] = 2250; | 210 | input_dev->absmax[ABS_Y] = 2250; |
| 199 | acecad->dev.absmax[ABS_PRESSURE] = 1024; | 211 | input_dev->absmax[ABS_PRESSURE] = 1024; |
| 200 | if (!strlen(acecad->name)) | 212 | if (!strlen(acecad->name)) |
| 201 | snprintf(acecad->name, sizeof(acecad->name), | 213 | snprintf(acecad->name, sizeof(acecad->name), |
| 202 | "USB Acecad 302 Tablet %04x:%04x", | 214 | "USB Acecad 302 Tablet %04x:%04x", |
| 203 | dev->descriptor.idVendor, dev->descriptor.idProduct); | 215 | le16_to_cpu(dev->descriptor.idVendor), |
| 216 | le16_to_cpu(dev->descriptor.idProduct)); | ||
| 204 | break; | 217 | break; |
| 205 | } | 218 | } |
| 206 | 219 | ||
| 207 | acecad->dev.absfuzz[ABS_X] = 4; | 220 | input_dev->absfuzz[ABS_X] = 4; |
| 208 | acecad->dev.absfuzz[ABS_Y] = 4; | 221 | input_dev->absfuzz[ABS_Y] = 4; |
| 209 | |||
| 210 | acecad->dev.private = acecad; | ||
| 211 | acecad->dev.open = usb_acecad_open; | ||
| 212 | acecad->dev.close = usb_acecad_close; | ||
| 213 | |||
| 214 | acecad->dev.name = acecad->name; | ||
| 215 | acecad->dev.phys = acecad->phys; | ||
| 216 | usb_to_input_id(dev, &acecad->dev.id); | ||
| 217 | acecad->dev.dev = &intf->dev; | ||
| 218 | 222 | ||
| 219 | usb_fill_int_urb(acecad->irq, dev, pipe, | 223 | usb_fill_int_urb(acecad->irq, dev, pipe, |
| 220 | acecad->data, maxp > 8 ? 8 : maxp, | 224 | acecad->data, maxp > 8 ? 8 : maxp, |
| @@ -222,17 +226,15 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
| 222 | acecad->irq->transfer_dma = acecad->data_dma; | 226 | acecad->irq->transfer_dma = acecad->data_dma; |
| 223 | acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 227 | acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 224 | 228 | ||
| 225 | input_register_device(&acecad->dev); | 229 | input_register_device(acecad->input); |
| 226 | |||
| 227 | printk(KERN_INFO "input: %s with packet size %d on %s\n", | ||
| 228 | acecad->name, maxp, path); | ||
| 229 | 230 | ||
| 230 | usb_set_intfdata(intf, acecad); | 231 | usb_set_intfdata(intf, acecad); |
| 231 | 232 | ||
| 232 | return 0; | 233 | return 0; |
| 233 | 234 | ||
| 234 | fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); | 235 | fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); |
| 235 | fail1: kfree(acecad); | 236 | fail1: input_free_device(input_dev); |
| 237 | kfree(acecad); | ||
| 236 | return -ENOMEM; | 238 | return -ENOMEM; |
| 237 | } | 239 | } |
| 238 | 240 | ||
| @@ -243,7 +245,7 @@ static void usb_acecad_disconnect(struct usb_interface *intf) | |||
| 243 | usb_set_intfdata(intf, NULL); | 245 | usb_set_intfdata(intf, NULL); |
| 244 | if (acecad) { | 246 | if (acecad) { |
| 245 | usb_kill_urb(acecad->irq); | 247 | usb_kill_urb(acecad->irq); |
| 246 | input_unregister_device(&acecad->dev); | 248 | input_unregister_device(acecad->input); |
| 247 | usb_free_urb(acecad->irq); | 249 | usb_free_urb(acecad->irq); |
| 248 | usb_buffer_free(interface_to_usbdev(intf), 10, acecad->data, acecad->data_dma); | 250 | usb_buffer_free(interface_to_usbdev(intf), 10, acecad->data, acecad->data_dma); |
| 249 | kfree(acecad); | 251 | kfree(acecad); |
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c index cd0cbfe20723..1c5205321d83 100644 --- a/drivers/usb/input/aiptek.c +++ b/drivers/usb/input/aiptek.c | |||
| @@ -317,7 +317,7 @@ struct aiptek_settings { | |||
| 317 | }; | 317 | }; |
| 318 | 318 | ||
| 319 | struct aiptek { | 319 | struct aiptek { |
| 320 | struct input_dev inputdev; /* input device struct */ | 320 | struct input_dev *inputdev; /* input device struct */ |
| 321 | struct usb_device *usbdev; /* usb device struct */ | 321 | struct usb_device *usbdev; /* usb device struct */ |
| 322 | struct urb *urb; /* urb for incoming reports */ | 322 | struct urb *urb; /* urb for incoming reports */ |
| 323 | dma_addr_t data_dma; /* our dma stuffage */ | 323 | dma_addr_t data_dma; /* our dma stuffage */ |
| @@ -402,7 +402,7 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) | |||
| 402 | { | 402 | { |
| 403 | struct aiptek *aiptek = urb->context; | 403 | struct aiptek *aiptek = urb->context; |
| 404 | unsigned char *data = aiptek->data; | 404 | unsigned char *data = aiptek->data; |
| 405 | struct input_dev *inputdev = &aiptek->inputdev; | 405 | struct input_dev *inputdev = aiptek->inputdev; |
| 406 | int jitterable = 0; | 406 | int jitterable = 0; |
| 407 | int retval, macro, x, y, z, left, right, middle, p, dv, tip, bs, pck; | 407 | int retval, macro, x, y, z, left, right, middle, p, dv, tip, bs, pck; |
| 408 | 408 | ||
| @@ -955,20 +955,20 @@ static int aiptek_program_tablet(struct aiptek *aiptek) | |||
| 955 | /* Query getXextension */ | 955 | /* Query getXextension */ |
| 956 | if ((ret = aiptek_query(aiptek, 0x01, 0x00)) < 0) | 956 | if ((ret = aiptek_query(aiptek, 0x01, 0x00)) < 0) |
| 957 | return ret; | 957 | return ret; |
| 958 | aiptek->inputdev.absmin[ABS_X] = 0; | 958 | aiptek->inputdev->absmin[ABS_X] = 0; |
| 959 | aiptek->inputdev.absmax[ABS_X] = ret - 1; | 959 | aiptek->inputdev->absmax[ABS_X] = ret - 1; |
| 960 | 960 | ||
| 961 | /* Query getYextension */ | 961 | /* Query getYextension */ |
| 962 | if ((ret = aiptek_query(aiptek, 0x01, 0x01)) < 0) | 962 | if ((ret = aiptek_query(aiptek, 0x01, 0x01)) < 0) |
| 963 | return ret; | 963 | return ret; |
| 964 | aiptek->inputdev.absmin[ABS_Y] = 0; | 964 | aiptek->inputdev->absmin[ABS_Y] = 0; |
| 965 | aiptek->inputdev.absmax[ABS_Y] = ret - 1; | 965 | aiptek->inputdev->absmax[ABS_Y] = ret - 1; |
| 966 | 966 | ||
| 967 | /* Query getPressureLevels */ | 967 | /* Query getPressureLevels */ |
| 968 | if ((ret = aiptek_query(aiptek, 0x08, 0x00)) < 0) | 968 | if ((ret = aiptek_query(aiptek, 0x08, 0x00)) < 0) |
| 969 | return ret; | 969 | return ret; |
| 970 | aiptek->inputdev.absmin[ABS_PRESSURE] = 0; | 970 | aiptek->inputdev->absmin[ABS_PRESSURE] = 0; |
| 971 | aiptek->inputdev.absmax[ABS_PRESSURE] = ret - 1; | 971 | aiptek->inputdev->absmax[ABS_PRESSURE] = ret - 1; |
| 972 | 972 | ||
| 973 | /* Depending on whether we are in absolute or relative mode, we will | 973 | /* Depending on whether we are in absolute or relative mode, we will |
| 974 | * do a switchToTablet(absolute) or switchToMouse(relative) command. | 974 | * do a switchToTablet(absolute) or switchToMouse(relative) command. |
| @@ -1025,8 +1025,8 @@ static ssize_t show_tabletSize(struct device *dev, struct device_attribute *attr | |||
| 1025 | return 0; | 1025 | return 0; |
| 1026 | 1026 | ||
| 1027 | return snprintf(buf, PAGE_SIZE, "%dx%d\n", | 1027 | return snprintf(buf, PAGE_SIZE, "%dx%d\n", |
| 1028 | aiptek->inputdev.absmax[ABS_X] + 1, | 1028 | aiptek->inputdev->absmax[ABS_X] + 1, |
| 1029 | aiptek->inputdev.absmax[ABS_Y] + 1); | 1029 | aiptek->inputdev->absmax[ABS_Y] + 1); |
| 1030 | } | 1030 | } |
| 1031 | 1031 | ||
| 1032 | /* These structs define the sysfs files, param #1 is the name of the | 1032 | /* These structs define the sysfs files, param #1 is the name of the |
| @@ -1048,7 +1048,7 @@ static ssize_t show_tabletProductId(struct device *dev, struct device_attribute | |||
| 1048 | return 0; | 1048 | return 0; |
| 1049 | 1049 | ||
| 1050 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", | 1050 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", |
| 1051 | aiptek->inputdev.id.product); | 1051 | aiptek->inputdev->id.product); |
| 1052 | } | 1052 | } |
| 1053 | 1053 | ||
| 1054 | static DEVICE_ATTR(product_id, S_IRUGO, show_tabletProductId, NULL); | 1054 | static DEVICE_ATTR(product_id, S_IRUGO, show_tabletProductId, NULL); |
| @@ -1063,7 +1063,7 @@ static ssize_t show_tabletVendorId(struct device *dev, struct device_attribute * | |||
| 1063 | if (aiptek == NULL) | 1063 | if (aiptek == NULL) |
| 1064 | return 0; | 1064 | return 0; |
| 1065 | 1065 | ||
| 1066 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->inputdev.id.vendor); | 1066 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->inputdev->id.vendor); |
| 1067 | } | 1067 | } |
| 1068 | 1068 | ||
| 1069 | static DEVICE_ATTR(vendor_id, S_IRUGO, show_tabletVendorId, NULL); | 1069 | static DEVICE_ATTR(vendor_id, S_IRUGO, show_tabletVendorId, NULL); |
| @@ -1977,7 +1977,6 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1977 | struct input_dev *inputdev; | 1977 | struct input_dev *inputdev; |
| 1978 | struct input_handle *inputhandle; | 1978 | struct input_handle *inputhandle; |
| 1979 | struct list_head *node, *next; | 1979 | struct list_head *node, *next; |
| 1980 | char path[64 + 1]; | ||
| 1981 | int i; | 1980 | int i; |
| 1982 | int speeds[] = { 0, | 1981 | int speeds[] = { 0, |
| 1983 | AIPTEK_PROGRAMMABLE_DELAY_50, | 1982 | AIPTEK_PROGRAMMABLE_DELAY_50, |
| @@ -1996,24 +1995,26 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1996 | */ | 1995 | */ |
| 1997 | speeds[0] = programmableDelay; | 1996 | speeds[0] = programmableDelay; |
| 1998 | 1997 | ||
| 1999 | if ((aiptek = kmalloc(sizeof(struct aiptek), GFP_KERNEL)) == NULL) | 1998 | aiptek = kzalloc(sizeof(struct aiptek), GFP_KERNEL); |
| 2000 | return -ENOMEM; | 1999 | inputdev = input_allocate_device(); |
| 2001 | memset(aiptek, 0, sizeof(struct aiptek)); | 2000 | if (!aiptek || !inputdev) |
| 2001 | goto fail1; | ||
| 2002 | 2002 | ||
| 2003 | aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, | 2003 | aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, |
| 2004 | SLAB_ATOMIC, &aiptek->data_dma); | 2004 | SLAB_ATOMIC, &aiptek->data_dma); |
| 2005 | if (aiptek->data == NULL) { | 2005 | if (!aiptek->data) |
| 2006 | kfree(aiptek); | 2006 | goto fail1; |
| 2007 | return -ENOMEM; | ||
| 2008 | } | ||
| 2009 | 2007 | ||
| 2010 | aiptek->urb = usb_alloc_urb(0, GFP_KERNEL); | 2008 | aiptek->urb = usb_alloc_urb(0, GFP_KERNEL); |
| 2011 | if (aiptek->urb == NULL) { | 2009 | if (!aiptek->urb) |
| 2012 | usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, | 2010 | goto fail2; |
| 2013 | aiptek->data_dma); | 2011 | |
| 2014 | kfree(aiptek); | 2012 | aiptek->inputdev = inputdev; |
| 2015 | return -ENOMEM; | 2013 | aiptek->usbdev = usbdev; |
| 2016 | } | 2014 | aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber; |
| 2015 | aiptek->inDelay = 0; | ||
| 2016 | aiptek->endDelay = 0; | ||
| 2017 | aiptek->previousJitterable = 0; | ||
| 2017 | 2018 | ||
| 2018 | /* Set up the curSettings struct. Said struct contains the current | 2019 | /* Set up the curSettings struct. Said struct contains the current |
| 2019 | * programmable parameters. The newSetting struct contains changes | 2020 | * programmable parameters. The newSetting struct contains changes |
| @@ -2036,31 +2037,48 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 2036 | 2037 | ||
| 2037 | /* Both structs should have equivalent settings | 2038 | /* Both structs should have equivalent settings |
| 2038 | */ | 2039 | */ |
| 2039 | memcpy(&aiptek->newSetting, &aiptek->curSetting, | 2040 | aiptek->newSetting = aiptek->curSetting; |
| 2040 | sizeof(struct aiptek_settings)); | 2041 | |
| 2042 | /* Determine the usb devices' physical path. | ||
| 2043 | * Asketh not why we always pretend we're using "../input0", | ||
| 2044 | * but I suspect this will have to be refactored one | ||
| 2045 | * day if a single USB device can be a keyboard & a mouse | ||
| 2046 | * & a tablet, and the inputX number actually will tell | ||
| 2047 | * us something... | ||
| 2048 | */ | ||
| 2049 | usb_make_path(usbdev, aiptek->features.usbPath, | ||
| 2050 | sizeof(aiptek->features.usbPath)); | ||
| 2051 | strlcat(aiptek->features.usbPath, "/input0", | ||
| 2052 | sizeof(aiptek->features.usbPath)); | ||
| 2053 | |||
| 2054 | /* Set up client data, pointers to open and close routines | ||
| 2055 | * for the input device. | ||
| 2056 | */ | ||
| 2057 | inputdev->name = "Aiptek"; | ||
| 2058 | inputdev->phys = aiptek->features.usbPath; | ||
| 2059 | usb_to_input_id(usbdev, &inputdev->id); | ||
| 2060 | inputdev->cdev.dev = &intf->dev; | ||
| 2061 | inputdev->private = aiptek; | ||
| 2062 | inputdev->open = aiptek_open; | ||
| 2063 | inputdev->close = aiptek_close; | ||
| 2041 | 2064 | ||
| 2042 | /* Now program the capacities of the tablet, in terms of being | 2065 | /* Now program the capacities of the tablet, in terms of being |
| 2043 | * an input device. | 2066 | * an input device. |
| 2044 | */ | 2067 | */ |
| 2045 | aiptek->inputdev.evbit[0] |= BIT(EV_KEY) | 2068 | inputdev->evbit[0] |= BIT(EV_KEY) |
| 2046 | | BIT(EV_ABS) | 2069 | | BIT(EV_ABS) |
| 2047 | | BIT(EV_REL) | 2070 | | BIT(EV_REL) |
| 2048 | | BIT(EV_MSC); | 2071 | | BIT(EV_MSC); |
| 2049 | 2072 | ||
| 2050 | aiptek->inputdev.absbit[0] |= | 2073 | inputdev->absbit[0] |= BIT(ABS_MISC); |
| 2051 | (BIT(ABS_X) | | ||
| 2052 | BIT(ABS_Y) | | ||
| 2053 | BIT(ABS_PRESSURE) | | ||
| 2054 | BIT(ABS_TILT_X) | | ||
| 2055 | BIT(ABS_TILT_Y) | BIT(ABS_WHEEL) | BIT(ABS_MISC)); | ||
| 2056 | 2074 | ||
| 2057 | aiptek->inputdev.relbit[0] |= | 2075 | inputdev->relbit[0] |= |
| 2058 | (BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL) | BIT(REL_MISC)); | 2076 | (BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL) | BIT(REL_MISC)); |
| 2059 | 2077 | ||
| 2060 | aiptek->inputdev.keybit[LONG(BTN_LEFT)] |= | 2078 | inputdev->keybit[LONG(BTN_LEFT)] |= |
| 2061 | (BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE)); | 2079 | (BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE)); |
| 2062 | 2080 | ||
| 2063 | aiptek->inputdev.keybit[LONG(BTN_DIGI)] |= | 2081 | inputdev->keybit[LONG(BTN_DIGI)] |= |
| 2064 | (BIT(BTN_TOOL_PEN) | | 2082 | (BIT(BTN_TOOL_PEN) | |
| 2065 | BIT(BTN_TOOL_RUBBER) | | 2083 | BIT(BTN_TOOL_RUBBER) | |
| 2066 | BIT(BTN_TOOL_PENCIL) | | 2084 | BIT(BTN_TOOL_PENCIL) | |
| @@ -2070,70 +2088,26 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 2070 | BIT(BTN_TOOL_LENS) | | 2088 | BIT(BTN_TOOL_LENS) | |
| 2071 | BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2)); | 2089 | BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2)); |
| 2072 | 2090 | ||
| 2073 | aiptek->inputdev.mscbit[0] = BIT(MSC_SERIAL); | 2091 | inputdev->mscbit[0] = BIT(MSC_SERIAL); |
| 2074 | 2092 | ||
| 2075 | /* Programming the tablet macro keys needs to be done with a for loop | 2093 | /* Programming the tablet macro keys needs to be done with a for loop |
| 2076 | * as the keycodes are discontiguous. | 2094 | * as the keycodes are discontiguous. |
| 2077 | */ | 2095 | */ |
| 2078 | for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i) | 2096 | for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i) |
| 2079 | set_bit(macroKeyEvents[i], aiptek->inputdev.keybit); | 2097 | set_bit(macroKeyEvents[i], inputdev->keybit); |
| 2080 | |||
| 2081 | /* Set up client data, pointers to open and close routines | ||
| 2082 | * for the input device. | ||
| 2083 | */ | ||
| 2084 | aiptek->inputdev.private = aiptek; | ||
| 2085 | aiptek->inputdev.open = aiptek_open; | ||
| 2086 | aiptek->inputdev.close = aiptek_close; | ||
| 2087 | |||
| 2088 | /* Determine the usb devices' physical path. | ||
| 2089 | * Asketh not why we always pretend we're using "../input0", | ||
| 2090 | * but I suspect this will have to be refactored one | ||
| 2091 | * day if a single USB device can be a keyboard & a mouse | ||
| 2092 | * & a tablet, and the inputX number actually will tell | ||
| 2093 | * us something... | ||
| 2094 | */ | ||
| 2095 | if (usb_make_path(usbdev, path, 64) > 0) | ||
| 2096 | sprintf(aiptek->features.usbPath, "%s/input0", path); | ||
| 2097 | 2098 | ||
| 2098 | /* Program the input device coordinate capacities. We do not yet | 2099 | /* |
| 2100 | * Program the input device coordinate capacities. We do not yet | ||
| 2099 | * know what maximum X, Y, and Z values are, so we're putting fake | 2101 | * know what maximum X, Y, and Z values are, so we're putting fake |
| 2100 | * values in. Later, we'll ask the tablet to put in the correct | 2102 | * values in. Later, we'll ask the tablet to put in the correct |
| 2101 | * values. | 2103 | * values. |
| 2102 | */ | 2104 | */ |
| 2103 | aiptek->inputdev.absmin[ABS_X] = 0; | 2105 | input_set_abs_params(inputdev, ABS_X, 0, 2999, 0, 0); |
| 2104 | aiptek->inputdev.absmax[ABS_X] = 2999; | 2106 | input_set_abs_params(inputdev, ABS_X, 0, 2249, 0, 0); |
| 2105 | aiptek->inputdev.absmin[ABS_Y] = 0; | 2107 | input_set_abs_params(inputdev, ABS_PRESSURE, 0, 511, 0, 0); |
| 2106 | aiptek->inputdev.absmax[ABS_Y] = 2249; | 2108 | input_set_abs_params(inputdev, ABS_TILT_X, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0); |
| 2107 | aiptek->inputdev.absmin[ABS_PRESSURE] = 0; | 2109 | input_set_abs_params(inputdev, ABS_TILT_Y, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0); |
| 2108 | aiptek->inputdev.absmax[ABS_PRESSURE] = 511; | 2110 | input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0); |
| 2109 | aiptek->inputdev.absmin[ABS_TILT_X] = AIPTEK_TILT_MIN; | ||
| 2110 | aiptek->inputdev.absmax[ABS_TILT_X] = AIPTEK_TILT_MAX; | ||
| 2111 | aiptek->inputdev.absmin[ABS_TILT_Y] = AIPTEK_TILT_MIN; | ||
| 2112 | aiptek->inputdev.absmax[ABS_TILT_Y] = AIPTEK_TILT_MAX; | ||
| 2113 | aiptek->inputdev.absmin[ABS_WHEEL] = AIPTEK_WHEEL_MIN; | ||
| 2114 | aiptek->inputdev.absmax[ABS_WHEEL] = AIPTEK_WHEEL_MAX - 1; | ||
| 2115 | aiptek->inputdev.absfuzz[ABS_X] = 0; | ||
| 2116 | aiptek->inputdev.absfuzz[ABS_Y] = 0; | ||
| 2117 | aiptek->inputdev.absfuzz[ABS_PRESSURE] = 0; | ||
| 2118 | aiptek->inputdev.absfuzz[ABS_TILT_X] = 0; | ||
| 2119 | aiptek->inputdev.absfuzz[ABS_TILT_Y] = 0; | ||
| 2120 | aiptek->inputdev.absfuzz[ABS_WHEEL] = 0; | ||
| 2121 | aiptek->inputdev.absflat[ABS_X] = 0; | ||
| 2122 | aiptek->inputdev.absflat[ABS_Y] = 0; | ||
| 2123 | aiptek->inputdev.absflat[ABS_PRESSURE] = 0; | ||
| 2124 | aiptek->inputdev.absflat[ABS_TILT_X] = 0; | ||
| 2125 | aiptek->inputdev.absflat[ABS_TILT_Y] = 0; | ||
| 2126 | aiptek->inputdev.absflat[ABS_WHEEL] = 0; | ||
| 2127 | aiptek->inputdev.name = "Aiptek"; | ||
| 2128 | aiptek->inputdev.phys = aiptek->features.usbPath; | ||
| 2129 | usb_to_input_id(usbdev, &aiptek->inputdev.id); | ||
| 2130 | aiptek->inputdev.dev = &intf->dev; | ||
| 2131 | |||
| 2132 | aiptek->usbdev = usbdev; | ||
| 2133 | aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber; | ||
| 2134 | aiptek->inDelay = 0; | ||
| 2135 | aiptek->endDelay = 0; | ||
| 2136 | aiptek->previousJitterable = 0; | ||
| 2137 | 2111 | ||
| 2138 | endpoint = &intf->altsetting[0].endpoint[0].desc; | 2112 | endpoint = &intf->altsetting[0].endpoint[0].desc; |
| 2139 | 2113 | ||
| @@ -2150,28 +2124,6 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 2150 | aiptek->urb->transfer_dma = aiptek->data_dma; | 2124 | aiptek->urb->transfer_dma = aiptek->data_dma; |
| 2151 | aiptek->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 2125 | aiptek->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 2152 | 2126 | ||
| 2153 | /* Register the tablet as an Input Device | ||
| 2154 | */ | ||
| 2155 | input_register_device(&aiptek->inputdev); | ||
| 2156 | |||
| 2157 | /* We now will look for the evdev device which is mapped to | ||
| 2158 | * the tablet. The partial name is kept in the link list of | ||
| 2159 | * input_handles associated with this input device. | ||
| 2160 | * What identifies an evdev input_handler is that it begins | ||
| 2161 | * with 'event', continues with a digit, and that in turn | ||
| 2162 | * is mapped to /{devfs}/input/eventN. | ||
| 2163 | */ | ||
| 2164 | inputdev = &aiptek->inputdev; | ||
| 2165 | list_for_each_safe(node, next, &inputdev->h_list) { | ||
| 2166 | inputhandle = to_handle(node); | ||
| 2167 | if (strncmp(inputhandle->name, "event", 5) == 0) { | ||
| 2168 | strcpy(aiptek->features.inputPath, inputhandle->name); | ||
| 2169 | break; | ||
| 2170 | } | ||
| 2171 | } | ||
| 2172 | |||
| 2173 | info("input: Aiptek on %s (%s)\n", path, aiptek->features.inputPath); | ||
| 2174 | |||
| 2175 | /* Program the tablet. This sets the tablet up in the mode | 2127 | /* Program the tablet. This sets the tablet up in the mode |
| 2176 | * specified in newSetting, and also queries the tablet's | 2128 | * specified in newSetting, and also queries the tablet's |
| 2177 | * physical capacities. | 2129 | * physical capacities. |
| @@ -2186,13 +2138,32 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 2186 | for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) { | 2138 | for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) { |
| 2187 | aiptek->curSetting.programmableDelay = speeds[i]; | 2139 | aiptek->curSetting.programmableDelay = speeds[i]; |
| 2188 | (void)aiptek_program_tablet(aiptek); | 2140 | (void)aiptek_program_tablet(aiptek); |
| 2189 | if (aiptek->inputdev.absmax[ABS_X] > 0) { | 2141 | if (aiptek->inputdev->absmax[ABS_X] > 0) { |
| 2190 | info("input: Aiptek using %d ms programming speed\n", | 2142 | info("input: Aiptek using %d ms programming speed\n", |
| 2191 | aiptek->curSetting.programmableDelay); | 2143 | aiptek->curSetting.programmableDelay); |
| 2192 | break; | 2144 | break; |
| 2193 | } | 2145 | } |
| 2194 | } | 2146 | } |
| 2195 | 2147 | ||
| 2148 | /* Register the tablet as an Input Device | ||
| 2149 | */ | ||
| 2150 | input_register_device(aiptek->inputdev); | ||
| 2151 | |||
| 2152 | /* We now will look for the evdev device which is mapped to | ||
| 2153 | * the tablet. The partial name is kept in the link list of | ||
| 2154 | * input_handles associated with this input device. | ||
| 2155 | * What identifies an evdev input_handler is that it begins | ||
| 2156 | * with 'event', continues with a digit, and that in turn | ||
| 2157 | * is mapped to /{devfs}/input/eventN. | ||
| 2158 | */ | ||
| 2159 | list_for_each_safe(node, next, &inputdev->h_list) { | ||
| 2160 | inputhandle = to_handle(node); | ||
| 2161 | if (strncmp(inputhandle->name, "event", 5) == 0) { | ||
| 2162 | strcpy(aiptek->features.inputPath, inputhandle->name); | ||
| 2163 | break; | ||
| 2164 | } | ||
| 2165 | } | ||
| 2166 | |||
| 2196 | /* Associate this driver's struct with the usb interface. | 2167 | /* Associate this driver's struct with the usb interface. |
| 2197 | */ | 2168 | */ |
| 2198 | usb_set_intfdata(intf, aiptek); | 2169 | usb_set_intfdata(intf, aiptek); |
| @@ -2207,6 +2178,12 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 2207 | info("aiptek: error loading 'evdev' module"); | 2178 | info("aiptek: error loading 'evdev' module"); |
| 2208 | 2179 | ||
| 2209 | return 0; | 2180 | return 0; |
| 2181 | |||
| 2182 | fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, | ||
| 2183 | aiptek->data_dma); | ||
| 2184 | fail1: input_free_device(inputdev); | ||
| 2185 | kfree(aiptek); | ||
| 2186 | return -ENOMEM; | ||
| 2210 | } | 2187 | } |
| 2211 | 2188 | ||
| 2212 | /* Forward declaration */ | 2189 | /* Forward declaration */ |
| @@ -2234,7 +2211,7 @@ static void aiptek_disconnect(struct usb_interface *intf) | |||
| 2234 | /* Free & unhook everything from the system. | 2211 | /* Free & unhook everything from the system. |
| 2235 | */ | 2212 | */ |
| 2236 | usb_kill_urb(aiptek->urb); | 2213 | usb_kill_urb(aiptek->urb); |
| 2237 | input_unregister_device(&aiptek->inputdev); | 2214 | input_unregister_device(aiptek->inputdev); |
| 2238 | aiptek_delete_files(&intf->dev); | 2215 | aiptek_delete_files(&intf->dev); |
| 2239 | usb_free_urb(aiptek->urb); | 2216 | usb_free_urb(aiptek->urb); |
| 2240 | usb_buffer_free(interface_to_usbdev(intf), | 2217 | usb_buffer_free(interface_to_usbdev(intf), |
diff --git a/drivers/usb/input/appletouch.c b/drivers/usb/input/appletouch.c index e03c1c567a14..15840db092a5 100644 --- a/drivers/usb/input/appletouch.c +++ b/drivers/usb/input/appletouch.c | |||
| @@ -39,7 +39,7 @@ | |||
| 39 | #define APPLE_VENDOR_ID 0x05AC | 39 | #define APPLE_VENDOR_ID 0x05AC |
| 40 | 40 | ||
| 41 | #define ATP_DEVICE(prod) \ | 41 | #define ATP_DEVICE(prod) \ |
| 42 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ | 42 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ |
| 43 | USB_DEVICE_ID_MATCH_INT_CLASS | \ | 43 | USB_DEVICE_ID_MATCH_INT_CLASS | \ |
| 44 | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ | 44 | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ |
| 45 | .idVendor = APPLE_VENDOR_ID, \ | 45 | .idVendor = APPLE_VENDOR_ID, \ |
| @@ -78,9 +78,9 @@ MODULE_DEVICE_TABLE (usb, atp_table); | |||
| 78 | * We try to keep the touchpad aspect ratio while still doing only simple | 78 | * We try to keep the touchpad aspect ratio while still doing only simple |
| 79 | * arithmetics. | 79 | * arithmetics. |
| 80 | * The factors below give coordinates like: | 80 | * The factors below give coordinates like: |
| 81 | * 0 <= x < 960 on 12" and 15" Powerbooks | 81 | * 0 <= x < 960 on 12" and 15" Powerbooks |
| 82 | * 0 <= x < 1600 on 17" Powerbooks | 82 | * 0 <= x < 1600 on 17" Powerbooks |
| 83 | * 0 <= y < 646 | 83 | * 0 <= y < 646 |
| 84 | */ | 84 | */ |
| 85 | #define ATP_XFACT 64 | 85 | #define ATP_XFACT 64 |
| 86 | #define ATP_YFACT 43 | 86 | #define ATP_YFACT 43 |
| @@ -93,11 +93,12 @@ MODULE_DEVICE_TABLE (usb, atp_table); | |||
| 93 | 93 | ||
| 94 | /* Structure to hold all of our device specific stuff */ | 94 | /* Structure to hold all of our device specific stuff */ |
| 95 | struct atp { | 95 | struct atp { |
| 96 | char phys[64]; | ||
| 96 | struct usb_device * udev; /* usb device */ | 97 | struct usb_device * udev; /* usb device */ |
| 97 | struct urb * urb; /* usb request block */ | 98 | struct urb * urb; /* usb request block */ |
| 98 | signed char * data; /* transferred data */ | 99 | signed char * data; /* transferred data */ |
| 99 | int open; /* non-zero if opened */ | 100 | int open; /* non-zero if opened */ |
| 100 | struct input_dev input; /* input dev */ | 101 | struct input_dev *input; /* input dev */ |
| 101 | int valid; /* are the sensors valid ? */ | 102 | int valid; /* are the sensors valid ? */ |
| 102 | int x_old; /* last reported x/y, */ | 103 | int x_old; /* last reported x/y, */ |
| 103 | int y_old; /* used for smoothing */ | 104 | int y_old; /* used for smoothing */ |
| @@ -114,11 +115,11 @@ struct atp { | |||
| 114 | int i; \ | 115 | int i; \ |
| 115 | printk("appletouch: %s %lld", msg, (long long)jiffies); \ | 116 | printk("appletouch: %s %lld", msg, (long long)jiffies); \ |
| 116 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) \ | 117 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) \ |
| 117 | printk(" %02x", tab[i]); \ | 118 | printk(" %02x", tab[i]); \ |
| 118 | printk("\n"); \ | 119 | printk("\n"); \ |
| 119 | } | 120 | } |
| 120 | 121 | ||
| 121 | #define dprintk(format, a...) \ | 122 | #define dprintk(format, a...) \ |
| 122 | do { \ | 123 | do { \ |
| 123 | if (debug) printk(format, ##a); \ | 124 | if (debug) printk(format, ##a); \ |
| 124 | } while (0) | 125 | } while (0) |
| @@ -219,8 +220,8 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs) | |||
| 219 | for (i = 16; i < ATP_XSENSORS; i++) | 220 | for (i = 16; i < ATP_XSENSORS; i++) |
| 220 | if (dev->xy_cur[i]) { | 221 | if (dev->xy_cur[i]) { |
| 221 | printk("appletouch: 17\" model detected.\n"); | 222 | printk("appletouch: 17\" model detected.\n"); |
| 222 | input_set_abs_params(&dev->input, ABS_X, 0, | 223 | input_set_abs_params(dev->input, ABS_X, 0, |
| 223 | (ATP_XSENSORS - 1) * | 224 | (ATP_XSENSORS - 1) * |
| 224 | ATP_XFACT - 1, | 225 | ATP_XFACT - 1, |
| 225 | ATP_FUZZ, 0); | 226 | ATP_FUZZ, 0); |
| 226 | break; | 227 | break; |
| @@ -260,12 +261,12 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs) | |||
| 260 | "Xz: %3d Yz: %3d\n", | 261 | "Xz: %3d Yz: %3d\n", |
| 261 | x, y, x_z, y_z); | 262 | x, y, x_z, y_z); |
| 262 | 263 | ||
| 263 | input_report_key(&dev->input, BTN_TOUCH, 1); | 264 | input_report_key(dev->input, BTN_TOUCH, 1); |
| 264 | input_report_abs(&dev->input, ABS_X, x); | 265 | input_report_abs(dev->input, ABS_X, x); |
| 265 | input_report_abs(&dev->input, ABS_Y, y); | 266 | input_report_abs(dev->input, ABS_Y, y); |
| 266 | input_report_abs(&dev->input, ABS_PRESSURE, | 267 | input_report_abs(dev->input, ABS_PRESSURE, |
| 267 | min(ATP_PRESSURE, x_z + y_z)); | 268 | min(ATP_PRESSURE, x_z + y_z)); |
| 268 | atp_report_fingers(&dev->input, max(x_f, y_f)); | 269 | atp_report_fingers(dev->input, max(x_f, y_f)); |
| 269 | } | 270 | } |
| 270 | dev->x_old = x; | 271 | dev->x_old = x; |
| 271 | dev->y_old = y; | 272 | dev->y_old = y; |
| @@ -273,17 +274,17 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs) | |||
| 273 | else if (!x && !y) { | 274 | else if (!x && !y) { |
| 274 | 275 | ||
| 275 | dev->x_old = dev->y_old = -1; | 276 | dev->x_old = dev->y_old = -1; |
| 276 | input_report_key(&dev->input, BTN_TOUCH, 0); | 277 | input_report_key(dev->input, BTN_TOUCH, 0); |
| 277 | input_report_abs(&dev->input, ABS_PRESSURE, 0); | 278 | input_report_abs(dev->input, ABS_PRESSURE, 0); |
| 278 | atp_report_fingers(&dev->input, 0); | 279 | atp_report_fingers(dev->input, 0); |
| 279 | 280 | ||
| 280 | /* reset the accumulator on release */ | 281 | /* reset the accumulator on release */ |
| 281 | memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); | 282 | memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); |
| 282 | } | 283 | } |
| 283 | 284 | ||
| 284 | input_report_key(&dev->input, BTN_LEFT, !!dev->data[80]); | 285 | input_report_key(dev->input, BTN_LEFT, !!dev->data[80]); |
| 285 | 286 | ||
| 286 | input_sync(&dev->input); | 287 | input_sync(dev->input); |
| 287 | 288 | ||
| 288 | exit: | 289 | exit: |
| 289 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); | 290 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); |
| @@ -314,21 +315,14 @@ static void atp_close(struct input_dev *input) | |||
| 314 | 315 | ||
| 315 | static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) | 316 | static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) |
| 316 | { | 317 | { |
| 317 | struct atp *dev = NULL; | 318 | struct atp *dev; |
| 319 | struct input_dev *input_dev; | ||
| 320 | struct usb_device *udev = interface_to_usbdev(iface); | ||
| 318 | struct usb_host_interface *iface_desc; | 321 | struct usb_host_interface *iface_desc; |
| 319 | struct usb_endpoint_descriptor *endpoint; | 322 | struct usb_endpoint_descriptor *endpoint; |
| 320 | int int_in_endpointAddr = 0; | 323 | int int_in_endpointAddr = 0; |
| 321 | int i, retval = -ENOMEM; | 324 | int i, retval = -ENOMEM; |
| 322 | 325 | ||
| 323 | /* allocate memory for our device state and initialize it */ | ||
| 324 | dev = kmalloc(sizeof(struct atp), GFP_KERNEL); | ||
| 325 | if (dev == NULL) { | ||
| 326 | err("Out of memory"); | ||
| 327 | goto err_kmalloc; | ||
| 328 | } | ||
| 329 | memset(dev, 0, sizeof(struct atp)); | ||
| 330 | |||
| 331 | dev->udev = interface_to_usbdev(iface); | ||
| 332 | 326 | ||
| 333 | /* set up the endpoint information */ | 327 | /* set up the endpoint information */ |
| 334 | /* use only the first interrupt-in endpoint */ | 328 | /* use only the first interrupt-in endpoint */ |
| @@ -345,70 +339,82 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id | |||
| 345 | } | 339 | } |
| 346 | } | 340 | } |
| 347 | if (!int_in_endpointAddr) { | 341 | if (!int_in_endpointAddr) { |
| 348 | retval = -EIO; | ||
| 349 | err("Could not find int-in endpoint"); | 342 | err("Could not find int-in endpoint"); |
| 350 | goto err_endpoint; | 343 | return -EIO; |
| 351 | } | 344 | } |
| 352 | 345 | ||
| 353 | /* save our data pointer in this interface device */ | 346 | /* allocate memory for our device state and initialize it */ |
| 354 | usb_set_intfdata(iface, dev); | 347 | dev = kzalloc(sizeof(struct atp), GFP_KERNEL); |
| 348 | input_dev = input_allocate_device(); | ||
| 349 | if (!dev || !input_dev) { | ||
| 350 | err("Out of memory"); | ||
| 351 | goto err_free_devs; | ||
| 352 | } | ||
| 353 | |||
| 354 | dev->udev = udev; | ||
| 355 | dev->input = input_dev; | ||
| 355 | 356 | ||
| 356 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); | 357 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); |
| 357 | if (!dev->urb) { | 358 | if (!dev->urb) { |
| 358 | retval = -ENOMEM; | 359 | retval = -ENOMEM; |
| 359 | goto err_usballoc; | 360 | goto err_free_devs; |
| 360 | } | 361 | } |
| 362 | |||
| 361 | dev->data = usb_buffer_alloc(dev->udev, ATP_DATASIZE, GFP_KERNEL, | 363 | dev->data = usb_buffer_alloc(dev->udev, ATP_DATASIZE, GFP_KERNEL, |
| 362 | &dev->urb->transfer_dma); | 364 | &dev->urb->transfer_dma); |
| 363 | if (!dev->data) { | 365 | if (!dev->data) { |
| 364 | retval = -ENOMEM; | 366 | retval = -ENOMEM; |
| 365 | goto err_usbbufalloc; | 367 | goto err_free_urb; |
| 366 | } | 368 | } |
| 367 | usb_fill_int_urb(dev->urb, dev->udev, | 369 | |
| 368 | usb_rcvintpipe(dev->udev, int_in_endpointAddr), | 370 | usb_fill_int_urb(dev->urb, udev, |
| 371 | usb_rcvintpipe(udev, int_in_endpointAddr), | ||
| 369 | dev->data, ATP_DATASIZE, atp_complete, dev, 1); | 372 | dev->data, ATP_DATASIZE, atp_complete, dev, 1); |
| 370 | 373 | ||
| 371 | init_input_dev(&dev->input); | 374 | usb_make_path(udev, dev->phys, sizeof(dev->phys)); |
| 372 | dev->input.name = "appletouch"; | 375 | strlcat(dev->phys, "/input0", sizeof(dev->phys)); |
| 373 | dev->input.dev = &iface->dev; | 376 | |
| 374 | dev->input.private = dev; | 377 | input_dev->name = "appletouch"; |
| 375 | dev->input.open = atp_open; | 378 | input_dev->phys = dev->phys; |
| 376 | dev->input.close = atp_close; | 379 | usb_to_input_id(dev->udev, &input_dev->id); |
| 380 | input_dev->cdev.dev = &iface->dev; | ||
| 377 | 381 | ||
| 378 | usb_to_input_id(dev->udev, &dev->input.id); | 382 | input_dev->private = dev; |
| 383 | input_dev->open = atp_open; | ||
| 384 | input_dev->close = atp_close; | ||
| 379 | 385 | ||
| 380 | set_bit(EV_ABS, dev->input.evbit); | 386 | set_bit(EV_ABS, input_dev->evbit); |
| 381 | 387 | ||
| 382 | /* | 388 | /* |
| 383 | * 12" and 15" Powerbooks only have 16 x sensors, | 389 | * 12" and 15" Powerbooks only have 16 x sensors, |
| 384 | * 17" models are detected later. | 390 | * 17" models are detected later. |
| 385 | */ | 391 | */ |
| 386 | input_set_abs_params(&dev->input, ABS_X, 0, | 392 | input_set_abs_params(input_dev, ABS_X, 0, |
| 387 | (16 - 1) * ATP_XFACT - 1, ATP_FUZZ, 0); | 393 | (16 - 1) * ATP_XFACT - 1, ATP_FUZZ, 0); |
| 388 | input_set_abs_params(&dev->input, ABS_Y, 0, | 394 | input_set_abs_params(input_dev, ABS_Y, 0, |
| 389 | (ATP_YSENSORS - 1) * ATP_YFACT - 1, ATP_FUZZ, 0); | 395 | (ATP_YSENSORS - 1) * ATP_YFACT - 1, ATP_FUZZ, 0); |
| 390 | input_set_abs_params(&dev->input, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); | 396 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); |
| 391 | 397 | ||
| 392 | set_bit(EV_KEY, dev->input.evbit); | 398 | set_bit(EV_KEY, input_dev->evbit); |
| 393 | set_bit(BTN_TOUCH, dev->input.keybit); | 399 | set_bit(BTN_TOUCH, input_dev->keybit); |
| 394 | set_bit(BTN_TOOL_FINGER, dev->input.keybit); | 400 | set_bit(BTN_TOOL_FINGER, input_dev->keybit); |
| 395 | set_bit(BTN_TOOL_DOUBLETAP, dev->input.keybit); | 401 | set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); |
| 396 | set_bit(BTN_TOOL_TRIPLETAP, dev->input.keybit); | 402 | set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); |
| 397 | set_bit(BTN_LEFT, dev->input.keybit); | 403 | set_bit(BTN_LEFT, input_dev->keybit); |
| 398 | 404 | ||
| 399 | input_register_device(&dev->input); | 405 | input_register_device(dev->input); |
| 400 | 406 | ||
| 401 | printk(KERN_INFO "input: appletouch connected\n"); | 407 | /* save our data pointer in this interface device */ |
| 408 | usb_set_intfdata(iface, dev); | ||
| 402 | 409 | ||
| 403 | return 0; | 410 | return 0; |
| 404 | 411 | ||
| 405 | err_usbbufalloc: | 412 | err_free_urb: |
| 406 | usb_free_urb(dev->urb); | 413 | usb_free_urb(dev->urb); |
| 407 | err_usballoc: | 414 | err_free_devs: |
| 408 | usb_set_intfdata(iface, NULL); | 415 | usb_set_intfdata(iface, NULL); |
| 409 | err_endpoint: | ||
| 410 | kfree(dev); | 416 | kfree(dev); |
| 411 | err_kmalloc: | 417 | input_free_device(input_dev); |
| 412 | return retval; | 418 | return retval; |
| 413 | } | 419 | } |
| 414 | 420 | ||
| @@ -419,7 +425,7 @@ static void atp_disconnect(struct usb_interface *iface) | |||
| 419 | usb_set_intfdata(iface, NULL); | 425 | usb_set_intfdata(iface, NULL); |
| 420 | if (dev) { | 426 | if (dev) { |
| 421 | usb_kill_urb(dev->urb); | 427 | usb_kill_urb(dev->urb); |
| 422 | input_unregister_device(&dev->input); | 428 | input_unregister_device(dev->input); |
| 423 | usb_free_urb(dev->urb); | 429 | usb_free_urb(dev->urb); |
| 424 | usb_buffer_free(dev->udev, ATP_DATASIZE, | 430 | usb_buffer_free(dev->udev, ATP_DATASIZE, |
| 425 | dev->data, dev->urb->transfer_dma); | 431 | dev->data, dev->urb->transfer_dma); |
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index fd99681ee483..9a2a47db9494 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c | |||
| @@ -112,7 +112,6 @@ | |||
| 112 | 112 | ||
| 113 | #define NAME_BUFSIZE 80 /* size of product name, path buffers */ | 113 | #define NAME_BUFSIZE 80 /* size of product name, path buffers */ |
| 114 | #define DATA_BUFSIZE 63 /* size of URB data buffers */ | 114 | #define DATA_BUFSIZE 63 /* size of URB data buffers */ |
| 115 | #define ATI_INPUTNUM 1 /* Which input device to register as */ | ||
| 116 | 115 | ||
| 117 | static unsigned long channel_mask; | 116 | static unsigned long channel_mask; |
| 118 | module_param(channel_mask, ulong, 0444); | 117 | module_param(channel_mask, ulong, 0444); |
| @@ -162,7 +161,7 @@ static char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; | |||
| 162 | static DECLARE_MUTEX(disconnect_sem); | 161 | static DECLARE_MUTEX(disconnect_sem); |
| 163 | 162 | ||
| 164 | struct ati_remote { | 163 | struct ati_remote { |
| 165 | struct input_dev idev; | 164 | struct input_dev *idev; |
| 166 | struct usb_device *udev; | 165 | struct usb_device *udev; |
| 167 | struct usb_interface *interface; | 166 | struct usb_interface *interface; |
| 168 | 167 | ||
| @@ -198,15 +197,13 @@ struct ati_remote { | |||
| 198 | #define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/ | 197 | #define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/ |
| 199 | 198 | ||
| 200 | /* Translation table from hardware messages to input events. */ | 199 | /* Translation table from hardware messages to input events. */ |
| 201 | static struct | 200 | static struct { |
| 202 | { | ||
| 203 | short kind; | 201 | short kind; |
| 204 | unsigned char data1, data2; | 202 | unsigned char data1, data2; |
| 205 | int type; | 203 | int type; |
| 206 | unsigned int code; | 204 | unsigned int code; |
| 207 | int value; | 205 | int value; |
| 208 | } ati_remote_tbl[] = | 206 | } ati_remote_tbl[] = { |
| 209 | { | ||
| 210 | /* Directional control pad axes */ | 207 | /* Directional control pad axes */ |
| 211 | {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */ | 208 | {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */ |
| 212 | {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */ | 209 | {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */ |
| @@ -286,7 +283,6 @@ static struct | |||
| 286 | 283 | ||
| 287 | /* Local function prototypes */ | 284 | /* Local function prototypes */ |
| 288 | static void ati_remote_dump (unsigned char *data, unsigned int actual_length); | 285 | static void ati_remote_dump (unsigned char *data, unsigned int actual_length); |
| 289 | static void ati_remote_delete (struct ati_remote *dev); | ||
| 290 | static int ati_remote_open (struct input_dev *inputdev); | 286 | static int ati_remote_open (struct input_dev *inputdev); |
| 291 | static void ati_remote_close (struct input_dev *inputdev); | 287 | static void ati_remote_close (struct input_dev *inputdev); |
| 292 | static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data); | 288 | static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data); |
| @@ -428,7 +424,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) | |||
| 428 | { | 424 | { |
| 429 | struct ati_remote *ati_remote = urb->context; | 425 | struct ati_remote *ati_remote = urb->context; |
| 430 | unsigned char *data= ati_remote->inbuf; | 426 | unsigned char *data= ati_remote->inbuf; |
| 431 | struct input_dev *dev = &ati_remote->idev; | 427 | struct input_dev *dev = ati_remote->idev; |
| 432 | int index, acc; | 428 | int index, acc; |
| 433 | int remote_num; | 429 | int remote_num; |
| 434 | 430 | ||
| @@ -587,38 +583,55 @@ static void ati_remote_irq_in(struct urb *urb, struct pt_regs *regs) | |||
| 587 | } | 583 | } |
| 588 | 584 | ||
| 589 | /* | 585 | /* |
| 590 | * ati_remote_delete | 586 | * ati_remote_alloc_buffers |
| 591 | */ | 587 | */ |
| 592 | static void ati_remote_delete(struct ati_remote *ati_remote) | 588 | static int ati_remote_alloc_buffers(struct usb_device *udev, |
| 589 | struct ati_remote *ati_remote) | ||
| 593 | { | 590 | { |
| 594 | if (ati_remote->irq_urb) | 591 | ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, |
| 595 | usb_kill_urb(ati_remote->irq_urb); | 592 | &ati_remote->inbuf_dma); |
| 593 | if (!ati_remote->inbuf) | ||
| 594 | return -1; | ||
| 596 | 595 | ||
| 597 | if (ati_remote->out_urb) | 596 | ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, |
| 598 | usb_kill_urb(ati_remote->out_urb); | 597 | &ati_remote->outbuf_dma); |
| 598 | if (!ati_remote->outbuf) | ||
| 599 | return -1; | ||
| 599 | 600 | ||
| 600 | input_unregister_device(&ati_remote->idev); | 601 | ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); |
| 602 | if (!ati_remote->irq_urb) | ||
| 603 | return -1; | ||
| 601 | 604 | ||
| 602 | if (ati_remote->inbuf) | 605 | ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL); |
| 603 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | 606 | if (!ati_remote->out_urb) |
| 604 | ati_remote->inbuf, ati_remote->inbuf_dma); | 607 | return -1; |
| 605 | 608 | ||
| 606 | if (ati_remote->outbuf) | 609 | return 0; |
| 607 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | 610 | } |
| 608 | ati_remote->outbuf, ati_remote->outbuf_dma); | ||
| 609 | 611 | ||
| 612 | /* | ||
| 613 | * ati_remote_free_buffers | ||
| 614 | */ | ||
| 615 | static void ati_remote_free_buffers(struct ati_remote *ati_remote) | ||
| 616 | { | ||
| 610 | if (ati_remote->irq_urb) | 617 | if (ati_remote->irq_urb) |
| 611 | usb_free_urb(ati_remote->irq_urb); | 618 | usb_free_urb(ati_remote->irq_urb); |
| 612 | 619 | ||
| 613 | if (ati_remote->out_urb) | 620 | if (ati_remote->out_urb) |
| 614 | usb_free_urb(ati_remote->out_urb); | 621 | usb_free_urb(ati_remote->out_urb); |
| 615 | 622 | ||
| 616 | kfree(ati_remote); | 623 | if (ati_remote->inbuf) |
| 624 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | ||
| 625 | ati_remote->inbuf, ati_remote->inbuf_dma); | ||
| 626 | |||
| 627 | if (ati_remote->outbuf) | ||
| 628 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | ||
| 629 | ati_remote->inbuf, ati_remote->outbuf_dma); | ||
| 617 | } | 630 | } |
| 618 | 631 | ||
| 619 | static void ati_remote_input_init(struct ati_remote *ati_remote) | 632 | static void ati_remote_input_init(struct ati_remote *ati_remote) |
| 620 | { | 633 | { |
| 621 | struct input_dev *idev = &(ati_remote->idev); | 634 | struct input_dev *idev = ati_remote->idev; |
| 622 | int i; | 635 | int i; |
| 623 | 636 | ||
| 624 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 637 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
| @@ -637,7 +650,7 @@ static void ati_remote_input_init(struct ati_remote *ati_remote) | |||
| 637 | idev->phys = ati_remote->phys; | 650 | idev->phys = ati_remote->phys; |
| 638 | 651 | ||
| 639 | usb_to_input_id(ati_remote->udev, &idev->id); | 652 | usb_to_input_id(ati_remote->udev, &idev->id); |
| 640 | idev->dev = &ati_remote->udev->dev; | 653 | idev->cdev.dev = &ati_remote->udev->dev; |
| 641 | } | 654 | } |
| 642 | 655 | ||
| 643 | static int ati_remote_initialize(struct ati_remote *ati_remote) | 656 | static int ati_remote_initialize(struct ati_remote *ati_remote) |
| @@ -674,7 +687,7 @@ static int ati_remote_initialize(struct ati_remote *ati_remote) | |||
| 674 | (ati_remote_sendpacket(ati_remote, 0x8007, init2))) { | 687 | (ati_remote_sendpacket(ati_remote, 0x8007, init2))) { |
| 675 | dev_err(&ati_remote->interface->dev, | 688 | dev_err(&ati_remote->interface->dev, |
| 676 | "Initializing ati_remote hardware failed.\n"); | 689 | "Initializing ati_remote hardware failed.\n"); |
| 677 | return 1; | 690 | return -EIO; |
| 678 | } | 691 | } |
| 679 | 692 | ||
| 680 | return 0; | 693 | return 0; |
| @@ -686,95 +699,83 @@ static int ati_remote_initialize(struct ati_remote *ati_remote) | |||
| 686 | static int ati_remote_probe(struct usb_interface *interface, const struct usb_device_id *id) | 699 | static int ati_remote_probe(struct usb_interface *interface, const struct usb_device_id *id) |
| 687 | { | 700 | { |
| 688 | struct usb_device *udev = interface_to_usbdev(interface); | 701 | struct usb_device *udev = interface_to_usbdev(interface); |
| 689 | struct ati_remote *ati_remote = NULL; | 702 | struct usb_host_interface *iface_host = interface->cur_altsetting; |
| 690 | struct usb_host_interface *iface_host; | 703 | struct usb_endpoint_descriptor *endpoint_in, *endpoint_out; |
| 691 | int retval = -ENOMEM; | 704 | struct ati_remote *ati_remote; |
| 692 | char path[64]; | 705 | struct input_dev *input_dev; |
| 693 | 706 | int err = -ENOMEM; | |
| 694 | /* Allocate and clear an ati_remote struct */ | ||
| 695 | if (!(ati_remote = kmalloc(sizeof (struct ati_remote), GFP_KERNEL))) | ||
| 696 | return -ENOMEM; | ||
| 697 | memset(ati_remote, 0x00, sizeof (struct ati_remote)); | ||
| 698 | 707 | ||
| 699 | iface_host = interface->cur_altsetting; | ||
| 700 | if (iface_host->desc.bNumEndpoints != 2) { | 708 | if (iface_host->desc.bNumEndpoints != 2) { |
| 701 | err("%s: Unexpected desc.bNumEndpoints\n", __FUNCTION__); | 709 | err("%s: Unexpected desc.bNumEndpoints\n", __FUNCTION__); |
| 702 | retval = -ENODEV; | 710 | return -ENODEV; |
| 703 | goto error; | ||
| 704 | } | 711 | } |
| 705 | 712 | ||
| 706 | ati_remote->endpoint_in = &(iface_host->endpoint[0].desc); | 713 | endpoint_in = &iface_host->endpoint[0].desc; |
| 707 | ati_remote->endpoint_out = &(iface_host->endpoint[1].desc); | 714 | endpoint_out = &iface_host->endpoint[1].desc; |
| 708 | ati_remote->udev = udev; | ||
| 709 | ati_remote->interface = interface; | ||
| 710 | 715 | ||
| 711 | if (!(ati_remote->endpoint_in->bEndpointAddress & 0x80)) { | 716 | if (!(endpoint_in->bEndpointAddress & USB_DIR_IN)) { |
| 712 | err("%s: Unexpected endpoint_in->bEndpointAddress\n", __FUNCTION__); | 717 | err("%s: Unexpected endpoint_in->bEndpointAddress\n", __FUNCTION__); |
| 713 | retval = -ENODEV; | 718 | return -ENODEV; |
| 714 | goto error; | ||
| 715 | } | 719 | } |
| 716 | if ((ati_remote->endpoint_in->bmAttributes & 3) != 3) { | 720 | if ((endpoint_in->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) { |
| 717 | err("%s: Unexpected endpoint_in->bmAttributes\n", __FUNCTION__); | 721 | err("%s: Unexpected endpoint_in->bmAttributes\n", __FUNCTION__); |
| 718 | retval = -ENODEV; | 722 | return -ENODEV; |
| 719 | goto error; | ||
| 720 | } | 723 | } |
| 721 | if (le16_to_cpu(ati_remote->endpoint_in->wMaxPacketSize) == 0) { | 724 | if (le16_to_cpu(endpoint_in->wMaxPacketSize) == 0) { |
| 722 | err("%s: endpoint_in message size==0? \n", __FUNCTION__); | 725 | err("%s: endpoint_in message size==0? \n", __FUNCTION__); |
| 723 | retval = -ENODEV; | 726 | return -ENODEV; |
| 724 | goto error; | ||
| 725 | } | 727 | } |
| 726 | 728 | ||
| 727 | /* Allocate URB buffers, URBs */ | 729 | ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL); |
| 728 | ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, | 730 | input_dev = input_allocate_device(); |
| 729 | &ati_remote->inbuf_dma); | 731 | if (!ati_remote || !input_dev) |
| 730 | if (!ati_remote->inbuf) | 732 | goto fail1; |
| 731 | goto error; | ||
| 732 | 733 | ||
| 733 | ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, | 734 | /* Allocate URB buffers, URBs */ |
| 734 | &ati_remote->outbuf_dma); | 735 | if (ati_remote_alloc_buffers(udev, ati_remote)) |
| 735 | if (!ati_remote->outbuf) | 736 | goto fail2; |
| 736 | goto error; | ||
| 737 | 737 | ||
| 738 | ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); | 738 | ati_remote->endpoint_in = endpoint_in; |
| 739 | if (!ati_remote->irq_urb) | 739 | ati_remote->endpoint_out = endpoint_out; |
| 740 | goto error; | 740 | ati_remote->udev = udev; |
| 741 | ati_remote->idev = input_dev; | ||
| 742 | ati_remote->interface = interface; | ||
| 741 | 743 | ||
| 742 | ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL); | 744 | usb_make_path(udev, ati_remote->phys, sizeof(ati_remote->phys)); |
| 743 | if (!ati_remote->out_urb) | 745 | strlcpy(ati_remote->phys, "/input0", sizeof(ati_remote->phys)); |
| 744 | goto error; | ||
| 745 | 746 | ||
| 746 | usb_make_path(udev, path, NAME_BUFSIZE); | ||
| 747 | sprintf(ati_remote->phys, "%s/input%d", path, ATI_INPUTNUM); | ||
| 748 | if (udev->manufacturer) | 747 | if (udev->manufacturer) |
| 749 | strcat(ati_remote->name, udev->manufacturer); | 748 | strlcpy(ati_remote->name, udev->manufacturer, sizeof(ati_remote->name)); |
| 750 | 749 | ||
| 751 | if (udev->product) | 750 | if (udev->product) |
| 752 | sprintf(ati_remote->name, "%s %s", ati_remote->name, udev->product); | 751 | snprintf(ati_remote->name, sizeof(ati_remote->name), |
| 752 | "%s %s", ati_remote->name, udev->product); | ||
| 753 | 753 | ||
| 754 | if (!strlen(ati_remote->name)) | 754 | if (!strlen(ati_remote->name)) |
| 755 | sprintf(ati_remote->name, DRIVER_DESC "(%04x,%04x)", | 755 | snprintf(ati_remote->name, sizeof(ati_remote->name), |
| 756 | DRIVER_DESC "(%04x,%04x)", | ||
| 756 | le16_to_cpu(ati_remote->udev->descriptor.idVendor), | 757 | le16_to_cpu(ati_remote->udev->descriptor.idVendor), |
| 757 | le16_to_cpu(ati_remote->udev->descriptor.idProduct)); | 758 | le16_to_cpu(ati_remote->udev->descriptor.idProduct)); |
| 758 | 759 | ||
| 760 | ati_remote_input_init(ati_remote); | ||
| 761 | |||
| 759 | /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ | 762 | /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ |
| 760 | retval = ati_remote_initialize(ati_remote); | 763 | err = ati_remote_initialize(ati_remote); |
| 761 | if (retval) | 764 | if (err) |
| 762 | goto error; | 765 | goto fail3; |
| 763 | 766 | ||
| 764 | /* Set up and register input device */ | 767 | /* Set up and register input device */ |
| 765 | ati_remote_input_init(ati_remote); | 768 | input_register_device(ati_remote->idev); |
| 766 | input_register_device(&ati_remote->idev); | ||
| 767 | |||
| 768 | dev_info(&ati_remote->interface->dev, "Input registered: %s on %s\n", | ||
| 769 | ati_remote->name, path); | ||
| 770 | 769 | ||
| 771 | usb_set_intfdata(interface, ati_remote); | 770 | usb_set_intfdata(interface, ati_remote); |
| 771 | return 0; | ||
| 772 | 772 | ||
| 773 | error: | 773 | fail3: usb_kill_urb(ati_remote->irq_urb); |
| 774 | if (retval) | 774 | usb_kill_urb(ati_remote->out_urb); |
| 775 | ati_remote_delete(ati_remote); | 775 | fail2: ati_remote_free_buffers(ati_remote); |
| 776 | 776 | fail1: input_free_device(input_dev); | |
| 777 | return retval; | 777 | kfree(ati_remote); |
| 778 | return err; | ||
| 778 | } | 779 | } |
| 779 | 780 | ||
| 780 | /* | 781 | /* |
| @@ -791,7 +792,11 @@ static void ati_remote_disconnect(struct usb_interface *interface) | |||
| 791 | return; | 792 | return; |
| 792 | } | 793 | } |
| 793 | 794 | ||
| 794 | ati_remote_delete(ati_remote); | 795 | usb_kill_urb(ati_remote->irq_urb); |
| 796 | usb_kill_urb(ati_remote->out_urb); | ||
| 797 | input_unregister_device(ati_remote->idev); | ||
| 798 | ati_remote_free_buffers(ati_remote); | ||
| 799 | kfree(ati_remote); | ||
| 795 | } | 800 | } |
| 796 | 801 | ||
| 797 | /* | 802 | /* |
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 41f92b924761..411a0645a7a3 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
| @@ -1619,8 +1619,8 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
| 1619 | struct hid_descriptor *hdesc; | 1619 | struct hid_descriptor *hdesc; |
| 1620 | struct hid_device *hid; | 1620 | struct hid_device *hid; |
| 1621 | unsigned quirks = 0, rsize = 0; | 1621 | unsigned quirks = 0, rsize = 0; |
| 1622 | char *buf, *rdesc; | 1622 | char *rdesc; |
| 1623 | int n, insize = 0; | 1623 | int n, len, insize = 0; |
| 1624 | 1624 | ||
| 1625 | for (n = 0; hid_blacklist[n].idVendor; n++) | 1625 | for (n = 0; hid_blacklist[n].idVendor; n++) |
| 1626 | if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && | 1626 | if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && |
| @@ -1630,10 +1630,11 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
| 1630 | if (quirks & HID_QUIRK_IGNORE) | 1630 | if (quirks & HID_QUIRK_IGNORE) |
| 1631 | return NULL; | 1631 | return NULL; |
| 1632 | 1632 | ||
| 1633 | if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && ((!interface->desc.bNumEndpoints) || | 1633 | if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && |
| 1634 | usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { | 1634 | (!interface->desc.bNumEndpoints || |
| 1635 | dbg("class descriptor not present\n"); | 1635 | usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { |
| 1636 | return NULL; | 1636 | dbg("class descriptor not present\n"); |
| 1637 | return NULL; | ||
| 1637 | } | 1638 | } |
| 1638 | 1639 | ||
| 1639 | for (n = 0; n < hdesc->bNumDescriptors; n++) | 1640 | for (n = 0; n < hdesc->bNumDescriptors; n++) |
| @@ -1749,32 +1750,34 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
| 1749 | 1750 | ||
| 1750 | hid->name[0] = 0; | 1751 | hid->name[0] = 0; |
| 1751 | 1752 | ||
| 1752 | if (!(buf = kmalloc(64, GFP_KERNEL))) | 1753 | if (dev->manufacturer) |
| 1753 | goto fail; | 1754 | strlcpy(hid->name, dev->manufacturer, sizeof(hid->name)); |
| 1755 | |||
| 1756 | if (dev->product) { | ||
| 1757 | if (dev->manufacturer) | ||
| 1758 | strlcat(hid->name, " ", sizeof(hid->name)); | ||
| 1759 | strlcat(hid->name, dev->product, sizeof(hid->name)); | ||
| 1760 | } | ||
| 1761 | |||
| 1762 | if (!strlen(hid->name)) | ||
| 1763 | snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x", | ||
| 1764 | le16_to_cpu(dev->descriptor.idVendor), | ||
| 1765 | le16_to_cpu(dev->descriptor.idProduct)); | ||
| 1754 | 1766 | ||
| 1755 | if (dev->manufacturer) { | 1767 | usb_make_path(dev, hid->phys, sizeof(hid->phys)); |
| 1756 | strcat(hid->name, dev->manufacturer); | 1768 | strlcat(hid->phys, "/input", sizeof(hid->phys)); |
| 1757 | if (dev->product) | 1769 | len = strlen(hid->phys); |
| 1758 | snprintf(hid->name, 64, "%s %s", hid->name, dev->product); | 1770 | if (len < sizeof(hid->phys) - 1) |
| 1759 | } else if (dev->product) { | 1771 | snprintf(hid->phys + len, sizeof(hid->phys) - len, |
| 1760 | snprintf(hid->name, 128, "%s", dev->product); | 1772 | "%d", intf->altsetting[0].desc.bInterfaceNumber); |
| 1761 | } else | ||
| 1762 | snprintf(hid->name, 128, "%04x:%04x", | ||
| 1763 | le16_to_cpu(dev->descriptor.idVendor), | ||
| 1764 | le16_to_cpu(dev->descriptor.idProduct)); | ||
| 1765 | |||
| 1766 | usb_make_path(dev, buf, 64); | ||
| 1767 | snprintf(hid->phys, 64, "%s/input%d", buf, | ||
| 1768 | intf->altsetting[0].desc.bInterfaceNumber); | ||
| 1769 | 1773 | ||
| 1770 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) | 1774 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) |
| 1771 | hid->uniq[0] = 0; | 1775 | hid->uniq[0] = 0; |
| 1772 | 1776 | ||
| 1773 | kfree(buf); | ||
| 1774 | |||
| 1775 | hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); | 1777 | hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); |
| 1776 | if (!hid->urbctrl) | 1778 | if (!hid->urbctrl) |
| 1777 | goto fail; | 1779 | goto fail; |
| 1780 | |||
| 1778 | usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr, | 1781 | usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr, |
| 1779 | hid->ctrlbuf, 1, hid_ctrl, hid); | 1782 | hid->ctrlbuf, 1, hid_ctrl, hid); |
| 1780 | hid->urbctrl->setup_dma = hid->cr_dma; | 1783 | hid->urbctrl->setup_dma = hid->cr_dma; |
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 0b6452248a39..9ff25eb520a6 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c | |||
| @@ -76,8 +76,8 @@ static struct { | |||
| 76 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, | 76 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, |
| 77 | struct hid_usage *usage) | 77 | struct hid_usage *usage) |
| 78 | { | 78 | { |
| 79 | struct input_dev *input = &hidinput->input; | 79 | struct input_dev *input = hidinput->input; |
| 80 | struct hid_device *device = hidinput->input.private; | 80 | struct hid_device *device = input->private; |
| 81 | int max = 0, code; | 81 | int max = 0, code; |
| 82 | unsigned long *bit = NULL; | 82 | unsigned long *bit = NULL; |
| 83 | 83 | ||
| @@ -461,7 +461,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct | |||
| 461 | 461 | ||
| 462 | if (!field->hidinput) | 462 | if (!field->hidinput) |
| 463 | return; | 463 | return; |
| 464 | input = &field->hidinput->input; | 464 | |
| 465 | input = field->hidinput->input; | ||
| 465 | 466 | ||
| 466 | input_regs(input, regs); | 467 | input_regs(input, regs); |
| 467 | 468 | ||
| @@ -533,13 +534,10 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct | |||
| 533 | 534 | ||
| 534 | void hidinput_report_event(struct hid_device *hid, struct hid_report *report) | 535 | void hidinput_report_event(struct hid_device *hid, struct hid_report *report) |
| 535 | { | 536 | { |
| 536 | struct list_head *lh; | ||
| 537 | struct hid_input *hidinput; | 537 | struct hid_input *hidinput; |
| 538 | 538 | ||
| 539 | list_for_each (lh, &hid->inputs) { | 539 | list_for_each_entry(hidinput, &hid->inputs, list) |
| 540 | hidinput = list_entry(lh, struct hid_input, list); | 540 | input_sync(hidinput->input); |
| 541 | input_sync(&hidinput->input); | ||
| 542 | } | ||
| 543 | } | 541 | } |
| 544 | 542 | ||
| 545 | static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field) | 543 | static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field) |
| @@ -604,6 +602,7 @@ int hidinput_connect(struct hid_device *hid) | |||
| 604 | struct usb_device *dev = hid->dev; | 602 | struct usb_device *dev = hid->dev; |
| 605 | struct hid_report *report; | 603 | struct hid_report *report; |
| 606 | struct hid_input *hidinput = NULL; | 604 | struct hid_input *hidinput = NULL; |
| 605 | struct input_dev *input_dev; | ||
| 607 | int i, j, k; | 606 | int i, j, k; |
| 608 | 607 | ||
| 609 | INIT_LIST_HEAD(&hid->inputs); | 608 | INIT_LIST_HEAD(&hid->inputs); |
| @@ -624,25 +623,28 @@ int hidinput_connect(struct hid_device *hid) | |||
| 624 | continue; | 623 | continue; |
| 625 | 624 | ||
| 626 | if (!hidinput) { | 625 | if (!hidinput) { |
| 627 | hidinput = kmalloc(sizeof(*hidinput), GFP_KERNEL); | 626 | hidinput = kzalloc(sizeof(*hidinput), GFP_KERNEL); |
| 628 | if (!hidinput) { | 627 | input_dev = input_allocate_device(); |
| 628 | if (!hidinput || !input_dev) { | ||
| 629 | kfree(hidinput); | ||
| 630 | input_free_device(input_dev); | ||
| 629 | err("Out of memory during hid input probe"); | 631 | err("Out of memory during hid input probe"); |
| 630 | return -1; | 632 | return -1; |
| 631 | } | 633 | } |
| 632 | memset(hidinput, 0, sizeof(*hidinput)); | ||
| 633 | 634 | ||
| 634 | list_add_tail(&hidinput->list, &hid->inputs); | 635 | input_dev->private = hid; |
| 636 | input_dev->event = hidinput_input_event; | ||
| 637 | input_dev->open = hidinput_open; | ||
| 638 | input_dev->close = hidinput_close; | ||
| 635 | 639 | ||
| 636 | hidinput->input.private = hid; | 640 | input_dev->name = hid->name; |
| 637 | hidinput->input.event = hidinput_input_event; | 641 | input_dev->phys = hid->phys; |
| 638 | hidinput->input.open = hidinput_open; | 642 | input_dev->uniq = hid->uniq; |
| 639 | hidinput->input.close = hidinput_close; | 643 | usb_to_input_id(dev, &input_dev->id); |
| 644 | input_dev->cdev.dev = &hid->intf->dev; | ||
| 640 | 645 | ||
| 641 | hidinput->input.name = hid->name; | 646 | hidinput->input = input_dev; |
| 642 | hidinput->input.phys = hid->phys; | 647 | list_add_tail(&hidinput->list, &hid->inputs); |
| 643 | hidinput->input.uniq = hid->uniq; | ||
| 644 | usb_to_input_id(dev, &hidinput->input.id); | ||
| 645 | hidinput->input.dev = &hid->intf->dev; | ||
| 646 | } | 648 | } |
| 647 | 649 | ||
| 648 | for (i = 0; i < report->maxfield; i++) | 650 | for (i = 0; i < report->maxfield; i++) |
| @@ -657,7 +659,7 @@ int hidinput_connect(struct hid_device *hid) | |||
| 657 | * UGCI) cram a lot of unrelated inputs into the | 659 | * UGCI) cram a lot of unrelated inputs into the |
| 658 | * same interface. */ | 660 | * same interface. */ |
| 659 | hidinput->report = report; | 661 | hidinput->report = report; |
| 660 | input_register_device(&hidinput->input); | 662 | input_register_device(hidinput->input); |
| 661 | hidinput = NULL; | 663 | hidinput = NULL; |
| 662 | } | 664 | } |
| 663 | } | 665 | } |
| @@ -667,7 +669,7 @@ int hidinput_connect(struct hid_device *hid) | |||
| 667 | * only useful in this case, and not for multi-input quirks. */ | 669 | * only useful in this case, and not for multi-input quirks. */ |
| 668 | if (hidinput) { | 670 | if (hidinput) { |
| 669 | hid_ff_init(hid); | 671 | hid_ff_init(hid); |
| 670 | input_register_device(&hidinput->input); | 672 | input_register_device(hidinput->input); |
| 671 | } | 673 | } |
| 672 | 674 | ||
| 673 | return 0; | 675 | return 0; |
| @@ -675,13 +677,11 @@ int hidinput_connect(struct hid_device *hid) | |||
| 675 | 677 | ||
| 676 | void hidinput_disconnect(struct hid_device *hid) | 678 | void hidinput_disconnect(struct hid_device *hid) |
| 677 | { | 679 | { |
| 678 | struct list_head *lh, *next; | 680 | struct hid_input *hidinput, *next; |
| 679 | struct hid_input *hidinput; | ||
| 680 | 681 | ||
| 681 | list_for_each_safe(lh, next, &hid->inputs) { | 682 | list_for_each_entry_safe(hidinput, next, &hid->inputs, list) { |
| 682 | hidinput = list_entry(lh, struct hid_input, list); | ||
| 683 | input_unregister_device(&hidinput->input); | ||
| 684 | list_del(&hidinput->list); | 683 | list_del(&hidinput->list); |
| 684 | input_unregister_device(hidinput->input); | ||
| 685 | kfree(hidinput); | 685 | kfree(hidinput); |
| 686 | } | 686 | } |
| 687 | } | 687 | } |
diff --git a/drivers/usb/input/hid-lgff.c b/drivers/usb/input/hid-lgff.c index 0c4c77aa31ea..f82c9c9e5d51 100644 --- a/drivers/usb/input/hid-lgff.c +++ b/drivers/usb/input/hid-lgff.c | |||
| @@ -255,22 +255,19 @@ static void hid_lgff_input_init(struct hid_device* hid) | |||
| 255 | u16 idVendor = le16_to_cpu(hid->dev->descriptor.idVendor); | 255 | u16 idVendor = le16_to_cpu(hid->dev->descriptor.idVendor); |
| 256 | u16 idProduct = le16_to_cpu(hid->dev->descriptor.idProduct); | 256 | u16 idProduct = le16_to_cpu(hid->dev->descriptor.idProduct); |
| 257 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | 257 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
| 258 | struct input_dev *input_dev = hidinput->input; | ||
| 258 | 259 | ||
| 259 | while (dev->idVendor && (idVendor != dev->idVendor || idProduct != dev->idProduct)) | 260 | while (dev->idVendor && (idVendor != dev->idVendor || idProduct != dev->idProduct)) |
| 260 | dev++; | 261 | dev++; |
| 261 | 262 | ||
| 262 | ff = dev->ff; | 263 | for (ff = dev->ff; *ff >= 0; ff++) |
| 264 | set_bit(*ff, input_dev->ffbit); | ||
| 263 | 265 | ||
| 264 | while (*ff >= 0) { | 266 | input_dev->upload_effect = hid_lgff_upload_effect; |
| 265 | set_bit(*ff, hidinput->input.ffbit); | 267 | input_dev->flush = hid_lgff_flush; |
| 266 | ++ff; | ||
| 267 | } | ||
| 268 | |||
| 269 | hidinput->input.upload_effect = hid_lgff_upload_effect; | ||
| 270 | hidinput->input.flush = hid_lgff_flush; | ||
| 271 | 268 | ||
| 272 | set_bit(EV_FF, hidinput->input.evbit); | 269 | set_bit(EV_FF, input_dev->evbit); |
| 273 | hidinput->input.ff_effects_max = LGFF_EFFECTS; | 270 | input_dev->ff_effects_max = LGFF_EFFECTS; |
| 274 | } | 271 | } |
| 275 | 272 | ||
| 276 | static void hid_lgff_exit(struct hid_device* hid) | 273 | static void hid_lgff_exit(struct hid_device* hid) |
diff --git a/drivers/usb/input/hid-tmff.c b/drivers/usb/input/hid-tmff.c index 8f6a0a6f94a9..023fd5ac31c8 100644 --- a/drivers/usb/input/hid-tmff.c +++ b/drivers/usb/input/hid-tmff.c | |||
| @@ -111,6 +111,7 @@ int hid_tmff_init(struct hid_device *hid) | |||
| 111 | struct tmff_device *private; | 111 | struct tmff_device *private; |
| 112 | struct list_head *pos; | 112 | struct list_head *pos; |
| 113 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | 113 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
| 114 | struct input_dev *input_dev = hidinput->input; | ||
| 114 | 115 | ||
| 115 | private = kmalloc(sizeof(struct tmff_device), GFP_KERNEL); | 116 | private = kmalloc(sizeof(struct tmff_device), GFP_KERNEL); |
| 116 | if (!private) | 117 | if (!private) |
| @@ -155,7 +156,7 @@ int hid_tmff_init(struct hid_device *hid) | |||
| 155 | private->report = report; | 156 | private->report = report; |
| 156 | private->rumble = field; | 157 | private->rumble = field; |
| 157 | 158 | ||
| 158 | set_bit(FF_RUMBLE, hidinput->input.ffbit); | 159 | set_bit(FF_RUMBLE, input_dev->ffbit); |
| 159 | break; | 160 | break; |
| 160 | 161 | ||
| 161 | default: | 162 | default: |
| @@ -164,11 +165,11 @@ int hid_tmff_init(struct hid_device *hid) | |||
| 164 | } | 165 | } |
| 165 | 166 | ||
| 166 | /* Fallthrough to here only when a valid usage is found */ | 167 | /* Fallthrough to here only when a valid usage is found */ |
| 167 | hidinput->input.upload_effect = hid_tmff_upload_effect; | 168 | input_dev->upload_effect = hid_tmff_upload_effect; |
| 168 | hidinput->input.flush = hid_tmff_flush; | 169 | input_dev->flush = hid_tmff_flush; |
| 169 | 170 | ||
| 170 | set_bit(EV_FF, hidinput->input.evbit); | 171 | set_bit(EV_FF, input_dev->evbit); |
| 171 | hidinput->input.ff_effects_max = TMFF_EFFECTS; | 172 | input_dev->ff_effects_max = TMFF_EFFECTS; |
| 172 | } | 173 | } |
| 173 | } | 174 | } |
| 174 | 175 | ||
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index ec2412c42f1e..ee48a2276104 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h | |||
| @@ -371,7 +371,7 @@ struct hid_control_fifo { | |||
| 371 | struct hid_input { | 371 | struct hid_input { |
| 372 | struct list_head list; | 372 | struct list_head list; |
| 373 | struct hid_report *report; | 373 | struct hid_report *report; |
| 374 | struct input_dev input; | 374 | struct input_dev *input; |
| 375 | }; | 375 | }; |
| 376 | 376 | ||
| 377 | struct hid_device { /* device report descriptor */ | 377 | struct hid_device { /* device report descriptor */ |
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c index becb87efb869..3b581853cf10 100644 --- a/drivers/usb/input/itmtouch.c +++ b/drivers/usb/input/itmtouch.c | |||
| @@ -73,7 +73,7 @@ MODULE_LICENSE( DRIVER_LICENSE ); | |||
| 73 | 73 | ||
| 74 | struct itmtouch_dev { | 74 | struct itmtouch_dev { |
| 75 | struct usb_device *usbdev; /* usb device */ | 75 | struct usb_device *usbdev; /* usb device */ |
| 76 | struct input_dev inputdev; /* input device */ | 76 | struct input_dev *inputdev; /* input device */ |
| 77 | struct urb *readurb; /* urb */ | 77 | struct urb *readurb; /* urb */ |
| 78 | char rbuf[ITM_BUFSIZE]; /* data */ | 78 | char rbuf[ITM_BUFSIZE]; /* data */ |
| 79 | int users; | 79 | int users; |
| @@ -88,9 +88,9 @@ static struct usb_device_id itmtouch_ids [] = { | |||
| 88 | 88 | ||
| 89 | static void itmtouch_irq(struct urb *urb, struct pt_regs *regs) | 89 | static void itmtouch_irq(struct urb *urb, struct pt_regs *regs) |
| 90 | { | 90 | { |
| 91 | struct itmtouch_dev * itmtouch = urb->context; | 91 | struct itmtouch_dev *itmtouch = urb->context; |
| 92 | unsigned char *data = urb->transfer_buffer; | 92 | unsigned char *data = urb->transfer_buffer; |
| 93 | struct input_dev *dev = &itmtouch->inputdev; | 93 | struct input_dev *dev = itmtouch->inputdev; |
| 94 | int retval; | 94 | int retval; |
| 95 | 95 | ||
| 96 | switch (urb->status) { | 96 | switch (urb->status) { |
| @@ -156,49 +156,62 @@ static void itmtouch_close(struct input_dev *input) | |||
| 156 | static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id) | 156 | static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 157 | { | 157 | { |
| 158 | struct itmtouch_dev *itmtouch; | 158 | struct itmtouch_dev *itmtouch; |
| 159 | struct input_dev *input_dev; | ||
| 159 | struct usb_host_interface *interface; | 160 | struct usb_host_interface *interface; |
| 160 | struct usb_endpoint_descriptor *endpoint; | 161 | struct usb_endpoint_descriptor *endpoint; |
| 161 | struct usb_device *udev = interface_to_usbdev(intf); | 162 | struct usb_device *udev = interface_to_usbdev(intf); |
| 162 | unsigned int pipe; | 163 | unsigned int pipe; |
| 163 | unsigned int maxp; | 164 | unsigned int maxp; |
| 164 | char path[PATH_SIZE]; | ||
| 165 | 165 | ||
| 166 | interface = intf->cur_altsetting; | 166 | interface = intf->cur_altsetting; |
| 167 | endpoint = &interface->endpoint[0].desc; | 167 | endpoint = &interface->endpoint[0].desc; |
| 168 | 168 | ||
| 169 | if (!(itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL))) { | 169 | itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL); |
| 170 | input_dev = input_allocate_device(); | ||
| 171 | if (!itmtouch || !input_dev) { | ||
| 170 | err("%s - Out of memory.", __FUNCTION__); | 172 | err("%s - Out of memory.", __FUNCTION__); |
| 171 | return -ENOMEM; | 173 | goto fail; |
| 172 | } | 174 | } |
| 173 | 175 | ||
| 174 | itmtouch->usbdev = udev; | 176 | itmtouch->usbdev = udev; |
| 177 | itmtouch->inputdev = input_dev; | ||
| 175 | 178 | ||
| 176 | itmtouch->inputdev.private = itmtouch; | 179 | if (udev->manufacturer) |
| 177 | itmtouch->inputdev.open = itmtouch_open; | 180 | strlcpy(itmtouch->name, udev->manufacturer, sizeof(itmtouch->name)); |
| 178 | itmtouch->inputdev.close = itmtouch_close; | ||
| 179 | 181 | ||
| 180 | usb_make_path(udev, path, PATH_SIZE); | 182 | if (udev->product) { |
| 181 | 183 | if (udev->manufacturer) | |
| 182 | itmtouch->inputdev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 184 | strlcat(itmtouch->name, " ", sizeof(itmtouch->name)); |
| 183 | itmtouch->inputdev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | 185 | strlcat(itmtouch->name, udev->product, sizeof(itmtouch->name)); |
| 184 | itmtouch->inputdev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 186 | } |
| 185 | |||
| 186 | itmtouch->inputdev.name = itmtouch->name; | ||
| 187 | itmtouch->inputdev.phys = itmtouch->phys; | ||
| 188 | usb_to_input_id(udev, &itmtouch->inputdev.id); | ||
| 189 | itmtouch->inputdev.dev = &intf->dev; | ||
| 190 | 187 | ||
| 191 | if (!strlen(itmtouch->name)) | 188 | if (!strlen(itmtouch->name)) |
| 192 | sprintf(itmtouch->name, "USB ITM touchscreen"); | 189 | sprintf(itmtouch->name, "USB ITM touchscreen"); |
| 193 | 190 | ||
| 191 | usb_make_path(udev, itmtouch->phys, sizeof(itmtouch->phys)); | ||
| 192 | strlcpy(itmtouch->phys, "/input0", sizeof(itmtouch->phys)); | ||
| 193 | |||
| 194 | input_dev->name = itmtouch->name; | ||
| 195 | input_dev->phys = itmtouch->phys; | ||
| 196 | usb_to_input_id(udev, &input_dev->id); | ||
| 197 | input_dev->cdev.dev = &intf->dev; | ||
| 198 | input_dev->private = itmtouch; | ||
| 199 | |||
| 200 | input_dev->open = itmtouch_open; | ||
| 201 | input_dev->close = itmtouch_close; | ||
| 202 | |||
| 203 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
| 204 | input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
| 205 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
| 206 | |||
| 194 | /* device limits */ | 207 | /* device limits */ |
| 195 | /* as specified by the ITM datasheet, X and Y are 12bit, | 208 | /* as specified by the ITM datasheet, X and Y are 12bit, |
| 196 | * Z (pressure) is 8 bit. However, the fields are defined up | 209 | * Z (pressure) is 8 bit. However, the fields are defined up |
| 197 | * to 14 bits for future possible expansion. | 210 | * to 14 bits for future possible expansion. |
| 198 | */ | 211 | */ |
| 199 | input_set_abs_params(&itmtouch->inputdev, ABS_X, 0, 0x0FFF, 2, 0); | 212 | input_set_abs_params(input_dev, ABS_X, 0, 0x0FFF, 2, 0); |
| 200 | input_set_abs_params(&itmtouch->inputdev, ABS_Y, 0, 0x0FFF, 2, 0); | 213 | input_set_abs_params(input_dev, ABS_Y, 0, 0x0FFF, 2, 0); |
| 201 | input_set_abs_params(&itmtouch->inputdev, ABS_PRESSURE, 0, 0xFF, 2, 0); | 214 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xFF, 2, 0); |
| 202 | 215 | ||
| 203 | /* initialise the URB so we can read from the transport stream */ | 216 | /* initialise the URB so we can read from the transport stream */ |
| 204 | pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress); | 217 | pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress); |
| @@ -208,22 +221,23 @@ static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id | |||
| 208 | maxp = ITM_BUFSIZE; | 221 | maxp = ITM_BUFSIZE; |
| 209 | 222 | ||
| 210 | itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL); | 223 | itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL); |
| 211 | |||
| 212 | if (!itmtouch->readurb) { | 224 | if (!itmtouch->readurb) { |
| 213 | dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__); | 225 | dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__); |
| 214 | kfree(itmtouch); | 226 | goto fail; |
| 215 | return -ENOMEM; | ||
| 216 | } | 227 | } |
| 217 | 228 | ||
| 218 | usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf, | 229 | usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf, |
| 219 | maxp, itmtouch_irq, itmtouch, endpoint->bInterval); | 230 | maxp, itmtouch_irq, itmtouch, endpoint->bInterval); |
| 220 | 231 | ||
| 221 | input_register_device(&itmtouch->inputdev); | 232 | input_register_device(itmtouch->inputdev); |
| 222 | 233 | ||
| 223 | printk(KERN_INFO "itmtouch: %s registered on %s\n", itmtouch->name, path); | ||
| 224 | usb_set_intfdata(intf, itmtouch); | 234 | usb_set_intfdata(intf, itmtouch); |
| 225 | 235 | ||
| 226 | return 0; | 236 | return 0; |
| 237 | |||
| 238 | fail: input_free_device(input_dev); | ||
| 239 | kfree(itmtouch); | ||
| 240 | return -ENOMEM; | ||
| 227 | } | 241 | } |
| 228 | 242 | ||
| 229 | static void itmtouch_disconnect(struct usb_interface *intf) | 243 | static void itmtouch_disconnect(struct usb_interface *intf) |
| @@ -233,7 +247,7 @@ static void itmtouch_disconnect(struct usb_interface *intf) | |||
| 233 | usb_set_intfdata(intf, NULL); | 247 | usb_set_intfdata(intf, NULL); |
| 234 | 248 | ||
| 235 | if (itmtouch) { | 249 | if (itmtouch) { |
| 236 | input_unregister_device(&itmtouch->inputdev); | 250 | input_unregister_device(itmtouch->inputdev); |
| 237 | usb_kill_urb(itmtouch->readurb); | 251 | usb_kill_urb(itmtouch->readurb); |
| 238 | usb_free_urb(itmtouch->readurb); | 252 | usb_free_urb(itmtouch->readurb); |
| 239 | kfree(itmtouch); | 253 | kfree(itmtouch); |
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c index b6f6ac8d9c2f..a248664b5d1d 100644 --- a/drivers/usb/input/kbtab.c +++ b/drivers/usb/input/kbtab.c | |||
| @@ -34,7 +34,7 @@ MODULE_PARM_DESC(kb_pressure_click, "pressure threshold for clicks"); | |||
| 34 | struct kbtab { | 34 | struct kbtab { |
| 35 | signed char *data; | 35 | signed char *data; |
| 36 | dma_addr_t data_dma; | 36 | dma_addr_t data_dma; |
| 37 | struct input_dev dev; | 37 | struct input_dev *dev; |
| 38 | struct usb_device *usbdev; | 38 | struct usb_device *usbdev; |
| 39 | struct urb *irq; | 39 | struct urb *irq; |
| 40 | int x, y; | 40 | int x, y; |
| @@ -48,7 +48,7 @@ static void kbtab_irq(struct urb *urb, struct pt_regs *regs) | |||
| 48 | { | 48 | { |
| 49 | struct kbtab *kbtab = urb->context; | 49 | struct kbtab *kbtab = urb->context; |
| 50 | unsigned char *data = kbtab->data; | 50 | unsigned char *data = kbtab->data; |
| 51 | struct input_dev *dev = &kbtab->dev; | 51 | struct input_dev *dev = kbtab->dev; |
| 52 | int retval; | 52 | int retval; |
| 53 | 53 | ||
| 54 | switch (urb->status) { | 54 | switch (urb->status) { |
| @@ -124,53 +124,43 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
| 124 | struct usb_device *dev = interface_to_usbdev(intf); | 124 | struct usb_device *dev = interface_to_usbdev(intf); |
| 125 | struct usb_endpoint_descriptor *endpoint; | 125 | struct usb_endpoint_descriptor *endpoint; |
| 126 | struct kbtab *kbtab; | 126 | struct kbtab *kbtab; |
| 127 | char path[64]; | 127 | struct input_dev *input_dev; |
| 128 | 128 | ||
| 129 | if (!(kbtab = kmalloc(sizeof(struct kbtab), GFP_KERNEL))) | 129 | kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); |
| 130 | return -ENOMEM; | 130 | input_dev = input_allocate_device(); |
| 131 | memset(kbtab, 0, sizeof(struct kbtab)); | 131 | if (!kbtab || !input_dev) |
| 132 | goto fail1; | ||
| 132 | 133 | ||
| 133 | kbtab->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &kbtab->data_dma); | 134 | kbtab->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &kbtab->data_dma); |
| 134 | if (!kbtab->data) { | 135 | if (!kbtab->data) |
| 135 | kfree(kbtab); | 136 | goto fail1; |
| 136 | return -ENOMEM; | ||
| 137 | } | ||
| 138 | 137 | ||
| 139 | kbtab->irq = usb_alloc_urb(0, GFP_KERNEL); | 138 | kbtab->irq = usb_alloc_urb(0, GFP_KERNEL); |
| 140 | if (!kbtab->irq) { | 139 | if (!kbtab->irq) |
| 141 | usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); | 140 | goto fail2; |
| 142 | kfree(kbtab); | ||
| 143 | return -ENOMEM; | ||
| 144 | } | ||
| 145 | |||
| 146 | kbtab->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); | ||
| 147 | kbtab->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
| 148 | |||
| 149 | kbtab->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | ||
| 150 | |||
| 151 | kbtab->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH); | ||
| 152 | 141 | ||
| 153 | kbtab->dev.mscbit[0] |= BIT(MSC_SERIAL); | 142 | kbtab->usbdev = dev; |
| 154 | 143 | kbtab->dev = input_dev; | |
| 155 | kbtab->dev.absmax[ABS_X] = 0x2000; | ||
| 156 | kbtab->dev.absmax[ABS_Y] = 0x1750; | ||
| 157 | kbtab->dev.absmax[ABS_PRESSURE] = 0xff; | ||
| 158 | 144 | ||
| 159 | kbtab->dev.absfuzz[ABS_X] = 4; | 145 | usb_make_path(dev, kbtab->phys, sizeof(kbtab->phys)); |
| 160 | kbtab->dev.absfuzz[ABS_Y] = 4; | 146 | strlcat(kbtab->phys, "/input0", sizeof(kbtab->phys)); |
| 161 | 147 | ||
| 162 | kbtab->dev.private = kbtab; | 148 | input_dev->name = "KB Gear Tablet"; |
| 163 | kbtab->dev.open = kbtab_open; | 149 | input_dev->phys = kbtab->phys; |
| 164 | kbtab->dev.close = kbtab_close; | 150 | usb_to_input_id(dev, &input_dev->id); |
| 151 | input_dev->cdev.dev = &intf->dev; | ||
| 152 | input_dev->private = kbtab; | ||
| 165 | 153 | ||
| 166 | usb_make_path(dev, path, 64); | 154 | input_dev->open = kbtab_open; |
| 167 | sprintf(kbtab->phys, "%s/input0", path); | 155 | input_dev->close = kbtab_close; |
| 168 | 156 | ||
| 169 | kbtab->dev.name = "KB Gear Tablet"; | 157 | input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); |
| 170 | kbtab->dev.phys = kbtab->phys; | 158 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
| 171 | usb_to_input_id(dev, &kbtab->dev.id); | 159 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH); |
| 172 | kbtab->dev.dev = &intf->dev; | 160 | input_dev->mscbit[0] |= BIT(MSC_SERIAL); |
| 173 | kbtab->usbdev = dev; | 161 | input_set_abs_params(input_dev, ABS_X, 0, 0x2000, 4, 0); |
| 162 | input_set_abs_params(input_dev, ABS_X, 0, 0x1750, 4, 0); | ||
| 163 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0); | ||
| 174 | 164 | ||
| 175 | endpoint = &intf->cur_altsetting->endpoint[0].desc; | 165 | endpoint = &intf->cur_altsetting->endpoint[0].desc; |
| 176 | 166 | ||
| @@ -181,23 +171,25 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
| 181 | kbtab->irq->transfer_dma = kbtab->data_dma; | 171 | kbtab->irq->transfer_dma = kbtab->data_dma; |
| 182 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 172 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 183 | 173 | ||
| 184 | input_register_device(&kbtab->dev); | 174 | input_register_device(kbtab->dev); |
| 185 | |||
| 186 | printk(KERN_INFO "input: KB Gear Tablet on %s\n", path); | ||
| 187 | 175 | ||
| 188 | usb_set_intfdata(intf, kbtab); | 176 | usb_set_intfdata(intf, kbtab); |
| 189 | |||
| 190 | return 0; | 177 | return 0; |
| 178 | |||
| 179 | fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); | ||
| 180 | fail1: input_free_device(input_dev); | ||
| 181 | kfree(kbtab); | ||
| 182 | return -ENOMEM; | ||
| 191 | } | 183 | } |
| 192 | 184 | ||
| 193 | static void kbtab_disconnect(struct usb_interface *intf) | 185 | static void kbtab_disconnect(struct usb_interface *intf) |
| 194 | { | 186 | { |
| 195 | struct kbtab *kbtab = usb_get_intfdata (intf); | 187 | struct kbtab *kbtab = usb_get_intfdata(intf); |
| 196 | 188 | ||
| 197 | usb_set_intfdata(intf, NULL); | 189 | usb_set_intfdata(intf, NULL); |
| 198 | if (kbtab) { | 190 | if (kbtab) { |
| 199 | usb_kill_urb(kbtab->irq); | 191 | usb_kill_urb(kbtab->irq); |
| 200 | input_unregister_device(&kbtab->dev); | 192 | input_unregister_device(kbtab->dev); |
| 201 | usb_free_urb(kbtab->irq); | 193 | usb_free_urb(kbtab->irq); |
| 202 | usb_buffer_free(interface_to_usbdev(intf), 10, kbtab->data, kbtab->data_dma); | 194 | usb_buffer_free(interface_to_usbdev(intf), 10, kbtab->data, kbtab->data_dma); |
| 203 | kfree(kbtab); | 195 | kfree(kbtab); |
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c index 99de1b33c07d..5b8d65f62abf 100644 --- a/drivers/usb/input/keyspan_remote.c +++ b/drivers/usb/input/keyspan_remote.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/moduleparam.h> | 20 | #include <linux/moduleparam.h> |
| 21 | #include <linux/input.h> | 21 | #include <linux/input.h> |
| 22 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
| 23 | #include <linux/usb_input.h> | ||
| 23 | 24 | ||
| 24 | #define DRIVER_VERSION "v0.1" | 25 | #define DRIVER_VERSION "v0.1" |
| 25 | #define DRIVER_AUTHOR "Michael Downey <downey@zymeta.com>" | 26 | #define DRIVER_AUTHOR "Michael Downey <downey@zymeta.com>" |
| @@ -75,7 +76,7 @@ struct usb_keyspan { | |||
| 75 | char name[128]; | 76 | char name[128]; |
| 76 | char phys[64]; | 77 | char phys[64]; |
| 77 | struct usb_device* udev; | 78 | struct usb_device* udev; |
| 78 | struct input_dev input; | 79 | struct input_dev *input; |
| 79 | struct usb_interface* interface; | 80 | struct usb_interface* interface; |
| 80 | struct usb_endpoint_descriptor* in_endpoint; | 81 | struct usb_endpoint_descriptor* in_endpoint; |
| 81 | struct urb* irq_urb; | 82 | struct urb* irq_urb; |
| @@ -136,12 +137,11 @@ static struct usb_driver keyspan_driver; | |||
| 136 | */ | 137 | */ |
| 137 | static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/ | 138 | static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/ |
| 138 | { | 139 | { |
| 139 | char codes[4*RECV_SIZE]; | 140 | char codes[4 * RECV_SIZE]; |
| 140 | int i; | 141 | int i; |
| 141 | 142 | ||
| 142 | for (i = 0; i < RECV_SIZE; i++) { | 143 | for (i = 0; i < RECV_SIZE; i++) |
| 143 | snprintf(codes+i*3, 4, "%02x ", dev->in_buffer[i]); | 144 | snprintf(codes + i * 3, 4, "%02x ", dev->in_buffer[i]); |
| 144 | } | ||
| 145 | 145 | ||
| 146 | dev_info(&dev->udev->dev, "%s\n", codes); | 146 | dev_info(&dev->udev->dev, "%s\n", codes); |
| 147 | } | 147 | } |
| @@ -153,7 +153,7 @@ static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/ | |||
| 153 | static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) | 153 | static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) |
| 154 | { | 154 | { |
| 155 | if (dev->data.bits_left >= bits_needed) | 155 | if (dev->data.bits_left >= bits_needed) |
| 156 | return(0); | 156 | return 0; |
| 157 | 157 | ||
| 158 | /* | 158 | /* |
| 159 | * Somehow we've missed the last message. The message will be repeated | 159 | * Somehow we've missed the last message. The message will be repeated |
| @@ -162,7 +162,7 @@ static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) | |||
| 162 | if (dev->data.pos >= dev->data.len) { | 162 | if (dev->data.pos >= dev->data.len) { |
| 163 | dev_dbg(&dev->udev, "%s - Error ran out of data. pos: %d, len: %d\n", | 163 | dev_dbg(&dev->udev, "%s - Error ran out of data. pos: %d, len: %d\n", |
| 164 | __FUNCTION__, dev->data.pos, dev->data.len); | 164 | __FUNCTION__, dev->data.pos, dev->data.len); |
| 165 | return(-1); | 165 | return -1; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | /* Load as much as we can into the tester. */ | 168 | /* Load as much as we can into the tester. */ |
| @@ -172,7 +172,7 @@ static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) | |||
| 172 | dev->data.bits_left += 8; | 172 | dev->data.bits_left += 8; |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | return(0); | 175 | return 0; |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | /* | 178 | /* |
| @@ -311,10 +311,10 @@ static void keyspan_check_data(struct usb_keyspan *remote, struct pt_regs *regs) | |||
| 311 | __FUNCTION__, message.system, message.button, message.toggle); | 311 | __FUNCTION__, message.system, message.button, message.toggle); |
| 312 | 312 | ||
| 313 | if (message.toggle != remote->toggle) { | 313 | if (message.toggle != remote->toggle) { |
| 314 | input_regs(&remote->input, regs); | 314 | input_regs(remote->input, regs); |
| 315 | input_report_key(&remote->input, keyspan_key_table[message.button], 1); | 315 | input_report_key(remote->input, keyspan_key_table[message.button], 1); |
| 316 | input_report_key(&remote->input, keyspan_key_table[message.button], 0); | 316 | input_report_key(remote->input, keyspan_key_table[message.button], 0); |
| 317 | input_sync(&remote->input); | 317 | input_sync(remote->input); |
| 318 | remote->toggle = message.toggle; | 318 | remote->toggle = message.toggle; |
| 319 | } | 319 | } |
| 320 | 320 | ||
| @@ -397,14 +397,9 @@ static int keyspan_open(struct input_dev *dev) | |||
| 397 | { | 397 | { |
| 398 | struct usb_keyspan *remote = dev->private; | 398 | struct usb_keyspan *remote = dev->private; |
| 399 | 399 | ||
| 400 | if (remote->open++) | ||
| 401 | return 0; | ||
| 402 | |||
| 403 | remote->irq_urb->dev = remote->udev; | 400 | remote->irq_urb->dev = remote->udev; |
| 404 | if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) { | 401 | if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) |
| 405 | remote->open--; | ||
| 406 | return -EIO; | 402 | return -EIO; |
| 407 | } | ||
| 408 | 403 | ||
| 409 | return 0; | 404 | return 0; |
| 410 | } | 405 | } |
| @@ -413,8 +408,26 @@ static void keyspan_close(struct input_dev *dev) | |||
| 413 | { | 408 | { |
| 414 | struct usb_keyspan *remote = dev->private; | 409 | struct usb_keyspan *remote = dev->private; |
| 415 | 410 | ||
| 416 | if (!--remote->open) | 411 | usb_kill_urb(remote->irq_urb); |
| 417 | usb_kill_urb(remote->irq_urb); | 412 | } |
| 413 | |||
| 414 | static struct usb_endpoint_descriptor *keyspan_get_in_endpoint(struct usb_host_interface *iface) | ||
| 415 | { | ||
| 416 | |||
| 417 | struct usb_endpoint_descriptor *endpoint; | ||
| 418 | int i; | ||
| 419 | |||
| 420 | for (i = 0; i < iface->desc.bNumEndpoints; ++i) { | ||
| 421 | endpoint = &iface->endpoint[i].desc; | ||
| 422 | |||
| 423 | if ((endpoint->bEndpointAddress & USB_DIR_IN) && | ||
| 424 | ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) { | ||
| 425 | /* we found our interrupt in endpoint */ | ||
| 426 | return endpoint; | ||
| 427 | } | ||
| 428 | } | ||
| 429 | |||
| 430 | return NULL; | ||
| 418 | } | 431 | } |
| 419 | 432 | ||
| 420 | /* | 433 | /* |
| @@ -422,110 +435,78 @@ static void keyspan_close(struct input_dev *dev) | |||
| 422 | */ | 435 | */ |
| 423 | static int keyspan_probe(struct usb_interface *interface, const struct usb_device_id *id) | 436 | static int keyspan_probe(struct usb_interface *interface, const struct usb_device_id *id) |
| 424 | { | 437 | { |
| 425 | int i; | 438 | struct usb_device *udev = interface_to_usbdev(interface); |
| 426 | int retval = -ENOMEM; | ||
| 427 | char path[64]; | ||
| 428 | char *buf; | ||
| 429 | struct usb_keyspan *remote = NULL; | ||
| 430 | struct usb_host_interface *iface_desc; | ||
| 431 | struct usb_endpoint_descriptor *endpoint; | 439 | struct usb_endpoint_descriptor *endpoint; |
| 432 | struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface)); | 440 | struct usb_keyspan *remote; |
| 441 | struct input_dev *input_dev; | ||
| 442 | int i, retval; | ||
| 433 | 443 | ||
| 434 | /* allocate memory for our device state and initialize it */ | 444 | endpoint = keyspan_get_in_endpoint(interface->cur_altsetting); |
| 435 | remote = kmalloc(sizeof(*remote), GFP_KERNEL); | 445 | if (!endpoint) |
| 436 | if (remote == NULL) { | 446 | return -ENODEV; |
| 437 | err("Out of memory\n"); | 447 | |
| 438 | goto error; | 448 | remote = kzalloc(sizeof(*remote), GFP_KERNEL); |
| 449 | input_dev = input_allocate_device(); | ||
| 450 | if (!remote || !input_dev) { | ||
| 451 | retval = -ENOMEM; | ||
| 452 | goto fail1; | ||
| 439 | } | 453 | } |
| 440 | memset(remote, 0x00, sizeof(*remote)); | ||
| 441 | 454 | ||
| 442 | remote->udev = udev; | 455 | remote->udev = udev; |
| 456 | remote->input = input_dev; | ||
| 443 | remote->interface = interface; | 457 | remote->interface = interface; |
| 458 | remote->in_endpoint = endpoint; | ||
| 444 | remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ | 459 | remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ |
| 445 | 460 | ||
| 446 | /* set up the endpoint information */ | 461 | remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma); |
| 447 | /* use only the first in interrupt endpoint */ | 462 | if (!remote->in_buffer) { |
| 448 | iface_desc = interface->cur_altsetting; | 463 | retval = -ENOMEM; |
| 449 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { | 464 | goto fail1; |
| 450 | endpoint = &iface_desc->endpoint[i].desc; | ||
| 451 | |||
| 452 | if (!remote->in_endpoint && | ||
| 453 | (endpoint->bEndpointAddress & USB_DIR_IN) && | ||
| 454 | ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) { | ||
| 455 | /* we found our interrupt in endpoint */ | ||
| 456 | remote->in_endpoint = endpoint; | ||
| 457 | |||
| 458 | remote->in_buffer = usb_buffer_alloc(remote->udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma); | ||
| 459 | if (!remote->in_buffer) { | ||
| 460 | retval = -ENOMEM; | ||
| 461 | goto error; | ||
| 462 | } | ||
| 463 | } | ||
| 464 | } | ||
| 465 | |||
| 466 | if (!remote->in_endpoint) { | ||
| 467 | err("Could not find interrupt input endpoint.\n"); | ||
| 468 | retval = -ENODEV; | ||
| 469 | goto error; | ||
| 470 | } | 465 | } |
| 471 | 466 | ||
| 472 | remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); | 467 | remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); |
| 473 | if (!remote->irq_urb) { | 468 | if (!remote->irq_urb) { |
| 474 | err("Failed to allocate urb.\n"); | ||
| 475 | retval = -ENOMEM; | 469 | retval = -ENOMEM; |
| 476 | goto error; | 470 | goto fail2; |
| 477 | } | 471 | } |
| 478 | 472 | ||
| 479 | retval = keyspan_setup(remote->udev); | 473 | retval = keyspan_setup(udev); |
| 480 | if (retval) { | 474 | if (retval) { |
| 481 | err("Failed to setup device.\n"); | ||
| 482 | retval = -ENODEV; | 475 | retval = -ENODEV; |
| 483 | goto error; | 476 | goto fail3; |
| 484 | } | ||
| 485 | |||
| 486 | /* | ||
| 487 | * Setup the input system with the bits we are going to be reporting | ||
| 488 | */ | ||
| 489 | remote->input.evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */ | ||
| 490 | for (i = 0; i < 32; ++i) { | ||
| 491 | if (keyspan_key_table[i] != KEY_RESERVED) { | ||
| 492 | set_bit(keyspan_key_table[i], remote->input.keybit); | ||
| 493 | } | ||
| 494 | } | 477 | } |
| 495 | 478 | ||
| 496 | remote->input.private = remote; | 479 | if (udev->manufacturer) |
| 497 | remote->input.open = keyspan_open; | 480 | strlcpy(remote->name, udev->manufacturer, sizeof(remote->name)); |
| 498 | remote->input.close = keyspan_close; | ||
| 499 | |||
| 500 | usb_make_path(remote->udev, path, 64); | ||
| 501 | sprintf(remote->phys, "%s/input0", path); | ||
| 502 | 481 | ||
| 503 | remote->input.name = remote->name; | 482 | if (udev->product) { |
| 504 | remote->input.phys = remote->phys; | 483 | if (udev->manufacturer) |
| 505 | remote->input.id.bustype = BUS_USB; | 484 | strlcat(remote->name, " ", sizeof(remote->name)); |
| 506 | remote->input.id.vendor = le16_to_cpu(remote->udev->descriptor.idVendor); | 485 | strlcat(remote->name, udev->product, sizeof(remote->name)); |
| 507 | remote->input.id.product = le16_to_cpu(remote->udev->descriptor.idProduct); | ||
| 508 | remote->input.id.version = le16_to_cpu(remote->udev->descriptor.bcdDevice); | ||
| 509 | |||
| 510 | if (!(buf = kmalloc(63, GFP_KERNEL))) { | ||
| 511 | usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma); | ||
| 512 | kfree(remote); | ||
| 513 | return -ENOMEM; | ||
| 514 | } | 486 | } |
| 515 | 487 | ||
| 516 | if (remote->udev->descriptor.iManufacturer && | 488 | if (!strlen(remote->name)) |
| 517 | usb_string(remote->udev, remote->udev->descriptor.iManufacturer, buf, 63) > 0) | 489 | snprintf(remote->name, sizeof(remote->name), |
| 518 | strcat(remote->name, buf); | 490 | "USB Keyspan Remote %04x:%04x", |
| 491 | le16_to_cpu(udev->descriptor.idVendor), | ||
| 492 | le16_to_cpu(udev->descriptor.idProduct)); | ||
| 519 | 493 | ||
| 520 | if (remote->udev->descriptor.iProduct && | 494 | usb_make_path(udev, remote->phys, sizeof(remote->phys)); |
| 521 | usb_string(remote->udev, remote->udev->descriptor.iProduct, buf, 63) > 0) | 495 | strlcat(remote->phys, "/input0", sizeof(remote->phys)); |
| 522 | sprintf(remote->name, "%s %s", remote->name, buf); | ||
| 523 | 496 | ||
| 524 | if (!strlen(remote->name)) | 497 | input_dev->name = remote->name; |
| 525 | sprintf(remote->name, "USB Keyspan Remote %04x:%04x", | 498 | input_dev->phys = remote->phys; |
| 526 | remote->input.id.vendor, remote->input.id.product); | 499 | usb_to_input_id(udev, &input_dev->id); |
| 500 | input_dev->cdev.dev = &interface->dev; | ||
| 527 | 501 | ||
| 528 | kfree(buf); | 502 | input_dev->evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */ |
| 503 | for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++) | ||
| 504 | if (keyspan_key_table[i] != KEY_RESERVED) | ||
| 505 | set_bit(keyspan_key_table[i], input_dev->keybit); | ||
| 506 | |||
| 507 | input_dev->private = remote; | ||
| 508 | input_dev->open = keyspan_open; | ||
| 509 | input_dev->close = keyspan_close; | ||
| 529 | 510 | ||
| 530 | /* | 511 | /* |
| 531 | * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open() | 512 | * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open() |
| @@ -538,27 +519,17 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic | |||
| 538 | remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 519 | remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 539 | 520 | ||
| 540 | /* we can register the device now, as it is ready */ | 521 | /* we can register the device now, as it is ready */ |
| 541 | input_register_device(&remote->input); | 522 | input_register_device(remote->input); |
| 542 | 523 | ||
| 543 | /* save our data pointer in this interface device */ | 524 | /* save our data pointer in this interface device */ |
| 544 | usb_set_intfdata(interface, remote); | 525 | usb_set_intfdata(interface, remote); |
| 545 | 526 | ||
| 546 | /* let the user know what node this device is now attached to */ | ||
| 547 | info("connected: %s on %s", remote->name, path); | ||
| 548 | return 0; | 527 | return 0; |
| 549 | 528 | ||
| 550 | error: | 529 | fail3: usb_free_urb(remote->irq_urb); |
| 551 | /* | 530 | fail2: usb_buffer_free(udev, RECV_SIZE, remote->in_buffer, remote->in_dma); |
| 552 | * In case of error we need to clean up any allocated buffers | 531 | fail1: kfree(remote); |
| 553 | */ | 532 | input_free_device(input_dev); |
| 554 | if (remote->irq_urb) | ||
| 555 | usb_free_urb(remote->irq_urb); | ||
| 556 | |||
| 557 | if (remote->in_buffer) | ||
| 558 | usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma); | ||
| 559 | |||
| 560 | if (remote) | ||
| 561 | kfree(remote); | ||
| 562 | 533 | ||
| 563 | return retval; | 534 | return retval; |
| 564 | } | 535 | } |
| @@ -570,23 +541,16 @@ static void keyspan_disconnect(struct usb_interface *interface) | |||
| 570 | { | 541 | { |
| 571 | struct usb_keyspan *remote; | 542 | struct usb_keyspan *remote; |
| 572 | 543 | ||
| 573 | /* prevent keyspan_open() from racing keyspan_disconnect() */ | ||
| 574 | lock_kernel(); | ||
| 575 | |||
| 576 | remote = usb_get_intfdata(interface); | 544 | remote = usb_get_intfdata(interface); |
| 577 | usb_set_intfdata(interface, NULL); | 545 | usb_set_intfdata(interface, NULL); |
| 578 | 546 | ||
| 579 | if (remote) { /* We have a valid driver structure so clean up everything we allocated. */ | 547 | if (remote) { /* We have a valid driver structure so clean up everything we allocated. */ |
| 580 | input_unregister_device(&remote->input); | 548 | input_unregister_device(remote->input); |
| 581 | usb_kill_urb(remote->irq_urb); | 549 | usb_kill_urb(remote->irq_urb); |
| 582 | usb_free_urb(remote->irq_urb); | 550 | usb_free_urb(remote->irq_urb); |
| 583 | usb_buffer_free(interface_to_usbdev(interface), RECV_SIZE, remote->in_buffer, remote->in_dma); | 551 | usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma); |
| 584 | kfree(remote); | 552 | kfree(remote); |
| 585 | } | 553 | } |
| 586 | |||
| 587 | unlock_kernel(); | ||
| 588 | |||
| 589 | info("USB Keyspan now disconnected"); | ||
| 590 | } | 554 | } |
| 591 | 555 | ||
| 592 | /* | 556 | /* |
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c index ff9275057a18..7fce526560ca 100644 --- a/drivers/usb/input/mtouchusb.c +++ b/drivers/usb/input/mtouchusb.c | |||
| @@ -98,7 +98,7 @@ struct mtouch_usb { | |||
| 98 | dma_addr_t data_dma; | 98 | dma_addr_t data_dma; |
| 99 | struct urb *irq; | 99 | struct urb *irq; |
| 100 | struct usb_device *udev; | 100 | struct usb_device *udev; |
| 101 | struct input_dev input; | 101 | struct input_dev *input; |
| 102 | char name[128]; | 102 | char name[128]; |
| 103 | char phys[64]; | 103 | char phys[64]; |
| 104 | }; | 104 | }; |
| @@ -135,14 +135,14 @@ static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs) | |||
| 135 | goto exit; | 135 | goto exit; |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | input_regs(&mtouch->input, regs); | 138 | input_regs(mtouch->input, regs); |
| 139 | input_report_key(&mtouch->input, BTN_TOUCH, | 139 | input_report_key(mtouch->input, BTN_TOUCH, |
| 140 | MTOUCHUSB_GET_TOUCHED(mtouch->data)); | 140 | MTOUCHUSB_GET_TOUCHED(mtouch->data)); |
| 141 | input_report_abs(&mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); | 141 | input_report_abs(mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); |
| 142 | input_report_abs(&mtouch->input, ABS_Y, | 142 | input_report_abs(mtouch->input, ABS_Y, |
| 143 | (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) | 143 | (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) |
| 144 | - MTOUCHUSB_GET_YC(mtouch->data)); | 144 | - MTOUCHUSB_GET_YC(mtouch->data)); |
| 145 | input_sync(&mtouch->input); | 145 | input_sync(mtouch->input); |
| 146 | 146 | ||
| 147 | exit: | 147 | exit: |
| 148 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 148 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
| @@ -195,10 +195,10 @@ static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *m | |||
| 195 | static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) | 195 | static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 196 | { | 196 | { |
| 197 | struct mtouch_usb *mtouch; | 197 | struct mtouch_usb *mtouch; |
| 198 | struct input_dev *input_dev; | ||
| 198 | struct usb_host_interface *interface; | 199 | struct usb_host_interface *interface; |
| 199 | struct usb_endpoint_descriptor *endpoint; | 200 | struct usb_endpoint_descriptor *endpoint; |
| 200 | struct usb_device *udev = interface_to_usbdev(intf); | 201 | struct usb_device *udev = interface_to_usbdev(intf); |
| 201 | char path[64]; | ||
| 202 | int nRet; | 202 | int nRet; |
| 203 | 203 | ||
| 204 | dbg("%s - called", __FUNCTION__); | 204 | dbg("%s - called", __FUNCTION__); |
| @@ -209,57 +209,55 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
| 209 | dbg("%s - setting endpoint", __FUNCTION__); | 209 | dbg("%s - setting endpoint", __FUNCTION__); |
| 210 | endpoint = &interface->endpoint[0].desc; | 210 | endpoint = &interface->endpoint[0].desc; |
| 211 | 211 | ||
| 212 | if (!(mtouch = kmalloc(sizeof(struct mtouch_usb), GFP_KERNEL))) { | 212 | mtouch = kzalloc(sizeof(struct mtouch_usb), GFP_KERNEL); |
| 213 | input_dev = input_allocate_device(); | ||
| 214 | if (!mtouch || !input_dev) { | ||
| 213 | err("%s - Out of memory.", __FUNCTION__); | 215 | err("%s - Out of memory.", __FUNCTION__); |
| 214 | return -ENOMEM; | 216 | goto fail1; |
| 215 | } | 217 | } |
| 216 | 218 | ||
| 217 | memset(mtouch, 0, sizeof(struct mtouch_usb)); | ||
| 218 | mtouch->udev = udev; | ||
| 219 | |||
| 220 | dbg("%s - allocating buffers", __FUNCTION__); | 219 | dbg("%s - allocating buffers", __FUNCTION__); |
| 221 | if (mtouchusb_alloc_buffers(udev, mtouch)) { | 220 | if (mtouchusb_alloc_buffers(udev, mtouch)) |
| 222 | mtouchusb_free_buffers(udev, mtouch); | 221 | goto fail2; |
| 223 | kfree(mtouch); | ||
| 224 | return -ENOMEM; | ||
| 225 | } | ||
| 226 | 222 | ||
| 227 | mtouch->input.private = mtouch; | 223 | mtouch->udev = udev; |
| 228 | mtouch->input.open = mtouchusb_open; | 224 | mtouch->input = input_dev; |
| 229 | mtouch->input.close = mtouchusb_close; | ||
| 230 | |||
| 231 | usb_make_path(udev, path, 64); | ||
| 232 | sprintf(mtouch->phys, "%s/input0", path); | ||
| 233 | |||
| 234 | mtouch->input.name = mtouch->name; | ||
| 235 | mtouch->input.phys = mtouch->phys; | ||
| 236 | usb_to_input_id(udev, &mtouch->input.id); | ||
| 237 | mtouch->input.dev = &intf->dev; | ||
| 238 | |||
| 239 | mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
| 240 | mtouch->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | ||
| 241 | mtouch->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
| 242 | |||
| 243 | /* Used to Scale Compensated Data and Flip Y */ | ||
| 244 | mtouch->input.absmin[ABS_X] = MTOUCHUSB_MIN_XC; | ||
| 245 | mtouch->input.absmax[ABS_X] = raw_coordinates ? | ||
| 246 | MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC; | ||
| 247 | mtouch->input.absfuzz[ABS_X] = MTOUCHUSB_XC_FUZZ; | ||
| 248 | mtouch->input.absflat[ABS_X] = MTOUCHUSB_XC_FLAT; | ||
| 249 | mtouch->input.absmin[ABS_Y] = MTOUCHUSB_MIN_YC; | ||
| 250 | mtouch->input.absmax[ABS_Y] = raw_coordinates ? | ||
| 251 | MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC; | ||
| 252 | mtouch->input.absfuzz[ABS_Y] = MTOUCHUSB_YC_FUZZ; | ||
| 253 | mtouch->input.absflat[ABS_Y] = MTOUCHUSB_YC_FLAT; | ||
| 254 | 225 | ||
| 255 | if (udev->manufacturer) | 226 | if (udev->manufacturer) |
| 256 | strcat(mtouch->name, udev->manufacturer); | 227 | strlcpy(mtouch->name, udev->manufacturer, sizeof(mtouch->name)); |
| 257 | if (udev->product) | 228 | |
| 258 | sprintf(mtouch->name, "%s %s", mtouch->name, udev->product); | 229 | if (udev->product) { |
| 230 | if (udev->manufacturer) | ||
| 231 | strlcat(mtouch->name, " ", sizeof(mtouch->name)); | ||
| 232 | strlcat(mtouch->name, udev->product, sizeof(mtouch->name)); | ||
| 233 | } | ||
| 259 | 234 | ||
| 260 | if (!strlen(mtouch->name)) | 235 | if (!strlen(mtouch->name)) |
| 261 | sprintf(mtouch->name, "USB Touchscreen %04x:%04x", | 236 | snprintf(mtouch->name, sizeof(mtouch->name), |
| 262 | mtouch->input.id.vendor, mtouch->input.id.product); | 237 | "USB Touchscreen %04x:%04x", |
| 238 | le16_to_cpu(udev->descriptor.idVendor), | ||
| 239 | le16_to_cpu(udev->descriptor.idProduct)); | ||
| 240 | |||
| 241 | usb_make_path(udev, mtouch->phys, sizeof(mtouch->phys)); | ||
| 242 | strlcpy(mtouch->phys, "/input0", sizeof(mtouch->phys)); | ||
| 243 | |||
| 244 | input_dev->name = mtouch->name; | ||
| 245 | input_dev->phys = mtouch->phys; | ||
| 246 | usb_to_input_id(udev, &input_dev->id); | ||
| 247 | input_dev->cdev.dev = &intf->dev; | ||
| 248 | input_dev->private = mtouch; | ||
| 249 | |||
| 250 | input_dev->open = mtouchusb_open; | ||
| 251 | input_dev->close = mtouchusb_close; | ||
| 252 | |||
| 253 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
| 254 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
| 255 | input_set_abs_params(input_dev, ABS_X, MTOUCHUSB_MIN_XC, | ||
| 256 | raw_coordinates ? MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC, | ||
| 257 | MTOUCHUSB_XC_FUZZ, MTOUCHUSB_XC_FLAT); | ||
| 258 | input_set_abs_params(input_dev, ABS_Y, MTOUCHUSB_MIN_YC, | ||
| 259 | raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC, | ||
| 260 | MTOUCHUSB_YC_FUZZ, MTOUCHUSB_YC_FLAT); | ||
| 263 | 261 | ||
| 264 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), | 262 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), |
| 265 | MTOUCHUSB_RESET, | 263 | MTOUCHUSB_RESET, |
| @@ -272,9 +270,7 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
| 272 | mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); | 270 | mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); |
| 273 | if (!mtouch->irq) { | 271 | if (!mtouch->irq) { |
| 274 | dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); | 272 | dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); |
| 275 | mtouchusb_free_buffers(udev, mtouch); | 273 | goto fail2; |
| 276 | kfree(mtouch); | ||
| 277 | return -ENOMEM; | ||
| 278 | } | 274 | } |
| 279 | 275 | ||
| 280 | dbg("%s - usb_fill_int_urb", __FUNCTION__); | 276 | dbg("%s - usb_fill_int_urb", __FUNCTION__); |
| @@ -284,7 +280,7 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
| 284 | mtouchusb_irq, mtouch, endpoint->bInterval); | 280 | mtouchusb_irq, mtouch, endpoint->bInterval); |
| 285 | 281 | ||
| 286 | dbg("%s - input_register_device", __FUNCTION__); | 282 | dbg("%s - input_register_device", __FUNCTION__); |
| 287 | input_register_device(&mtouch->input); | 283 | input_register_device(mtouch->input); |
| 288 | 284 | ||
| 289 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), | 285 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), |
| 290 | MTOUCHUSB_ASYNC_REPORT, | 286 | MTOUCHUSB_ASYNC_REPORT, |
| @@ -293,10 +289,13 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
| 293 | dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", | 289 | dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", |
| 294 | __FUNCTION__, nRet); | 290 | __FUNCTION__, nRet); |
| 295 | 291 | ||
| 296 | printk(KERN_INFO "input: %s on %s\n", mtouch->name, path); | ||
| 297 | usb_set_intfdata(intf, mtouch); | 292 | usb_set_intfdata(intf, mtouch); |
| 298 | |||
| 299 | return 0; | 293 | return 0; |
| 294 | |||
| 295 | fail2: mtouchusb_free_buffers(udev, mtouch); | ||
| 296 | fail1: input_free_device(input_dev); | ||
| 297 | kfree(mtouch); | ||
| 298 | return -ENOMEM; | ||
| 300 | } | 299 | } |
| 301 | 300 | ||
| 302 | static void mtouchusb_disconnect(struct usb_interface *intf) | 301 | static void mtouchusb_disconnect(struct usb_interface *intf) |
| @@ -308,7 +307,7 @@ static void mtouchusb_disconnect(struct usb_interface *intf) | |||
| 308 | if (mtouch) { | 307 | if (mtouch) { |
| 309 | dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); | 308 | dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); |
| 310 | usb_kill_urb(mtouch->irq); | 309 | usb_kill_urb(mtouch->irq); |
| 311 | input_unregister_device(&mtouch->input); | 310 | input_unregister_device(mtouch->input); |
| 312 | usb_free_urb(mtouch->irq); | 311 | usb_free_urb(mtouch->irq); |
| 313 | mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); | 312 | mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); |
| 314 | kfree(mtouch); | 313 | kfree(mtouch); |
diff --git a/drivers/usb/input/pid.c b/drivers/usb/input/pid.c index acc71ec560e9..a00672c96644 100644 --- a/drivers/usb/input/pid.c +++ b/drivers/usb/input/pid.c | |||
| @@ -262,6 +262,7 @@ int hid_pid_init(struct hid_device *hid) | |||
| 262 | { | 262 | { |
| 263 | struct hid_ff_pid *private; | 263 | struct hid_ff_pid *private; |
| 264 | struct hid_input *hidinput = list_entry(&hid->inputs, struct hid_input, list); | 264 | struct hid_input *hidinput = list_entry(&hid->inputs, struct hid_input, list); |
| 265 | struct input_dev *input_dev = hidinput->input; | ||
| 265 | 266 | ||
| 266 | private = hid->ff_private = kzalloc(sizeof(struct hid_ff_pid), GFP_KERNEL); | 267 | private = hid->ff_private = kzalloc(sizeof(struct hid_ff_pid), GFP_KERNEL); |
| 267 | if (!private) | 268 | if (!private) |
| @@ -281,11 +282,12 @@ int hid_pid_init(struct hid_device *hid) | |||
| 281 | usb_fill_control_urb(private->urbffout, hid->dev, 0, | 282 | usb_fill_control_urb(private->urbffout, hid->dev, 0, |
| 282 | (void *)&private->ffcr, private->ctrl_buffer, 8, | 283 | (void *)&private->ffcr, private->ctrl_buffer, 8, |
| 283 | hid_pid_ctrl_out, hid); | 284 | hid_pid_ctrl_out, hid); |
| 284 | hidinput->input.upload_effect = hid_pid_upload_effect; | 285 | |
| 285 | hidinput->input.flush = hid_pid_flush; | 286 | input_dev->upload_effect = hid_pid_upload_effect; |
| 286 | hidinput->input.ff_effects_max = 8; // A random default | 287 | input_dev->flush = hid_pid_flush; |
| 287 | set_bit(EV_FF, hidinput->input.evbit); | 288 | input_dev->ff_effects_max = 8; // A random default |
| 288 | set_bit(EV_FF_STATUS, hidinput->input.evbit); | 289 | set_bit(EV_FF, input_dev->evbit); |
| 290 | set_bit(EV_FF_STATUS, input_dev->evbit); | ||
| 289 | 291 | ||
| 290 | spin_lock_init(&private->lock); | 292 | spin_lock_init(&private->lock); |
| 291 | 293 | ||
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c index ad4afe7e5897..b7476233ef5d 100644 --- a/drivers/usb/input/powermate.c +++ b/drivers/usb/input/powermate.c | |||
| @@ -68,7 +68,7 @@ struct powermate_device { | |||
| 68 | struct usb_ctrlrequest *configcr; | 68 | struct usb_ctrlrequest *configcr; |
| 69 | dma_addr_t configcr_dma; | 69 | dma_addr_t configcr_dma; |
| 70 | struct usb_device *udev; | 70 | struct usb_device *udev; |
| 71 | struct input_dev input; | 71 | struct input_dev *input; |
| 72 | spinlock_t lock; | 72 | spinlock_t lock; |
| 73 | int static_brightness; | 73 | int static_brightness; |
| 74 | int pulse_speed; | 74 | int pulse_speed; |
| @@ -106,10 +106,10 @@ static void powermate_irq(struct urb *urb, struct pt_regs *regs) | |||
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | /* handle updates to device state */ | 108 | /* handle updates to device state */ |
| 109 | input_regs(&pm->input, regs); | 109 | input_regs(pm->input, regs); |
| 110 | input_report_key(&pm->input, BTN_0, pm->data[0] & 0x01); | 110 | input_report_key(pm->input, BTN_0, pm->data[0] & 0x01); |
| 111 | input_report_rel(&pm->input, REL_DIAL, pm->data[1]); | 111 | input_report_rel(pm->input, REL_DIAL, pm->data[1]); |
| 112 | input_sync(&pm->input); | 112 | input_sync(pm->input); |
| 113 | 113 | ||
| 114 | exit: | 114 | exit: |
| 115 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 115 | retval = usb_submit_urb (urb, GFP_ATOMIC); |
| @@ -153,10 +153,10 @@ static void powermate_sync_state(struct powermate_device *pm) | |||
| 153 | 153 | ||
| 154 | Only values of 'arg' quite close to 255 are particularly useful/spectacular. | 154 | Only values of 'arg' quite close to 255 are particularly useful/spectacular. |
| 155 | */ | 155 | */ |
| 156 | if (pm->pulse_speed < 255){ | 156 | if (pm->pulse_speed < 255) { |
| 157 | op = 0; // divide | 157 | op = 0; // divide |
| 158 | arg = 255 - pm->pulse_speed; | 158 | arg = 255 - pm->pulse_speed; |
| 159 | } else if (pm->pulse_speed > 255){ | 159 | } else if (pm->pulse_speed > 255) { |
| 160 | op = 2; // multiply | 160 | op = 2; // multiply |
| 161 | arg = pm->pulse_speed - 255; | 161 | arg = pm->pulse_speed - 255; |
| 162 | } else { | 162 | } else { |
| @@ -166,11 +166,11 @@ static void powermate_sync_state(struct powermate_device *pm) | |||
| 166 | pm->configcr->wValue = cpu_to_le16( (pm->pulse_table << 8) | SET_PULSE_MODE ); | 166 | pm->configcr->wValue = cpu_to_le16( (pm->pulse_table << 8) | SET_PULSE_MODE ); |
| 167 | pm->configcr->wIndex = cpu_to_le16( (arg << 8) | op ); | 167 | pm->configcr->wIndex = cpu_to_le16( (arg << 8) | op ); |
| 168 | pm->requires_update &= ~UPDATE_PULSE_MODE; | 168 | pm->requires_update &= ~UPDATE_PULSE_MODE; |
| 169 | }else if (pm->requires_update & UPDATE_STATIC_BRIGHTNESS){ | 169 | } else if (pm->requires_update & UPDATE_STATIC_BRIGHTNESS) { |
| 170 | pm->configcr->wValue = cpu_to_le16( SET_STATIC_BRIGHTNESS ); | 170 | pm->configcr->wValue = cpu_to_le16( SET_STATIC_BRIGHTNESS ); |
| 171 | pm->configcr->wIndex = cpu_to_le16( pm->static_brightness ); | 171 | pm->configcr->wIndex = cpu_to_le16( pm->static_brightness ); |
| 172 | pm->requires_update &= ~UPDATE_STATIC_BRIGHTNESS; | 172 | pm->requires_update &= ~UPDATE_STATIC_BRIGHTNESS; |
| 173 | }else{ | 173 | } else { |
| 174 | printk(KERN_ERR "powermate: unknown update required"); | 174 | printk(KERN_ERR "powermate: unknown update required"); |
| 175 | pm->requires_update = 0; /* fudge the bug */ | 175 | pm->requires_update = 0; /* fudge the bug */ |
| 176 | return; | 176 | return; |
| @@ -228,19 +228,19 @@ static void powermate_pulse_led(struct powermate_device *pm, int static_brightne | |||
| 228 | spin_lock_irqsave(&pm->lock, flags); | 228 | spin_lock_irqsave(&pm->lock, flags); |
| 229 | 229 | ||
| 230 | /* mark state updates which are required */ | 230 | /* mark state updates which are required */ |
| 231 | if (static_brightness != pm->static_brightness){ | 231 | if (static_brightness != pm->static_brightness) { |
| 232 | pm->static_brightness = static_brightness; | 232 | pm->static_brightness = static_brightness; |
| 233 | pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; | 233 | pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; |
| 234 | } | 234 | } |
| 235 | if (pulse_asleep != pm->pulse_asleep){ | 235 | if (pulse_asleep != pm->pulse_asleep) { |
| 236 | pm->pulse_asleep = pulse_asleep; | 236 | pm->pulse_asleep = pulse_asleep; |
| 237 | pm->requires_update |= (UPDATE_PULSE_ASLEEP | UPDATE_STATIC_BRIGHTNESS); | 237 | pm->requires_update |= (UPDATE_PULSE_ASLEEP | UPDATE_STATIC_BRIGHTNESS); |
| 238 | } | 238 | } |
| 239 | if (pulse_awake != pm->pulse_awake){ | 239 | if (pulse_awake != pm->pulse_awake) { |
| 240 | pm->pulse_awake = pulse_awake; | 240 | pm->pulse_awake = pulse_awake; |
| 241 | pm->requires_update |= (UPDATE_PULSE_AWAKE | UPDATE_STATIC_BRIGHTNESS); | 241 | pm->requires_update |= (UPDATE_PULSE_AWAKE | UPDATE_STATIC_BRIGHTNESS); |
| 242 | } | 242 | } |
| 243 | if (pulse_speed != pm->pulse_speed || pulse_table != pm->pulse_table){ | 243 | if (pulse_speed != pm->pulse_speed || pulse_table != pm->pulse_table) { |
| 244 | pm->pulse_speed = pulse_speed; | 244 | pm->pulse_speed = pulse_speed; |
| 245 | pm->pulse_table = pulse_table; | 245 | pm->pulse_table = pulse_table; |
| 246 | pm->requires_update |= UPDATE_PULSE_MODE; | 246 | pm->requires_update |= UPDATE_PULSE_MODE; |
| @@ -283,6 +283,7 @@ static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_dev | |||
| 283 | SLAB_ATOMIC, &pm->data_dma); | 283 | SLAB_ATOMIC, &pm->data_dma); |
| 284 | if (!pm->data) | 284 | if (!pm->data) |
| 285 | return -1; | 285 | return -1; |
| 286 | |||
| 286 | pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), | 287 | pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), |
| 287 | SLAB_ATOMIC, &pm->configcr_dma); | 288 | SLAB_ATOMIC, &pm->configcr_dma); |
| 288 | if (!pm->configcr) | 289 | if (!pm->configcr) |
| @@ -308,8 +309,9 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
| 308 | struct usb_host_interface *interface; | 309 | struct usb_host_interface *interface; |
| 309 | struct usb_endpoint_descriptor *endpoint; | 310 | struct usb_endpoint_descriptor *endpoint; |
| 310 | struct powermate_device *pm; | 311 | struct powermate_device *pm; |
| 312 | struct input_dev *input_dev; | ||
| 311 | int pipe, maxp; | 313 | int pipe, maxp; |
| 312 | char path[64]; | 314 | int err = -ENOMEM; |
| 313 | 315 | ||
| 314 | interface = intf->cur_altsetting; | 316 | interface = intf->cur_altsetting; |
| 315 | endpoint = &interface->endpoint[0].desc; | 317 | endpoint = &interface->endpoint[0].desc; |
| @@ -323,42 +325,61 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
| 323 | 0, interface->desc.bInterfaceNumber, NULL, 0, | 325 | 0, interface->desc.bInterfaceNumber, NULL, 0, |
| 324 | USB_CTRL_SET_TIMEOUT); | 326 | USB_CTRL_SET_TIMEOUT); |
| 325 | 327 | ||
| 326 | if (!(pm = kmalloc(sizeof(struct powermate_device), GFP_KERNEL))) | 328 | pm = kzalloc(sizeof(struct powermate_device), GFP_KERNEL); |
| 327 | return -ENOMEM; | 329 | input_dev = input_allocate_device(); |
| 328 | 330 | if (!pm || !input_dev) | |
| 329 | memset(pm, 0, sizeof(struct powermate_device)); | 331 | goto fail1; |
| 330 | pm->udev = udev; | ||
| 331 | 332 | ||
| 332 | if (powermate_alloc_buffers(udev, pm)) { | 333 | if (powermate_alloc_buffers(udev, pm)) |
| 333 | powermate_free_buffers(udev, pm); | 334 | goto fail2; |
| 334 | kfree(pm); | ||
| 335 | return -ENOMEM; | ||
| 336 | } | ||
| 337 | 335 | ||
| 338 | pm->irq = usb_alloc_urb(0, GFP_KERNEL); | 336 | pm->irq = usb_alloc_urb(0, GFP_KERNEL); |
| 339 | if (!pm->irq) { | 337 | if (!pm->irq) |
| 340 | powermate_free_buffers(udev, pm); | 338 | goto fail2; |
| 341 | kfree(pm); | ||
| 342 | return -ENOMEM; | ||
| 343 | } | ||
| 344 | 339 | ||
| 345 | pm->config = usb_alloc_urb(0, GFP_KERNEL); | 340 | pm->config = usb_alloc_urb(0, GFP_KERNEL); |
| 346 | if (!pm->config) { | 341 | if (!pm->config) |
| 347 | usb_free_urb(pm->irq); | 342 | goto fail3; |
| 348 | powermate_free_buffers(udev, pm); | 343 | |
| 349 | kfree(pm); | 344 | pm->udev = udev; |
| 350 | return -ENOMEM; | 345 | pm->input = input_dev; |
| 351 | } | 346 | |
| 347 | usb_make_path(udev, pm->phys, sizeof(pm->phys)); | ||
| 348 | strlcpy(pm->phys, "/input0", sizeof(pm->phys)); | ||
| 352 | 349 | ||
| 353 | spin_lock_init(&pm->lock); | 350 | spin_lock_init(&pm->lock); |
| 354 | init_input_dev(&pm->input); | 351 | |
| 352 | switch (le16_to_cpu(udev->descriptor.idProduct)) { | ||
| 353 | case POWERMATE_PRODUCT_NEW: | ||
| 354 | input_dev->name = pm_name_powermate; | ||
| 355 | break; | ||
| 356 | case POWERMATE_PRODUCT_OLD: | ||
| 357 | input_dev->name = pm_name_soundknob; | ||
| 358 | break; | ||
| 359 | default: | ||
| 360 | input_dev->name = pm_name_soundknob; | ||
| 361 | printk(KERN_WARNING "powermate: unknown product id %04x\n", | ||
| 362 | le16_to_cpu(udev->descriptor.idProduct)); | ||
| 363 | } | ||
| 364 | |||
| 365 | input_dev->phys = pm->phys; | ||
| 366 | usb_to_input_id(udev, &input_dev->id); | ||
| 367 | input_dev->cdev.dev = &intf->dev; | ||
| 368 | input_dev->private = pm; | ||
| 369 | |||
| 370 | input_dev->event = powermate_input_event; | ||
| 371 | |||
| 372 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_MSC); | ||
| 373 | input_dev->keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
| 374 | input_dev->relbit[LONG(REL_DIAL)] = BIT(REL_DIAL); | ||
| 375 | input_dev->mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED); | ||
| 355 | 376 | ||
| 356 | /* get a handle to the interrupt data pipe */ | 377 | /* get a handle to the interrupt data pipe */ |
| 357 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); | 378 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); |
| 358 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); | 379 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); |
| 359 | 380 | ||
| 360 | if(maxp < POWERMATE_PAYLOAD_SIZE_MIN || maxp > POWERMATE_PAYLOAD_SIZE_MAX){ | 381 | if (maxp < POWERMATE_PAYLOAD_SIZE_MIN || maxp > POWERMATE_PAYLOAD_SIZE_MAX) { |
| 361 | printk("powermate: Expected payload of %d--%d bytes, found %d bytes!\n", | 382 | printk(KERN_WARNING "powermate: Expected payload of %d--%d bytes, found %d bytes!\n", |
| 362 | POWERMATE_PAYLOAD_SIZE_MIN, POWERMATE_PAYLOAD_SIZE_MAX, maxp); | 383 | POWERMATE_PAYLOAD_SIZE_MIN, POWERMATE_PAYLOAD_SIZE_MAX, maxp); |
| 363 | maxp = POWERMATE_PAYLOAD_SIZE_MAX; | 384 | maxp = POWERMATE_PAYLOAD_SIZE_MAX; |
| 364 | } | 385 | } |
| @@ -371,35 +392,11 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
| 371 | 392 | ||
| 372 | /* register our interrupt URB with the USB system */ | 393 | /* register our interrupt URB with the USB system */ |
| 373 | if (usb_submit_urb(pm->irq, GFP_KERNEL)) { | 394 | if (usb_submit_urb(pm->irq, GFP_KERNEL)) { |
| 374 | powermate_free_buffers(udev, pm); | 395 | err = -EIO; |
| 375 | kfree(pm); | 396 | goto fail4; |
| 376 | return -EIO; /* failure */ | ||
| 377 | } | 397 | } |
| 378 | 398 | ||
| 379 | switch (le16_to_cpu(udev->descriptor.idProduct)) { | 399 | input_register_device(pm->input); |
| 380 | case POWERMATE_PRODUCT_NEW: pm->input.name = pm_name_powermate; break; | ||
| 381 | case POWERMATE_PRODUCT_OLD: pm->input.name = pm_name_soundknob; break; | ||
| 382 | default: | ||
| 383 | pm->input.name = pm_name_soundknob; | ||
| 384 | printk(KERN_WARNING "powermate: unknown product id %04x\n", | ||
| 385 | le16_to_cpu(udev->descriptor.idProduct)); | ||
| 386 | } | ||
| 387 | |||
| 388 | pm->input.private = pm; | ||
| 389 | pm->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_MSC); | ||
| 390 | pm->input.keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
| 391 | pm->input.relbit[LONG(REL_DIAL)] = BIT(REL_DIAL); | ||
| 392 | pm->input.mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED); | ||
| 393 | usb_to_input_id(udev, &pm->input.id); | ||
| 394 | pm->input.event = powermate_input_event; | ||
| 395 | pm->input.dev = &intf->dev; | ||
| 396 | pm->input.phys = pm->phys; | ||
| 397 | |||
| 398 | input_register_device(&pm->input); | ||
| 399 | |||
| 400 | usb_make_path(udev, path, 64); | ||
| 401 | snprintf(pm->phys, 64, "%s/input0", path); | ||
| 402 | printk(KERN_INFO "input: %s on %s\n", pm->input.name, pm->input.phys); | ||
| 403 | 400 | ||
| 404 | /* force an update of everything */ | 401 | /* force an update of everything */ |
| 405 | pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; | 402 | pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; |
| @@ -407,6 +404,13 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
| 407 | 404 | ||
| 408 | usb_set_intfdata(intf, pm); | 405 | usb_set_intfdata(intf, pm); |
| 409 | return 0; | 406 | return 0; |
| 407 | |||
| 408 | fail4: usb_free_urb(pm->config); | ||
| 409 | fail3: usb_free_urb(pm->irq); | ||
| 410 | fail2: powermate_free_buffers(udev, pm); | ||
| 411 | fail1: input_free_device(input_dev); | ||
| 412 | kfree(pm); | ||
| 413 | return err; | ||
| 410 | } | 414 | } |
| 411 | 415 | ||
| 412 | /* Called when a USB device we've accepted ownership of is removed */ | 416 | /* Called when a USB device we've accepted ownership of is removed */ |
| @@ -418,7 +422,7 @@ static void powermate_disconnect(struct usb_interface *intf) | |||
| 418 | if (pm) { | 422 | if (pm) { |
| 419 | pm->requires_update = 0; | 423 | pm->requires_update = 0; |
| 420 | usb_kill_urb(pm->irq); | 424 | usb_kill_urb(pm->irq); |
| 421 | input_unregister_device(&pm->input); | 425 | input_unregister_device(pm->input); |
| 422 | usb_free_urb(pm->irq); | 426 | usb_free_urb(pm->irq); |
| 423 | usb_free_urb(pm->config); | 427 | usb_free_urb(pm->config); |
| 424 | powermate_free_buffers(interface_to_usbdev(intf), pm); | 428 | powermate_free_buffers(interface_to_usbdev(intf), pm); |
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); |
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c index 28987f15eeee..226b6f90a907 100644 --- a/drivers/usb/input/usbkbd.c +++ b/drivers/usb/input/usbkbd.c | |||
| @@ -66,7 +66,7 @@ static unsigned char usb_kbd_keycode[256] = { | |||
| 66 | }; | 66 | }; |
| 67 | 67 | ||
| 68 | struct usb_kbd { | 68 | struct usb_kbd { |
| 69 | struct input_dev dev; | 69 | struct input_dev *dev; |
| 70 | struct usb_device *usbdev; | 70 | struct usb_device *usbdev; |
| 71 | unsigned char old[8]; | 71 | unsigned char old[8]; |
| 72 | struct urb *irq, *led; | 72 | struct urb *irq, *led; |
| @@ -99,29 +99,29 @@ static void usb_kbd_irq(struct urb *urb, struct pt_regs *regs) | |||
| 99 | goto resubmit; | 99 | goto resubmit; |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | input_regs(&kbd->dev, regs); | 102 | input_regs(kbd->dev, regs); |
| 103 | 103 | ||
| 104 | for (i = 0; i < 8; i++) | 104 | for (i = 0; i < 8; i++) |
| 105 | input_report_key(&kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); | 105 | input_report_key(kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); |
| 106 | 106 | ||
| 107 | for (i = 2; i < 8; i++) { | 107 | for (i = 2; i < 8; i++) { |
| 108 | 108 | ||
| 109 | if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == kbd->new + 8) { | 109 | if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == kbd->new + 8) { |
| 110 | if (usb_kbd_keycode[kbd->old[i]]) | 110 | if (usb_kbd_keycode[kbd->old[i]]) |
| 111 | input_report_key(&kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); | 111 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); |
| 112 | else | 112 | else |
| 113 | info("Unknown key (scancode %#x) released.", kbd->old[i]); | 113 | info("Unknown key (scancode %#x) released.", kbd->old[i]); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { | 116 | if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { |
| 117 | if (usb_kbd_keycode[kbd->new[i]]) | 117 | if (usb_kbd_keycode[kbd->new[i]]) |
| 118 | input_report_key(&kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); | 118 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); |
| 119 | else | 119 | else |
| 120 | info("Unknown key (scancode %#x) pressed.", kbd->new[i]); | 120 | info("Unknown key (scancode %#x) pressed.", kbd->new[i]); |
| 121 | } | 121 | } |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | input_sync(&kbd->dev); | 124 | input_sync(kbd->dev); |
| 125 | 125 | ||
| 126 | memcpy(kbd->old, kbd->new, 8); | 126 | memcpy(kbd->old, kbd->new, 8); |
| 127 | 127 | ||
| @@ -227,12 +227,12 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) | |||
| 227 | static int usb_kbd_probe(struct usb_interface *iface, | 227 | static int usb_kbd_probe(struct usb_interface *iface, |
| 228 | const struct usb_device_id *id) | 228 | const struct usb_device_id *id) |
| 229 | { | 229 | { |
| 230 | struct usb_device * dev = interface_to_usbdev(iface); | 230 | struct usb_device *dev = interface_to_usbdev(iface); |
| 231 | struct usb_host_interface *interface; | 231 | struct usb_host_interface *interface; |
| 232 | struct usb_endpoint_descriptor *endpoint; | 232 | struct usb_endpoint_descriptor *endpoint; |
| 233 | struct usb_kbd *kbd; | 233 | struct usb_kbd *kbd; |
| 234 | struct input_dev *input_dev; | ||
| 234 | int i, pipe, maxp; | 235 | int i, pipe, maxp; |
| 235 | char path[64]; | ||
| 236 | 236 | ||
| 237 | interface = iface->cur_altsetting; | 237 | interface = iface->cur_altsetting; |
| 238 | 238 | ||
| @@ -240,37 +240,59 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
| 240 | return -ENODEV; | 240 | return -ENODEV; |
| 241 | 241 | ||
| 242 | endpoint = &interface->endpoint[0].desc; | 242 | endpoint = &interface->endpoint[0].desc; |
| 243 | if (!(endpoint->bEndpointAddress & 0x80)) | 243 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
| 244 | return -ENODEV; | 244 | return -ENODEV; |
| 245 | if ((endpoint->bmAttributes & 3) != 3) | 245 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) |
| 246 | return -ENODEV; | 246 | return -ENODEV; |
| 247 | 247 | ||
| 248 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); | 248 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
| 249 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | 249 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
| 250 | 250 | ||
| 251 | if (!(kbd = kmalloc(sizeof(struct usb_kbd), GFP_KERNEL))) | 251 | kbd = kzalloc(sizeof(struct usb_kbd), GFP_KERNEL); |
| 252 | return -ENOMEM; | 252 | input_dev = input_allocate_device(); |
| 253 | memset(kbd, 0, sizeof(struct usb_kbd)); | 253 | if (!kbd || !input_dev) |
| 254 | goto fail1; | ||
| 254 | 255 | ||
| 255 | if (usb_kbd_alloc_mem(dev, kbd)) { | 256 | if (usb_kbd_alloc_mem(dev, kbd)) |
| 256 | usb_kbd_free_mem(dev, kbd); | 257 | goto fail2; |
| 257 | kfree(kbd); | ||
| 258 | return -ENOMEM; | ||
| 259 | } | ||
| 260 | 258 | ||
| 261 | kbd->usbdev = dev; | 259 | kbd->usbdev = dev; |
| 260 | kbd->dev = input_dev; | ||
| 261 | |||
| 262 | if (dev->manufacturer) | ||
| 263 | strlcpy(kbd->name, dev->manufacturer, sizeof(kbd->name)); | ||
| 264 | |||
| 265 | if (dev->product) { | ||
| 266 | if (dev->manufacturer) | ||
| 267 | strlcat(kbd->name, " ", sizeof(kbd->name)); | ||
| 268 | strlcat(kbd->name, dev->product, sizeof(kbd->name)); | ||
| 269 | } | ||
| 270 | |||
| 271 | if (!strlen(kbd->name)) | ||
| 272 | snprintf(kbd->name, sizeof(kbd->name), | ||
| 273 | "USB HIDBP Keyboard %04x:%04x", | ||
| 274 | le16_to_cpu(dev->descriptor.idVendor), | ||
| 275 | le16_to_cpu(dev->descriptor.idProduct)); | ||
| 276 | |||
| 277 | usb_make_path(dev, kbd->phys, sizeof(kbd->phys)); | ||
| 278 | strlcpy(kbd->phys, "/input0", sizeof(kbd->phys)); | ||
| 262 | 279 | ||
| 263 | kbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); | 280 | input_dev->name = kbd->name; |
| 264 | kbd->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); | 281 | input_dev->phys = kbd->phys; |
| 282 | usb_to_input_id(dev, &input_dev->id); | ||
| 283 | input_dev->cdev.dev = &iface->dev; | ||
| 284 | input_dev->private = kbd; | ||
| 285 | |||
| 286 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); | ||
| 287 | input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); | ||
| 265 | 288 | ||
| 266 | for (i = 0; i < 255; i++) | 289 | for (i = 0; i < 255; i++) |
| 267 | set_bit(usb_kbd_keycode[i], kbd->dev.keybit); | 290 | set_bit(usb_kbd_keycode[i], input_dev->keybit); |
| 268 | clear_bit(0, kbd->dev.keybit); | 291 | clear_bit(0, input_dev->keybit); |
| 269 | 292 | ||
| 270 | kbd->dev.private = kbd; | 293 | input_dev->event = usb_kbd_event; |
| 271 | kbd->dev.event = usb_kbd_event; | 294 | input_dev->open = usb_kbd_open; |
| 272 | kbd->dev.open = usb_kbd_open; | 295 | input_dev->close = usb_kbd_close; |
| 273 | kbd->dev.close = usb_kbd_close; | ||
| 274 | 296 | ||
| 275 | usb_fill_int_urb(kbd->irq, dev, pipe, | 297 | usb_fill_int_urb(kbd->irq, dev, pipe, |
| 276 | kbd->new, (maxp > 8 ? 8 : maxp), | 298 | kbd->new, (maxp > 8 ? 8 : maxp), |
| @@ -284,37 +306,22 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
| 284 | kbd->cr->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); | 306 | kbd->cr->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); |
| 285 | kbd->cr->wLength = cpu_to_le16(1); | 307 | kbd->cr->wLength = cpu_to_le16(1); |
| 286 | 308 | ||
| 287 | usb_make_path(dev, path, 64); | ||
| 288 | sprintf(kbd->phys, "%s/input0", path); | ||
| 289 | |||
| 290 | kbd->dev.name = kbd->name; | ||
| 291 | kbd->dev.phys = kbd->phys; | ||
| 292 | usb_to_input_id(dev, &kbd->dev.id); | ||
| 293 | kbd->dev.dev = &iface->dev; | ||
| 294 | |||
| 295 | if (dev->manufacturer) | ||
| 296 | strcat(kbd->name, dev->manufacturer); | ||
| 297 | if (dev->product) | ||
| 298 | sprintf(kbd->name, "%s %s", kbd->name, dev->product); | ||
| 299 | |||
| 300 | if (!strlen(kbd->name)) | ||
| 301 | sprintf(kbd->name, "USB HIDBP Keyboard %04x:%04x", | ||
| 302 | kbd->dev.id.vendor, kbd->dev.id.product); | ||
| 303 | |||
| 304 | usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0), | 309 | usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0), |
| 305 | (void *) kbd->cr, kbd->leds, 1, | 310 | (void *) kbd->cr, kbd->leds, 1, |
| 306 | usb_kbd_led, kbd); | 311 | usb_kbd_led, kbd); |
| 307 | kbd->led->setup_dma = kbd->cr_dma; | 312 | kbd->led->setup_dma = kbd->cr_dma; |
| 308 | kbd->led->transfer_dma = kbd->leds_dma; | 313 | kbd->led->transfer_dma = kbd->leds_dma; |
| 309 | kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | 314 | kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); |
| 310 | | URB_NO_SETUP_DMA_MAP); | ||
| 311 | 315 | ||
| 312 | input_register_device(&kbd->dev); | 316 | input_register_device(kbd->dev); |
| 313 | |||
| 314 | printk(KERN_INFO "input: %s on %s\n", kbd->name, path); | ||
| 315 | 317 | ||
| 316 | usb_set_intfdata(iface, kbd); | 318 | usb_set_intfdata(iface, kbd); |
| 317 | return 0; | 319 | return 0; |
| 320 | |||
| 321 | fail2: usb_kbd_free_mem(dev, kbd); | ||
| 322 | fail1: input_free_device(input_dev); | ||
| 323 | kfree(kbd); | ||
| 324 | return -ENOMEM; | ||
| 318 | } | 325 | } |
| 319 | 326 | ||
| 320 | static void usb_kbd_disconnect(struct usb_interface *intf) | 327 | static void usb_kbd_disconnect(struct usb_interface *intf) |
| @@ -324,7 +331,7 @@ static void usb_kbd_disconnect(struct usb_interface *intf) | |||
| 324 | usb_set_intfdata(intf, NULL); | 331 | usb_set_intfdata(intf, NULL); |
| 325 | if (kbd) { | 332 | if (kbd) { |
| 326 | usb_kill_urb(kbd->irq); | 333 | usb_kill_urb(kbd->irq); |
| 327 | input_unregister_device(&kbd->dev); | 334 | input_unregister_device(kbd->dev); |
| 328 | usb_kbd_free_mem(interface_to_usbdev(intf), kbd); | 335 | usb_kbd_free_mem(interface_to_usbdev(intf), kbd); |
| 329 | kfree(kbd); | 336 | kfree(kbd); |
| 330 | } | 337 | } |
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c index 4104dec847fb..230f6b1b314a 100644 --- a/drivers/usb/input/usbmouse.c +++ b/drivers/usb/input/usbmouse.c | |||
| @@ -50,7 +50,7 @@ struct usb_mouse { | |||
| 50 | char name[128]; | 50 | char name[128]; |
| 51 | char phys[64]; | 51 | char phys[64]; |
| 52 | struct usb_device *usbdev; | 52 | struct usb_device *usbdev; |
| 53 | struct input_dev dev; | 53 | struct input_dev *dev; |
| 54 | struct urb *irq; | 54 | struct urb *irq; |
| 55 | 55 | ||
| 56 | signed char *data; | 56 | signed char *data; |
| @@ -61,7 +61,7 @@ static void usb_mouse_irq(struct urb *urb, struct pt_regs *regs) | |||
| 61 | { | 61 | { |
| 62 | struct usb_mouse *mouse = urb->context; | 62 | struct usb_mouse *mouse = urb->context; |
| 63 | signed char *data = mouse->data; | 63 | signed char *data = mouse->data; |
| 64 | struct input_dev *dev = &mouse->dev; | 64 | struct input_dev *dev = mouse->dev; |
| 65 | int status; | 65 | int status; |
| 66 | 66 | ||
| 67 | switch (urb->status) { | 67 | switch (urb->status) { |
| @@ -115,14 +115,14 @@ static void usb_mouse_close(struct input_dev *dev) | |||
| 115 | usb_kill_urb(mouse->irq); | 115 | usb_kill_urb(mouse->irq); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_id * id) | 118 | static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 119 | { | 119 | { |
| 120 | struct usb_device * dev = interface_to_usbdev(intf); | 120 | struct usb_device *dev = interface_to_usbdev(intf); |
| 121 | struct usb_host_interface *interface; | 121 | struct usb_host_interface *interface; |
| 122 | struct usb_endpoint_descriptor *endpoint; | 122 | struct usb_endpoint_descriptor *endpoint; |
| 123 | struct usb_mouse *mouse; | 123 | struct usb_mouse *mouse; |
| 124 | struct input_dev *input_dev; | ||
| 124 | int pipe, maxp; | 125 | int pipe, maxp; |
| 125 | char path[64]; | ||
| 126 | 126 | ||
| 127 | interface = intf->cur_altsetting; | 127 | interface = intf->cur_altsetting; |
| 128 | 128 | ||
| @@ -130,59 +130,62 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_ | |||
| 130 | return -ENODEV; | 130 | return -ENODEV; |
| 131 | 131 | ||
| 132 | endpoint = &interface->endpoint[0].desc; | 132 | endpoint = &interface->endpoint[0].desc; |
| 133 | if (!(endpoint->bEndpointAddress & 0x80)) | 133 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
| 134 | return -ENODEV; | 134 | return -ENODEV; |
| 135 | if ((endpoint->bmAttributes & 3) != 3) | 135 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) |
| 136 | return -ENODEV; | 136 | return -ENODEV; |
| 137 | 137 | ||
| 138 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); | 138 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
| 139 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | 139 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
| 140 | 140 | ||
| 141 | if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) | 141 | mouse = kzalloc(sizeof(struct usb_mouse), GFP_KERNEL); |
| 142 | return -ENOMEM; | 142 | input_dev = input_allocate_device(); |
| 143 | memset(mouse, 0, sizeof(struct usb_mouse)); | 143 | if (!mouse || !input_dev) |
| 144 | goto fail1; | ||
| 144 | 145 | ||
| 145 | mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); | 146 | mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); |
| 146 | if (!mouse->data) { | 147 | if (!mouse->data) |
| 147 | kfree(mouse); | 148 | goto fail1; |
| 148 | return -ENOMEM; | ||
| 149 | } | ||
| 150 | 149 | ||
| 151 | mouse->irq = usb_alloc_urb(0, GFP_KERNEL); | 150 | mouse->irq = usb_alloc_urb(0, GFP_KERNEL); |
| 152 | if (!mouse->irq) { | 151 | if (!mouse->irq) |
| 153 | usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); | 152 | goto fail2; |
| 154 | kfree(mouse); | ||
| 155 | return -ENODEV; | ||
| 156 | } | ||
| 157 | 153 | ||
| 158 | mouse->usbdev = dev; | 154 | mouse->usbdev = dev; |
| 155 | mouse->dev = input_dev; | ||
| 156 | |||
| 157 | if (dev->manufacturer) | ||
| 158 | strlcpy(mouse->name, dev->manufacturer, sizeof(mouse->name)); | ||
| 159 | 159 | ||
| 160 | mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 160 | if (dev->product) { |
| 161 | mouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 161 | if (dev->manufacturer) |
| 162 | mouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); | 162 | strlcat(mouse->name, " ", sizeof(mouse->name)); |
| 163 | mouse->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 163 | strlcat(mouse->name, dev->product, sizeof(mouse->name)); |
| 164 | mouse->dev.relbit[0] |= BIT(REL_WHEEL); | 164 | } |
| 165 | 165 | ||
| 166 | mouse->dev.private = mouse; | 166 | if (!strlen(mouse->name)) |
| 167 | mouse->dev.open = usb_mouse_open; | 167 | snprintf(mouse->name, sizeof(mouse->name), |
| 168 | mouse->dev.close = usb_mouse_close; | 168 | "USB HIDBP Mouse %04x:%04x", |
| 169 | le16_to_cpu(dev->descriptor.idVendor), | ||
| 170 | le16_to_cpu(dev->descriptor.idProduct)); | ||
| 169 | 171 | ||
| 170 | usb_make_path(dev, path, 64); | 172 | usb_make_path(dev, mouse->phys, sizeof(mouse->phys)); |
| 171 | sprintf(mouse->phys, "%s/input0", path); | 173 | strlcat(mouse->phys, "/input0", sizeof(mouse->phys)); |
| 172 | 174 | ||
| 173 | mouse->dev.name = mouse->name; | 175 | input_dev->name = mouse->name; |
| 174 | mouse->dev.phys = mouse->phys; | 176 | input_dev->phys = mouse->phys; |
| 175 | usb_to_input_id(dev, &mouse->dev.id); | 177 | usb_to_input_id(dev, &input_dev->id); |
| 176 | mouse->dev.dev = &intf->dev; | 178 | input_dev->cdev.dev = &intf->dev; |
| 177 | 179 | ||
| 178 | if (dev->manufacturer) | 180 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
| 179 | strcat(mouse->name, dev->manufacturer); | 181 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
| 180 | if (dev->product) | 182 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); |
| 181 | sprintf(mouse->name, "%s %s", mouse->name, dev->product); | 183 | input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); |
| 184 | input_dev->relbit[0] |= BIT(REL_WHEEL); | ||
| 182 | 185 | ||
| 183 | if (!strlen(mouse->name)) | 186 | input_dev->private = mouse; |
| 184 | sprintf(mouse->name, "USB HIDBP Mouse %04x:%04x", | 187 | input_dev->open = usb_mouse_open; |
| 185 | mouse->dev.id.vendor, mouse->dev.id.product); | 188 | input_dev->close = usb_mouse_close; |
| 186 | 189 | ||
| 187 | usb_fill_int_urb(mouse->irq, dev, pipe, mouse->data, | 190 | usb_fill_int_urb(mouse->irq, dev, pipe, mouse->data, |
| 188 | (maxp > 8 ? 8 : maxp), | 191 | (maxp > 8 ? 8 : maxp), |
| @@ -190,11 +193,15 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_ | |||
| 190 | mouse->irq->transfer_dma = mouse->data_dma; | 193 | mouse->irq->transfer_dma = mouse->data_dma; |
| 191 | mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 194 | mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 192 | 195 | ||
| 193 | input_register_device(&mouse->dev); | 196 | input_register_device(mouse->dev); |
| 194 | printk(KERN_INFO "input: %s on %s\n", mouse->name, path); | ||
| 195 | 197 | ||
| 196 | usb_set_intfdata(intf, mouse); | 198 | usb_set_intfdata(intf, mouse); |
| 197 | return 0; | 199 | return 0; |
| 200 | |||
| 201 | fail2: usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); | ||
| 202 | fail1: input_free_device(input_dev); | ||
| 203 | kfree(mouse); | ||
| 204 | return -ENOMEM; | ||
| 198 | } | 205 | } |
| 199 | 206 | ||
| 200 | static void usb_mouse_disconnect(struct usb_interface *intf) | 207 | static void usb_mouse_disconnect(struct usb_interface *intf) |
| @@ -204,7 +211,7 @@ static void usb_mouse_disconnect(struct usb_interface *intf) | |||
| 204 | usb_set_intfdata(intf, NULL); | 211 | usb_set_intfdata(intf, NULL); |
| 205 | if (mouse) { | 212 | if (mouse) { |
| 206 | usb_kill_urb(mouse->irq); | 213 | usb_kill_urb(mouse->irq); |
| 207 | input_unregister_device(&mouse->dev); | 214 | input_unregister_device(mouse->dev); |
| 208 | usb_free_urb(mouse->irq); | 215 | usb_free_urb(mouse->irq); |
| 209 | usb_buffer_free(interface_to_usbdev(intf), 8, mouse->data, mouse->data_dma); | 216 | usb_buffer_free(interface_to_usbdev(intf), 8, mouse->data, mouse->data_dma); |
| 210 | kfree(mouse); | 217 | kfree(mouse); |
diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c index 3b266af3048a..ea0f75773ae1 100644 --- a/drivers/usb/input/wacom.c +++ b/drivers/usb/input/wacom.c | |||
| @@ -111,7 +111,7 @@ struct wacom_features { | |||
| 111 | struct wacom { | 111 | struct wacom { |
| 112 | signed char *data; | 112 | signed char *data; |
| 113 | dma_addr_t data_dma; | 113 | dma_addr_t data_dma; |
| 114 | struct input_dev dev; | 114 | struct input_dev *dev; |
| 115 | struct usb_device *usbdev; | 115 | struct usb_device *usbdev; |
| 116 | struct urb *irq; | 116 | struct urb *irq; |
| 117 | struct wacom_features *features; | 117 | struct wacom_features *features; |
| @@ -135,7 +135,7 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs) | |||
| 135 | { | 135 | { |
| 136 | struct wacom *wacom = urb->context; | 136 | struct wacom *wacom = urb->context; |
| 137 | unsigned char *data = wacom->data; | 137 | unsigned char *data = wacom->data; |
| 138 | struct input_dev *dev = &wacom->dev; | 138 | struct input_dev *dev = wacom->dev; |
| 139 | int prox, pressure; | 139 | int prox, pressure; |
| 140 | int retval; | 140 | int retval; |
| 141 | 141 | ||
| @@ -225,7 +225,7 @@ static void wacom_ptu_irq(struct urb *urb, struct pt_regs *regs) | |||
| 225 | { | 225 | { |
| 226 | struct wacom *wacom = urb->context; | 226 | struct wacom *wacom = urb->context; |
| 227 | unsigned char *data = wacom->data; | 227 | unsigned char *data = wacom->data; |
| 228 | struct input_dev *dev = &wacom->dev; | 228 | struct input_dev *dev = wacom->dev; |
| 229 | int retval; | 229 | int retval; |
| 230 | 230 | ||
| 231 | switch (urb->status) { | 231 | switch (urb->status) { |
| @@ -275,7 +275,7 @@ static void wacom_penpartner_irq(struct urb *urb, struct pt_regs *regs) | |||
| 275 | { | 275 | { |
| 276 | struct wacom *wacom = urb->context; | 276 | struct wacom *wacom = urb->context; |
| 277 | unsigned char *data = wacom->data; | 277 | unsigned char *data = wacom->data; |
| 278 | struct input_dev *dev = &wacom->dev; | 278 | struct input_dev *dev = wacom->dev; |
| 279 | int retval; | 279 | int retval; |
| 280 | 280 | ||
| 281 | switch (urb->status) { | 281 | switch (urb->status) { |
| @@ -318,7 +318,7 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs) | |||
| 318 | { | 318 | { |
| 319 | struct wacom *wacom = urb->context; | 319 | struct wacom *wacom = urb->context; |
| 320 | unsigned char *data = wacom->data; | 320 | unsigned char *data = wacom->data; |
| 321 | struct input_dev *dev = &wacom->dev; | 321 | struct input_dev *dev = wacom->dev; |
| 322 | int x, y; | 322 | int x, y; |
| 323 | int retval; | 323 | int retval; |
| 324 | 324 | ||
| @@ -397,7 +397,7 @@ static int wacom_intuos_inout(struct urb *urb) | |||
| 397 | { | 397 | { |
| 398 | struct wacom *wacom = urb->context; | 398 | struct wacom *wacom = urb->context; |
| 399 | unsigned char *data = wacom->data; | 399 | unsigned char *data = wacom->data; |
| 400 | struct input_dev *dev = &wacom->dev; | 400 | struct input_dev *dev = wacom->dev; |
| 401 | int idx; | 401 | int idx; |
| 402 | 402 | ||
| 403 | /* tool number */ | 403 | /* tool number */ |
| @@ -479,7 +479,7 @@ static void wacom_intuos_general(struct urb *urb) | |||
| 479 | { | 479 | { |
| 480 | struct wacom *wacom = urb->context; | 480 | struct wacom *wacom = urb->context; |
| 481 | unsigned char *data = wacom->data; | 481 | unsigned char *data = wacom->data; |
| 482 | struct input_dev *dev = &wacom->dev; | 482 | struct input_dev *dev = wacom->dev; |
| 483 | unsigned int t; | 483 | unsigned int t; |
| 484 | 484 | ||
| 485 | /* general pen packet */ | 485 | /* general pen packet */ |
| @@ -509,7 +509,7 @@ static void wacom_intuos_irq(struct urb *urb, struct pt_regs *regs) | |||
| 509 | { | 509 | { |
| 510 | struct wacom *wacom = urb->context; | 510 | struct wacom *wacom = urb->context; |
| 511 | unsigned char *data = wacom->data; | 511 | unsigned char *data = wacom->data; |
| 512 | struct input_dev *dev = &wacom->dev; | 512 | struct input_dev *dev = wacom->dev; |
| 513 | unsigned int t; | 513 | unsigned int t; |
| 514 | int idx; | 514 | int idx; |
| 515 | int retval; | 515 | int retval; |
| @@ -738,95 +738,83 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
| 738 | { | 738 | { |
| 739 | struct usb_device *dev = interface_to_usbdev(intf); | 739 | struct usb_device *dev = interface_to_usbdev(intf); |
| 740 | struct usb_endpoint_descriptor *endpoint; | 740 | struct usb_endpoint_descriptor *endpoint; |
| 741 | char rep_data[2] = {0x02, 0x02}; | ||
| 742 | struct wacom *wacom; | 741 | struct wacom *wacom; |
| 743 | char path[64]; | 742 | struct input_dev *input_dev; |
| 743 | char rep_data[2] = {0x02, 0x02}; | ||
| 744 | 744 | ||
| 745 | if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL))) | 745 | wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); |
| 746 | return -ENOMEM; | 746 | input_dev = input_allocate_device(); |
| 747 | memset(wacom, 0, sizeof(struct wacom)); | 747 | if (!wacom || !input_dev) |
| 748 | goto fail1; | ||
| 748 | 749 | ||
| 749 | wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma); | 750 | wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma); |
| 750 | if (!wacom->data) { | 751 | if (!wacom->data) |
| 751 | kfree(wacom); | 752 | goto fail1; |
| 752 | return -ENOMEM; | ||
| 753 | } | ||
| 754 | 753 | ||
| 755 | wacom->irq = usb_alloc_urb(0, GFP_KERNEL); | 754 | wacom->irq = usb_alloc_urb(0, GFP_KERNEL); |
| 756 | if (!wacom->irq) { | 755 | if (!wacom->irq) |
| 757 | usb_buffer_free(dev, 10, wacom->data, wacom->data_dma); | 756 | goto fail2; |
| 758 | kfree(wacom); | 757 | |
| 759 | return -ENOMEM; | 758 | wacom->usbdev = dev; |
| 760 | } | 759 | wacom->dev = input_dev; |
| 760 | usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); | ||
| 761 | strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); | ||
| 761 | 762 | ||
| 762 | wacom->features = wacom_features + (id - wacom_ids); | 763 | wacom->features = wacom_features + (id - wacom_ids); |
| 764 | if (wacom->features->pktlen > 10) | ||
| 765 | BUG(); | ||
| 766 | |||
| 767 | input_dev->name = wacom->features->name; | ||
| 768 | usb_to_input_id(dev, &input_dev->id); | ||
| 763 | 769 | ||
| 764 | wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS); | 770 | input_dev->cdev.dev = &intf->dev; |
| 765 | wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | 771 | input_dev->private = wacom; |
| 766 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); | 772 | input_dev->open = wacom_open; |
| 773 | input_dev->close = wacom_close; | ||
| 774 | |||
| 775 | input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS); | ||
| 776 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); | ||
| 777 | input_set_abs_params(input_dev, ABS_X, 0, wacom->features->y_max, 4, 0); | ||
| 778 | input_set_abs_params(input_dev, ABS_Y, 0, wacom->features->y_max, 4, 0); | ||
| 779 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom->features->pressure_max, 0, 0); | ||
| 767 | 780 | ||
| 768 | switch (wacom->features->type) { | 781 | switch (wacom->features->type) { |
| 769 | case GRAPHIRE: | 782 | case GRAPHIRE: |
| 770 | wacom->dev.evbit[0] |= BIT(EV_REL); | 783 | input_dev->evbit[0] |= BIT(EV_REL); |
| 771 | wacom->dev.relbit[0] |= BIT(REL_WHEEL); | 784 | input_dev->relbit[0] |= BIT(REL_WHEEL); |
| 772 | wacom->dev.absbit[0] |= BIT(ABS_DISTANCE); | 785 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
| 773 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 786 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); |
| 774 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); | 787 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0); |
| 775 | break; | 788 | break; |
| 776 | 789 | ||
| 777 | case INTUOS3: | 790 | case INTUOS3: |
| 778 | case CINTIQ: | 791 | case CINTIQ: |
| 779 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); | 792 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); |
| 780 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); | 793 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); |
| 781 | wacom->dev.absbit[0] |= BIT(ABS_RX) | BIT(ABS_RY); | 794 | input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0); |
| 795 | input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0); | ||
| 782 | /* fall through */ | 796 | /* fall through */ |
| 783 | 797 | ||
| 784 | case INTUOS: | 798 | case INTUOS: |
| 785 | wacom->dev.evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); | 799 | input_dev->evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); |
| 786 | wacom->dev.mscbit[0] |= BIT(MSC_SERIAL); | 800 | input_dev->mscbit[0] |= BIT(MSC_SERIAL); |
| 787 | wacom->dev.relbit[0] |= BIT(REL_WHEEL); | 801 | input_dev->relbit[0] |= BIT(REL_WHEEL); |
| 788 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 802 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); |
| 789 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) | 803 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) |
| 790 | | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); | 804 | | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); |
| 791 | wacom->dev.absbit[0] |= BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE); | 805 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0); |
| 806 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); | ||
| 807 | input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); | ||
| 808 | input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0); | ||
| 809 | input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0); | ||
| 810 | input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); | ||
| 792 | break; | 811 | break; |
| 793 | 812 | ||
| 794 | case PL: | 813 | case PL: |
| 795 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); | 814 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); |
| 796 | break; | 815 | break; |
| 797 | } | 816 | } |
| 798 | 817 | ||
| 799 | wacom->dev.absmax[ABS_X] = wacom->features->x_max; | ||
| 800 | wacom->dev.absmax[ABS_Y] = wacom->features->y_max; | ||
| 801 | wacom->dev.absmax[ABS_PRESSURE] = wacom->features->pressure_max; | ||
| 802 | wacom->dev.absmax[ABS_DISTANCE] = wacom->features->distance_max; | ||
| 803 | wacom->dev.absmax[ABS_TILT_X] = 127; | ||
| 804 | wacom->dev.absmax[ABS_TILT_Y] = 127; | ||
| 805 | wacom->dev.absmax[ABS_WHEEL] = 1023; | ||
| 806 | |||
| 807 | wacom->dev.absmax[ABS_RX] = 4097; | ||
| 808 | wacom->dev.absmax[ABS_RY] = 4097; | ||
| 809 | wacom->dev.absmin[ABS_RZ] = -900; | ||
| 810 | wacom->dev.absmax[ABS_RZ] = 899; | ||
| 811 | wacom->dev.absmin[ABS_THROTTLE] = -1023; | ||
| 812 | wacom->dev.absmax[ABS_THROTTLE] = 1023; | ||
| 813 | |||
| 814 | wacom->dev.absfuzz[ABS_X] = 4; | ||
| 815 | wacom->dev.absfuzz[ABS_Y] = 4; | ||
| 816 | |||
| 817 | wacom->dev.private = wacom; | ||
| 818 | wacom->dev.open = wacom_open; | ||
| 819 | wacom->dev.close = wacom_close; | ||
| 820 | |||
| 821 | usb_make_path(dev, path, 64); | ||
| 822 | sprintf(wacom->phys, "%s/input0", path); | ||
| 823 | |||
| 824 | wacom->dev.name = wacom->features->name; | ||
| 825 | wacom->dev.phys = wacom->phys; | ||
| 826 | usb_to_input_id(dev, &wacom->dev.id); | ||
| 827 | wacom->dev.dev = &intf->dev; | ||
| 828 | wacom->usbdev = dev; | ||
| 829 | |||
| 830 | endpoint = &intf->cur_altsetting->endpoint[0].desc; | 818 | endpoint = &intf->cur_altsetting->endpoint[0].desc; |
| 831 | 819 | ||
| 832 | if (wacom->features->pktlen > 10) | 820 | if (wacom->features->pktlen > 10) |
| @@ -839,18 +827,20 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
| 839 | wacom->irq->transfer_dma = wacom->data_dma; | 827 | wacom->irq->transfer_dma = wacom->data_dma; |
| 840 | wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 828 | wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 841 | 829 | ||
| 842 | input_register_device(&wacom->dev); | 830 | input_register_device(wacom->dev); |
| 843 | 831 | ||
| 844 | /* ask the tablet to report tablet data */ | 832 | /* ask the tablet to report tablet data */ |
| 845 | usb_set_report(intf, 3, 2, rep_data, 2); | 833 | usb_set_report(intf, 3, 2, rep_data, 2); |
| 846 | /* repeat once (not sure why the first call often fails) */ | 834 | /* repeat once (not sure why the first call often fails) */ |
| 847 | usb_set_report(intf, 3, 2, rep_data, 2); | 835 | usb_set_report(intf, 3, 2, rep_data, 2); |
| 848 | 836 | ||
| 849 | printk(KERN_INFO "input: %s on %s\n", wacom->features->name, path); | ||
| 850 | |||
| 851 | usb_set_intfdata(intf, wacom); | 837 | usb_set_intfdata(intf, wacom); |
| 852 | |||
| 853 | return 0; | 838 | return 0; |
| 839 | |||
| 840 | fail2: usb_buffer_free(dev, 10, wacom->data, wacom->data_dma); | ||
| 841 | fail1: input_free_device(input_dev); | ||
| 842 | kfree(wacom); | ||
| 843 | return -ENOMEM; | ||
| 854 | } | 844 | } |
| 855 | 845 | ||
| 856 | static void wacom_disconnect(struct usb_interface *intf) | 846 | static void wacom_disconnect(struct usb_interface *intf) |
| @@ -860,7 +850,7 @@ static void wacom_disconnect(struct usb_interface *intf) | |||
| 860 | usb_set_intfdata(intf, NULL); | 850 | usb_set_intfdata(intf, NULL); |
| 861 | if (wacom) { | 851 | if (wacom) { |
| 862 | usb_kill_urb(wacom->irq); | 852 | usb_kill_urb(wacom->irq); |
| 863 | input_unregister_device(&wacom->dev); | 853 | input_unregister_device(wacom->dev); |
| 864 | usb_free_urb(wacom->irq); | 854 | usb_free_urb(wacom->irq); |
| 865 | usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma); | 855 | usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma); |
| 866 | kfree(wacom); | 856 | kfree(wacom); |
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c index 18125e0bffa2..43112f040b6d 100644 --- a/drivers/usb/input/xpad.c +++ b/drivers/usb/input/xpad.c | |||
| @@ -103,7 +103,7 @@ static struct usb_device_id xpad_table [] = { | |||
| 103 | MODULE_DEVICE_TABLE (usb, xpad_table); | 103 | MODULE_DEVICE_TABLE (usb, xpad_table); |
| 104 | 104 | ||
| 105 | struct usb_xpad { | 105 | struct usb_xpad { |
| 106 | struct input_dev dev; /* input device interface */ | 106 | struct input_dev *dev; /* input device interface */ |
| 107 | struct usb_device *udev; /* usb device */ | 107 | struct usb_device *udev; /* usb device */ |
| 108 | 108 | ||
| 109 | struct urb *irq_in; /* urb for interrupt in report */ | 109 | struct urb *irq_in; /* urb for interrupt in report */ |
| @@ -125,7 +125,7 @@ struct usb_xpad { | |||
| 125 | 125 | ||
| 126 | static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data, struct pt_regs *regs) | 126 | static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data, struct pt_regs *regs) |
| 127 | { | 127 | { |
| 128 | struct input_dev *dev = &xpad->dev; | 128 | struct input_dev *dev = xpad->dev; |
| 129 | 129 | ||
| 130 | input_regs(dev, regs); | 130 | input_regs(dev, regs); |
| 131 | 131 | ||
| @@ -214,9 +214,9 @@ static void xpad_close (struct input_dev *dev) | |||
| 214 | static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) | 214 | static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 215 | { | 215 | { |
| 216 | struct usb_device *udev = interface_to_usbdev (intf); | 216 | struct usb_device *udev = interface_to_usbdev (intf); |
| 217 | struct usb_xpad *xpad = NULL; | 217 | struct usb_xpad *xpad; |
| 218 | struct input_dev *input_dev; | ||
| 218 | struct usb_endpoint_descriptor *ep_irq_in; | 219 | struct usb_endpoint_descriptor *ep_irq_in; |
| 219 | char path[64]; | ||
| 220 | int i; | 220 | int i; |
| 221 | 221 | ||
| 222 | for (i = 0; xpad_device[i].idVendor; i++) { | 222 | for (i = 0; xpad_device[i].idVendor; i++) { |
| @@ -225,89 +225,80 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
| 225 | break; | 225 | break; |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | if ((xpad = kmalloc (sizeof(struct usb_xpad), GFP_KERNEL)) == NULL) { | 228 | xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); |
| 229 | err("cannot allocate memory for new pad"); | 229 | input_dev = input_allocate_device(); |
| 230 | return -ENOMEM; | 230 | if (!xpad || !input_dev) |
| 231 | } | 231 | goto fail1; |
| 232 | memset(xpad, 0, sizeof(struct usb_xpad)); | ||
| 233 | 232 | ||
| 234 | xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, | 233 | xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, |
| 235 | SLAB_ATOMIC, &xpad->idata_dma); | 234 | SLAB_ATOMIC, &xpad->idata_dma); |
| 236 | if (!xpad->idata) { | 235 | if (!xpad->idata) |
| 237 | kfree(xpad); | 236 | goto fail1; |
| 238 | return -ENOMEM; | ||
| 239 | } | ||
| 240 | 237 | ||
| 241 | xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); | 238 | xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); |
| 242 | if (!xpad->irq_in) { | 239 | if (!xpad->irq_in) |
| 243 | err("cannot allocate memory for new pad irq urb"); | 240 | goto fail2; |
| 244 | usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | ||
| 245 | kfree(xpad); | ||
| 246 | return -ENOMEM; | ||
| 247 | } | ||
| 248 | |||
| 249 | ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; | ||
| 250 | |||
| 251 | usb_fill_int_urb(xpad->irq_in, udev, | ||
| 252 | usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), | ||
| 253 | xpad->idata, XPAD_PKT_LEN, xpad_irq_in, | ||
| 254 | xpad, ep_irq_in->bInterval); | ||
| 255 | xpad->irq_in->transfer_dma = xpad->idata_dma; | ||
| 256 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
| 257 | 241 | ||
| 258 | xpad->udev = udev; | 242 | xpad->udev = udev; |
| 243 | xpad->dev = input_dev; | ||
| 244 | usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); | ||
| 245 | strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); | ||
| 259 | 246 | ||
| 260 | usb_to_input_id(udev, &xpad->dev.id); | 247 | input_dev->name = xpad_device[i].name; |
| 261 | xpad->dev.dev = &intf->dev; | 248 | input_dev->phys = xpad->phys; |
| 262 | xpad->dev.private = xpad; | 249 | usb_to_input_id(udev, &input_dev->id); |
| 263 | xpad->dev.name = xpad_device[i].name; | 250 | input_dev->cdev.dev = &intf->dev; |
| 264 | xpad->dev.phys = xpad->phys; | 251 | input_dev->private = xpad; |
| 265 | xpad->dev.open = xpad_open; | 252 | input_dev->open = xpad_open; |
| 266 | xpad->dev.close = xpad_close; | 253 | input_dev->close = xpad_close; |
| 267 | |||
| 268 | usb_make_path(udev, path, 64); | ||
| 269 | snprintf(xpad->phys, 64, "%s/input0", path); | ||
| 270 | 254 | ||
| 271 | xpad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 255 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
| 272 | 256 | ||
| 273 | for (i = 0; xpad_btn[i] >= 0; i++) | 257 | for (i = 0; xpad_btn[i] >= 0; i++) |
| 274 | set_bit(xpad_btn[i], xpad->dev.keybit); | 258 | set_bit(xpad_btn[i], input_dev->keybit); |
| 275 | 259 | ||
| 276 | for (i = 0; xpad_abs[i] >= 0; i++) { | 260 | for (i = 0; xpad_abs[i] >= 0; i++) { |
| 277 | 261 | ||
| 278 | signed short t = xpad_abs[i]; | 262 | signed short t = xpad_abs[i]; |
| 279 | 263 | ||
| 280 | set_bit(t, xpad->dev.absbit); | 264 | set_bit(t, input_dev->absbit); |
| 281 | 265 | ||
| 282 | switch (t) { | 266 | switch (t) { |
| 283 | case ABS_X: | 267 | case ABS_X: |
| 284 | case ABS_Y: | 268 | case ABS_Y: |
| 285 | case ABS_RX: | 269 | case ABS_RX: |
| 286 | case ABS_RY: /* the two sticks */ | 270 | case ABS_RY: /* the two sticks */ |
| 287 | xpad->dev.absmax[t] = 32767; | 271 | input_set_abs_params(input_dev, t, -32768, 32767, 16, 128); |
| 288 | xpad->dev.absmin[t] = -32768; | ||
| 289 | xpad->dev.absflat[t] = 128; | ||
| 290 | xpad->dev.absfuzz[t] = 16; | ||
| 291 | break; | 272 | break; |
| 292 | case ABS_Z: | 273 | case ABS_Z: |
| 293 | case ABS_RZ: /* the triggers */ | 274 | case ABS_RZ: /* the triggers */ |
| 294 | xpad->dev.absmax[t] = 255; | 275 | input_set_abs_params(input_dev, t, 0, 255, 0, 0); |
| 295 | xpad->dev.absmin[t] = 0; | ||
| 296 | break; | 276 | break; |
| 297 | case ABS_HAT0X: | 277 | case ABS_HAT0X: |
| 298 | case ABS_HAT0Y: /* the d-pad */ | 278 | case ABS_HAT0Y: /* the d-pad */ |
| 299 | xpad->dev.absmax[t] = 1; | 279 | input_set_abs_params(input_dev, t, -1, 1, 0, 0); |
| 300 | xpad->dev.absmin[t] = -1; | ||
| 301 | break; | 280 | break; |
| 302 | } | 281 | } |
| 303 | } | 282 | } |
| 304 | 283 | ||
| 305 | input_register_device(&xpad->dev); | 284 | ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; |
| 285 | usb_fill_int_urb(xpad->irq_in, udev, | ||
| 286 | usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), | ||
| 287 | xpad->idata, XPAD_PKT_LEN, xpad_irq_in, | ||
| 288 | xpad, ep_irq_in->bInterval); | ||
| 289 | xpad->irq_in->transfer_dma = xpad->idata_dma; | ||
| 290 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
| 306 | 291 | ||
| 307 | printk(KERN_INFO "input: %s on %s", xpad->dev.name, path); | 292 | input_register_device(xpad->dev); |
| 308 | 293 | ||
| 309 | usb_set_intfdata(intf, xpad); | 294 | usb_set_intfdata(intf, xpad); |
| 310 | return 0; | 295 | return 0; |
| 296 | |||
| 297 | fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | ||
| 298 | fail1: input_free_device(input_dev); | ||
| 299 | kfree(xpad); | ||
| 300 | return -ENOMEM; | ||
| 301 | |||
| 311 | } | 302 | } |
| 312 | 303 | ||
| 313 | static void xpad_disconnect(struct usb_interface *intf) | 304 | static void xpad_disconnect(struct usb_interface *intf) |
| @@ -317,7 +308,7 @@ static void xpad_disconnect(struct usb_interface *intf) | |||
| 317 | usb_set_intfdata(intf, NULL); | 308 | usb_set_intfdata(intf, NULL); |
| 318 | if (xpad) { | 309 | if (xpad) { |
| 319 | usb_kill_urb(xpad->irq_in); | 310 | usb_kill_urb(xpad->irq_in); |
| 320 | input_unregister_device(&xpad->dev); | 311 | input_unregister_device(xpad->dev); |
| 321 | usb_free_urb(xpad->irq_in); | 312 | usb_free_urb(xpad->irq_in); |
| 322 | usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | 313 | usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); |
| 323 | kfree(xpad); | 314 | kfree(xpad); |
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c index 58a176ef96a5..f526aebea502 100644 --- a/drivers/usb/input/yealink.c +++ b/drivers/usb/input/yealink.c | |||
| @@ -54,6 +54,7 @@ | |||
| 54 | #include <linux/module.h> | 54 | #include <linux/module.h> |
| 55 | #include <linux/rwsem.h> | 55 | #include <linux/rwsem.h> |
| 56 | #include <linux/usb.h> | 56 | #include <linux/usb.h> |
| 57 | #include <linux/usb_input.h> | ||
| 57 | 58 | ||
| 58 | #include "map_to_7segment.h" | 59 | #include "map_to_7segment.h" |
| 59 | #include "yealink.h" | 60 | #include "yealink.h" |
| @@ -101,12 +102,12 @@ static const struct lcd_segment_map { | |||
| 101 | }; | 102 | }; |
| 102 | 103 | ||
| 103 | struct yealink_dev { | 104 | struct yealink_dev { |
| 104 | struct input_dev idev; /* input device */ | 105 | struct input_dev *idev; /* input device */ |
| 105 | struct usb_device *udev; /* usb device */ | 106 | struct usb_device *udev; /* usb device */ |
| 106 | 107 | ||
| 107 | /* irq input channel */ | 108 | /* irq input channel */ |
| 108 | struct yld_ctl_packet *irq_data; | 109 | struct yld_ctl_packet *irq_data; |
| 109 | dma_addr_t irq_dma; | 110 | dma_addr_t irq_dma; |
| 110 | struct urb *urb_irq; | 111 | struct urb *urb_irq; |
| 111 | 112 | ||
| 112 | /* control output channel */ | 113 | /* control output channel */ |
| @@ -237,7 +238,7 @@ static int map_p1k_to_key(int scancode) | |||
| 237 | */ | 238 | */ |
| 238 | static void report_key(struct yealink_dev *yld, int key, struct pt_regs *regs) | 239 | static void report_key(struct yealink_dev *yld, int key, struct pt_regs *regs) |
| 239 | { | 240 | { |
| 240 | struct input_dev *idev = &yld->idev; | 241 | struct input_dev *idev = yld->idev; |
| 241 | 242 | ||
| 242 | input_regs(idev, regs); | 243 | input_regs(idev, regs); |
| 243 | if (yld->key_code >= 0) { | 244 | if (yld->key_code >= 0) { |
| @@ -809,8 +810,12 @@ static int usb_cleanup(struct yealink_dev *yld, int err) | |||
| 809 | } | 810 | } |
| 810 | if (yld->urb_ctl) | 811 | if (yld->urb_ctl) |
| 811 | usb_free_urb(yld->urb_ctl); | 812 | usb_free_urb(yld->urb_ctl); |
| 812 | if (yld->idev.dev) | 813 | if (yld->idev) { |
| 813 | input_unregister_device(&yld->idev); | 814 | if (err) |
| 815 | input_free_device(yld->idev); | ||
| 816 | else | ||
| 817 | input_unregister_device(yld->idev); | ||
| 818 | } | ||
| 814 | if (yld->ctl_req) | 819 | if (yld->ctl_req) |
| 815 | usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)), | 820 | usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)), |
| 816 | yld->ctl_req, yld->ctl_req_dma); | 821 | yld->ctl_req, yld->ctl_req_dma); |
| @@ -857,7 +862,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 857 | struct usb_host_interface *interface; | 862 | struct usb_host_interface *interface; |
| 858 | struct usb_endpoint_descriptor *endpoint; | 863 | struct usb_endpoint_descriptor *endpoint; |
| 859 | struct yealink_dev *yld; | 864 | struct yealink_dev *yld; |
| 860 | char path[64]; | 865 | struct input_dev *input_dev; |
| 861 | int ret, pipe, i; | 866 | int ret, pipe, i; |
| 862 | 867 | ||
| 863 | i = usb_match(udev); | 868 | i = usb_match(udev); |
| @@ -866,17 +871,21 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 866 | 871 | ||
| 867 | interface = intf->cur_altsetting; | 872 | interface = intf->cur_altsetting; |
| 868 | endpoint = &interface->endpoint[0].desc; | 873 | endpoint = &interface->endpoint[0].desc; |
| 869 | if (!(endpoint->bEndpointAddress & 0x80)) | 874 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
| 870 | return -EIO; | 875 | return -EIO; |
| 871 | if ((endpoint->bmAttributes & 3) != 3) | 876 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) |
| 872 | return -EIO; | 877 | return -EIO; |
| 873 | 878 | ||
| 874 | if ((yld = kmalloc(sizeof(struct yealink_dev), GFP_KERNEL)) == NULL) | 879 | yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL); |
| 880 | if (!yld) | ||
| 875 | return -ENOMEM; | 881 | return -ENOMEM; |
| 876 | 882 | ||
| 877 | memset(yld, 0, sizeof(*yld)); | ||
| 878 | yld->udev = udev; | 883 | yld->udev = udev; |
| 879 | 884 | ||
| 885 | yld->idev = input_dev = input_allocate_device(); | ||
| 886 | if (!input_dev) | ||
| 887 | return usb_cleanup(yld, -ENOMEM); | ||
| 888 | |||
| 880 | /* allocate usb buffers */ | 889 | /* allocate usb buffers */ |
| 881 | yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, | 890 | yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, |
| 882 | SLAB_ATOMIC, &yld->irq_dma); | 891 | SLAB_ATOMIC, &yld->irq_dma); |
| @@ -935,42 +944,37 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 935 | yld->urb_ctl->dev = udev; | 944 | yld->urb_ctl->dev = udev; |
| 936 | 945 | ||
| 937 | /* find out the physical bus location */ | 946 | /* find out the physical bus location */ |
| 938 | if (usb_make_path(udev, path, sizeof(path)) > 0) | 947 | usb_make_path(udev, yld->phys, sizeof(yld->phys)); |
| 939 | snprintf(yld->phys, sizeof(yld->phys)-1, "%s/input0", path); | 948 | strlcat(yld->phys, "/input0", sizeof(yld->phys)); |
| 940 | 949 | ||
| 941 | /* register settings for the input device */ | 950 | /* register settings for the input device */ |
| 942 | init_input_dev(&yld->idev); | 951 | input_dev->name = yld_device[i].name; |
| 943 | yld->idev.private = yld; | 952 | input_dev->phys = yld->phys; |
| 944 | yld->idev.id.bustype = BUS_USB; | 953 | usb_to_input_id(udev, &input_dev->id); |
| 945 | yld->idev.id.vendor = le16_to_cpu(udev->descriptor.idVendor); | 954 | input_dev->cdev.dev = &intf->dev; |
| 946 | yld->idev.id.product = le16_to_cpu(udev->descriptor.idProduct); | 955 | |
| 947 | yld->idev.id.version = le16_to_cpu(udev->descriptor.bcdDevice); | 956 | input_dev->private = yld; |
| 948 | yld->idev.dev = &intf->dev; | 957 | input_dev->open = input_open; |
| 949 | yld->idev.name = yld_device[i].name; | 958 | input_dev->close = input_close; |
| 950 | yld->idev.phys = yld->phys; | 959 | /* input_dev->event = input_ev; TODO */ |
| 951 | /* yld->idev.event = input_ev; TODO */ | ||
| 952 | yld->idev.open = input_open; | ||
| 953 | yld->idev.close = input_close; | ||
| 954 | 960 | ||
| 955 | /* register available key events */ | 961 | /* register available key events */ |
| 956 | yld->idev.evbit[0] = BIT(EV_KEY); | 962 | input_dev->evbit[0] = BIT(EV_KEY); |
| 957 | for (i = 0; i < 256; i++) { | 963 | for (i = 0; i < 256; i++) { |
| 958 | int k = map_p1k_to_key(i); | 964 | int k = map_p1k_to_key(i); |
| 959 | if (k >= 0) { | 965 | if (k >= 0) { |
| 960 | set_bit(k & 0xff, yld->idev.keybit); | 966 | set_bit(k & 0xff, input_dev->keybit); |
| 961 | if (k >> 8) | 967 | if (k >> 8) |
| 962 | set_bit(k >> 8, yld->idev.keybit); | 968 | set_bit(k >> 8, input_dev->keybit); |
| 963 | } | 969 | } |
| 964 | } | 970 | } |
| 965 | 971 | ||
| 966 | printk(KERN_INFO "input: %s on %s\n", yld->idev.name, path); | 972 | input_register_device(yld->idev); |
| 967 | |||
| 968 | input_register_device(&yld->idev); | ||
| 969 | 973 | ||
| 970 | usb_set_intfdata(intf, yld); | 974 | usb_set_intfdata(intf, yld); |
| 971 | 975 | ||
| 972 | /* clear visible elements */ | 976 | /* clear visible elements */ |
| 973 | for (i=0; i<ARRAY_SIZE(lcdMap); i++) | 977 | for (i = 0; i < ARRAY_SIZE(lcdMap); i++) |
| 974 | setChar(yld, i, ' '); | 978 | setChar(yld, i, ' '); |
| 975 | 979 | ||
| 976 | /* display driver version on LCD line 3 */ | 980 | /* display driver version on LCD line 3 */ |
diff --git a/drivers/usb/media/konicawc.c b/drivers/usb/media/konicawc.c index 20ac9e1069d4..9fe2c2710d13 100644 --- a/drivers/usb/media/konicawc.c +++ b/drivers/usb/media/konicawc.c | |||
| @@ -119,7 +119,7 @@ struct konicawc { | |||
| 119 | int yplanesz; /* Number of bytes in the Y plane */ | 119 | int yplanesz; /* Number of bytes in the Y plane */ |
| 120 | unsigned int buttonsts:1; | 120 | unsigned int buttonsts:1; |
| 121 | #ifdef CONFIG_INPUT | 121 | #ifdef CONFIG_INPUT |
| 122 | struct input_dev input; | 122 | struct input_dev *input; |
| 123 | char input_physname[64]; | 123 | char input_physname[64]; |
| 124 | #endif | 124 | #endif |
| 125 | }; | 125 | }; |
| @@ -218,6 +218,57 @@ static void konicawc_adjust_picture(struct uvd *uvd) | |||
| 218 | konicawc_camera_on(uvd); | 218 | konicawc_camera_on(uvd); |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | #ifdef CONFIG_INPUT | ||
| 222 | |||
| 223 | static void konicawc_register_input(struct konicawc *cam, struct usb_device *dev) | ||
| 224 | { | ||
| 225 | struct input_dev *input_dev; | ||
| 226 | |||
| 227 | usb_make_path(dev, cam->input_physname, sizeof(cam->input_physname)); | ||
| 228 | strncat(cam->input_physname, "/input0", sizeof(cam->input_physname)); | ||
| 229 | |||
| 230 | cam->input = input_dev = input_allocate_device(); | ||
| 231 | if (!input_dev) { | ||
| 232 | warn("Not enough memory for camera's input device\n"); | ||
| 233 | return; | ||
| 234 | } | ||
| 235 | |||
| 236 | input_dev->name = "Konicawc snapshot button"; | ||
| 237 | input_dev->phys = cam->input_physname; | ||
| 238 | usb_to_input_id(dev, &input_dev->id); | ||
| 239 | input_dev->cdev.dev = &dev->dev; | ||
| 240 | |||
| 241 | input_dev->evbit[0] = BIT(EV_KEY); | ||
| 242 | input_dev->keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
| 243 | |||
| 244 | input_dev->private = cam; | ||
| 245 | |||
| 246 | input_register_device(cam->input); | ||
| 247 | } | ||
| 248 | |||
| 249 | static void konicawc_unregister_input(struct konicawc *cam) | ||
| 250 | { | ||
| 251 | if (cam->input) { | ||
| 252 | input_unregister_device(cam->input); | ||
| 253 | cam->input = NULL; | ||
| 254 | } | ||
| 255 | } | ||
| 256 | |||
| 257 | static void konicawc_report_buttonstat(struct konicawc *cam) | ||
| 258 | { | ||
| 259 | if (cam->input) { | ||
| 260 | input_report_key(cam->input, BTN_0, cam->buttonsts); | ||
| 261 | input_sync(cam->input); | ||
| 262 | } | ||
| 263 | } | ||
| 264 | |||
| 265 | #else | ||
| 266 | |||
| 267 | static inline void konicawc_register_input(struct konicawc *cam, struct usb_device *dev) { } | ||
| 268 | static inline void konicawc_unregister_input(struct konicawc *cam) { } | ||
| 269 | static inline void konicawc_report_buttonstat(struct konicawc *cam) { } | ||
| 270 | |||
| 271 | #endif /* CONFIG_INPUT */ | ||
| 221 | 272 | ||
| 222 | static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct urb *stsurb) | 273 | static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct urb *stsurb) |
| 223 | { | 274 | { |
| @@ -273,10 +324,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur | |||
| 273 | if(button != cam->buttonsts) { | 324 | if(button != cam->buttonsts) { |
| 274 | DEBUG(2, "button: %sclicked", button ? "" : "un"); | 325 | DEBUG(2, "button: %sclicked", button ? "" : "un"); |
| 275 | cam->buttonsts = button; | 326 | cam->buttonsts = button; |
| 276 | #ifdef CONFIG_INPUT | 327 | konicawc_report_buttonstat(cam); |
| 277 | input_report_key(&cam->input, BTN_0, cam->buttonsts); | ||
| 278 | input_sync(&cam->input); | ||
| 279 | #endif | ||
| 280 | } | 328 | } |
| 281 | 329 | ||
| 282 | if(sts == 0x01) { /* drop frame */ | 330 | if(sts == 0x01) { /* drop frame */ |
| @@ -645,9 +693,9 @@ static int konicawc_set_video_mode(struct uvd *uvd, struct video_window *vw) | |||
| 645 | RingQueue_Flush(&uvd->dp); | 693 | RingQueue_Flush(&uvd->dp); |
| 646 | cam->lastframe = -2; | 694 | cam->lastframe = -2; |
| 647 | if(uvd->curframe != -1) { | 695 | if(uvd->curframe != -1) { |
| 648 | uvd->frame[uvd->curframe].curline = 0; | 696 | uvd->frame[uvd->curframe].curline = 0; |
| 649 | uvd->frame[uvd->curframe].seqRead_Length = 0; | 697 | uvd->frame[uvd->curframe].seqRead_Length = 0; |
| 650 | uvd->frame[uvd->curframe].seqRead_Index = 0; | 698 | uvd->frame[uvd->curframe].seqRead_Index = 0; |
| 651 | } | 699 | } |
| 652 | 700 | ||
| 653 | konicawc_start_data(uvd); | 701 | konicawc_start_data(uvd); |
| @@ -718,7 +766,6 @@ static void konicawc_configure_video(struct uvd *uvd) | |||
| 718 | DEBUG(1, "setting initial values"); | 766 | DEBUG(1, "setting initial values"); |
| 719 | } | 767 | } |
| 720 | 768 | ||
| 721 | |||
| 722 | static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id *devid) | 769 | static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id *devid) |
| 723 | { | 770 | { |
| 724 | struct usb_device *dev = interface_to_usbdev(intf); | 771 | struct usb_device *dev = interface_to_usbdev(intf); |
| @@ -839,21 +886,8 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id | |||
| 839 | err("usbvideo_RegisterVideoDevice() failed."); | 886 | err("usbvideo_RegisterVideoDevice() failed."); |
| 840 | uvd = NULL; | 887 | uvd = NULL; |
| 841 | } | 888 | } |
| 842 | #ifdef CONFIG_INPUT | 889 | |
| 843 | /* Register input device for button */ | 890 | konicawc_register_input(cam, dev); |
| 844 | memset(&cam->input, 0, sizeof(struct input_dev)); | ||
| 845 | cam->input.name = "Konicawc snapshot button"; | ||
| 846 | cam->input.private = cam; | ||
| 847 | cam->input.evbit[0] = BIT(EV_KEY); | ||
| 848 | cam->input.keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
| 849 | usb_to_input_id(dev, &cam->input.id); | ||
| 850 | input_register_device(&cam->input); | ||
| 851 | |||
| 852 | usb_make_path(dev, cam->input_physname, 56); | ||
| 853 | strcat(cam->input_physname, "/input0"); | ||
| 854 | cam->input.phys = cam->input_physname; | ||
| 855 | info("konicawc: %s on %s\n", cam->input.name, cam->input.phys); | ||
| 856 | #endif | ||
| 857 | } | 891 | } |
| 858 | 892 | ||
| 859 | if (uvd) { | 893 | if (uvd) { |
| @@ -869,10 +903,9 @@ static void konicawc_free_uvd(struct uvd *uvd) | |||
| 869 | int i; | 903 | int i; |
| 870 | struct konicawc *cam = (struct konicawc *)uvd->user_data; | 904 | struct konicawc *cam = (struct konicawc *)uvd->user_data; |
| 871 | 905 | ||
| 872 | #ifdef CONFIG_INPUT | 906 | konicawc_unregister_input(cam); |
| 873 | input_unregister_device(&cam->input); | 907 | |
| 874 | #endif | 908 | for (i = 0; i < USBVIDEO_NUMSBUF; i++) { |
| 875 | for (i=0; i < USBVIDEO_NUMSBUF; i++) { | ||
| 876 | usb_free_urb(cam->sts_urb[i]); | 909 | usb_free_urb(cam->sts_urb[i]); |
| 877 | cam->sts_urb[i] = NULL; | 910 | cam->sts_urb[i] = NULL; |
| 878 | } | 911 | } |
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c index 03fb70ef2eb3..0592cb5e6c4d 100644 --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c | |||
| @@ -137,7 +137,7 @@ static void async_complete(struct urb *urb, struct pt_regs *ptregs) | |||
| 137 | 137 | ||
| 138 | static struct uss720_async_request *submit_async_request(struct parport_uss720_private *priv, | 138 | static struct uss720_async_request *submit_async_request(struct parport_uss720_private *priv, |
| 139 | __u8 request, __u8 requesttype, __u16 value, __u16 index, | 139 | __u8 request, __u8 requesttype, __u16 value, __u16 index, |
| 140 | unsigned int mem_flags) | 140 | gfp_t mem_flags) |
| 141 | { | 141 | { |
| 142 | struct usb_device *usbdev; | 142 | struct usb_device *usbdev; |
| 143 | struct uss720_async_request *rq; | 143 | struct uss720_async_request *rq; |
| @@ -204,7 +204,7 @@ static unsigned int kill_all_async_requests_priv(struct parport_uss720_private * | |||
| 204 | 204 | ||
| 205 | /* --------------------------------------------------------------------- */ | 205 | /* --------------------------------------------------------------------- */ |
| 206 | 206 | ||
| 207 | static int get_1284_register(struct parport *pp, unsigned char reg, unsigned char *val, unsigned int mem_flags) | 207 | static int get_1284_register(struct parport *pp, unsigned char reg, unsigned char *val, gfp_t mem_flags) |
| 208 | { | 208 | { |
| 209 | struct parport_uss720_private *priv; | 209 | struct parport_uss720_private *priv; |
| 210 | struct uss720_async_request *rq; | 210 | struct uss720_async_request *rq; |
| @@ -238,7 +238,7 @@ static int get_1284_register(struct parport *pp, unsigned char reg, unsigned cha | |||
| 238 | return -EIO; | 238 | return -EIO; |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | static int set_1284_register(struct parport *pp, unsigned char reg, unsigned char val, unsigned int mem_flags) | 241 | static int set_1284_register(struct parport *pp, unsigned char reg, unsigned char val, gfp_t mem_flags) |
| 242 | { | 242 | { |
| 243 | struct parport_uss720_private *priv; | 243 | struct parport_uss720_private *priv; |
| 244 | struct uss720_async_request *rq; | 244 | struct uss720_async_request *rq; |
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c index 861f00a43750..252a34fbb42c 100644 --- a/drivers/usb/net/asix.c +++ b/drivers/usb/net/asix.c | |||
| @@ -753,7 +753,7 @@ static int ax88772_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
| 753 | } | 753 | } |
| 754 | 754 | ||
| 755 | static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb, | 755 | static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb, |
| 756 | unsigned flags) | 756 | gfp_t flags) |
| 757 | { | 757 | { |
| 758 | int padlen; | 758 | int padlen; |
| 759 | int headroom = skb_headroom(skb); | 759 | int headroom = skb_headroom(skb); |
diff --git a/drivers/usb/net/gl620a.c b/drivers/usb/net/gl620a.c index c8763ae33c73..c0f263b202a6 100644 --- a/drivers/usb/net/gl620a.c +++ b/drivers/usb/net/gl620a.c | |||
| @@ -301,7 +301,7 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | static struct sk_buff * | 303 | static struct sk_buff * |
| 304 | genelink_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) | 304 | genelink_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) |
| 305 | { | 305 | { |
| 306 | int padlen; | 306 | int padlen; |
| 307 | int length = skb->len; | 307 | int length = skb->len; |
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c index e04b0ce3611a..c82655d3d448 100644 --- a/drivers/usb/net/kaweth.c +++ b/drivers/usb/net/kaweth.c | |||
| @@ -477,13 +477,13 @@ static int kaweth_reset(struct kaweth_device *kaweth) | |||
| 477 | } | 477 | } |
| 478 | 478 | ||
| 479 | static void kaweth_usb_receive(struct urb *, struct pt_regs *regs); | 479 | static void kaweth_usb_receive(struct urb *, struct pt_regs *regs); |
| 480 | static int kaweth_resubmit_rx_urb(struct kaweth_device *, unsigned); | 480 | static int kaweth_resubmit_rx_urb(struct kaweth_device *, gfp_t); |
| 481 | 481 | ||
| 482 | /**************************************************************** | 482 | /**************************************************************** |
| 483 | int_callback | 483 | int_callback |
| 484 | *****************************************************************/ | 484 | *****************************************************************/ |
| 485 | 485 | ||
| 486 | static void kaweth_resubmit_int_urb(struct kaweth_device *kaweth, int mf) | 486 | static void kaweth_resubmit_int_urb(struct kaweth_device *kaweth, gfp_t mf) |
| 487 | { | 487 | { |
| 488 | int status; | 488 | int status; |
| 489 | 489 | ||
| @@ -550,7 +550,7 @@ static void kaweth_resubmit_tl(void *d) | |||
| 550 | * kaweth_resubmit_rx_urb | 550 | * kaweth_resubmit_rx_urb |
| 551 | ****************************************************************/ | 551 | ****************************************************************/ |
| 552 | static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth, | 552 | static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth, |
| 553 | unsigned mem_flags) | 553 | gfp_t mem_flags) |
| 554 | { | 554 | { |
| 555 | int result; | 555 | int result; |
| 556 | 556 | ||
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c index a4309c4a491b..cee55f8cf64f 100644 --- a/drivers/usb/net/net1080.c +++ b/drivers/usb/net/net1080.c | |||
| @@ -500,7 +500,7 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
| 500 | } | 500 | } |
| 501 | 501 | ||
| 502 | static struct sk_buff * | 502 | static struct sk_buff * |
| 503 | net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) | 503 | net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) |
| 504 | { | 504 | { |
| 505 | int padlen; | 505 | int padlen; |
| 506 | struct sk_buff *skb2; | 506 | struct sk_buff *skb2; |
diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c index 2ed2e5fb7778..b5a925dc1beb 100644 --- a/drivers/usb/net/rndis_host.c +++ b/drivers/usb/net/rndis_host.c | |||
| @@ -517,7 +517,7 @@ static int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
| 517 | } | 517 | } |
| 518 | 518 | ||
| 519 | static struct sk_buff * | 519 | static struct sk_buff * |
| 520 | rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) | 520 | rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) |
| 521 | { | 521 | { |
| 522 | struct rndis_data_hdr *hdr; | 522 | struct rndis_data_hdr *hdr; |
| 523 | struct sk_buff *skb2; | 523 | struct sk_buff *skb2; |
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 6c460918d54f..fce81d738933 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c | |||
| @@ -288,7 +288,7 @@ EXPORT_SYMBOL_GPL(usbnet_defer_kevent); | |||
| 288 | 288 | ||
| 289 | static void rx_complete (struct urb *urb, struct pt_regs *regs); | 289 | static void rx_complete (struct urb *urb, struct pt_regs *regs); |
| 290 | 290 | ||
| 291 | static void rx_submit (struct usbnet *dev, struct urb *urb, unsigned flags) | 291 | static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags) |
| 292 | { | 292 | { |
| 293 | struct sk_buff *skb; | 293 | struct sk_buff *skb; |
| 294 | struct skb_data *entry; | 294 | struct skb_data *entry; |
diff --git a/drivers/usb/net/usbnet.h b/drivers/usb/net/usbnet.h index 7aa0abd1a9bd..89fc4958eecf 100644 --- a/drivers/usb/net/usbnet.h +++ b/drivers/usb/net/usbnet.h | |||
| @@ -107,7 +107,7 @@ struct driver_info { | |||
| 107 | 107 | ||
| 108 | /* fixup tx packet (add framing) */ | 108 | /* fixup tx packet (add framing) */ |
| 109 | struct sk_buff *(*tx_fixup)(struct usbnet *dev, | 109 | struct sk_buff *(*tx_fixup)(struct usbnet *dev, |
| 110 | struct sk_buff *skb, unsigned flags); | 110 | struct sk_buff *skb, gfp_t flags); |
| 111 | 111 | ||
| 112 | /* for new devices, use the descriptor-reading code instead */ | 112 | /* for new devices, use the descriptor-reading code instead */ |
| 113 | int in; /* rx endpoint */ | 113 | int in; /* rx endpoint */ |
diff --git a/drivers/usb/net/zaurus.c b/drivers/usb/net/zaurus.c index ee3b892aeabc..5d4b7d55b097 100644 --- a/drivers/usb/net/zaurus.c +++ b/drivers/usb/net/zaurus.c | |||
| @@ -62,7 +62,7 @@ | |||
| 62 | */ | 62 | */ |
| 63 | 63 | ||
| 64 | static struct sk_buff * | 64 | static struct sk_buff * |
| 65 | zaurus_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) | 65 | zaurus_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) |
| 66 | { | 66 | { |
| 67 | int padlen; | 67 | int padlen; |
| 68 | struct sk_buff *skb2; | 68 | struct sk_buff *skb2; |
diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c index c4e479ee926a..2f52261c7cc1 100644 --- a/drivers/usb/net/zd1201.c +++ b/drivers/usb/net/zd1201.c | |||
| @@ -521,7 +521,7 @@ static int zd1201_setconfig(struct zd1201 *zd, int rid, void *buf, int len, int | |||
| 521 | int reqlen; | 521 | int reqlen; |
| 522 | char seq=0; | 522 | char seq=0; |
| 523 | struct urb *urb; | 523 | struct urb *urb; |
| 524 | unsigned int gfp_mask = wait ? GFP_NOIO : GFP_ATOMIC; | 524 | gfp_t gfp_mask = wait ? GFP_NOIO : GFP_ATOMIC; |
| 525 | 525 | ||
| 526 | len += 4; /* first 4 are for header */ | 526 | len += 4; /* first 4 are for header */ |
| 527 | 527 | ||
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index 2c9402dc702b..89401a59f952 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | * Copyright (c) 2005 Nick Sillik <n.sillik@temple.edu> | 5 | * Copyright (c) 2005 Nick Sillik <n.sillik@temple.edu> |
| 6 | * | 6 | * |
| 7 | * Initial work by: | 7 | * Initial work by: |
| 8 | * Copyright (c) 2003 Erik Thyren <erth7411@student.uu.se> | 8 | * Copyright (c) 2003 Erik Thyren <erth7411@student.uu.se> |
| 9 | * | 9 | * |
| 10 | * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann) | 10 | * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann) |
| 11 | * | 11 | * |
| @@ -46,7 +46,7 @@ void onetouch_release_input(void *onetouch_); | |||
| 46 | struct usb_onetouch { | 46 | struct usb_onetouch { |
| 47 | char name[128]; | 47 | char name[128]; |
| 48 | char phys[64]; | 48 | char phys[64]; |
| 49 | struct input_dev dev; /* input device interface */ | 49 | struct input_dev *dev; /* input device interface */ |
| 50 | struct usb_device *udev; /* usb device */ | 50 | struct usb_device *udev; /* usb device */ |
| 51 | 51 | ||
| 52 | struct urb *irq; /* urb for interrupt in report */ | 52 | struct urb *irq; /* urb for interrupt in report */ |
| @@ -58,7 +58,7 @@ static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs) | |||
| 58 | { | 58 | { |
| 59 | struct usb_onetouch *onetouch = urb->context; | 59 | struct usb_onetouch *onetouch = urb->context; |
| 60 | signed char *data = onetouch->data; | 60 | signed char *data = onetouch->data; |
| 61 | struct input_dev *dev = &onetouch->dev; | 61 | struct input_dev *dev = onetouch->dev; |
| 62 | int status; | 62 | int status; |
| 63 | 63 | ||
| 64 | switch (urb->status) { | 64 | switch (urb->status) { |
| @@ -74,11 +74,9 @@ static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs) | |||
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | input_regs(dev, regs); | 76 | input_regs(dev, regs); |
| 77 | 77 | input_report_key(dev, ONETOUCH_BUTTON, data[0] & 0x02); | |
| 78 | input_report_key(&onetouch->dev, ONETOUCH_BUTTON, | ||
| 79 | data[0] & 0x02); | ||
| 80 | |||
| 81 | input_sync(dev); | 78 | input_sync(dev); |
| 79 | |||
| 82 | resubmit: | 80 | resubmit: |
| 83 | status = usb_submit_urb (urb, SLAB_ATOMIC); | 81 | status = usb_submit_urb (urb, SLAB_ATOMIC); |
| 84 | if (status) | 82 | if (status) |
| @@ -113,8 +111,8 @@ int onetouch_connect_input(struct us_data *ss) | |||
| 113 | struct usb_host_interface *interface; | 111 | struct usb_host_interface *interface; |
| 114 | struct usb_endpoint_descriptor *endpoint; | 112 | struct usb_endpoint_descriptor *endpoint; |
| 115 | struct usb_onetouch *onetouch; | 113 | struct usb_onetouch *onetouch; |
| 114 | struct input_dev *input_dev; | ||
| 116 | int pipe, maxp; | 115 | int pipe, maxp; |
| 117 | char path[64]; | ||
| 118 | 116 | ||
| 119 | interface = ss->pusb_intf->cur_altsetting; | 117 | interface = ss->pusb_intf->cur_altsetting; |
| 120 | 118 | ||
| @@ -122,62 +120,62 @@ int onetouch_connect_input(struct us_data *ss) | |||
| 122 | return -ENODEV; | 120 | return -ENODEV; |
| 123 | 121 | ||
| 124 | endpoint = &interface->endpoint[2].desc; | 122 | endpoint = &interface->endpoint[2].desc; |
| 125 | if(!(endpoint->bEndpointAddress & USB_DIR_IN)) | 123 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
| 126 | return -ENODEV; | 124 | return -ENODEV; |
| 127 | if((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) | 125 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) |
| 128 | != USB_ENDPOINT_XFER_INT) | 126 | != USB_ENDPOINT_XFER_INT) |
| 129 | return -ENODEV; | 127 | return -ENODEV; |
| 130 | 128 | ||
| 131 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); | 129 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); |
| 132 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); | 130 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); |
| 133 | 131 | ||
| 134 | if (!(onetouch = kcalloc(1, sizeof(struct usb_onetouch), GFP_KERNEL))) | 132 | onetouch = kzalloc(sizeof(struct usb_onetouch), GFP_KERNEL); |
| 135 | return -ENOMEM; | 133 | input_dev = input_allocate_device(); |
| 134 | if (!onetouch || !input_dev) | ||
| 135 | goto fail1; | ||
| 136 | 136 | ||
| 137 | onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, | 137 | onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, |
| 138 | SLAB_ATOMIC, &onetouch->data_dma); | 138 | SLAB_ATOMIC, &onetouch->data_dma); |
| 139 | if (!onetouch->data){ | 139 | if (!onetouch->data) |
| 140 | kfree(onetouch); | 140 | goto fail1; |
| 141 | return -ENOMEM; | ||
| 142 | } | ||
| 143 | 141 | ||
| 144 | onetouch->irq = usb_alloc_urb(0, GFP_KERNEL); | 142 | onetouch->irq = usb_alloc_urb(0, GFP_KERNEL); |
| 145 | if (!onetouch->irq){ | 143 | if (!onetouch->irq) |
| 146 | kfree(onetouch); | 144 | goto fail2; |
| 147 | usb_buffer_free(udev, ONETOUCH_PKT_LEN, | ||
| 148 | onetouch->data, onetouch->data_dma); | ||
| 149 | return -ENODEV; | ||
| 150 | } | ||
| 151 | |||
| 152 | 145 | ||
| 153 | onetouch->udev = udev; | 146 | onetouch->udev = udev; |
| 147 | onetouch->dev = input_dev; | ||
| 154 | 148 | ||
| 155 | set_bit(EV_KEY, onetouch->dev.evbit); | 149 | if (udev->manufacturer) |
| 156 | set_bit(ONETOUCH_BUTTON, onetouch->dev.keybit); | 150 | strlcpy(onetouch->name, udev->manufacturer, |
| 157 | clear_bit(0, onetouch->dev.keybit); | 151 | sizeof(onetouch->name)); |
| 152 | if (udev->product) { | ||
| 153 | if (udev->manufacturer) | ||
| 154 | strlcat(onetouch->name, " ", sizeof(onetouch->name)); | ||
| 155 | strlcat(onetouch->name, udev->product, sizeof(onetouch->name)); | ||
| 156 | } | ||
| 158 | 157 | ||
| 159 | onetouch->dev.private = onetouch; | 158 | if (!strlen(onetouch->name)) |
| 160 | onetouch->dev.open = usb_onetouch_open; | 159 | snprintf(onetouch->name, sizeof(onetouch->name), |
| 161 | onetouch->dev.close = usb_onetouch_close; | 160 | "Maxtor Onetouch %04x:%04x", |
| 161 | le16_to_cpu(udev->descriptor.idVendor), | ||
| 162 | le16_to_cpu(udev->descriptor.idProduct)); | ||
| 162 | 163 | ||
| 163 | usb_make_path(udev, path, sizeof(path)); | 164 | usb_make_path(udev, onetouch->phys, sizeof(onetouch->phys)); |
| 164 | sprintf(onetouch->phys, "%s/input0", path); | 165 | strlcat(onetouch->phys, "/input0", sizeof(onetouch->phys)); |
| 165 | 166 | ||
| 166 | onetouch->dev.name = onetouch->name; | 167 | input_dev->name = onetouch->name; |
| 167 | onetouch->dev.phys = onetouch->phys; | 168 | input_dev->phys = onetouch->phys; |
| 169 | usb_to_input_id(udev, &input_dev->id); | ||
| 170 | input_dev->cdev.dev = &udev->dev; | ||
| 168 | 171 | ||
| 169 | usb_to_input_id(udev, &onetouch->dev.id); | 172 | set_bit(EV_KEY, input_dev->evbit); |
| 173 | set_bit(ONETOUCH_BUTTON, input_dev->keybit); | ||
| 174 | clear_bit(0, input_dev->keybit); | ||
| 170 | 175 | ||
| 171 | onetouch->dev.dev = &udev->dev; | 176 | input_dev->private = onetouch; |
| 172 | 177 | input_dev->open = usb_onetouch_open; | |
| 173 | if (udev->manufacturer) | 178 | input_dev->close = usb_onetouch_close; |
| 174 | strcat(onetouch->name, udev->manufacturer); | ||
| 175 | if (udev->product) | ||
| 176 | sprintf(onetouch->name, "%s %s", onetouch->name, | ||
| 177 | udev->product); | ||
| 178 | if (!strlen(onetouch->name)) | ||
| 179 | sprintf(onetouch->name, "Maxtor Onetouch %04x:%04x", | ||
| 180 | onetouch->dev.id.vendor, onetouch->dev.id.product); | ||
| 181 | 179 | ||
| 182 | usb_fill_int_urb(onetouch->irq, udev, pipe, onetouch->data, | 180 | usb_fill_int_urb(onetouch->irq, udev, pipe, onetouch->data, |
| 183 | (maxp > 8 ? 8 : maxp), | 181 | (maxp > 8 ? 8 : maxp), |
| @@ -188,10 +186,15 @@ int onetouch_connect_input(struct us_data *ss) | |||
| 188 | ss->extra_destructor = onetouch_release_input; | 186 | ss->extra_destructor = onetouch_release_input; |
| 189 | ss->extra = onetouch; | 187 | ss->extra = onetouch; |
| 190 | 188 | ||
| 191 | input_register_device(&onetouch->dev); | 189 | input_register_device(onetouch->dev); |
| 192 | printk(KERN_INFO "usb-input: %s on %s\n", onetouch->dev.name, path); | ||
| 193 | 190 | ||
| 194 | return 0; | 191 | return 0; |
| 192 | |||
| 193 | fail2: usb_buffer_free(udev, ONETOUCH_PKT_LEN, | ||
| 194 | onetouch->data, onetouch->data_dma); | ||
| 195 | fail1: kfree(onetouch); | ||
| 196 | input_free_device(input_dev); | ||
| 197 | return -ENOMEM; | ||
| 195 | } | 198 | } |
| 196 | 199 | ||
| 197 | void onetouch_release_input(void *onetouch_) | 200 | void onetouch_release_input(void *onetouch_) |
| @@ -200,11 +203,9 @@ void onetouch_release_input(void *onetouch_) | |||
| 200 | 203 | ||
| 201 | if (onetouch) { | 204 | if (onetouch) { |
| 202 | usb_kill_urb(onetouch->irq); | 205 | usb_kill_urb(onetouch->irq); |
| 203 | input_unregister_device(&onetouch->dev); | 206 | input_unregister_device(onetouch->dev); |
| 204 | usb_free_urb(onetouch->irq); | 207 | usb_free_urb(onetouch->irq); |
| 205 | usb_buffer_free(onetouch->udev, ONETOUCH_PKT_LEN, | 208 | usb_buffer_free(onetouch->udev, ONETOUCH_PKT_LEN, |
| 206 | onetouch->data, onetouch->data_dma); | 209 | onetouch->data, onetouch->data_dma); |
| 207 | printk(KERN_INFO "usb-input: deregistering %s\n", | ||
| 208 | onetouch->dev.name); | ||
| 209 | } | 210 | } |
| 210 | } | 211 | } |
