From patchwork Thu Jul 28 07:02:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2278 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 EDD1F3F013 for ; Thu, 28 Jul 2022 09:03:12 +0200 (CEST) Received: by mail-ed1-f72.google.com with SMTP id f13-20020a0564021e8d00b00437a2acb543sf547594edf.7 for ; Thu, 28 Jul 2022 00:03:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658991792; cv=pass; d=google.com; s=arc-20160816; b=ckli8IMQ9FeNL0WH0MiiaWhwGu6DUQIx2goVIvZZs2ZEoXSTOwZfqFS5jjHggU/JVA jb0nA43vD1WwCx6FhPyYDEL1AsgkvTVuxwTBHM/hGschWexGQV8V3Hx9W/GEJh2d1vgB I68bORY2XLZEppzXSUCtTRdv93F+3iP7z9UrkFWqya5LbtuHp7lg9fj46rX7jTL6oo0m aLPc3zaMJJIQo4CvCgeDttEt2ho1e7Zo6oNslUAdIjQ/MTHOJHGzR2qkszE9KAgmQbfL DnoqKyc+L4KW0sK81SRgXyq6qWlarwgJe6js0/WfBCVD6iEwheobX9ROUhRgcW1YnpcL hm8Q== 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=ld54SDtYXLxUGopup6ScpeTylocEzEsXm7cbEHLuHgE=; b=I/55EAquJsZhl5PFM8DmlqOpWPDol81iHts3LGagiUbq0mfR0qJg7hw+AWGPSu3d5E ua7gXJKeoeIegLXuXbbtnFCNcK4U9b98AJCQ0DiLEa1d+E3hBP2x0jKhLNVMUvt6uFCy hngb5F3Gg+s/cGCAORCV5qQnecXLiB9AcOQfvwihcxYSIhoPXOWRoQ6tMmUxLB2+EFw4 ZgPQw08rUCn2CbIXdtRAHgcS2HHTTeDFTrKqbXqrqbGAvBeQ7PsCxdHbQ+kUgM/m8l/K ZSuq6NiBwHzsX6nlsoVVPNP1u3jZY7eN1X+2yKHLBYFp72rn4anQFSXKYHbPNlVPkzOK CnJw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=C7FiLKyP; 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=ld54SDtYXLxUGopup6ScpeTylocEzEsXm7cbEHLuHgE=; b=VBxYhuxJ7f8sjCyNPVDng3aTDMGVZtbb9SnmfKGIfZ9iEPVDDGIi4SjiETAj9QqWyf bPhPVoK7uXVYGSzT03fSP12MPHbqptYfd2/1vXYeAS18/eebo1+XQXD3DlTqpCCIMj5q g1ErVqX61UNWBwefP+7Q6BDoVra8gch6l7xPg= 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=ld54SDtYXLxUGopup6ScpeTylocEzEsXm7cbEHLuHgE=; b=GLpeszBOEYboRHHAoCnIujgYDQjhkmLiKZkinlT3ZbuJfIoanFDxVOcSDkcA4B+qSH dAo9j2aS7cLOtJTZSr+9KR00qjiJ4XOjZb974BgENB9gYDoY2jtcyWIQqIcgJvedwQ2I WL6rvRN9U9Gfeqhj4hyRHeT1BnbKDDdRZf2JLubabw5gDKQj+g0e7737zSfcl2vasKoL ZhDR7zKzmWkrok05IULS1bam49+E9PiqsxiW82jNU07Vd6yxbpfz/4hdOg7p4Q4nElJP mn68n4m+xphOP1mQUPNkX7y71g+xgTNCYk9M8ywHnzPVqqoK4WYhDdLixTzceZr6D+N5 /zlg== X-Gm-Message-State: AJIora8ulJB0ije42N8lkqqStvatszTQcrL6VFoH/DalBrqdK3qjFZQT a7HkXTGWDIUG4aQZ8vVofTCrFc7w X-Google-Smtp-Source: AGRyM1uyCMgPB1NAmwUVw8mkRwm7y46XxaItqZzH6znyppELb0O6HWBX1GIcPD9+xfvxZiskZi3T7A== X-Received: by 2002:a05:6402:27ca:b0:43c:2a52:a90f with SMTP id c10-20020a05640227ca00b0043c2a52a90fmr14999784ede.328.1658991792776; Thu, 28 Jul 2022 00:03:12 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:35cb:b0:43a:7c1c:8981 with SMTP id z11-20020a05640235cb00b0043a7c1c8981ls979353edc.0.-pod-prod-gmail; Thu, 28 Jul 2022 00:03:11 -0700 (PDT) X-Received: by 2002:a05:6402:26cd:b0:43b:e3eb:241b with SMTP id x13-20020a05640226cd00b0043be3eb241bmr23313396edd.133.1658991791637; Thu, 28 Jul 2022 00:03:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658991791; cv=none; d=google.com; s=arc-20160816; b=tIJy9PuVHfO1yoSdWUOXVaFFfiXfAAYjh9FoXv1N7qDbI82VkLmDmCSxWfs+zO6LnP 8WwOHLJ3YSt2kqz31eX3IjnhdZH7Kt91mFr1Sru6V3Z7uc9/7UoaUtp2qA478XsiQtH+ 6VQcQEdqhIES+tBN+sjkyuD9B+p/2yhAXL2+YV+Xi7m9dBkVWTmxgia8bCQyisDzyEjP x8kReLTPST6utilngH3aiZ1EAf691l+aT6KkEvDqUiEJ3E17PxwoZtO3wf20srhGjQLs Yhu1P0IsmP9kgwaLvkHL1bsSZdAJqyIlY1vzd96RqyrgzUCuiqZniObK3/Xih/cfMGLf P83g== 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=rbjoK64u0Nv21CxxlQFKwTPmVGnv7nDMih2pZ9805sY=; b=CQbUwP7OW0FTt42RDGtae2EROY+4zXjG0SF7gwSFs/anZsPVsI3CRPgI5ndJ9nThd9 OYSt0aJ0Gw9bw53QO5vs8fwUErFKp8dTAF792V9+X+GVkVftz3NW+VSsBN5a5LmM1Mnm IB4NNmiL40xxnvbAOkqtPlSY3yNFP6VfubN2BmKFr7uqPbOJNVdZSc9roOR3fzPbEd2m Fqt+YWvtQzahAF4UW+Oei110eN960jbkX/WoF0QVSIBaPscX6veE0UHVT9jrFGCg63Vp tRA2muC38FSpt0jvORWkZTowN0R2OI9n3TrpA6ye9qC351fKfh+rPvCL6cyWfgZlGbnN wdqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=C7FiLKyP; 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 i27-20020a50871b000000b0043a179a030fsor124002edb.26.2022.07.28.00.03.11 for (Google Transport Security); Thu, 28 Jul 2022 00:03:11 -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:194f:b0:43a:298f:f39c with SMTP id f15-20020a056402194f00b0043a298ff39cmr26569587edz.106.1658991791472; Thu, 28 Jul 2022 00:03:11 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-31-31-9.retail.telecomitalia.it. [79.31.31.9]) by smtp.gmail.com with ESMTPSA id r18-20020aa7d152000000b0042de3d661d2sm154742edo.1.2022.07.28.00.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 00:03:11 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-can@vger.kernel.org, Marc Kleine-Budde , Jeroen Hofstee , michael@amarulasolutions.com, Amarula patchwork , Oliver Hartkopp , Dario Binacchi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wolfgang Grandegger , netdev@vger.kernel.org Subject: [PATCH v4 6/7] can: slcan: add support for listen-only mode Date: Thu, 28 Jul 2022 09:02:53 +0200 Message-Id: <20220728070254.267974-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220728070254.267974-1-dario.binacchi@amarulasolutions.com> References: <20220728070254.267974-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=C7FiLKyP; 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: , 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 --- (no changes since v2) Changes in v2: - Remove comment on listen-only command. - Update the commit subject and description. drivers/net/can/slcan/slcan-core.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c index d12d98426f37..45e521910236 100644 --- a/drivers/net/can/slcan/slcan-core.c +++ b/drivers/net/can/slcan/slcan-core.c @@ -726,10 +726,20 @@ 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; + 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; + } } } @@ -816,6 +826,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;