Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: appletouch - refactor endpoint lookup

Use the common USB helpers for looking up interrupt-in endpoints (and
determining endpoint numbers) instead of open coding.

Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260330095948.1663141-3-johan@kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Johan Hovold and committed by
Dmitry Torokhov
5bb3ab0d a7675c1f

+6 -15
+6 -15
drivers/input/mouse/appletouch.c
··· 829 829 struct atp *dev; 830 830 struct input_dev *input_dev; 831 831 struct usb_device *udev = interface_to_usbdev(iface); 832 - struct usb_host_interface *iface_desc; 833 - struct usb_endpoint_descriptor *endpoint; 834 - int int_in_endpointAddr = 0; 835 - int i, error = -ENOMEM; 832 + struct usb_endpoint_descriptor *ep; 833 + int error; 836 834 const struct atp_info *info = (const struct atp_info *)id->driver_info; 837 835 838 836 /* set up the endpoint information */ 839 837 /* use only the first interrupt-in endpoint */ 840 - iface_desc = iface->cur_altsetting; 841 - for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { 842 - endpoint = &iface_desc->endpoint[i].desc; 843 - if (!int_in_endpointAddr && usb_endpoint_is_int_in(endpoint)) { 844 - /* we found an interrupt in endpoint */ 845 - int_in_endpointAddr = endpoint->bEndpointAddress; 846 - break; 847 - } 848 - } 849 - if (!int_in_endpointAddr) { 838 + error = usb_find_int_in_endpoint(iface->cur_altsetting, &ep); 839 + if (error) { 850 840 dev_err(&iface->dev, "Could not find int-in endpoint\n"); 851 841 return -EIO; 852 842 } 853 843 854 844 /* allocate memory for our device state and initialize it */ 845 + error = -ENOMEM; 855 846 dev = kzalloc_obj(*dev); 856 847 input_dev = input_allocate_device(); 857 848 if (!dev || !input_dev) { ··· 866 875 goto err_free_urb; 867 876 868 877 usb_fill_int_urb(dev->urb, udev, 869 - usb_rcvintpipe(udev, int_in_endpointAddr), 878 + usb_rcvintpipe(udev, usb_endpoint_num(ep)), 870 879 dev->data, dev->info->datalen, 871 880 dev->info->callback, dev, 1); 872 881