From patchwork Sun Jun 12 21:39:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2056 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 07C803F1DD for ; Sun, 12 Jun 2022 23:40:16 +0200 (CEST) Received: by mail-ed1-f72.google.com with SMTP id s15-20020a056402520f00b004327f126170sf2961896edd.7 for ; Sun, 12 Jun 2022 14:40:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655070015; cv=pass; d=google.com; s=arc-20160816; b=B0gvoCxQr4gvqIirLti9Css786nnMY270bSV/WIvvNhWCjoAt3fWWhBgqxLVo1mUSA an0zb4D+ksE226a44zF+EDDhfI8MjBTNBddr6TjAVVFiBro1ABY+eT85K1AzoiT32bd8 ptO9A+s+txSy2vwjsHdmgLMCC1Z+Uo+0rYcJMm35O2Cc1Xwra9t+g57xZY6ZX4KaC+Xd QZkwAYSDUsJYkYSdtdkPEfLqJJeWGIHJt6Hj09MKmA+LtA/2jOlmfPRo+/QzuMh1vauf 5SWNDdWa9pfbZtwXn5BPCp14Cpht1OcdJnxk5FKPVydXG/6cgOVBP8ghuiYCc3gLgv2O yqJg== 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=Bk35j8bZnTVquX4v82VtOEK7U7HzburEvhwFE//XSUE=; b=ELrerfhsXtKAUh0dYi0mVkX7GzqBAaQBnl8dPw2HEbMJ2m6lR1623hi/jY0OsxBUFN J0mbxPOH4bp8C3jhKC2+7j0ljGHdqa3I4iCYhY/L45gk9KYMXlKVt8ATOIOGToGWNZtJ P8aEgi1+lMfZDXle7V8flrvNzKj2xfBMNawOGR6Ejb/xSwAo1IM1Ow+po4PkT/47TKII RmkTH9O1CZGbqubi9xk8KWgZ2qEGuJphwbPe7QtYh3BKCD59P8H1ydpTRigS1dbxjcpx RjbTNW3ovagtPQkiw26qTDxYGwxwgrvrHU0XJn0HN+/auycOIuW3heiVGUxkzZr07iet ggHg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gKCrFNo3; 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=Bk35j8bZnTVquX4v82VtOEK7U7HzburEvhwFE//XSUE=; b=PrOVi0p3CZvzRml2Or4ZAhPwFuCp5pPm4efa86su9jJ5KwPYv6VbutLjxHIg3TMCBI hz1PUG6BYTzk2/oueRFGEpRoZInQH/2qyZ36xWgoq/RoPVyl1NNOU/Zf865k6XDdx+pW i7FeHIZKlV2RTl7/iOkXu4+P7IC/y2O4lv9wM= 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=Bk35j8bZnTVquX4v82VtOEK7U7HzburEvhwFE//XSUE=; b=s2auB2K6nQLtRfCVK82FwoPvenzk/LrJ37fIgQRC2mOmRFhYRf8wOHy7DoItrAvzRL g/VdxWpWSI9tVWBcH5frIa6J3Ul7gz6FIrRELV7GuEzyUi3hh4orrFs0H62B80psJLry FAh/9khudpIB+7WFw3xT4y7fYvJ92H6SbwtENmL6LpT4BwvDfDIQKkv1g8hLkAgxWTZI YNgGrJeZWG1aN4pY0cdiADtBBKICJpnWULTaGhapgHB8bnVn13x763ZFH92VWD6KOck0 IoGxBaqMPGQiUQyuBfabVP+Zdib1ZtsuUwx9BLLCDrmifZcpIrzcvA3+fzKVVMNkOpZz g8kQ== X-Gm-Message-State: AOAM530U2hNu1eJjmSyIe+Q4XoKnAp3y+9Fr/0KBQGSQ4Y5o0b4iWZ8Q ODLeV/qQrp0Sb40J/kj2BiBZUXs3 X-Google-Smtp-Source: ABdhPJzUhaboUOinCH3VdQDqz9qFq5J/ezXgkMY9e9vhfMHiwohhPL7YoLKcF+ReVHx6sJgp/ZA4YA== X-Received: by 2002:a17:906:c347:b0:718:ca61:e7b7 with SMTP id ci7-20020a170906c34700b00718ca61e7b7mr342831ejb.746.1655070015831; Sun, 12 Jun 2022 14:40:15 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:709:b0:431:3a5e:75b3 with SMTP id w9-20020a056402070900b004313a5e75b3ls1836056edx.1.gmail; Sun, 12 Jun 2022 14:40:14 -0700 (PDT) X-Received: by 2002:a05:6402:3325:b0:42d:e1d8:99e9 with SMTP id e37-20020a056402332500b0042de1d899e9mr60650742eda.87.1655070014794; Sun, 12 Jun 2022 14:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655070014; cv=none; d=google.com; s=arc-20160816; b=ibMx8cXhnoHwVK2mxXsMPa/T3Mv4546JM3OSamAwKg1CCUZUp5/lifD1X062aZT/XR zeWrIyJg3zZWw1VRusdltko67cKuLj4SJMPtKD1tZr2jaruK/j4P37eeqK3P6natp+Jx AQoXRHT4+rr476NUAs4ko3W1pmaj+TNmpBb36o4HBS/owiEt8KVnKCYLBB7SNVgmFk+d ICutjHbEmM3pQhN3SyecxcyCcX4nVsZmuOJWwIQV51R8Xq9n8v6pf967K9zUMw94VyKr CsPRV4mzMDfOMnqGYO2J9zuFqEgDuOV8k5z4x1l5lJssU7H8jKYVPcjXQlb3z1GORaWu cQyA== 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=O0zVHGTWOUK0yHY7/MxDgofJ+b/Xb1B9oJbEk1RTZ7Q=; b=io+x7U/afpgDFmxfZRDpXo5AV8K/Ld4/CXa/DFNt27Ij917Oy5yStdkLcwQjZhg+TV 6s6lX1IxfvfKf7q9j+KbQwKd21a3OJd6UTeBYEcNbmMeWqYU+09x5SfvsiQuM74qoxmM F+UAmh3KMkop0GPAEQHvxWBd/bW102I49fUKrUi1rd6TLUgNqxU+c1zfJBDaRk027kiB Bj7e9bLbYx5kfCR7dxINjVO0G/RxOb8Mxn/cB/EML2CPyeAibWszWQ0oF8B1eVtsqCcp V2rpaPXAJR5wFMH+nI0dqCH/UYDXm6WfDr0y6yifXp2k/dNqJxzF7YcyR5Whb3jcD0yO 32+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gKCrFNo3; 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 b6-20020a05640202c600b0042b65394344sor1571834edx.55.2022.06.12.14.40.14 for (Google Transport Security); Sun, 12 Jun 2022 14:40:14 -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:1543:b0:431:9d90:49f7 with SMTP id p3-20020a056402154300b004319d9049f7mr28466532edx.397.1655070014591; Sun, 12 Jun 2022 14:40:14 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id u10-20020a1709061daa00b00711d546f8a8sm2909398ejh.139.2022.06.12.14.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jun 2022 14:40:14 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, Amarula patchwork , 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 v3 09/13] can: slcan: send the close command to the adapter Date: Sun, 12 Jun 2022 23:39:23 +0200 Message-Id: <20220612213927.3004444-10-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220612213927.3004444-1-dario.binacchi@amarulasolutions.com> References: <20220612213927.3004444-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=gKCrFNo3; 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 close command ("C\r") to the adapter. Signed-off-by: Dario Binacchi --- (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); }