From patchwork Sat Jul 16 17:00:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2185 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 972703F046 for ; Sat, 16 Jul 2022 19:00:20 +0200 (CEST) Received: by mail-ed1-f72.google.com with SMTP id w15-20020a056402268f00b0043ac600a6bcsf5344705edd.6 for ; Sat, 16 Jul 2022 10:00:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657990820; cv=pass; d=google.com; s=arc-20160816; b=gHFab/dtOQujY7nhNuS5cQbStAfk3sI+aBIxPcmqh1VwYZ6Tt9zNpLBK6o1kqYsPuM HGqQqjOSXLpP6LhUW/yNiSlIBEBcXTKUiJtCWi8eJqvus3DRUUxE4W1eyKMDSmDFUKLX 51LzmZ9ReQotKD3rt2VdsY55rHfChn/ANuhfXDJ0mUfhzdhzjSY3dDwi/3DVKbUVMel+ lMw8vMppH1XepT7cY597EH+b79puZP8wAGQeUSfFlhXpt5Ofo06cMcqTpwUFw0MtNjKe SOxWar2bs+IRIVER9OCajxtRMjUIf9UQWm3R83OteaTy/uw1qB9ecLlZZzL0S0GWl+nL y8pw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=JTe1pHK7dxQyfRxAkRaE9oMjCZ7/bhT9FR3CSdHNO3E=; b=YIIzE1HlKXXPimy6Jggt4MqxcybGmxCpBlzPzSdrUmcfFIuKJ6QPd9/oI2t3NjV0R3 WkoQ/7s3Y3fAmi5TiObLmQXVIBx3bfzl5MsDTqK41BDHr2X6bsvPmNSsnhYQIH8XOIuK k+rgVWw+Gw0xG6BI7JmuEvGgHzZCF+9Ti6Ws0socCZb3Ad6QRl4GnkaYeDZnu1inxkzo STfp4nhdcQCYqvzSCC8eOrk4v48cQ6qCaFWF3xH5PcYz75cesVXWJ+sM9RMROe6YPn6d 064/CduX2+hx0JH2X1JGYNpCwsZR8sd9FqVO+dmjzJi+kTM6OT3P0PPPy8uAryfLLzJD 9Ibg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=iQf244o1; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=JTe1pHK7dxQyfRxAkRaE9oMjCZ7/bhT9FR3CSdHNO3E=; b=jQI93GVROOKgigmn5GwQbgiVw8atGVUjtE7LeA58wN+BwfwX8YS29GVGr2h2hw0dLz ApwGml0539dXduYQTJK3nntjgbILoH1eHMvmOTXOB252al80IJksNI3z94Jy7Tc30Cvt KR0ZouVKgQ/cP/lBcqvwlns3EaRYv4CNYLHm8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=JTe1pHK7dxQyfRxAkRaE9oMjCZ7/bhT9FR3CSdHNO3E=; b=HBHS14DcraSa48GXryOIFG/nTRwmZJQFTKpl2priQY3Mibz+RnvxUyPqCDmXBOB0Eq SDMeejpcZbaoTRADsDJthblh78hVOdDz/P/X+k3TZS7MiEmaTcIe2+F1a1CISOqrKga9 JQZaUSpVqrqwlcp8p9bBLK3du0wXo67EHYfjJ2lV6HO5UpQaLtClAbzDEicaby+4rbVp V+6oppN2hx+bOlLg4HsbXeEiAlyFx8GtcKh7q95zBGD3Me/z3PF/70vbQ5EniOCyiYAS mmpuw3xUI+aufJSjKQt94nb20FL+UXKUdmy41lY1Y7qtTE0fANQQPn1FtOP0NSpgKd9d viUw== X-Gm-Message-State: AJIora/3+2J7awL+G+JTSbGA9W2P1JIQfmd7lXD/zg82AEys+ZPLEDre i8pabn9EPVYVObgz7TS5E9K+r652 X-Google-Smtp-Source: AGRyM1v2gV0G9WzB00CW9ZqcoMvZnOb4ZUM03RmtsWHBRN8JnDHvK/cra/uw7cpVIzBAJARouy8Nhw== X-Received: by 2002:a17:906:2086:b0:717:4e91:f1db with SMTP id 6-20020a170906208600b007174e91f1dbmr18702049ejq.345.1657990820434; Sat, 16 Jul 2022 10:00:20 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:94c:b0:72f:1dfc:6374 with SMTP id j12-20020a170906094c00b0072f1dfc6374ls270025ejd.3.-pod-prod-gmail; Sat, 16 Jul 2022 10:00:19 -0700 (PDT) X-Received: by 2002:a17:907:d88:b0:72b:1127:33f5 with SMTP id go8-20020a1709070d8800b0072b112733f5mr19361368ejc.725.1657990819286; Sat, 16 Jul 2022 10:00:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657990819; cv=none; d=google.com; s=arc-20160816; b=IJArz0APbd37wm9GQZOxP0viCaSO7tZbvMBDRTxdWTNcDDNZyojlhOJ4KUAIcBsYc9 DQQ6uWWjEuN9uxJD5NsHvZRhAVDCE+zxIA1EZXHkAfkvCi0LADTulNG0Ngb5DzOK91Tu QIXgy/vvsHm3lNA4Ey71EaH9wH6Qr7Do/tXcH0Cs50yy0/1VMPqiCjThYb313brohgmC oepdrEISHByzJcxwKfg5y0By9ifYSo+pn0h48pakN0KRwGk+N6ENmQxEXRiOdl33ISQj 4pxqiKlFQ+efyZXuOup4h4NYVgROzclW8h1ZrFpW14L9iogBmB8dj4uqxjgj+pE4vvWR fTtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+8/uBRwlHoO2r+QA6MM57OwP4K1pVboHuwKMksUhKgk=; b=YbwNZG9NH+WndZ40wCgHURjouev/id3plhIXLkDBaegGfbQ9bYsIUgtRUNieIXU5Kg yqJhlExtYb4+olPkzglNR+I7gA15s6j3+e1x1bnSbBEU02AQSk5H/DnK1puZ3iJQ2dnH W9TnLjS7gLdhi67soR66kuYFJv6TFBedGVBcuus+eSz/f6jvhy0o7qGEKwQsTfe6fDw1 s7y+kohAdknDuClMxIQoRQYOSpwiTcQizFhWMKUhLSWPy0rHJzhU8QQW6Isz0YJp77wY f22HlliVfBLhamhHs0m2QKuU06MmsZopT7BAhWeMkgLF7wTzEfZVFK+ZapU6G11Azw9Y 64/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=iQf244o1; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id d11-20020a50c88b000000b00439d5301a15sor3595918edh.14.2022.07.16.10.00.19 for (Google Transport Security); Sat, 16 Jul 2022 10:00:19 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:e85:b0:434:f9d9:3b18 with SMTP id h5-20020a0564020e8500b00434f9d93b18mr27275747eda.37.1657990819011; Sat, 16 Jul 2022 10:00:19 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-182-13-224.pool80182.interbusiness.it. [80.182.13.224]) by smtp.gmail.com with ESMTPSA id g3-20020a170906538300b0072b14836087sm3363135ejo.103.2022.07.16.10.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Jul 2022 10:00:18 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Jeroen Hofstee , michael@amarulasolutions.com, Amarula patchwork , Dario Binacchi , "David S. Miller" , Eric Dumazet , Greg Kroah-Hartman , Jakub Kicinski , Jiri Slaby , Marc Kleine-Budde , Paolo Abeni , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 5/5] can: slcan: send the listen-only command to the adapter Date: Sat, 16 Jul 2022 19:00:07 +0200 Message-Id: <20220716170007.2020037-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220716170007.2020037-1-dario.binacchi@amarulasolutions.com> References: <20220716170007.2020037-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=iQf244o1; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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. Signed-off-by: Dario Binacchi --- 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 */ + 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;