Skip to content

Commit 036bff2

Browse files
passgatmarckleinebudde
authored andcommitted
can: netlink: dump bitrate 0 if can_priv::bittiming.bitrate is -1U
Upcoming changes on slcan driver will require you to specify a bitrate of value -1 to prevent the open_candev() from failing but at the same time highlighting that it is a fake value. In this case the command `ip --details -s -s link show' would print 4294967295 as the bitrate value. The patch change this value in 0. Link: https://lore.kernel.org/all/[email protected] Suggested-by: Marc Kleine-Budde <[email protected]> Signed-off-by: Dario Binacchi <[email protected]> Tested-by: Jeroen Hofstee <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 92a3178 commit 036bff2

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

drivers/net/can/dev/netlink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev)
511511
if (priv->do_get_state)
512512
priv->do_get_state(dev, &state);
513513

514-
if ((priv->bittiming.bitrate &&
514+
if ((priv->bittiming.bitrate != CAN_BITRATE_UNSET &&
515+
priv->bittiming.bitrate != CAN_BITRATE_UNKNOWN &&
515516
nla_put(skb, IFLA_CAN_BITTIMING,
516517
sizeof(priv->bittiming), &priv->bittiming)) ||
517518

include/linux/can/bittiming.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#define CAN_SYNC_SEG 1
1313

14+
#define CAN_BITRATE_UNSET 0
15+
#define CAN_BITRATE_UNKNOWN (-1U)
1416

1517
#define CAN_CTRLMODE_TDC_MASK \
1618
(CAN_CTRLMODE_TDC_AUTO | CAN_CTRLMODE_TDC_MANUAL)

0 commit comments

Comments
 (0)