mfd: dln2: Fix sanity checking for endpoints
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 26 Feb 2020 14:51:58 +0000 (16:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Apr 2020 05:59:01 +0000 (07:59 +0200)
[ Upstream commit fb945c95a482200876993977008b67ea658bd938 ]

While the commit 2b8bd606b1e6 ("mfd: dln2: More sanity checking for endpoints")
tries to harden the sanity checks it made at the same time a regression,
i.e.  mixed in and out endpoints. Obviously it should have been not tested on
real hardware at that time, but unluckily it didn't happen.

So, fix above mentioned typo and make device being enumerated again.

While here, introduce an enumerator for magic values to prevent similar issue
to happen in the future.

Fixes: 2b8bd606b1e6 ("mfd: dln2: More sanity checking for endpoints")
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mfd/dln2.c

index 95d0f2df0ad42d4107c5b9ee282d0fa365f6b6c2..672831d5ee32e1c6ba0737cb99a2f80d0e867373 100644 (file)
@@ -93,6 +93,11 @@ 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;
@@ -740,10 +745,10 @@ static int dln2_probe(struct usb_interface *interface,
            hostif->desc.bNumEndpoints < 2)
                return -ENODEV;
 
-       epin = &hostif->endpoint[0].desc;
-       epout = &hostif->endpoint[1].desc;
+       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;