All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Cc: linux-kernel@vger.kernel.org,
	Jeroen Hofstee <jhofstee@victronenergy.com>,
	michael@amarulasolutions.com,
	Amarula patchwork <linux-amarula@amarulasolutions.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Vincent Mailhol <mailhol.vincent@wanadoo.fr>,
	Wolfgang Grandegger <wg@grandegger.com>,
	linux-can@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [RFC PATCH 5/5] can: slcan: send the listen-only command to the adapter
Date: Mon, 18 Jul 2022 12:22:03 +0200	[thread overview]
Message-ID: <20220718102203.66y6glwwphptl2tu@pengutronix.de> (raw)
In-Reply-To: <20220716170007.2020037-6-dario.binacchi@amarulasolutions.com>

[-- Attachment #1: Type: text/plain, Size: 2462 bytes --]

The subject can be enhanced, as the listen-only command ist not send
unconditionally. What about: "add support for listen-only mode"?

On 16.07.2022 19:00:07, Dario Binacchi wrote:
> In case the bitrate has been set via ip tool, this patch changes the
> driver to send the listen-only ("L\r") command to the adapter.

...but only of CAN_CTRLMODE_LISTENONLY is requested.

What about:

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: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> 
> ---
> 
>  drivers/net/can/slcan/slcan-core.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c
> index 7a1540507ecd..d97dfeccbf9c 100644
> --- a/drivers/net/can/slcan/slcan-core.c
> +++ b/drivers/net/can/slcan/slcan-core.c
> @@ -711,10 +711,21 @@ static int slcan_netdev_open(struct net_device *dev)
>  			}
>  		}
>  
> -		err = slcan_transmit_cmd(sl, "O\r");
> -		if (err) {
> -			netdev_err(dev, "failed to send open command 'O\\r'\n");
> -			goto cmd_transmit_failed;
> +		/* listen-only command overrides open command */

I think this comment can be removed.

> +		if (sl->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) {
> +			err = slcan_transmit_cmd(sl, "L\r");
> +			if (err) {
> +				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;
> +			}
>  		}
>  	}
>  
> @@ -801,6 +812,7 @@ static int slcan_open(struct tty_struct *tty)
>  	/* Configure CAN metadata */
>  	sl->can.bitrate_const = slcan_bitrate_const;
>  	sl->can.bitrate_const_cnt = ARRAY_SIZE(slcan_bitrate_const);
> +	sl->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY;
>  
>  	/* Configure netdev interface */
>  	sl->dev	= dev;

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 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-07-18 10:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-16 17:00 [RFC PATCH 0/5] can: slcan: extend supported features (step 2) Dario Binacchi
2022-07-16 17:00 ` [RFC PATCH 1/5] can: slcan: remove useless header inclusions Dario Binacchi
2022-07-16 17:00 ` [RFC PATCH 2/5] can: slcan: remove legacy infrastructure Dario Binacchi
2022-07-17 21:38   ` Max Staudt
2022-07-18  6:57     ` Oliver Hartkopp
2022-07-18 10:15       ` Marc Kleine-Budde
2022-07-18 10:23         ` Oliver Hartkopp
2022-07-19  1:03           ` Max Staudt
2022-07-19 19:59             ` Marc Kleine-Budde
2022-07-25  6:40     ` Dario Binacchi
2022-07-25 13:09       ` Max Staudt
2022-07-26 14:59         ` Dario Binacchi
2022-07-16 17:00 ` [RFC PATCH 3/5] can: slcan: change every `slc' occurrence in `slcan' Dario Binacchi
2022-07-16 17:00 ` [RFC PATCH 4/5] can: slcan: use the generic can_change_mtu() Dario Binacchi
2022-07-16 17:00 ` [RFC PATCH 5/5] can: slcan: send the listen-only command to the adapter Dario Binacchi
2022-07-18 10:22   ` Marc Kleine-Budde [this message]
2022-07-21  8:17     ` Dario Binacchi
2022-07-17 14:12 ` [RFC PATCH 0/5] can: slcan: extend supported features (step 2) Oliver Hartkopp
2022-07-18  6:59   ` Dario Binacchi
2022-07-18  7:15     ` Oliver Hartkopp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220718102203.66y6glwwphptl2tu@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jhofstee@victronenergy.com \
    --cc=jirislaby@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-amarula@amarulasolutions.com \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mailhol.vincent@wanadoo.fr \
    --cc=michael@amarulasolutions.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=wg@grandegger.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.