Skip to content

Commit 0f2211f

Browse files
can: gs_usb: gs_usb_set_phys_id(): return with error if identify is not supported
Until commit 409c188 ("can: tree-wide: advertise software timestamping capabilities") the ethtool_ops was only assigned for devices which support the GS_CAN_FEATURE_IDENTIFY feature. That commit assigns ethtool_ops unconditionally. This results on controllers without GS_CAN_FEATURE_IDENTIFY support for the following ethtool error: | $ ethtool -p can0 1 | Cannot identify NIC: Broken pipe Restore the correct error value by checking for GS_CAN_FEATURE_IDENTIFY in the gs_usb_set_phys_id() function. | $ ethtool -p can0 1 | Cannot identify NIC: Operation not supported While there use the variable "netdev" for the "struct net_device" pointer and "dev" for the "struct gs_can" pointer as in the rest of the driver. Fixes: 409c188 ("can: tree-wide: advertise software timestamping capabilities") Link: http://lore.kernel.org/all/[email protected] Cc: Vincent Mailhol <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 5440428 commit 0f2211f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

drivers/net/can/usb/gs_usb.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -925,17 +925,21 @@ static int gs_usb_set_identify(struct net_device *netdev, bool do_identify)
925925
}
926926

927927
/* blink LED's for finding the this interface */
928-
static int gs_usb_set_phys_id(struct net_device *dev,
928+
static int gs_usb_set_phys_id(struct net_device *netdev,
929929
enum ethtool_phys_id_state state)
930930
{
931+
const struct gs_can *dev = netdev_priv(netdev);
931932
int rc = 0;
932933

934+
if (!(dev->feature & GS_CAN_FEATURE_IDENTIFY))
935+
return -EOPNOTSUPP;
936+
933937
switch (state) {
934938
case ETHTOOL_ID_ACTIVE:
935-
rc = gs_usb_set_identify(dev, GS_CAN_IDENTIFY_ON);
939+
rc = gs_usb_set_identify(netdev, GS_CAN_IDENTIFY_ON);
936940
break;
937941
case ETHTOOL_ID_INACTIVE:
938-
rc = gs_usb_set_identify(dev, GS_CAN_IDENTIFY_OFF);
942+
rc = gs_usb_set_identify(netdev, GS_CAN_IDENTIFY_OFF);
939943
break;
940944
default:
941945
break;
@@ -1072,9 +1076,10 @@ static struct gs_can *gs_make_candev(unsigned int channel,
10721076
dev->feature |= GS_CAN_FEATURE_REQ_USB_QUIRK_LPC546XX |
10731077
GS_CAN_FEATURE_QUIRK_BREQ_CANTACT_PRO;
10741078

1075-
if (le32_to_cpu(dconf->sw_version) > 1)
1076-
if (feature & GS_CAN_FEATURE_IDENTIFY)
1077-
netdev->ethtool_ops = &gs_usb_ethtool_ops;
1079+
/* GS_CAN_FEATURE_IDENTIFY is only supported for sw_version > 1 */
1080+
if (!(le32_to_cpu(dconf->sw_version) > 1 &&
1081+
feature & GS_CAN_FEATURE_IDENTIFY))
1082+
dev->feature &= ~GS_CAN_FEATURE_IDENTIFY;
10781083

10791084
kfree(bt_const);
10801085

0 commit comments

Comments
 (0)