From patchwork Mon Jul 25 06:54:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2249 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 61EDE3F046 for ; Mon, 25 Jul 2022 08:54:32 +0200 (CEST) Received: by mail-ej1-f69.google.com with SMTP id sc42-20020a1709078a2a00b0072b5f51a9dbsf2752286ejc.1 for ; Sun, 24 Jul 2022 23:54:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658732072; cv=pass; d=google.com; s=arc-20160816; b=C9p2NK3RW0JlBXbJHwLwb6XsisGjwN1jDQA4OgZPkogyOm6/tEAnVIQmLEP/+fsSpx qTYKDxaoWH/oECmsKFC9xI3/4Rp6/8wT9Nf1YZ3Ob9gsM2QYI4+cD5QnrlghVY9JCVa3 wOYLUcsYfbnZQfxQSs8Yf4ccmQWvVUFIhF5jeMuk7YUjhOjTDcVAzU5dCryZscOZhtP5 mf6vISMDwJV5NylGkMNxPfnYrlB/FzZCK4KsI/ecc/vq7Gw/MEKIPnbmIe+9Pc3vRNip dwXWBqsPW9EJQ6os0QFRR1GYyg7kYg0QHWxbUACvJCFBAIstk9dHP0pa1ZsjzUsivpU4 +TVQ== 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=sNzkDDR0xz432Drd0DAskCIS5G3/hC4iupN4x/XdKKE=; b=EmaaN/SbfhG31xkFqbUJcsorMnS51g4+hxK6veSD5kh9nTK269r6TwutLIoRhMhcbJ +uZcewMll9aEJtZ5xNwPldd3IUaQbp7sPL5NLSH68gkOAlYfBXsBOXOhxu0qchUp00Ld UyDhL4DF5xnQanvwPV97D6GAHVBO7IHaM28rGBYhE8OYis7qgCkur291tGa8Q9b4WV3m Cm7iWJTxNQWSBRKsV7IYp1LDT/aIb2H733JlrCU8yzGZ7WFIMZm72DyYoeRLvv4bRKSA 7rUEQJwxgYslVp/Utw2Wd/uRIsoDN6cTzRnthbo9LMFU6hO8TKTgyhbf7z3AIXfKKILH Aszw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=J1YmFNSG; 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=sNzkDDR0xz432Drd0DAskCIS5G3/hC4iupN4x/XdKKE=; b=CwxIeh7ap/8Ucm34IvWqxq3f7aPuToIivqX5NvXpuYFi+MXEWQrlqZMiWeCJ8Xx0yn FvU3ZS6whQ99wPnGz/v36bAHEKdg/uWp2BNcnBNsYOD91++nxTrk3xXrZCSBAKzMmbp2 AMINaJWy01QsUyYYnkyxYQl7mO/kDsQSpPmyA= 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=sNzkDDR0xz432Drd0DAskCIS5G3/hC4iupN4x/XdKKE=; b=VBIcBpMOYdHQXM7JadFNoNOauX4bHs2IBHjhmLur6+k0f0l9Av4hqkVqjJPovDraTj 1jJrYlD8/YF0cf85GRBWslUh5ASPDA5bREo85fw9xLoU6krMbJXJVTm1ptFdA36NDLYk KA0ifmGepXcgx3lwEtt0Zv6iyh12J/NsXO5WBItzgf2lHtrOf3JyUs9y10remBSXUVcK W9ejI4xB7f+x9vMW+QvN5TzjXvM8MWUG3l2zzqmMlqXdRPEjgJpxsuYvkl5BDLM7g2Ny u/lE6mej5avajMsvvYph7yxIklxF5Sfbk2m9NM3YTY6wInGAGN3aWWERojrloMAieojY nMkg== X-Gm-Message-State: AJIora9LdJSBuL/29711l08DQlK+O7gL7nTw6sbDWmXrg6CFK3gNb5xQ nBKqqzzts8DHVLyS74Wxlpdv6mRO X-Google-Smtp-Source: AGRyM1udrg4UqnoACEiL16x+hOra9oF6lUMezUDWxjvyEV5S4T0dzdV0tu0brJHD9zr7jxo6cIeTKA== X-Received: by 2002:a05:6402:3907:b0:431:6776:64e7 with SMTP id fe7-20020a056402390700b00431677664e7mr11429111edb.0.1658732072204; Sun, 24 Jul 2022 23:54:32 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:814b:b0:72f:6ce5:d858 with SMTP id z11-20020a170906814b00b0072f6ce5d858ls1661401ejw.4.-pod-prod-gmail; Sun, 24 Jul 2022 23:54:31 -0700 (PDT) X-Received: by 2002:a17:907:d28:b0:72b:5cc9:99c with SMTP id gn40-20020a1709070d2800b0072b5cc9099cmr8930667ejc.228.1658732071144; Sun, 24 Jul 2022 23:54:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658732071; cv=none; d=google.com; s=arc-20160816; b=hVb8YEFxB6x6XlgvDW3bsPjFCKzX5uYMe3BFr+zhwmyviQrqXFubGOzO3txyp49xGr rI0NvTzkbssXEKGqrbBF3GgvzZMqjouAHaz/ossmeP2w1oUu4zsQfwiSbHm82DjGx9WN Q47Zjm/j26ZbhIN/8y3wscx0LBZhMYHvvDqSrn4GAIQRkWpIicIYciIrh1owm2aGXvv9 z8DJBV8lm7NaTIrp1QlukTl+vwsQujMT3pBrtCzh2rtXQBU2FOjZ4LPAdvCCKdd9IIr1 IdUEkvwhziDuTJ3mGi7Y2adDALJU4/tNlE/byC4ZSqUKZ6gUwnmg7bu+DELmrRetIFK1 58FA== 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=pq/5uoR3fJ3+2D6CJyRqXD1+RmzBjoigPwoKjoPD5TI=; b=rQwkxrxjHYcNqD21xSIp0Y/8LAG9D1RPUSPExLoAF160GSrC68WNZfBzsrq6cHO9Y8 7x8RPfZ75WLBcONj7r99QPWjclq9DAcbqlVVXS6IOGJVIfeFoCN+sN+pFi50G9b3qZMt 8fAPZmbGy2mW2DSyD585bqhnR998WmubjFr6pVq9k4WmF4DQ4vI409aBNj8mgEUFAzgB F1h62FZZhNOlydr5vaqyCUVQGuUIb6/hxYtLGauW/uC51EhZ+V4MRoiEFBoAXPIDLKFR LZtH1oCK/qg4oYBA3cUADBz7kVCu/ar/KnK0ISBnBmuMMXz8xHxED1Hyptg6zurdYrXx kgFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=J1YmFNSG; 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 f17-20020a170906825100b006e05b7ccb57sor3976926ejx.10.2022.07.24.23.54.31 for (Google Transport Security); Sun, 24 Jul 2022 23:54:31 -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:a17:907:3ea6:b0:72b:4a06:989a with SMTP id hs38-20020a1709073ea600b0072b4a06989amr8756566ejc.168.1658732070983; Sun, 24 Jul 2022 23:54:30 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-87-14-98-67.retail.telecomitalia.it. [87.14.98.67]) by smtp.gmail.com with ESMTPSA id r2-20020a1709060d4200b00722e57fa051sm4967711ejh.90.2022.07.24.23.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jul 2022 23:54:30 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, Amarula patchwork , Jeroen Hofstee , Oliver Hartkopp , Dario Binacchi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Marc Kleine-Budde , Paolo Abeni , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v2 5/6] can: slcan: add support for listen-only mode Date: Mon, 25 Jul 2022 08:54:18 +0200 Message-Id: <20220725065419.3005015-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220725065419.3005015-1-dario.binacchi@amarulasolutions.com> References: <20220725065419.3005015-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=J1YmFNSG; 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 --- 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 919311890d2c..76f20dc1aa90 100644 --- a/drivers/net/can/slcan/slcan-core.c +++ b/drivers/net/can/slcan/slcan-core.c @@ -724,10 +724,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; + } } } @@ -814,6 +824,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;