arm-trusted-firmware-sunxi: Update to 2.10
[openwrt/staging/jow.git] / target / linux / generic / backport-5.15 / 795-v6.3-03-r8152-avoid-to-change-cfg-for-all-devices.patch
1 From 0d4cda805a183bbe523f2407edb5c14ade50b841 Mon Sep 17 00:00:00 2001
2 From: Hayes Wang <hayeswang@realtek.com>
3 Date: Tue, 17 Jan 2023 11:03:44 +0800
4 Subject: [PATCH] r8152: avoid to change cfg for all devices
5
6 The rtl8152_cfgselector_probe() should set the USB configuration to the
7 vendor mode only for the devices which the driver (r8152) supports.
8 Otherwise, no driver would be used for such devices.
9
10 Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
11 Signed-off-by: Hayes Wang <hayeswang@realtek.com>
12 Reviewed-by: Simon Horman <simon.horman@corigine.com>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
14 ---
15 drivers/net/usb/r8152.c | 20 +++++++++++++++++---
16 1 file changed, 17 insertions(+), 3 deletions(-)
17
18 --- a/drivers/net/usb/r8152.c
19 +++ b/drivers/net/usb/r8152.c
20 @@ -9545,9 +9545,8 @@ static int rtl_fw_init(struct r8152 *tp)
21 return 0;
22 }
23
24 -u8 rtl8152_get_version(struct usb_interface *intf)
25 +static u8 __rtl_get_hw_ver(struct usb_device *udev)
26 {
27 - struct usb_device *udev = interface_to_usbdev(intf);
28 u32 ocp_data = 0;
29 __le32 *tmp;
30 u8 version;
31 @@ -9617,10 +9616,19 @@ u8 rtl8152_get_version(struct usb_interf
32 break;
33 default:
34 version = RTL_VER_UNKNOWN;
35 - dev_info(&intf->dev, "Unknown version 0x%04x\n", ocp_data);
36 + dev_info(&udev->dev, "Unknown version 0x%04x\n", ocp_data);
37 break;
38 }
39
40 + return version;
41 +}
42 +
43 +u8 rtl8152_get_version(struct usb_interface *intf)
44 +{
45 + u8 version;
46 +
47 + version = __rtl_get_hw_ver(interface_to_usbdev(intf));
48 +
49 dev_dbg(&intf->dev, "Detected version 0x%04x\n", version);
50
51 return version;
52 @@ -9904,6 +9912,12 @@ static int rtl8152_cfgselector_probe(str
53 struct usb_host_config *c;
54 int i, num_configs;
55
56 + /* Switch the device to vendor mode, if and only if the vendor mode
57 + * driver supports it.
58 + */
59 + if (__rtl_get_hw_ver(udev) == RTL_VER_UNKNOWN)
60 + return 0;
61 +
62 /* The vendor mode is not always config #1, so to find it out. */
63 c = udev->config;
64 num_configs = udev->descriptor.bNumConfigurations;