From patchwork Tue Jun 7 09:47:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2022 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 1B6603F08A for ; Tue, 7 Jun 2022 11:48:29 +0200 (CEST) Received: by mail-wm1-f69.google.com with SMTP id bi22-20020a05600c3d9600b0039c4144992csf4791030wmb.5 for ; Tue, 07 Jun 2022 02:48:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595309; cv=pass; d=google.com; s=arc-20160816; b=m03EmjE1iXVd3oznFktr6/f4ebK+zVLNkTbipgmgMls+09zfP5po/lEJpw58GpnlLo e5KLD61qMhRKHvTESf2NYm423Exfa7zEie6T+ZyS0wn1domak0NX9oanF913OgFMWgD5 H4S0sEnO0gLyfEmYndHeXMj0d3h2nqNHpd+HYl+Fd+hrQFrnlxNJ5oBTQgA4ryyvbLpL P8GujLod880hJtLGfENvZwGpAezwdg44y+u09NrK0tCv/dpZ4NVpA7mZvufVHCIFRPjT QhSRcqDijQ0Yca00Wq+g0aH0zn4jMIsr95C6uXlm/n5YN3L2NqGHq26C5DFkNTX5Hhnh husw== 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=u6SSvQt/R2nD19PwdwhKJLCfAd51teSe3YYaNgaTgwc=; b=LUIVVAnHXVrRBSmjAq2GuMnQXt6k6JN6VyE9Gt8kymKF5RMtuviuLgSmPJh9s2DBfB QNWSOwWCPVQ78tbiiB2KXMmeLhat2o4BTZsGoU+MN8X/ZwuXKdVOI7FVLs65DJVdfTLA X8202vOqXJONafEWhFX2FJZVImhefHl4YOcOM3iD+/iLH7cz1G18aWzEtKK2i/g68svT GWosn4/2i+j7htYZr5TQBg/mvIa0i1l3PmMd2tEf4pzJuwFo0L5m0d++EeldHyTTkkZ9 yFxwFO0ulkQS7tWT2iSO3fPtPCLsCITk7Rr4Q4CInZQtykG8yi3Mv7H3izoOZssM6Tqz 9mcg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XBJoJxny; 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=u6SSvQt/R2nD19PwdwhKJLCfAd51teSe3YYaNgaTgwc=; b=Xt3FUpSE/md4vIxiMxAqjsC2EfhhJuD/58tO7taUyenqSzZagff7NkffDVoBW4F0qf eTnOXCDU6M6m1YrJsLl4V6gKBI33CofQtHfj6ZW/2qT/rDF/EBATUEJzenqlIq8yeShF 0+Fdyg/QNYAN+HM+j4VrI6j/kS9PjgC1U46C8= 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=u6SSvQt/R2nD19PwdwhKJLCfAd51teSe3YYaNgaTgwc=; b=A/huUHrY3M7go9WP8SjEmSmhbD37Kkju61sICz+AAaQaWLNy2mjkj+B0At1Oy7G47d Ho7K++TVs6kARCeofgP5Gs87GbPDe0HGdG7jE2mCjWufzVJ1S2yENsHN4OvISWrISrv6 XwhXrUfWcf+H80Y2XCPU3jncHrCPJdKS+2WdOYVH6dgFkbM3QGeZRAxeZnaQ7upGcJjM C9BS3/eJ/v/79zUAJamwHSx7J4A9qd5K6sRw00T1bCj8A+fsGjl4FNNh3zVpjV/8fZSd r3xgFAPYIQZ0QxHZhL/y0YpCaxiSvXibK6G++lmQznnKihjqRs9i6g77bG9zYmhmI7Xf q4rQ== X-Gm-Message-State: AOAM531EGdx9m7sJZrD10kci3qPd3KBNrSP3yTa9+BnxaoXkWhKxARW7 o4V+wlHA8MtVwnlejFujy+Bpjs/B X-Google-Smtp-Source: ABdhPJxnsHHTQYT6TO8b7k9ubN8iweVEPFhdlGi5VAGD3Z8BTSWlf/PXWQqeqL9FLSy0vL/BNwrZYw== X-Received: by 2002:a05:600c:1994:b0:398:557:a0a5 with SMTP id t20-20020a05600c199400b003980557a0a5mr50166013wmq.110.1654595308769; Tue, 07 Jun 2022 02:48:28 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:3d8c:b0:39c:5b80:3b5c with SMTP id bi12-20020a05600c3d8c00b0039c5b803b5cls393752wmb.2.gmail; Tue, 07 Jun 2022 02:48:28 -0700 (PDT) X-Received: by 2002:a05:600c:5011:b0:397:6e41:f6ec with SMTP id n17-20020a05600c501100b003976e41f6ecmr27681875wmr.190.1654595307835; Tue, 07 Jun 2022 02:48:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595307; cv=none; d=google.com; s=arc-20160816; b=k+0enS1kegiN1uq9lDsUOTI+T47uuqN0RGH2tMs7yMv/C4/tERFY7y4nEGEBfg9ZKd COgVEmklq3HCQgfwcwWbIRmx2gnw29Axzy/+2PtjWR4BDpzPfFhTBDuM3xTSkKwI0JKc ATRjUEsOcxJM0GuKSIFTTTFOoMBwtTyQkh1DG454FApLChl59dCNVZ2YPLRa+n/poxbk fyVOYUAe/qKpSwMFbhjujIRXGRvcCRJ1mq7xQT0TNaw6KEWuPbJDRebTGp8YbcyihaHE BHOhLIRyY/wGwPh5LGET/jjEUPbnzp3npdRGxqs+xkcAFM7jek1ccPdkhP8woRs4/Pwc FVxA== 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=rU6AiPibH9nPjTI2YMHiF2ibJt+OjRoO+BIERVnAwAU=; b=Nl22Qystp/6egQfUnJqa00FbFXt+gaGoMOGc93sGRY7KJVgIUVsJHO6UoyMvbIu8QY Il7GtqSC3s3hmcj5Rbgu3KrPWNqwoKv3M71sQ+zP9bBgcwhemlKxNOoFadwk1Na3lMBH J2N/WJXfeBdUEhX4faiPYvbIvztoDyJWuGJ/UOCcft5ZYHqXUgTemPnU4VUXuGeNhs40 mppXFXsthUt6CoYFsP1x4IGyxqP/yeGVipS0oe+zXXXee+COAmLUK0dMeS6nc8b/WNWN NCDZ3max9UtzTOXMVLo0I3ViXJrOjWozDhS0T119VAKVS3nYZE/tKKUHhL5B/uTvv0SM Mmkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XBJoJxny; 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 d3-20020adfe843000000b0021028d58491sor10027472wrn.79.2022.06.07.02.48.27 for (Google Transport Security); Tue, 07 Jun 2022 02:48:27 -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:a5d:4572:0:b0:213:bb00:86e6 with SMTP id a18-20020a5d4572000000b00213bb0086e6mr21860193wrc.284.1654595307649; Tue, 07 Jun 2022 02:48:27 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-137-51.net.vodafone.it. [5.90.137.51]) by smtp.gmail.com with ESMTPSA id o4-20020a05600c510400b0039748be12dbsm23200547wms.47.2022.06.07.02.48.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:27 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , michael@amarulasolutions.com, 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: [RFC PATCH 09/13] can: slcan: send the close command to the adapter Date: Tue, 7 Jun 2022 11:47:48 +0200 Message-Id: <20220607094752.1029295-10-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220607094752.1029295-1-dario.binacchi@amarulasolutions.com> References: <20220607094752.1029295-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=XBJoJxny; 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, it sends the close command ("C\r") to the adapter. Signed-off-by: Dario Binacchi --- 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 f18097c62222..d63d270d21da 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -438,9 +438,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); }