diff options
Diffstat (limited to 'drivers/usb/input/itmtouch.c')
-rw-r--r-- | drivers/usb/input/itmtouch.c | 70 |
1 files changed, 42 insertions, 28 deletions
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); |