[PATCH] net/can/gs_usb: populate net_device->dev_port

Celeste Liu posted 1 patch 2 months, 2 weeks ago
drivers/net/can/usb/gs_usb.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] net/can/gs_usb: populate net_device->dev_port
Posted by Celeste Liu 2 months, 2 weeks ago
The gs_usb driver supports USB devices with more than 1 CAN channel. In
old kernel before 3.15, it uses net_device->dev_id to distinguish
different channel in userspace, which was done in commit
acff76fa45b4 ("can: gs_usb: gs_make_candev(): set netdev->dev_id").
But since 3.15, the correct way is populating net_device->dev_port. And
according to documentation, if network device support multiple interface,
lack of net_device->dev_port SHALL be treated as a bug.

Fixes: acff76fa45b4 ("can: gs_usb: gs_make_candev(): set netdev->dev_id")
Cc: stable@vger.kernel.org
Signed-off-by: Celeste Liu <uwu@coelacanthus.name>
---
 drivers/net/can/usb/gs_usb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index c9482d6e947b0c7b033dc4f0c35f5b111e1bfd92..7ee68b47b569a142ffed3981edcaa9a1943ef0c2 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -1249,6 +1249,7 @@ static struct gs_can *gs_make_candev(unsigned int channel,
 
 	netdev->flags |= IFF_ECHO; /* we support full roundtrip echo */
 	netdev->dev_id = channel;
+	netdev->dev_port = channel;
 
 	/* dev setup */
 	strcpy(dev->bt_const.name, KBUILD_MODNAME);

---
base-commit: 30d4efb2f5a515a60fe6b0ca85362cbebea21e2f
change-id: 20250930-gs-usb-populate-net_device-dev_port-941f2d1c3889

Best regards,
-- 
Celeste Liu <uwu@coelacanthus.name>
Re: [PATCH] net/can/gs_usb: populate net_device->dev_port
Posted by Marc Kleine-Budde 2 months, 2 weeks ago
On 30.09.2025 14:53:39, Celeste Liu wrote:
> The gs_usb driver supports USB devices with more than 1 CAN channel. In
> old kernel before 3.15, it uses net_device->dev_id to distinguish
> different channel in userspace, which was done in commit
> acff76fa45b4 ("can: gs_usb: gs_make_candev(): set netdev->dev_id").
> But since 3.15, the correct way is populating net_device->dev_port. And
> according to documentation, if network device support multiple interface,
> lack of net_device->dev_port SHALL be treated as a bug.
> 
> Fixes: acff76fa45b4 ("can: gs_usb: gs_make_candev(): set netdev->dev_id")
> Cc: stable@vger.kernel.org
> Signed-off-by: Celeste Liu <uwu@coelacanthus.name>

Applied to linux-can.

Thanks,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |