Skip to content

Commit 5bb3ab0

Browse files
jhovolddtor
authored andcommitted
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>
1 parent a7675c1 commit 5bb3ab0

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

drivers/input/mouse/appletouch.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -829,29 +829,20 @@ static int atp_probe(struct usb_interface *iface,
829829
struct atp *dev;
830830
struct input_dev *input_dev;
831831
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;
836834
const struct atp_info *info = (const struct atp_info *)id->driver_info;
837835

838836
/* set up the endpoint information */
839837
/* 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) {
850840
dev_err(&iface->dev, "Could not find int-in endpoint\n");
851841
return -EIO;
852842
}
853843

854844
/* allocate memory for our device state and initialize it */
845+
error = -ENOMEM;
855846
dev = kzalloc_obj(*dev);
856847
input_dev = input_allocate_device();
857848
if (!dev || !input_dev) {
@@ -875,7 +866,7 @@ static int atp_probe(struct usb_interface *iface,
875866
goto err_free_urb;
876867

877868
usb_fill_int_urb(dev->urb, udev,
878-
usb_rcvintpipe(udev, int_in_endpointAddr),
869+
usb_rcvintpipe(udev, usb_endpoint_num(ep)),
879870
dev->data, dev->info->datalen,
880871
dev->info->callback, dev, 1);
881872

0 commit comments

Comments
 (0)