From patchwork Thu Jun 2 16:04:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1994 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 5ABBD3F06D for ; Thu, 2 Jun 2022 18:04:49 +0200 (CEST) Received: by mail-ej1-f69.google.com with SMTP id s4-20020a170906500400b006feaccb3a0esf2703483ejj.11 for ; Thu, 02 Jun 2022 09:04:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185889; cv=pass; d=google.com; s=arc-20160816; b=jeA/PLvx43JPgneUZN3E7xxRzvPJGwTs20FfE1mkpsYJNiJtkSMuPp5m3Wa7Fb1Qh7 pMbEBGEYL2yi6SMo9mB5SQEOGOEUYBJ295L8aT9SjX1d3/pdrsmV2Q2i5aF1lvdhGI0f 5jn2lcS/pP+oPwO/OIXUEmqpsEArDwajAR37iV+zXmaETVGx5IUT+Z9APmmg2HKOW4jc tY/kC3ZwgqmZubjNBt475xEpsmeYFBh8EiyXi77uBKSYe/k0S+ppKPvUHB1n9qkIaiuQ NwdejRwtpJaATS3JNK1wT6NjFJIIGTIVUO7DEjbmAm0n04SocQW6Pqd7OBxLNFOf6vl8 /sqw== 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=197GNd0qp9LLY1t3IgOssH0+cFkf1vznoyXLSEgJLQg=; b=bercIct8/BoNTc0YzjAIoK3EEb7EJi567ECGKx+pbl862f7ILUk4bANKr3YE9Zljbs 7AVtgUaeTI30O31r9mnFi8lmy1vvY/0WmWUVb3ptM7qbuGoaPBjMCibDWynq1dr3kuD7 MNAJqbso1DzaKVKRARNxMz3WThURZtX0d4IHLvBzLcYVTPg6UqZPTgyRt/VhPK/+9sDi BsujVg8yeiGjedfBv5gv2STw9Zs8waixGF61brq/OSAolIc+MDZl7rZMb8wiTGZmAU+B w4kt33oCdwfCQelUwQdiguQxQuRLE5UZYfdLu2qZ3Ai+R1OuiEyqr1ucBe8ny+X6GdEU KjWA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gHAVUrp3; 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=197GNd0qp9LLY1t3IgOssH0+cFkf1vznoyXLSEgJLQg=; b=MchqNf3xU33kmPAJO0RjnZpX7j4Pym+l9c07TCTP9d2nTo2YrpEXax+H4lH7yPSdDe x3s9UCZkckrbizjr9dX6vqb1qv7jvbDAuLoNy9gNei7hkwHe0aMTPwgu1FkuZdldNt2E J4fnJkuzrj1+pMpRBRWi4/zpC60dhqPLU+PpQ= 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=197GNd0qp9LLY1t3IgOssH0+cFkf1vznoyXLSEgJLQg=; b=gkEFWOLe57urJhD1TA6skF2gp1q4njJkrAY1sUQc0weTx5RgdJPL+fW2V/LbWx/fqs CvytIAjgV8Y82ZU1qnk6s4ObrxN6iY0LhsoAHpWg1gvoYMIduQkNo7fZ1xF70E7e/K7J kTPg3toTCgVkJbvU2ItGENRGs11YmpKRS6tIwmKOil5PKeoo7g5zmb3JGn/o3CP40eAc 3VNlNiaUV1qt0sntEZ/MeBx4ypn9NcYcR3/VHKzl6ic5SiVrid0vmapN1tSew7sAXnC/ 9ZMBFJCz+NT/hqoTaysqmvi+h8tkod+a0FSuUznzJ5NRmRmoMyY+Y/chDehZz5duy2pu M/2A== X-Gm-Message-State: AOAM532fOcDSNJiNpOrtTDEO2uq9hL/PVg5B4SNTTqxk9C7mofaCrZyL PQ286lrdkeZBPL5fQVR9n4tBp4Jm X-Google-Smtp-Source: ABdhPJxv8zcpawGSWN2bUr4iTxut3B/MOfCWyoBEKjqoA3cp4u1lxXdLq0nXiwQAKUlqZhneo6Qv4w== X-Received: by 2002:a05:6402:a41:b0:42b:e6ed:4170 with SMTP id bt1-20020a0564020a4100b0042be6ed4170mr6424205edb.344.1654185889227; Thu, 02 Jun 2022 09:04:49 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:95c1:b0:6ff:45d:c05d with SMTP id n1-20020a17090695c100b006ff045dc05dls2947711ejy.5.gmail; Thu, 02 Jun 2022 09:04:48 -0700 (PDT) X-Received: by 2002:a17:906:9b8f:b0:6ff:f3c:814d with SMTP id dd15-20020a1709069b8f00b006ff0f3c814dmr5078636ejc.381.1654185888063; Thu, 02 Jun 2022 09:04:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185888; cv=none; d=google.com; s=arc-20160816; b=g9fkoDxLzzpmuRLa4Kp4J/Aq6VDF7zEj0P8BEy4BbVroCMNXWAmlWMHy2bv0UvS8Ta oPf3RpyDFzcIjaKdO1h+39Ny/nzaq+mny7ll9rJuzM63dfoGe/vfXLd92qnAQ6EgweXb AZbTnR8XiFgEVzg+SpifpchIjDm05WvV349B2f0rEDNTcFIBj4Sxit3G2r90+teqiD5W 1U3FzJ1iW2aFG/Ogeti7tnZbc65i6f/+laZmgnC8huI/D66HmUHYCZ4Qpl6VyElaIrNx iNIOvS8WxLCIBnO0g/3qGGyG+Our+XMto1e0FTn2vS3GyPhqHstUQXXB2frfWe9pgBeB n5GQ== 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=RNI67WCvYDO9rjR6HszZMqDV7pcL71fog+WYkiNXWaI=; b=GCQ2CpCQqm+M6m1wUG9X8e30jgX+/sLOvyDWnm9GQe7bU2RzzzfKKTHNbL9KR4ncTD 2K2F60gZrDsP0IAHck5xXdqjr9yZpEksQ8O1Gua1mwbuw2MMm3nexSyOqN0zBZ/FsyAL pf/U040Siny48xKHAncHbNtyc5nyx2QUpL8suhVzU3xFybIv9dKTKyNrb6jSH/FoGBEC RewmmVGwOXVjpzozJQMIY3NU/7UovS44dk2KAQgW67E3F69ePPWLn8TREXSqa1zl6b4j WJsw/GqnBo/acmVgHx+8whDgYFO+HheDpGAI7tVaqsZ3oq6cIRhYSDl09FW/WM7Js3xu 0iSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gHAVUrp3; 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 a20-20020a1709064a5400b006fed02b16bdsor2522186ejv.36.2022.06.02.09.04.48 for (Google Transport Security); Thu, 02 Jun 2022 09:04:48 -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:7ea7:b0:6fe:fce4:e802 with SMTP id qb39-20020a1709077ea700b006fefce4e802mr4827382ejc.47.1654185887473; Thu, 02 Jun 2022 09:04:47 -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 f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:47 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 09/13] can: slcan: send the close command to the adapter Date: Thu, 2 Jun 2022 18:04:30 +0200 Message-Id: <20220602160434.225417-10-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-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=gHAVUrp3; 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 --- (no changes since v1) 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); }