Commit 3e720131 authored by Dario Binacchi's avatar Dario Binacchi Committed by Marc Kleine-Budde

can: slcan: add support for listen-only mode

For non-legacy, i.e. ip based configuration, add support for listen-only
mode. If listen-only is requested send a listen-only ("L\r") command
instead of an open ("O\r") command to the adapter.
Signed-off-by: default avatarDario Binacchi <dario.binacchi@amarulasolutions.com>
Link: https://lore.kernel.org/all/20220728070254.267974-7-dario.binacchi@amarulasolutions.comSigned-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 341c5724
...@@ -727,10 +727,20 @@ static int slcan_netdev_open(struct net_device *dev) ...@@ -727,10 +727,20 @@ static int slcan_netdev_open(struct net_device *dev)
} }
} }
err = slcan_transmit_cmd(sl, "O\r"); if (sl->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) {
if (err) { err = slcan_transmit_cmd(sl, "L\r");
netdev_err(dev, "failed to send open command 'O\\r'\n"); if (err) {
goto cmd_transmit_failed; netdev_err(dev,
"failed to send listen-only command 'L\\r'\n");
goto cmd_transmit_failed;
}
} else {
err = slcan_transmit_cmd(sl, "O\r");
if (err) {
netdev_err(dev,
"failed to send open command 'O\\r'\n");
goto cmd_transmit_failed;
}
} }
} }
...@@ -817,6 +827,7 @@ static int slcan_open(struct tty_struct *tty) ...@@ -817,6 +827,7 @@ static int slcan_open(struct tty_struct *tty)
/* Configure CAN metadata */ /* Configure CAN metadata */
sl->can.bitrate_const = slcan_bitrate_const; sl->can.bitrate_const = slcan_bitrate_const;
sl->can.bitrate_const_cnt = ARRAY_SIZE(slcan_bitrate_const); sl->can.bitrate_const_cnt = ARRAY_SIZE(slcan_bitrate_const);
sl->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY;
/* Configure netdev interface */ /* Configure netdev interface */
sl->dev = dev; sl->dev = dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment