2022-06-13 03:05:09

by Dario Binacchi

[permalink] [raw]
Subject: [PATCH v3 09/13] can: slcan: send the close command to the adapter

In case the bitrate has been set via ip tool, this patch changes the
driver to send the close command ("C\r") to the adapter.

Signed-off-by: Dario Binacchi <[email protected]>

---

(no changes since v2)

Changes in v2:
- Improve the commit message.

drivers/net/can/slcan.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index 9bbf8f363f58..82a42cec52d3 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -436,9 +436,20 @@ static int slcan_transmit_cmd(struct slcan *sl, const unsigned char *cmd)
static int slc_close(struct net_device *dev)
{
struct slcan *sl = netdev_priv(dev);
+ int err;

spin_lock_bh(&sl->lock);
if (sl->tty) {
+ if (sl->can.bittiming.bitrate &&
+ sl->can.bittiming.bitrate != -1) {
+ spin_unlock_bh(&sl->lock);
+ err = slcan_transmit_cmd(sl, "C\r");
+ spin_lock_bh(&sl->lock);
+ if (err)
+ netdev_warn(dev,
+ "failed to send close command 'C\\r'\n");
+ }
+
/* TTY discipline is running. */
clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
}
--
2.32.0


2022-06-13 08:01:45

by Marc Kleine-Budde

[permalink] [raw]
Subject: Re: [PATCH v3 09/13] can: slcan: send the close command to the adapter

On 12.06.2022 23:39:23, Dario Binacchi wrote:
> In case the bitrate has been set via ip tool, this patch changes the
> driver to send the close command ("C\r") to the adapter.
>
> Signed-off-by: Dario Binacchi <[email protected]>

Nitpick: Please squash the open and close patches.

Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |


Attachments:
(No filename) (587.00 B)
signature.asc (499.00 B)
Download all attachments