Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp91991iog; Sun, 12 Jun 2022 20:05:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5eJRedMyenScCR73NzM0x9DdWZBxO/exUoxfA/raUQP1K8PV9OsUoatIx9zTjcyRnsaS1 X-Received: by 2002:a17:90b:46c6:b0:1e3:524c:7f94 with SMTP id jx6-20020a17090b46c600b001e3524c7f94mr13355897pjb.177.1655089508824; Sun, 12 Jun 2022 20:05:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655089508; cv=none; d=google.com; s=arc-20160816; b=ZhSUXJzW7G2CVm+Vr3IdRbSWtbevuAToHHU2ChEn2Dhj1Ze05YhES3dHCTdWeqw+KI 77ICJzrM03hYw9qCkIOnMoUKZMqw66Fj0A3rOOBagqbR5jzJXPbK11NwSeACoMeoZgzr Nr0tRC2MpPIhEhNPsHiLtDXdI6HCDUot8CMuQsKJufZZim+JFg1lUT+iLhOAPzvgBkMK GFTWBrdED8p2a1NE06hXPd/JwclXjzgC5CKIGayyouWgo9kMgUS7cnB27W9skasDFTvI hZsN9DUCjoWu4CsHVbreN8VYp95VbdEe+5JBJy2f+TOFCgSwvSlFjV+i+/QFMcjT4M3a ol1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O0zVHGTWOUK0yHY7/MxDgofJ+b/Xb1B9oJbEk1RTZ7Q=; b=NRHWcPCj6P8TRa0yaYXiRlGFm+KowDVSTw8Ywl0/CWLUrELL+Izo2UZ7nD8DYm1VR3 ZV7aSKK/YwiQ7dW6MOSpOT8l21oD/GaIHpGrM7qAPnAEj5tXk/wwoR8ITvqYj+V1qz3+ aLTDPR2f7c91JvnebFphieRluWiUfW/uBTkRMYyChtVQybqgqd4QCeSRnukJof6gaVgS Ux4/rUUtbeJ8TttHhQz8bDTkhZjSCRZvHs6lqr7ziHsfcxcy6OAST53XJpmfYVxrlhzg DCyqwDUDIjPoAsBtGP79/8qD68wfNi1PAEsFVTygSpzs8oHUfXs8CBPhAeh4Qfda/4j/ t69w== 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 linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m13-20020a056a00080d00b00518947dd9e9si8697188pfk.326.2022.06.12.20.04.56; Sun, 12 Jun 2022 20:05:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gKCrFNo3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237424AbiFLVlJ (ORCPT + 99 others); Sun, 12 Jun 2022 17:41:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237255AbiFLVko (ORCPT ); Sun, 12 Jun 2022 17:40:44 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2FDB1CFE6 for ; Sun, 12 Jun 2022 14:40:15 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id c2so4907379edf.5 for ; Sun, 12 Jun 2022 14:40:15 -0700 (PDT) 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:content-transfer-encoding; bh=O0zVHGTWOUK0yHY7/MxDgofJ+b/Xb1B9oJbEk1RTZ7Q=; b=gKCrFNo3kTznvykOJ58dS73QN8xWLbgkEjvPMu7P0GX3Qr6KU25fZIpnewqc0feaFJ B/QBHD8NmlFK9oUBiJNaAdLkrVrZ5pTPmPTZIJG7ctdmND4+VeeL6dCQzxOWbTZG+x2o niNarrRIk6rpP0LRhpdivQKYVVzl64mtTe5GQ= 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:content-transfer-encoding; bh=O0zVHGTWOUK0yHY7/MxDgofJ+b/Xb1B9oJbEk1RTZ7Q=; b=GSyGe2zD9ds5Fw0yucw++eUEEdR7/UCX9XImOFLISk9RqVnwnrG5Tv1NI2oX5iwdnC xIg0RmMuK0A2z/cbrWSsk1Fd+eS87is7EBZrwtwBXgGZUPHW5x576ngHb0Bs7rnDlLF4 nxVzf87Vi+B1JrUBUE8plz2BIaXW78+H3gvch+qnIHrwoC/gtKhNoEXCFAbrbitwiQUk sSbd9aGWOE7UPpyGcTTcRAtODNXNi/hpFD+XsB0xQ8I6okTg1VyXIhvY2WSgmYjknf1E 1Q7ou5K/TuDn90CRIVhxq66M9tmOvRbf8OvyBYM+I1GYHcRv64sdGdDI7qTk16KkqSw1 LCeA== X-Gm-Message-State: AOAM530S7ReJNWYwSqLtUaps0CBuLBKvZ3+EHQmrgCZLgJypSU/IQfOH hq6L73NkGUmq9R4l4JGYZ+8wL4UsWyMXGA== 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); } -- 2.32.0