795-v6.3-03-r8152-avoid-to-change-cfg-for-all-devices.patch 2.0 KB

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