482c6c6f133b40906425a6668b20898eeac2aa38
[openwrt/staging/thess.git] /
1 From 02767440e1dda9861a11ca1dbe0f19a760b1d5c2 Mon Sep 17 00:00:00 2001
2 From: Hayes Wang <hayeswang@realtek.com>
3 Date: Thu, 19 Jan 2023 15:40:43 +0800
4 Subject: [PATCH] r8152: reduce the control transfer of rtl8152_get_version()
5
6 Reduce the control transfer by moving calling rtl8152_get_version() in
7 rtl8152_probe(). This could prevent from calling rtl8152_get_version()
8 for unnecessary situations. For example, after setting config #2 for the
9 device, there are two interfaces and rtl8152_probe() may be called
10 twice. However, we don't need to call rtl8152_get_version() for this
11 situation.
12
13 Signed-off-by: Hayes Wang <hayeswang@realtek.com>
14 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
15 ---
16 drivers/net/usb/r8152.c | 9 +++++----
17 1 file changed, 5 insertions(+), 4 deletions(-)
18
19 --- a/drivers/net/usb/r8152.c
20 +++ b/drivers/net/usb/r8152.c
21 @@ -9602,20 +9602,21 @@ static int rtl8152_probe(struct usb_inte
22 const struct usb_device_id *id)
23 {
24 struct usb_device *udev = interface_to_usbdev(intf);
25 - u8 version = rtl8152_get_version(intf);
26 struct r8152 *tp;
27 struct net_device *netdev;
28 + u8 version;
29 int ret;
30
31 - if (version == RTL_VER_UNKNOWN)
32 - return -ENODEV;
33 -
34 if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
35 return -ENODEV;
36
37 if (!rtl_check_vendor_ok(intf))
38 return -ENODEV;
39
40 + version = rtl8152_get_version(intf);
41 + if (version == RTL_VER_UNKNOWN)
42 + return -ENODEV;
43 +
44 usb_reset_device(udev);
45 netdev = alloc_etherdev(sizeof(struct r8152));
46 if (!netdev) {