netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] r8152: avoid to change cfg for all devices
@ 2023-01-16  7:59 Hayes Wang
  2023-01-17  3:03 ` [PATCH net-next v2] " Hayes Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Hayes Wang @ 2023-01-16  7:59 UTC (permalink / raw)
  To: kuba, davem, bjorn; +Cc: netdev, nic_swsd, linux-kernel, linux-usb, Hayes Wang

The rtl8152_cfgselector_probe() should set the USB configuration to the
vendor mode only for the devices which the driver (r8152) supports.
Otherwise, no driver would be used for such devices.

Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 66e70b5f8417..24be9449e4fc 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -9500,9 +9500,8 @@ static int rtl_fw_init(struct r8152 *tp)
 	return 0;
 }
 
-u8 rtl8152_get_version(struct usb_interface *intf)
+static u8 __rtl_get_hw_ver(struct usb_device *udev)
 {
-	struct usb_device *udev = interface_to_usbdev(intf);
 	u32 ocp_data = 0;
 	__le32 *tmp;
 	u8 version;
@@ -9571,10 +9570,19 @@ u8 rtl8152_get_version(struct usb_interface *intf)
 		break;
 	default:
 		version = RTL_VER_UNKNOWN;
-		dev_info(&intf->dev, "Unknown version 0x%04x\n", ocp_data);
+		dev_info(&udev->dev, "Unknown version 0x%04x\n", ocp_data);
 		break;
 	}
 
+	return version;
+}
+
+u8 rtl8152_get_version(struct usb_interface *intf)
+{
+	u8 version;
+
+	version = __rtl_get_hw_ver(interface_to_usbdev(intf));
+
 	dev_dbg(&intf->dev, "Detected version 0x%04x\n", version);
 
 	return version;
@@ -9869,6 +9877,12 @@ static int rtl8152_cfgselector_probe(struct usb_device *udev)
 	struct usb_host_config *c;
 	int i, num_configs;
 
+	/* Swtich the device to vendor mode, if and only if the vendor mode
+	 * driver supports it.
+	 */
+	if (__rtl_get_hw_ver(udev) == RTL_VER_UNKNOWN)
+		return 0;
+
 	/* The vendor mode is not always config #1, so to find it out. */
 	c = udev->config;
 	num_configs = udev->descriptor.bNumConfigurations;
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next v2] r8152: avoid to change cfg for all devices
  2023-01-16  7:59 [PATCH net-next] r8152: avoid to change cfg for all devices Hayes Wang
@ 2023-01-17  3:03 ` Hayes Wang
  2023-01-18 11:11   ` Simon Horman
  2023-01-18 14:30   ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Hayes Wang @ 2023-01-17  3:03 UTC (permalink / raw)
  To: kuba, davem; +Cc: netdev, nic_swsd, linux-kernel, linux-usb, bjorn, Hayes Wang

The rtl8152_cfgselector_probe() should set the USB configuration to the
vendor mode only for the devices which the driver (r8152) supports.
Otherwise, no driver would be used for such devices.

Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
v2: fix a typo for the comment.

 drivers/net/usb/r8152.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index a26d3127a4fe..4c5c1df5d7a4 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -9500,9 +9500,8 @@ static int rtl_fw_init(struct r8152 *tp)
 	return 0;
 }
 
-u8 rtl8152_get_version(struct usb_interface *intf)
+static u8 __rtl_get_hw_ver(struct usb_device *udev)
 {
-	struct usb_device *udev = interface_to_usbdev(intf);
 	u32 ocp_data = 0;
 	__le32 *tmp;
 	u8 version;
@@ -9571,10 +9570,19 @@ u8 rtl8152_get_version(struct usb_interface *intf)
 		break;
 	default:
 		version = RTL_VER_UNKNOWN;
-		dev_info(&intf->dev, "Unknown version 0x%04x\n", ocp_data);
+		dev_info(&udev->dev, "Unknown version 0x%04x\n", ocp_data);
 		break;
 	}
 
+	return version;
+}
+
+u8 rtl8152_get_version(struct usb_interface *intf)
+{
+	u8 version;
+
+	version = __rtl_get_hw_ver(interface_to_usbdev(intf));
+
 	dev_dbg(&intf->dev, "Detected version 0x%04x\n", version);
 
 	return version;
@@ -9870,6 +9878,12 @@ static int rtl8152_cfgselector_probe(struct usb_device *udev)
 	struct usb_host_config *c;
 	int i, num_configs;
 
+	/* Switch the device to vendor mode, if and only if the vendor mode
+	 * driver supports it.
+	 */
+	if (__rtl_get_hw_ver(udev) == RTL_VER_UNKNOWN)
+		return 0;
+
 	/* The vendor mode is not always config #1, so to find it out. */
 	c = udev->config;
 	num_configs = udev->descriptor.bNumConfigurations;
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2] r8152: avoid to change cfg for all devices
  2023-01-17  3:03 ` [PATCH net-next v2] " Hayes Wang
@ 2023-01-18 11:11   ` Simon Horman
  2023-01-18 14:30   ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-01-18 11:11 UTC (permalink / raw)
  To: Hayes Wang; +Cc: kuba, davem, netdev, nic_swsd, linux-kernel, linux-usb, bjorn

On Tue, Jan 17, 2023 at 11:03:44AM +0800, Hayes Wang wrote:
> The rtl8152_cfgselector_probe() should set the USB configuration to the
> vendor mode only for the devices which the driver (r8152) supports.
> Otherwise, no driver would be used for such devices.
> 
> Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
> Signed-off-by: Hayes Wang <hayeswang@realtek.com>
> ---
> v2: fix a typo for the comment.
> 
>  drivers/net/usb/r8152.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)

Assuming that all the versions covered in rtl8152_get_version()
support switching the device to vendor mode, then this looks good to me.

Reviewed-by: Simon Horman <simon.horman@corigine.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2] r8152: avoid to change cfg for all devices
  2023-01-17  3:03 ` [PATCH net-next v2] " Hayes Wang
  2023-01-18 11:11   ` Simon Horman
@ 2023-01-18 14:30   ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-18 14:30 UTC (permalink / raw)
  To: Hayes Wang; +Cc: kuba, davem, netdev, nic_swsd, linux-kernel, linux-usb, bjorn

Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Tue, 17 Jan 2023 11:03:44 +0800 you wrote:
> The rtl8152_cfgselector_probe() should set the USB configuration to the
> vendor mode only for the devices which the driver (r8152) supports.
> Otherwise, no driver would be used for such devices.
> 
> Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
> Signed-off-by: Hayes Wang <hayeswang@realtek.com>
> 
> [...]

Here is the summary with links:
  - [net-next,v2] r8152: avoid to change cfg for all devices
    https://git.kernel.org/netdev/net-next/c/0d4cda805a18

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-18 14:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-16  7:59 [PATCH net-next] r8152: avoid to change cfg for all devices Hayes Wang
2023-01-17  3:03 ` [PATCH net-next v2] " Hayes Wang
2023-01-18 11:11   ` Simon Horman
2023-01-18 14:30   ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).