r8152: Add RTL8152_INACCESSIBLE to r8153_pre_firmware_1()
authorDouglas Anderson <dianders@chromium.org>
Wed, 29 Nov 2023 21:25:23 +0000 (13:25 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Dec 2023 17:45:04 +0000 (18:45 +0100)
[ Upstream commit 8c53a7bd706535a9cf4e2ec3a4e8d61d46353ca0 ]

Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set
so that they don't delay too long if the device becomes
inaccessible. Add the break to the loop in r8153_pre_firmware_1().

Fixes: 9370f2d05a2a ("r8152: support request_firmware for RTL8153")
Reviewed-by: Grant Grundler <grundler@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/usb/r8152.c

index ec43279..4393ffd 100644 (file)
@@ -5612,6 +5612,8 @@ static int r8153_pre_firmware_1(struct r8152 *tp)
        for (i = 0; i < 104; i++) {
                u32 ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_WDT1_CTRL);
 
+               if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
+                       return -ENODEV;
                if (!(ocp_data & WTD1_EN))
                        break;
                usleep_range(1000, 2000);