From patchwork Wed Jun 8 16:51:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2036 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 01B823F1F7 for ; Wed, 8 Jun 2022 18:51:38 +0200 (CEST) Received: by mail-ej1-f69.google.com with SMTP id l2-20020a170906078200b006fed42bfeacsf9690124ejc.16 for ; Wed, 08 Jun 2022 09:51:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654707097; cv=pass; d=google.com; s=arc-20160816; b=mkc1l3WZ2FKgOTzZOa8t+ZBLUaoQ9ZAKLOJ+dU5yohXvGyu6eFURe6dkrjrJuhJTfr Vg82HAR/DdVf4/QGoSREGU+DKwmrpagnZc+qGnHSTbLP27FTvqN5MgDFC74ODkPV/NmX hH6OHDT3qOY/D01jS3zC9JAsjvPkB/aWgHUT9e4bBgnVS/UT6VKcbZmUzVON8+xe7qSf 0LRGdTnOnOEuqcJVfp6P7f+S/l0zPnXmOZpTMt+DlopKP4+N6hXxRXvV8Hos+6TxAalE N1ai3bkW1kibvVK0tA/pIRHzeFpf/H7CFBM3EnEbER98HS+ELpn/bzMMDE2qdbBMBM4g 1OFg== 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=NZckKQgRWBj2aLv1TdJHYF16HYCrqmTfZBzE04G/H2s=; b=Ouqx1cCyFXqIUqQf645SytGWC3nommNiv1KOO273W82EPZaypGSvkPrC6oX4zsw2I8 ShI8NESHnspfvOJNuUbjSvNqSCl00CRoRlkRn/XwmnlVk6Zqe6sgP4ecafQwIqadwljv 3BiaVvhIXO8euFfiNX9hSaQTE/Akv6s7vvcb4GEIe8Rx8Yex3NN6ZydHeziggMf7sHC/ PBExNxUeQiu41QWxEtgHSJOFl6tb5PRaeSmhKGrlgLvl8Gy4Et/KZrK0ZHf7e1AzrgAv y2igcLyBn+fCRZhSwpuQP3VyLymaMW1d8pu0l6dbpXKjcwwa1ypZd4zGW0KC79gLh5hz aUfQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="nl01/m/i"; 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=NZckKQgRWBj2aLv1TdJHYF16HYCrqmTfZBzE04G/H2s=; b=TN8B/aUfeOPawj/CsUVXW5kKHb1cdQoCIMXIikhPgMrbj99MG4AbvTxB6OTxui8+Gv QTX13kSD9HorBVnCGJsO/ZjO4wqNlVtuzyTkZ29inxGW06BUf8pDQnZzhqxotdgzkRho j69zYrymkEB3k9KRaCreC9YFYRdQzOOzzKOiw= 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=NZckKQgRWBj2aLv1TdJHYF16HYCrqmTfZBzE04G/H2s=; b=OIUl+fXYzLB/Re/2cXQ3/cF7lRNoLwYKYzsgMqmbEbKXK8FiWu6ze1PDW8Xy5wO/Sx vW7B+8QEzMKJCrgg9UwsNQb4drQI13AhY7a1lBpvprg4IQ7eNSm/+ML4CsQ8gaIfEMNv 1UU2xfk1WVfDQ84gNW+gH8ReHFMnxwtXYHNF59hR1K/0esmYokPBqev1khYwjYZEqx7W WVlCmmQS6/0aaH4h1tyWgefaRYFGBKlLcXJ7t5GtKvkJOQOn4jo+9ybcAwsPFJk5m/kM jopMBfqseSqPktPRDJyZ0DqK/4EwoaYAXgToAyzX5LyDmS/KEHeH6bsG6MaHooFuqHa8 1mZw== X-Gm-Message-State: AOAM530zLEn2WvrRbBPb9Q3D9etPbOgNRtBQMukEA1Jsr7pvaAAOCPU0 i4uSRm9RkkhO3k8S6KGQqCm5mJwr X-Google-Smtp-Source: ABdhPJwFUySkoaKDeVVlVovy0G0wJCHdgesDIShuR1NcTo83yon3NE7c41dEA5RykpZykefkXKfmvw== X-Received: by 2002:a05:6402:1e92:b0:42d:dc34:e233 with SMTP id f18-20020a0564021e9200b0042ddc34e233mr40738028edf.386.1654707097795; Wed, 08 Jun 2022 09:51:37 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:2741:b0:41f:7eee:e393 with SMTP id z1-20020a056402274100b0041f7eeee393ls189042edd.3.gmail; Wed, 08 Jun 2022 09:51:36 -0700 (PDT) X-Received: by 2002:aa7:c4d4:0:b0:42d:ed8b:3dd with SMTP id p20-20020aa7c4d4000000b0042ded8b03ddmr39483744edr.322.1654707096725; Wed, 08 Jun 2022 09:51:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654707096; cv=none; d=google.com; s=arc-20160816; b=e+ceepWg0mdB5MIAYuu5LRxV6MoOYwNgOhqly5ONqOX3T5h7E7uWt0C68GDfVCEIPu nP0YDv3Pa34DTzmWUx3XKL8+4HYm2tCo4Ispo/7BQ+C31z5DpN6R5SukGaYPvCjsioDn 3dSKtikouJaVxBHNSj2qkeNkW/HvolFioK+p3WfYjiabfXRNiGg6k4HQhXbhFf21oz8n 0kU37ZUmxuWCEONgBLYM8zBB6C7cXUpf+WdYK+++/11dTJ0lmmg85dkgcC9qLtiI1D5i H9nsD2x+WEz679jE9RYjzGIgmc5EV1mBpD99itPer/CsDFzjm/fA73KL7d1KaHxCmxxO zC4Q== 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=1tzR7s1CZMuNvxGPj/IhGD4aqO3yLek4cvJPPvYidL8=; b=lVNQNDalkTb8yeeOg2Jk1zgoGeqqFWhXe9o51vjM004gHsddeGGmNRXSGLecBVdY89 IMkgjVcx1WgKmN9v0foqxJXbLXfEW5YGtBX99TgHbz+Vv8JfdcapRAN1HYmZJYyF7X47 gMY16wvc2ILCXL8wpws/KZqajESECgt6zijOF9qAmOwZqpTrZ1qXSf7iD7khxO4VnyP8 ZQ4TAwkrI3d03Sm1HBa0u8py3mX687ygKjKh+jdR3o/YgK32Rzpe7czPgKwEQVkSCoyl jEqEauK4XXC3n+7GZVoshafU5+unKDJWTxtGLKgAsXsRRlQ69EXMLXe74X2UXjRPZSjA TBjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="nl01/m/i"; 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 f1-20020a1709067f8100b007062189d85dsor9632847ejr.79.2022.06.08.09.51.36 for (Google Transport Security); Wed, 08 Jun 2022 09:51:36 -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:906:79ca:b0:705:111f:12dc with SMTP id m10-20020a17090679ca00b00705111f12dcmr32096475ejo.602.1654707096469; Wed, 08 Jun 2022 09:51:36 -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 c22-20020a17090654d600b0070587f81bcfsm9569071ejp.19.2022.06.08.09.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:51:36 -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: [PATCH v2 09/13] can: slcan: send the close command to the adapter Date: Wed, 8 Jun 2022 18:51:12 +0200 Message-Id: <20220608165116.1575390-10-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220608165116.1575390-1-dario.binacchi@amarulasolutions.com> References: <20220608165116.1575390-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="nl01/m/i"; 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 --- 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 ec682715ce99..0722e7820564 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -430,9 +430,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); }