Skip to content

Commit

Permalink
can: netlink: dump bitrate 0 if can_priv::bittiming.bitrate is -1U
Browse files Browse the repository at this point in the history
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/20220628163137.413025-5-dario.binacchi@amarulasolutions.com
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Tested-by: Jeroen Hofstee <jhofstee@victronenergy.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Dario Binacchi authored and Marc Kleine-Budde committed Jul 3, 2022
1 parent 92a3178 commit 036bff2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/can/dev/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev)
if (priv->do_get_state)
priv->do_get_state(dev, &state);

if ((priv->bittiming.bitrate &&
if ((priv->bittiming.bitrate != CAN_BITRATE_UNSET &&
priv->bittiming.bitrate != CAN_BITRATE_UNKNOWN &&
nla_put(skb, IFLA_CAN_BITTIMING,
sizeof(priv->bittiming), &priv->bittiming)) ||

Expand Down
2 changes: 2 additions & 0 deletions include/linux/can/bittiming.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#define CAN_SYNC_SEG 1

#define CAN_BITRATE_UNSET 0
#define CAN_BITRATE_UNKNOWN (-1U)

#define CAN_CTRLMODE_TDC_MASK \
(CAN_CTRLMODE_TDC_AUTO | CAN_CTRLMODE_TDC_MANUAL)
Expand Down

0 comments on commit 036bff2

Please sign in to comment.