mfd: dln2: Automatically detect and fill endpoint pointers
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 17 Jun 2022 18:23:38 +0000 (21:23 +0300)
committerLee Jones <lee@kernel.org>
Tue, 19 Jul 2022 09:54:40 +0000 (10:54 +0100)
The usb_find_common_endpoints() finds and fills the endpoints
in accordance with their types. Use it to automatically detect
and fill endpoint pointers.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220617182338.32402-1-andriy.shevchenko@linux.intel.com
drivers/mfd/dln2.c

index 852129e..6cd0b0c 100644 (file)
@@ -91,11 +91,6 @@ struct dln2_mod_rx_slots {
        spinlock_t lock;
 };
 
-enum dln2_endpoint {
-       DLN2_EP_OUT     = 0,
-       DLN2_EP_IN      = 1,
-};
-
 struct dln2_dev {
        struct usb_device *usb_dev;
        struct usb_interface *interface;
@@ -777,16 +772,12 @@ static int dln2_probe(struct usb_interface *interface,
        int ret;
        int i, j;
 
-       if (hostif->desc.bInterfaceNumber != 0 ||
-           hostif->desc.bNumEndpoints < 2)
+       if (hostif->desc.bInterfaceNumber != 0)
                return -ENODEV;
 
-       epout = &hostif->endpoint[DLN2_EP_OUT].desc;
-       if (!usb_endpoint_is_bulk_out(epout))
-               return -ENODEV;
-       epin = &hostif->endpoint[DLN2_EP_IN].desc;
-       if (!usb_endpoint_is_bulk_in(epin))
-               return -ENODEV;
+       ret = usb_find_common_endpoints(hostif, &epin, &epout, NULL, NULL);
+       if (ret)
+               return ret;
 
        dln2 = kzalloc(sizeof(*dln2), GFP_KERNEL);
        if (!dln2)