From patchwork Tue Jun 7 09:47:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2014 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id DFA483F08A for ; Tue, 7 Jun 2022 11:48:12 +0200 (CEST) Received: by mail-wm1-f70.google.com with SMTP id m22-20020a7bcb96000000b0039c4f6ade4dsf941184wmi.8 for ; Tue, 07 Jun 2022 02:48:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595292; cv=pass; d=google.com; s=arc-20160816; b=qQjR0qMGt2c1+fasRuHYdNRldOVjmeKTcmftJlBYHQBeCRDWiBIEDy0/E20V7PrOd7 zaQWoYYPgxGvc5T7WgQGlozdUVgKsgQLS5v7M97//L+ZHn5ah+m/Srsar4wVvtRr9A7L Dzv7oioyXmVTdhA3gLlVZbZT/fXwgCw3sLQB6Ji5oPAW4c5YZutapS7wM14rwSS1PPjW 4/IM9OH2FMnps6I1n+4W2l5TEYn4fMelKI35K0odUASdKSlwtAHzyaYUC0fHBg2zGfkc KkyP0sq4fwu0erKtRlWzMTz4OcBbzqy4sjhDY6X3yTH0POeCK6DajgyUj+unrU35qCCy fCrg== 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=gOthReazouRdDqARs5P7AckfZSnohql48BVuvI/qJ6k=; b=jiFKLO/4juuQ/juF+o5MTGTvH28w7yamIVbg5WrlmJFlV16GVi4OcGYo/ErysQl75T nCoGwNBIE2UjM5DkVCPymaKuBj/Et4ZClBXWGOdXAhPGJxFjI6xDVuIf2ZskxEVjwIND uHDYGBdvWaQWah3mvsIBhke1RoZSYMWsDakeDyRPqmSV0/G/ZKk2roXhqX0PqV/JM2oF GD331VoHrRQ4NQjMQsNc9GS+dwIfWcjvBsheDT6WOMqJBkd57VWoaJ1WruKGiYyIoRm+ D5AlZBFaWubGF3MemtiA0Au0UuzIh7yHTBTZMxDWBfiZY99eR7H7/Nx7JrzU6enqYCn1 XRSA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WsqvRqj2; 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=gOthReazouRdDqARs5P7AckfZSnohql48BVuvI/qJ6k=; b=XiyEczHsgcqwPo9KuZis9EuD5ZsYUjn70vcduWuLhF2Bik6m4sGdyfcWRgBmGVuTQ5 suspm2mcGqeLZoLIWO4xHAkCWTK2bzcf9SR/DxsLz/uJ6qTQDOquG7OgS1L3Irrw6wAU AY1rJcz0ZVB6X/+wiygUJdNTTHpB2EWB7eAAc= 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=gOthReazouRdDqARs5P7AckfZSnohql48BVuvI/qJ6k=; b=ntOoMDJ75o9iqczhsvsOi4KZlvoznKrhxG9RJmuhRvf3NmZYbFu02Kibe2N0VCBRQQ F9FNWF1bqb2zk1+hCHTKO7v2xwQkIFgSZ1geot4Mlk4J2TPzIDeujngmLID5PtqUcRmM fNMHPSM+B1vfPwznxblt6Sh7HTon+C/d1QuvDswGcbeKm3u4gKJtSF+DQmdlOmxsxvoX UnoKql+nMY2bJCj2qq9Ok87pgVIUDcuyLvO7pqpOonGe1VSFeULejLiXnfGDyRJhhj9w fC8z1XTBEW/I14GxeL1I1M1fP5NfuOnXC1N6TurTtlfgmYMtSjdG7kqveNwtbEQyn71v puFw== X-Gm-Message-State: AOAM531wcq4NAQy8vlVI5d2yNPsavRgFXybPNwsi0t68rG96BbM4pGbo Bgn20j5nhpxFznAQEwcF2XP32MRY X-Google-Smtp-Source: ABdhPJxQiumBBfHNZnGEIKzkFTh7VmFAf3ab4zpi/84sakjfNEZRTCyH9eZG1RaI+xh9SJrvlz3R9A== X-Received: by 2002:a7b:cc13:0:b0:38e:67e3:db47 with SMTP id f19-20020a7bcc13000000b0038e67e3db47mr57688809wmh.133.1654595292692; Tue, 07 Jun 2022 02:48:12 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:6dab:0:b0:212:d9db:a98 with SMTP id u11-20020a5d6dab000000b00212d9db0a98ls4152719wrs.3.gmail; Tue, 07 Jun 2022 02:48:11 -0700 (PDT) X-Received: by 2002:a5d:4d05:0:b0:218:4d71:5d8 with SMTP id z5-20020a5d4d05000000b002184d7105d8mr3680831wrt.518.1654595291636; Tue, 07 Jun 2022 02:48:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595291; cv=none; d=google.com; s=arc-20160816; b=YyXAlhvOsl9o9ZFmPYaJ6HIhegXwbh9xPog32bxRGPhAyJCW4SfV9tNNwUhUpAZKqs 6nIBRDov8+qawKCvT+geXisu3GqJ6jLV/NY1zPmA4Vpiv/opBQtZS/uIlomq0CSfdwft +vFk86TK5vMnzS4YCyxpthBWfC7f5rP0Gvk48OmWZ11mswDVAtg2o07eqHxVQMeSwrB5 068R5PlniuBhBfj7XMXOBYRJE/pV0qqyZQeVAGtpCUg3dbusW+5UmruKzhFdxgAD/IZJ azWBsxseEgJMLbMVakSoBbS5HVnwu4TP/437KlBfX0y7+OQ2WXXVztvHqj8UZvjgF9I7 pPRg== 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=CBY26428AsgO42bUNkI3Xmu9+XGt4S7I1D7qDZJnCuY=; b=L3vnW0WiI3cPae3OJcy0FpvYE/SLb0L5E/V9Y2IJlSefdUeFFWjAYyeYKzqQVLnLyF q4wIfs0gAHfUx3tUPuRwhGeL798WkukmlG58nZIN7A2iBfjEmYuc5b5v4QtF3Iopj3mb dfFQCB8EiQFL8i+6i7m9HeHSXZgeahKhw6gKVB/ddfiimwp0iCXPrz5sSRgDz/guI42l BQAdSm/gSnHBi3M8SjK1hqS2j3OwCS30PnCeVuyeHllvgw4VSjyJB7GKMPb3CbAK9mXp zEwKMB1h2h2/AKcClgTBcs09v+Bo/27cc7Jbb6264zKYMllSu2+j37e0GUoH2+eah/Jc wn+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WsqvRqj2; 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 r9-20020a05600c424900b0039489e1bbe7sor5419941wmm.15.2022.06.07.02.48.11 for (Google Transport Security); Tue, 07 Jun 2022 02:48:11 -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:600c:3caa:b0:394:8fb8:716 with SMTP id bg42-20020a05600c3caa00b003948fb80716mr56163311wmb.105.1654595291462; Tue, 07 Jun 2022 02:48:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:11 -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 01/13] can: slcan: use the BIT() helper Date: Tue, 7 Jun 2022 11:47:40 +0200 Message-Id: <20220607094752.1029295-2-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=WsqvRqj2; 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: , Use the BIT() helper instead of an explicit shift. Signed-off-by: Dario Binacchi --- drivers/net/can/slcan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index 64a3aee8a7da..b37d35c2a23a 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -413,7 +413,7 @@ static int slc_open(struct net_device *dev) if (sl->tty == NULL) return -ENODEV; - sl->flags &= (1 << SLF_INUSE); + sl->flags &= BIT(SLF_INUSE); netif_start_queue(dev); return 0; } From patchwork Tue Jun 7 09:47:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2015 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id E7D2C3F08A for ; Tue, 7 Jun 2022 11:48:14 +0200 (CEST) Received: by mail-wr1-f71.google.com with SMTP id v4-20020adfebc4000000b002102c69be5esf3691661wrn.13 for ; Tue, 07 Jun 2022 02:48:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595294; cv=pass; d=google.com; s=arc-20160816; b=xnZijO+ep4YJrrrewHuWeN6CymIgtOIX6ZrAYXr7Dlzn5zPe1iuC3zReZhlKYyJ1/f yCPIk8VS9RGMFkHKSCOPeAKOr2KSsjJnFc4nXfYEwcOkiR2OGXzBbTx+/PfHgmaJe66T fG5rrLYAAgggbnTcPkQt5gAfGi3sZXDdyWoGdYbflG6bm5jUZarYMu6zzqgDnJYVGefl YKKNFQbyzpOyVsidC0V3i0+4YTwRIEW7NOfp6LC6wnYy7l5nXmGMCBliCuuWAMoVXLGm WNfwVc4+0VSMkmRE1LqD9HQXPbYLu6/V6/Pzp3rLZGpnfp0W/VfkZUt5H+9LxOo46OEf ESLw== 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=bjM6n5NUa9GCkY3tUTiK80yagFMtam1vcXQHsdwWxKE=; b=BxVyxRNzmRjjVsBBFzKGTkr0xnEtEf9ZYwavRLiMVpW8ybQkor7w0RQn1eGQVS7dku RT9thFuPiJltsMPHMPi7TcaRPcezBjsFB1XUhuL35w6yOYqLa1ySxzx+dwDoBhgq8cUJ whYeUuJk63NGZ4q19H/3BpFCzeJhb0BT6/p6IWse5jIkdRKtNsFBg5Gh3k22OwY4mhlz JoQYeIGdmlHygdESQZXJPgBbPGtIo7p4FKzZhS0hE/wPebtcthp5cZ7HH5280Pnfoa4Y p+XPNohwQwQIgOMZ/rx1jsDf2JC4XptSZoRNb0WFDOTWmAPc4iqYZl3SfIAsbA73dGmH B2CQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=aSj7vDU7; 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=bjM6n5NUa9GCkY3tUTiK80yagFMtam1vcXQHsdwWxKE=; b=EaJTmEOfcGuUd9RchaZgL3jyDxvXX53oAxm0CNaqHB/RvbuzzndKD43ilJncZ2koLk WqqyVj7T+MizOGlHLzPq5Zsl2wwybi4g/sEZJ4652a21lr6hjFfDiBq8NSKbow1qPvI8 HFtauNX/or7mG1Br2DW/TH4XhizXDL4/bi5lM= 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=bjM6n5NUa9GCkY3tUTiK80yagFMtam1vcXQHsdwWxKE=; b=pw1RqmtkFAbff5Bk0Z5RDhhVMeYpxV610VhH2Hw8i8rDiNrpT0b6bmVOv5DTQkSQB1 R9JaugbpiENSj3AtHTprjaJhLQMe7NU8XiDSO7rRxCip5gAk8j9TyXCbYbcRwd+bxQh2 Gvgb8R+dovx8GfXOAxXBm7BOI1o1s3ohZIKmC8lJ1A8h9wU4C5GyL8CedY0vuig6/HKR 1rcKPIog2PXWoij3ZBkLDefrsHdfzjPdhsU+4NqH2oFX8ZW38MJiSVQwWLt92V5fQG9B MJww+z1fW3JpRgDS/Bhiw4Q/Ogzo8rJLOyhhOVbfGrNkVMGuoIa6QiL9MabE5jQiM8kk h6XQ== X-Gm-Message-State: AOAM532d+XiYHgVzDz9hwC/gv72x96Gscf8rEBxTm8ZSut16h3QpzEHO 5kUc1Sfwnkdp4DJP0Ax+FQ2Eof9s X-Google-Smtp-Source: ABdhPJwbbOGDE5AvhqN7XTITwu9YDR046O+n/uifZaX8IA97IIv6cR6Vju5gbmwYu1D2VdsbPohrng== X-Received: by 2002:a5d:47a1:0:b0:218:423a:de8f with SMTP id 1-20020a5d47a1000000b00218423ade8fmr8445612wrb.420.1654595294544; Tue, 07 Jun 2022 02:48:14 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:59ab:0:b0:214:1ae1:5d70 with SMTP id p11-20020a5d59ab000000b002141ae15d70ls4149112wrr.2.gmail; Tue, 07 Jun 2022 02:48:13 -0700 (PDT) X-Received: by 2002:a5d:6dd1:0:b0:210:7a1:cda0 with SMTP id d17-20020a5d6dd1000000b0021007a1cda0mr26649259wrz.570.1654595293455; Tue, 07 Jun 2022 02:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595293; cv=none; d=google.com; s=arc-20160816; b=qsHjrejCq8lDIewjKjOrCMN0Oh/87vtKWj8fB/Oy/OzEoxsFQ7QRW1wvpS6rAySjYx vkQVklS4bjQ7Zv5+YgqPlH2AizNp0IODEA1YLuCtGxCe2vBkWh2xIaRYeW+kSBp48Jjo BCJHvT3UBc6m0rnCdUcEQfniuJxp6a9cb49soOkt9VPsHqBktFChOOZxOdlLnZ8tzNWC pax++griW5eBcUShkOVePKbrYO1wAd/p0xNYzGXlsyEOcR5+aFhPeGnTjA6+BKmj3vRP EOkSDYRtMFVtzp6CxDMlYWnSEmN3GjvzNeeEBXmLRyfvN5CmlY54U2ri4puwaoNjQZj3 eYEQ== 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=tNUOqb45O/Ilv1mJP0lwEr7O4bll5ez6OZhdGeCnOYk=; b=q7meAI6PgdQL9laHx87kcpoyiPbw1kxxsYSEV7LuwT9qyOTxNAGAdpSHIlD8hERKq+ bYqDukICzQVo5iEE76xZbGk3MCIYHjNtxN9AE/6quitRuVmNRzMiyeltZNT00xLNFoup kPUT3rP2f+5RuX9hhOyfOgaFWBysQNWsYZPslS8sGeAZxS1yo8FhgvQlGSUMjgudxiTW cN2fgawRgjjuZZej082CJaNF5qFFTrr34/dAi2Eis1lpg1QjK6QgFAV+T+Fw5pB2czfX 6Eq5BIVu4+dNm80z0mLjs5autIYyOZ2xLxr/sPXqy2SuOvrDcyB9HvGb/4oKBt0U2lhO wDCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=aSj7vDU7; 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 j4-20020adff544000000b00217fa88a7besor3264316wrp.62.2022.06.07.02.48.13 for (Google Transport Security); Tue, 07 Jun 2022 02:48:13 -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:6000:1acc:b0:20f:e35e:450 with SMTP id i12-20020a0560001acc00b0020fe35e0450mr25899806wry.531.1654595293242; Tue, 07 Jun 2022 02:48:13 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:12 -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 02/13] can: slcan: use netdev helpers to print out messages Date: Tue, 7 Jun 2022 11:47:41 +0200 Message-Id: <20220607094752.1029295-3-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=aSj7vDU7; 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: , Replace printk() calls with corresponding netdev helpers. Signed-off-by: Dario Binacchi --- drivers/net/can/slcan.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index b37d35c2a23a..6162a9c21672 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -365,7 +365,7 @@ static netdev_tx_t slc_xmit(struct sk_buff *skb, struct net_device *dev) spin_lock(&sl->lock); if (!netif_running(dev)) { spin_unlock(&sl->lock); - printk(KERN_WARNING "%s: xmit: iface is down\n", dev->name); + netdev_warn(dev, "xmit: iface is down\n"); goto out; } if (sl->tty == NULL) { @@ -776,8 +776,7 @@ static void __exit slcan_exit(void) sl = netdev_priv(dev); if (sl->tty) { - printk(KERN_ERR "%s: tty discipline still running\n", - dev->name); + netdev_err(dev, "tty discipline still running\n"); } unregister_netdev(dev); From patchwork Tue Jun 7 09:47:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2016 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 293473F08A for ; Tue, 7 Jun 2022 11:48:17 +0200 (CEST) Received: by mail-wm1-f69.google.com with SMTP id j31-20020a05600c1c1f00b0039c481c4664sf1483091wms.7 for ; Tue, 07 Jun 2022 02:48:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595297; cv=pass; d=google.com; s=arc-20160816; b=jHkhT+QBRe7WTyUEMygp910noMeP/AWCdNWo0dl+EY8ZqQeIHrKjURndGPAghmv/Fe t2hf3afnFLl1TZcvHHFtwOowCtCQjp81quvz6gfMX0FdMzY+1igVwi5yHfclJKnvnktZ ZI2Ae/0ZT1k8vk+bNouWPQE6FNYrAt15ghcjMm1AWxlTHDyhyBDUaZnTu+Aw/L5wqjvA kh6vul95NmIopk6zM/jqdFwMaToe4i8penDUryBOV/9MkUz6qU3qTnYFXV4hC08jVwYB gkLHykst0jTxvlJSAVw/fM5+56TLjUx8ISe1pmyiKa/hLD/TGTXBc+xFqUeD1RIh0oxw mLSQ== 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=XHA7f4LCtbrNkNnN4dtjW5H/4bu5CeCPdCr7gwLpDxc=; b=cM3EoPcNczRKFI/RB5HQ6sbWaeGFw9W9iraxi6l2FDQyR5rd7Bc6nEKyQDNaEurRMM D+oDJgM0WOviCcSRJ2GXxcuPZJedrgiz/QG2Kp1b7yWWh0RU9YzHyBepeSYUUNdM2NJA OvRH+v6JaMYmJqSQQIciilM2rIHWhmVLr1XE688JyzjyZj4YN53kRlJDIeeesZbNvLT3 8arkb4nZRZUMnV9EukuDJhzozEmFSbQO4k2h/0APpWHOQ8GSIiFz4MdXu3dJrSnQDbPx dV+j449q/GdlnDyR4M5J7oBJ5cNMneAw2d/TD5w6cx4YDMJgfbOYiia3bUWIhzoJiNpV NkNA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fD6TXB5k; 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=XHA7f4LCtbrNkNnN4dtjW5H/4bu5CeCPdCr7gwLpDxc=; b=QOVi/BMuXakOX3QLbMKqrwuLMigS6GYqJFbm9X/Pk23gWR80TSWV93cQvARUlQGou0 NGsAQ/BOCGMihaLjirR3alOxNIjb98cntaUAcoQZf9un7OLovL2Z1oYsgcYgHrcnAxQE ABHEU6msarIrd71dw8WbQNl5zB/LWEugLjB8o= 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=XHA7f4LCtbrNkNnN4dtjW5H/4bu5CeCPdCr7gwLpDxc=; b=RCGIf5UTvR3JfWRFsqFEWge4CTFg8maOt8gPA4bQGdQnWq8Ds8L4mbWP6KkjQXrR1t ns9b26wGWVzrK73O49VggLOPLjXPUcbOqJEPjrDq7RzwbJwLk5c0dX74bBLjdAkhLFuZ LzTdI9aD2+LGZAWdHgL6hcCPX724Ri1oiSXbJv75tkpotCFuYQj+yZgrOb9DRFVEQuSU ItiFjBYssg6swxHBmUUwT2A2kf3TJejM1fm3HDx+zzNgFAKILZos+I+5vKaU7llsrHlT qQ0qSIhAW6dRcVoAq4TTRorojka8l2OCZabeeZ/BONBHSNo9nqeO0fktToNki3FGzWNL Nmtw== X-Gm-Message-State: AOAM530au/5Il/IFLNNNAqhIkzsk1tz1WIY9GXDcLQpSG94LaAGAO3Fz 6f5p8/mIIA0biflqlwjKEL8l3kwo X-Google-Smtp-Source: ABdhPJzPVXN54yTfE1dgZ60beJRcDv/XotC3s9ojblfLMTaHOXDqXh6KaOTNL1jW0u4SwgeLfjQS7A== X-Received: by 2002:a5d:6386:0:b0:213:b939:8272 with SMTP id p6-20020a5d6386000000b00213b9398272mr22709649wru.396.1654595296763; Tue, 07 Jun 2022 02:48:16 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6000:144a:b0:20f:f1e7:c71c with SMTP id v10-20020a056000144a00b0020ff1e7c71cls4152110wrx.0.gmail; Tue, 07 Jun 2022 02:48:15 -0700 (PDT) X-Received: by 2002:adf:e30f:0:b0:210:346e:d5da with SMTP id b15-20020adfe30f000000b00210346ed5damr25983444wrj.313.1654595295616; Tue, 07 Jun 2022 02:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595295; cv=none; d=google.com; s=arc-20160816; b=r6hRMZvLNYTCgbifXLerD59N95th6YeUDMLl4rkrwqpIzIMWn4NdlbvCz+dgQ5/G3x P995FS6Cc0DRZRp+U81ytiT3PDHBKJcPYENS7oKAKy3zQBoAHFle8hgrQMFrGN18vxQ/ AhqdOxYDnh5igXGY9g1MktAU7b7ftitzD4xO6GLTlYVCgw/CQmop0G4R/MbceHujFTys 1v/H/sYA11x+U+CcCF1tDgNBsGEoYKqm4k9Ejfi8DRR1ZyVyWwNtbKI9Au3geFPl8+sk g2KKhh5/bJqjy8uGjPaf393tIz6tM1pZfJd966uVEoEuHdHwBIaQbjuQ/t+y2yVhsloy 8rZw== 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=ReHEa9nvpM4WWSAEnsEWGM+1xrVLxiybh/+LZPFyWR0=; b=sUJ0tRQWSduJELlJRA9K11YmScxKKBi32SZsNsXPpKg7c1PSYiqkuiYrEs+LWZSTgl U9gj7llsufcX3/rKF/r2Oh4CIguBUtxxDZyb68pVTUXmVEShwBUUEVlckYCbl2k3qkoM RxNNg9P551himkIcOAJSPKk27EYq1AOOr3gBslqFfdrcW0V/GNw00BVB0gENVcXPjjjS AbhFRHd4NvGQmUqgCXphx/GYRh/TNGobqDi9Xbti4dWmHDXujxmG6VkkCzdbZJ1NSPM5 s9nyrMa6TtmaxWQetPKiH9Wa7k4Z4yof52ydkQAmu8Ut9+B+F38IK/bXkyewruni5ZR/ s2fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fD6TXB5k; 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 t16-20020a05600c2f9000b00389ec8cb433sor6716640wmn.44.2022.06.07.02.48.15 for (Google Transport Security); Tue, 07 Jun 2022 02:48:15 -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:600c:1f0e:b0:397:707f:5a60 with SMTP id bd14-20020a05600c1f0e00b00397707f5a60mr27183939wmb.3.1654595295377; Tue, 07 Jun 2022 02:48:15 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:14 -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 03/13] can: slcan: use the alloc_can_skb() helper Date: Tue, 7 Jun 2022 11:47:42 +0200 Message-Id: <20220607094752.1029295-4-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=fD6TXB5k; 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: , It is used successfully by most (if not all) CAN device drivers. It allows to remove replicated code. Signed-off-by: Dario Binacchi --- drivers/net/can/slcan.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index 6162a9c21672..964b02f321ab 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -143,7 +144,7 @@ static struct net_device **slcan_devs; static void slc_bump(struct slcan *sl) { struct sk_buff *skb; - struct can_frame cf; + struct can_frame cf, *scf; int i, tmp; u32 tmpid; char *cmd = sl->rbuff; @@ -201,21 +202,11 @@ static void slc_bump(struct slcan *sl) } } - skb = dev_alloc_skb(sizeof(struct can_frame) + - sizeof(struct can_skb_priv)); - if (!skb) + skb = alloc_can_skb(sl->dev, &scf); + if (unlikely(!skb)) return; - skb->dev = sl->dev; - skb->protocol = htons(ETH_P_CAN); - skb->pkt_type = PACKET_BROADCAST; - skb->ip_summed = CHECKSUM_UNNECESSARY; - - can_skb_reserve(skb); - can_skb_prv(skb)->ifindex = sl->dev->ifindex; - can_skb_prv(skb)->skbcnt = 0; - - skb_put_data(skb, &cf, sizeof(struct can_frame)); + memcpy(scf, &cf, sizeof(*scf)); sl->dev->stats.rx_packets++; if (!(cf.can_id & CAN_RTR_FLAG)) From patchwork Tue Jun 7 09:47:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2017 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 DF77E3F08A for ; Tue, 7 Jun 2022 11:48:18 +0200 (CEST) Received: by mail-wm1-f69.google.com with SMTP id bi22-20020a05600c3d9600b0039c4144992csf4791030wmb.5 for ; Tue, 07 Jun 2022 02:48:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595298; cv=pass; d=google.com; s=arc-20160816; b=bRGAXBeLXOd8jic8cqmWEu7r6AimDMEdP9gmFvFEio/Rl5fPThga4XmpIe3fohSJ8Z gIwYT2gtrQIPv/90vUTWNpP3+RbifZP295gmMnoLNPayniIvTRWAsj1Io/OtZEcrF5qI 0d8WS/ikpJU1nFRbgA5Dcns3ZBgeQA2VRD+YD9Gy9oYfMP6LamhnaKRAj7Fav9GHdNob /U6haZUsRN3d06jD2Kc17I+/tyn22lrcP6o12u+YJBBCi0vG1uULA8vY61aFHEUU2ZSV mWH9p20HXT9GiYohTN1j9dE5KFfhvZ7FBd4bb6FbrCsolY6OpbN4COprAr58oeBuWfT3 1Lhw== 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=OhU7b9Cs4phuiaOFIPCS384ligvEjn+id8TYxD96mDo=; b=KoKnRZACpHSUolRfjyk4hPbLMEHRjANf0/r4cU5FFCojBoPvwlJkq99R2YVtg2/PN9 WtwUYUzNkdi5wfdtWcEurdd4I7V9wvKY6wGzwMPJfEb01sJdb/actTCCWt2VXuIlDQKd NVtbtSUZ/Yg3Q9wQaLILA3TKm3tUNEnHuqM+QPWvp6QRnuimEok6tTRhrvgM8tcHap0Q NBfjHokkvEJLWcC8RZEGZxHZAdFqjANFFI3vlpLBT1dOCZECdevJq8BYj08CbXbtdiZi VckDe8e+FNz7lWu1H/yZo9vuNxfW1n3s8xn/3nPoNHa189KDwn5+F4lR7YZjgO39JOOB teXg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Laes7FMm; 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=OhU7b9Cs4phuiaOFIPCS384ligvEjn+id8TYxD96mDo=; b=VCTKmNsxB+PQ8/KgSvDC4bGenjLL3hDq0QvgG0Q83UcJIe7jF3+VAerJG3sM6EB2CP xC5CzQxZesQBXiQTSHmPxtXqR0AxOjyRMXEn+LyIt2USaWykruriwxLD2FiFjZWcySl2 xbTSBxkxVzuT9FFjPKvEsW6d9aWOqZmU9GNTg= 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=OhU7b9Cs4phuiaOFIPCS384ligvEjn+id8TYxD96mDo=; b=w132Pco6Z4udW3Pqk+7qUQQyQrUw54E+QPfyhmJbBYYhhz9haU3tD6yigLy7ip7Xtp HVQ6AG/uOaCZVzqUh2nlfT8i6QUlDI633+kCnBbvDpnw9bdqJL4yMGYtHm0oX/PrBeT9 vcND3BapdfreLJmY7XqQts0suCeOFpHuHysgjCZ+aO+7uf0RKawDynPS9Xmj7A/dYWL+ cnNEBp7Lu1C+nwoxto8ghu7m3BAL9Q7YDmLFhP5z/m3psr6ebJ6fnlwnfpUh4u5Oyyv9 U3QKnDeLv1bwACB50VtL7+nvq4gR860IYaC8cCjpBE3FDuvvKvTPY3NO+FeCpcu71Jnr y/Gw== X-Gm-Message-State: AOAM5322GxN1r3Z0MTCLPHgpOJI16mvKyotWH6D5XexASHw54EQqXwR2 UJDgIfYTxtDpNGUMZq1ydgXaptEh X-Google-Smtp-Source: ABdhPJzKGNrVhr3cjupAcu0AFf7Xzg2gc1BG7R1AH7tgKj1cQHdLK1Vb3SGEU1ppcDZ4lBaCCoSmjw== X-Received: by 2002:a05:6000:170a:b0:215:6799:782c with SMTP id n10-20020a056000170a00b002156799782cmr19977075wrc.38.1654595298619; Tue, 07 Jun 2022 02:48:18 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:3d8c:b0:39c:5b80:3b5c with SMTP id bi12-20020a05600c3d8c00b0039c5b803b5cls393560wmb.2.gmail; Tue, 07 Jun 2022 02:48:17 -0700 (PDT) X-Received: by 2002:a05:600c:3d11:b0:39c:1c62:cebc with SMTP id bh17-20020a05600c3d1100b0039c1c62cebcmr35268931wmb.147.1654595297484; Tue, 07 Jun 2022 02:48:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595297; cv=none; d=google.com; s=arc-20160816; b=lK4MKnZE73zTCEa/Zrj3xtAU5UpX7T8/qU+zaMn+9B10w6rZLV0TLnxoUzU/dO8qXh LJ0UsMkvG6MC2LZWJrMJTTuuupbpwr7/W5OV595CW/Uz4GgslbVFoT8E3NXXAnlqu0z4 v9R8RobLhE7cFEueydvWfut2jQGoPcUEw86C3qAHeLs/AQz0lLcocAFMrrtHv/IIIC2z nBB3jqX6Y/IFCctzVsIiDFp+Ef//0J7iL0GtGPbwUy/frXbqKgfvh8cDnNfT5udu3OJj erBptHeYB7vXSP6V3KOMvfwaFLImIuA3BqDVjKzjdpD+AX0CQ1VYvsbYZwg0Pr6Zwld3 o9QA== 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=Hg+fyB+R4Q3yPGfYEvg6uZVcvjloB1KZxDlCqHLSkx0=; b=g0dJqCulS4rJryWzpFyblvle7/BG2oN8EuW2XVIP6RUwxICve9x/ja8es2qMcTjsNo z3ka+f41p/KNMYXnBe4CHn3SKAC23h15uWT9rHa6tCFhfBawOlN7QGlr9f/oGv0wXP/z BUXnB2eMGpa49qCF+Z2Kd3CX7pXUztyfodDwZSuKYqeoiUF0rzCxLjIgIdqDpPvnDKV3 IkOTeZcu0rmGgyQjiSpoNBNEmG5FZwul9bC0dgfuFyFxKUVbxBEWbDhpaPLrDQu/ozn9 x/uNlZJm7HLDR+57UWed/8JcjXBsIQ1CFs03IDclrcPCwaDQCsl6MrtzPRj0Ymz/xaFC YyMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Laes7FMm; 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 d5-20020adfef85000000b00210081209c9sor9876898wro.2.2022.06.07.02.48.17 for (Google Transport Security); Tue, 07 Jun 2022 02:48:17 -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:adf:eb11:0:b0:213:19dd:e1aa with SMTP id s17-20020adfeb11000000b0021319dde1aamr25605595wrn.324.1654595297228; Tue, 07 Jun 2022 02:48:17 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:16 -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 04/13] can: slcan: use CAN network device driver API Date: Tue, 7 Jun 2022 11:47:43 +0200 Message-Id: <20220607094752.1029295-5-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=Laes7FMm; 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: , As suggested by commit [1], now the driver uses the functions and the data structures provided by the CAN network device driver interface. There is no way to set bitrate for SLCAN based devices via ip tool, so you'll have to do this by slcand/slcan_attach invocation through the -sX parameter: - slcan_attach -f -s6 -o /dev/ttyACM0 - slcand -f -s8 -o /dev/ttyUSB0 where -s6 in will set adapter's bitrate to 500 Kbit/s and -s8 to 1Mbit/s. See the table below for further CAN bitrates: - s0 -> 10 Kbit/s - s1 -> 20 Kbit/s - s2 -> 50 Kbit/s - s3 -> 100 Kbit/s - s4 -> 125 Kbit/s - s5 -> 250 Kbit/s - s6 -> 500 Kbit/s - s7 -> 800 Kbit/s - s8 -> 1000 Kbit/s In doing so, the struct can_priv::bittiming.bitrate of the driver is not set and since the open_candev() checks that the bitrate has been set, it must be a non-zero value, the bitrate is set to a fake value (-1) before it is called. [1] 39549eef3587f ("can: CAN Network device driver and Netlink interface") Signed-off-by: Dario Binacchi --- drivers/net/can/slcan.c | 112 ++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index 964b02f321ab..956b47bd40a7 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -56,7 +56,6 @@ #include #include #include -#include MODULE_ALIAS_LDISC(N_SLCAN); MODULE_DESCRIPTION("serial line CAN interface"); @@ -79,6 +78,7 @@ MODULE_PARM_DESC(maxdev, "Maximum number of slcan interfaces"); #define SLC_EFF_ID_LEN 8 struct slcan { + struct can_priv can; int magic; /* Various fields. */ @@ -100,6 +100,7 @@ struct slcan { }; static struct net_device **slcan_devs; +static DEFINE_SPINLOCK(slcan_lock); /************************************************************************ * SLCAN ENCAPSULATION FORMAT * @@ -369,7 +370,7 @@ static netdev_tx_t slc_xmit(struct sk_buff *skb, struct net_device *dev) spin_unlock(&sl->lock); out: - kfree_skb(skb); + can_put_echo_skb(skb, dev, 0, 0); return NETDEV_TX_OK; } @@ -389,6 +390,8 @@ static int slc_close(struct net_device *dev) clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); } netif_stop_queue(dev); + close_candev(dev); + sl->can.state = CAN_STATE_STOPPED; sl->rcount = 0; sl->xleft = 0; spin_unlock_bh(&sl->lock); @@ -400,21 +403,36 @@ static int slc_close(struct net_device *dev) static int slc_open(struct net_device *dev) { struct slcan *sl = netdev_priv(dev); + int err; if (sl->tty == NULL) return -ENODEV; + /* The baud rate is not set with the command + * `ip link set type can bitrate ' and therefore + * can.bittiming.bitrate is 0, causing open_candev() to fail. + * So let's set to a fake value. + */ + sl->can.bittiming.bitrate = -1; + err = open_candev(dev); + if (err) { + netdev_err(dev, "failed to open can device\n"); + return err; + } + + sl->can.state = CAN_STATE_ERROR_ACTIVE; sl->flags &= BIT(SLF_INUSE); netif_start_queue(dev); return 0; } -/* Hook the destructor so we can free slcan devs at the right point in time */ -static void slc_free_netdev(struct net_device *dev) +static void slc_dealloc(struct slcan *sl) { - int i = dev->base_addr; + int i = sl->dev->base_addr; - slcan_devs[i] = NULL; + free_candev(sl->dev); + if (slcan_devs) + slcan_devs[i] = NULL; } static int slcan_change_mtu(struct net_device *dev, int new_mtu) @@ -429,24 +447,6 @@ static const struct net_device_ops slc_netdev_ops = { .ndo_change_mtu = slcan_change_mtu, }; -static void slc_setup(struct net_device *dev) -{ - dev->netdev_ops = &slc_netdev_ops; - dev->needs_free_netdev = true; - dev->priv_destructor = slc_free_netdev; - - dev->hard_header_len = 0; - dev->addr_len = 0; - dev->tx_queue_len = 10; - - dev->mtu = CAN_MTU; - dev->type = ARPHRD_CAN; - - /* New-style flags. */ - dev->flags = IFF_NOARP; - dev->features = NETIF_F_HW_CSUM; -} - /****************************************** Routines looking at TTY side. ******************************************/ @@ -509,11 +509,8 @@ static void slc_sync(void) static struct slcan *slc_alloc(void) { int i; - char name[IFNAMSIZ]; struct net_device *dev = NULL; - struct can_ml_priv *can_ml; struct slcan *sl; - int size; for (i = 0; i < maxdev; i++) { dev = slcan_devs[i]; @@ -526,16 +523,14 @@ static struct slcan *slc_alloc(void) if (i >= maxdev) return NULL; - sprintf(name, "slcan%d", i); - size = ALIGN(sizeof(*sl), NETDEV_ALIGN) + sizeof(struct can_ml_priv); - dev = alloc_netdev(size, name, NET_NAME_UNKNOWN, slc_setup); + dev = alloc_candev(sizeof(*sl), 1); if (!dev) return NULL; + snprintf(dev->name, sizeof(dev->name), "slcan%d", i); + dev->netdev_ops = &slc_netdev_ops; dev->base_addr = i; sl = netdev_priv(dev); - can_ml = (void *)sl + ALIGN(sizeof(*sl), NETDEV_ALIGN); - can_set_ml_priv(dev, can_ml); /* Initialize channel control data */ sl->magic = SLCAN_MAGIC; @@ -568,11 +563,7 @@ static int slcan_open(struct tty_struct *tty) if (tty->ops->write == NULL) return -EOPNOTSUPP; - /* RTnetlink lock is misused here to serialize concurrent - opens of slcan channels. There are better ways, but it is - the simplest one. - */ - rtnl_lock(); + spin_lock(&slcan_lock); /* Collect hanged up channels. */ slc_sync(); @@ -600,13 +591,15 @@ static int slcan_open(struct tty_struct *tty) set_bit(SLF_INUSE, &sl->flags); - err = register_netdevice(sl->dev); - if (err) + err = register_candev(sl->dev); + if (err) { + pr_err("slcan: can't register candev\n"); goto err_free_chan; + } } /* Done. We have linked the TTY line to a channel. */ - rtnl_unlock(); + spin_unlock(&slcan_lock); tty->receive_room = 65536; /* We don't flow control */ /* TTY layer expects 0 on success */ @@ -616,14 +609,10 @@ static int slcan_open(struct tty_struct *tty) sl->tty = NULL; tty->disc_data = NULL; clear_bit(SLF_INUSE, &sl->flags); - slc_free_netdev(sl->dev); - /* do not call free_netdev before rtnl_unlock */ - rtnl_unlock(); - free_netdev(sl->dev); - return err; + slc_dealloc(sl); err_exit: - rtnl_unlock(); + spin_unlock(&slcan_lock); /* Count references from TTY module */ return err; @@ -653,9 +642,11 @@ static void slcan_close(struct tty_struct *tty) synchronize_rcu(); flush_work(&sl->tx_work); - /* Flush network side */ - unregister_netdev(sl->dev); - /* This will complete via sl_free_netdev */ + slc_close(sl->dev); + unregister_candev(sl->dev); + spin_lock(&slcan_lock); + slc_dealloc(sl); + spin_unlock(&slcan_lock); } static void slcan_hangup(struct tty_struct *tty) @@ -763,18 +754,29 @@ static void __exit slcan_exit(void) dev = slcan_devs[i]; if (!dev) continue; - slcan_devs[i] = NULL; - sl = netdev_priv(dev); - if (sl->tty) { - netdev_err(dev, "tty discipline still running\n"); - } + spin_lock(&slcan_lock); + dev = slcan_devs[i]; + if (dev) { + slcan_devs[i] = NULL; + spin_unlock(&slcan_lock); + sl = netdev_priv(dev); + if (sl->tty) { + netdev_err(dev, + "tty discipline still running\n"); + } - unregister_netdev(dev); + slc_close(dev); + unregister_candev(dev); + } else { + spin_unlock(&slcan_lock); + } } + spin_lock(&slcan_lock); kfree(slcan_devs); slcan_devs = NULL; + spin_unlock(&slcan_lock); tty_unregister_ldisc(&slc_ldisc); } From patchwork Tue Jun 7 09:47:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2018 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 1E7643F08A for ; Tue, 7 Jun 2022 11:48:21 +0200 (CEST) Received: by mail-wr1-f69.google.com with SMTP id c7-20020adfa707000000b002184d715e69sf662154wrd.10 for ; Tue, 07 Jun 2022 02:48:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595301; cv=pass; d=google.com; s=arc-20160816; b=bo0WK5CcA5fMzI0i956obH2Jro0OVZyM6eexf6hvjLBMJo71pvnySLfozqS2+oQt3J Tm8ErKurlh9Z6gn1ntdLO8j6/JikIHXWv/Pk7Cn2gPLmHDwdzNpYtWagWLqyNLN+xfhk VQeVmFNDaIwfcAIHj5RKGe2f9NMMTY7rkNYWqrIIVazLZZG+NelY2gsSWMzkg11YOt8f PvsyW+c1Lw8gYg+QLBf8FW7ktVWzaa5L1ufRDhomWSqHbYYoHGTr44YSzRdubLi3acfw h//l9aHFcDZwag4ZFCl8MqxE1D3AfHgHLFTY3Qt5oBB7RfDIP7jSsL7IZoqIlrXgA3Ec uMpw== 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=78U3DragEiB6xQxI4mgX6XIi14CGHnMLtY3yLj8Ln+0=; b=DK3UgkjzRt5CDksqJ2rTI11QuA/uakneg2+3XdflcSoPVFbtV+n5N4lKuHTZTzRCF4 M0P7G2JgY1fWt8GJNrhGo2y3qc6ZZj6WvzhEm4h/tGWHtWAZwEJA8ctdAsGQLsgxxgTJ xfvlkEGXfejjHdU0cSm5n+I0WMTo5ByUXghL4k/Y8LR7BJk659qgZ4G3OwU+9p1Wldvx mc5xGlt/LljC7UMUL+FSA4+4BYf8nAPBimEXm7cJUn1SUrLEfJYY3JNftE6dLJbFuxPy MpXWe+XZ5ZdN87d2N6TPfJb5vQgke3xynsWvC+1KruY6IGwT8E2AKtlgwatMpSDBg/PG WRPA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Iqu6UNp7; 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=78U3DragEiB6xQxI4mgX6XIi14CGHnMLtY3yLj8Ln+0=; b=BXn7c/oQcEoIiv6TfqrD6asvN2FWEe+o6XA/ScLQ80PnjkIQmWR9Y0oH1DI3+Wlv1S c4TYW6/IKN+mrlL8Qfn6hjsE1K2xOwlOvIcqLIUyiHoicqFrk8KOUt+kaWOJta4JJBwv 55dZZ11KgFfuKZLuM83SJYBi9WgV3jUfoud0k= 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=78U3DragEiB6xQxI4mgX6XIi14CGHnMLtY3yLj8Ln+0=; b=XkW1TyavqEmZj71WhHR+p5AFvmDbl3KjOWFgNDHJ74pKaLpsT2/9dUeM+to0q39pzJ RJLpxKN5I9SxbcewLmQ0CAw/QUfEJoNMtHZQdU7jWOIncqfVJdYswUubcWU26fdg21Uh pzSw90mKB7f7zIvP5KkcHJpPyZUFwSZwzzDrFW1vQI40tP8OotUVKHW9klyrukQldYSt Hm7tBUbxeb3N0M5ObQvHUzyQcj5jhsKNzTZH66Ef8RrnSSRyVIjzzbEXkIthhFSNCY/S 3GAFdYYz4kywmG0HmWS9unIRwAkySPExZI7pnXHJQkSV9fELo4+JHWgRan95RUjcobZJ LAlA== X-Gm-Message-State: AOAM533qM/2CQtk0n7RkaKmqIb3SlNdUnvit1zQYg0boLfwJ0istR5er t+RFNnZxG2CdhsDWqvYE3uV9pGyP X-Google-Smtp-Source: ABdhPJwnCaXMtl5fxDrJ3aoimjXAPO/K1CC2dfURg0Z2AhnjoqBowYmo5U9p6nYuBhSzSwSzminUoA== X-Received: by 2002:a7b:c1c1:0:b0:39c:58c4:c701 with SMTP id a1-20020a7bc1c1000000b0039c58c4c701mr3352412wmj.117.1654595300844; Tue, 07 Jun 2022 02:48:20 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:648e:0:b0:217:c8b4:52e3 with SMTP id o14-20020a5d648e000000b00217c8b452e3ls4145020wri.1.gmail; Tue, 07 Jun 2022 02:48:19 -0700 (PDT) X-Received: by 2002:adf:e347:0:b0:217:6f4b:f3d6 with SMTP id n7-20020adfe347000000b002176f4bf3d6mr12942461wrj.73.1654595299692; Tue, 07 Jun 2022 02:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595299; cv=none; d=google.com; s=arc-20160816; b=jnPX5w7AbkeynqSiGhh6+eOXwlIJeqo73W2PfVn84n9HWrDwzUfRIiwSf4x6ts+5It DdoFgnWLp9Qu8vwupDlY5fK/MRXEImcpFSxg+v0id2teXKca6sqOy60YvoA7c+BzLPPB OENj+1J8QOkkwzQMU5yyg2SpmXUGudNVQXcIzaaqZ9qm04vjluRKo5Q6kYyVnJ5EhJm4 Xz/mzXDnoBqui3+yQohsp/sNPhrgAwjc2xkjQ3AeNZRtHCc5IEOQvYA1HUvnAeB8rnOO RjEYdLiJ6kOG9KxDHO5Lbd9e4qw7PcvExS66NZJShOQ5ffs8YXX0YET8PDV3gb4EBZb2 Lxgg== 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=flkxolnPRJ/fuZI8sau+S8LRxDQCGOpfvcgrJTeckZE=; b=mODbelgKbV2jaA3CELA90DGpWSE2AAFrKwmUxkLwVZzQ5wxmOOP4vVn8jEJjyUYeto 0Jgc5MlaG8+PtK8UCUvaI1j3wNUQ9ZOGg5In1Tb/r+gR2TLSH+KyxWcWV3lH6I7X7enN MgSWcIsACTdp0DtjAHdoIpzLyCLCW2QRJ+CuBCzLWegI0/ftjVXflLTYpYVu9k5p0kR+ /+AralXhJF51cohFv6AIdnqikgXrkhsD5znn2hGfrn1Hwhe2pBF+5GRartj7agCgBQIy byIy0UuryqBvy54iug8vwsp0pFyMttu4xPA0eO3c3/r8PLjww16ZLJXMFHJ+hntHGCyv UtKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Iqu6UNp7; 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 v13-20020a056000144d00b00210133f6cafsor10241905wrx.74.2022.06.07.02.48.19 for (Google Transport Security); Tue, 07 Jun 2022 02:48:19 -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:6000:186b:b0:20f:e2e5:f95f with SMTP id d11-20020a056000186b00b0020fe2e5f95fmr27169097wri.76.1654595299453; Tue, 07 Jun 2022 02:48:19 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:18 -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 05/13] can: slcan: simplify the device de-allocation Date: Tue, 7 Jun 2022 11:47:44 +0200 Message-Id: <20220607094752.1029295-6-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=Iqu6UNp7; 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: , Since slcan_devs array contains the addresses of the created devices, I think it is more natural to use its address to remove it from the list. It is not necessary to store the index of the array that points to the device in the driver's private data. Signed-off-by: Dario Binacchi --- drivers/net/can/slcan.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index 956b47bd40a7..4df0455e11a2 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -428,11 +428,17 @@ static int slc_open(struct net_device *dev) static void slc_dealloc(struct slcan *sl) { - int i = sl->dev->base_addr; + unsigned int i; - free_candev(sl->dev); - if (slcan_devs) - slcan_devs[i] = NULL; + for (i = 0; i < maxdev; i++) { + if (sl->dev == slcan_devs[i]) { + free_candev(sl->dev); + slcan_devs[i] = NULL; + return; + } + } + + pr_err("slcan: can't free %s resources\n", sl->dev->name); } static int slcan_change_mtu(struct net_device *dev, int new_mtu) @@ -529,7 +535,6 @@ static struct slcan *slc_alloc(void) snprintf(dev->name, sizeof(dev->name), "slcan%d", i); dev->netdev_ops = &slc_netdev_ops; - dev->base_addr = i; sl = netdev_priv(dev); /* Initialize channel control data */ From patchwork Tue Jun 7 09:47:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2019 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 0C0233F08A for ; Tue, 7 Jun 2022 11:48:23 +0200 (CEST) Received: by mail-wm1-f71.google.com with SMTP id k5-20020a05600c0b4500b003941ca130f9sf5595120wmr.0 for ; Tue, 07 Jun 2022 02:48:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595302; cv=pass; d=google.com; s=arc-20160816; b=Eet7Psr9l1e/Y5UH7eFMub0ijUqj8N5/DHXsQRdcABC2+Jbd1ve0PVpp2Rt6X1zpQ+ P0EvMYC0BL5EP0Wth9ZNxW3Cj96HdU+i382db6ZT759z7G7/cSu6mPkvBlffAaoug3Bw LSJlUgDGPkdjjOdLzbNLiwW4cjSySnPxmlH6i88z9v2z4TYFquzVxzzJCB/vTQNPhUOn oT+U5T+xmuKFoPfTjlw3zHrWIhRx8hfIns0V18ckbrTjYC+JAINNX683v6InpaXcnW1t Ah6rmH29PzdhmoL/OsAZKTKGYQ7QaFrzI3S7tlWlKCHwTXvRDS3rKZVIPaezF8Dpkgke Yf5g== 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=na9RjzBj2O3XOcAQsf/UObvj4bI+rIZ1Je36SvNQj3I=; b=jwi90f5h3fbVBvntTuKETAMI6XZlKVoejgSjnmmrqO3zQYyfpZsOsqT56SqnkUgbq4 rd3mxtYEd4lEZBHstCwMekh4NiivLuJItw6QIdmM990f5MO+L8bkXwoK+VJuK8QOLca7 AotiURygwNnQXiIVRZ67P22MkTRlMMCdCXYN6gwxjaDCX+Ste7xvpF7YlB0O4GoeCjBe vf5wNv54FeWN2GKecAB8z7gQkf75rShOj5OVk1ix3sAtZ6Wp6gzqmnHHt39O1OjZb43W fVZEL9+MBm4r0r+t1tuHdSDLoatQ9ZDkDdk3/z4+lUxUQkDy7DX6a4BT7X9beEuy1Hdy ZHTQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="jnJyM9v/"; 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=na9RjzBj2O3XOcAQsf/UObvj4bI+rIZ1Je36SvNQj3I=; b=gXhHRxg6ue2FgDStsRvul9MRIwk41OWzfzmnpKNQGTO6S9FCJ6vTeiwQ/CDG1RgDtZ GNBgD8uxowYrjq9ZvCJ3fSzuZqvy67EAtDHGvSt/RiRHlqYfWrP1AyPS5RCPrjiOxaQ+ s9ObMVk2aeas/3sIsbQU6J55gnORLp4x60wqM= 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=na9RjzBj2O3XOcAQsf/UObvj4bI+rIZ1Je36SvNQj3I=; b=Wz2f2Ois1kbV7129BbbA3JXOu3SUAqbpGVpuENp17VJh4Z72rTLE6pr3vklEVi1Xbb 8tm7I9ndY7KBrqICLe/RyiH+Qhyc5rcnygqgXLOrI0LyBPEQHGDFB1vZp7k1CtgHycJr 0f5Aa/9sC3ih7Oylq1E+y5U5kfEg6Itx4R7HZFPcMaEnGSI6UUAPUTvvxOZyDop+p61s FEavAsFkWVre7sa2/vJFCr30AIOd/8MPIwgBGL5WMDzv5fcA1zaEhStSPR8zQ9jw5c1d IHsEy5MybtgImM1Didh0p5OU87mgP2fRjvhAS5LItDKEU72LzFO/2KnaS6Z2zg1vvGcv E3NQ== X-Gm-Message-State: AOAM533Am3jpY0ZeP0Vj4D+c6RCyP2XYRZTjb2zrq5SzYCZBPnG71hGI hFT5LDpKIKkdnFaGuzy9mqNeBUCH X-Google-Smtp-Source: ABdhPJyUJsQ202Gmm9GmfLjKpwun8SbcUscu1G0qxQbeHIkIu0Pp3wLTAlH5xFy5yggPkes6iyyPlg== X-Received: by 2002:adf:b358:0:b0:216:508c:e0bf with SMTP id k24-20020adfb358000000b00216508ce0bfmr15628790wrd.204.1654595302852; Tue, 07 Jun 2022 02:48:22 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:648e:0:b0:217:c8b4:52e3 with SMTP id o14-20020a5d648e000000b00217c8b452e3ls4145147wri.1.gmail; Tue, 07 Jun 2022 02:48:22 -0700 (PDT) X-Received: by 2002:a05:6000:1568:b0:20f:d416:e5ac with SMTP id 8-20020a056000156800b0020fd416e5acmr27039639wrz.190.1654595301847; Tue, 07 Jun 2022 02:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595301; cv=none; d=google.com; s=arc-20160816; b=h841I6SQtuj5bvU1INd1f/mORf8MZKL85dxcy1U8ePiju71QmKd1CekMwn84kfNkUV 8FGphL4XbB0+oxcczVc4A38kQSo6iDXWUSrQoGEvmCGsVl3leqYImmpkMTWzmcEqpaM8 UPbOl8kxu4iI+ZNJyXdOJF2u3OxPvL2QvauNSS39sssWW8XDFXIa3y43BW193ShT7Vln mcNyUZ9gSWp+3QfcpsyAlXmrhisR1KTsiecSVkY8Aw3bxeCE/t2L4J7Fg5ZFdiYHqZi8 NO3zNCMXQFxi1FNtxapapDgjnhnY2yp53hzpq0ZPAETROfi0b2mGJotGS3G0RkgoleBN B/ew== 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=4002ZoQbfZgD0XX9YDZ6wPiQ9rsbL1Ku9Z7hWp9EhXQ=; b=oftWV2AnSg5zCHOvZGPHsuO/b5r/bZZlDdK++Qu7Fa1lKmebwcr5DSlQzWHxJrtapl Y3srSVUswwT9xMbw+UIIJpXNfzdM2+aC1Nt3X7Uw797xd2bXrqyPIwfz+VscUewjMBUx o+UT1fWchE7DYh2rM29lJoX3b9dRAiOwmLNdVFy49dDYcq6ZBxanP8J+Prg8107AodbU jBLS1dYHWjOsNGMMlUqasvYAPgxjKyzDS+7YdWllLIXD0TK+z7lpudDDtVOepnuOMcrY lIK26FKMcT4YG7J0gBA+Was9A1YSiOyV1NZS3nRAnTYAW08S6Q3GsiNu1sG2sW0nJCEx DMwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="jnJyM9v/"; 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 f8-20020adfdb48000000b00213b49a9fb8sor7268595wrj.35.2022.06.07.02.48.21 for (Google Transport Security); Tue, 07 Jun 2022 02:48:21 -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:adf:fb05:0:b0:20a:e113:8f3f with SMTP id c5-20020adffb05000000b0020ae1138f3fmr26424039wrr.534.1654595301578; Tue, 07 Jun 2022 02:48:21 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:20 -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 06/13] can: slcan: allow to send commands to the adapter Date: Tue, 7 Jun 2022 11:47:45 +0200 Message-Id: <20220607094752.1029295-7-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="jnJyM9v/"; 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: , This is a preparation patch for the upcoming support to change the bitrate via ip tool, reset the adapter error states via the ethtool API and, more generally, send commands to the adapter. Since some commands (e. g. setting the bitrate) will be sent before calling the open_candev(), the netif_running() will return false and so a new flag bit (i. e. SLF_XCMD) for serial transmission has to be added. Signed-off-by: Dario Binacchi --- drivers/net/can/slcan.c | 46 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index 4df0455e11a2..dbd4ebdfa024 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -97,6 +97,9 @@ struct slcan { unsigned long flags; /* Flag values/ mode etc */ #define SLF_INUSE 0 /* Channel in use */ #define SLF_ERROR 1 /* Parity, etc. error */ +#define SLF_XCMD 2 /* Command transmission */ + wait_queue_head_t xcmd_wait; /* Wait queue for commands */ + /* transmission */ }; static struct net_device **slcan_devs; @@ -310,12 +313,22 @@ static void slcan_transmit(struct work_struct *work) spin_lock_bh(&sl->lock); /* First make sure we're connected. */ - if (!sl->tty || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev)) { + if (!sl->tty || sl->magic != SLCAN_MAGIC || + (unlikely(!netif_running(sl->dev)) && + likely(!test_bit(SLF_XCMD, &sl->flags)))) { spin_unlock_bh(&sl->lock); return; } if (sl->xleft <= 0) { + if (unlikely(test_bit(SLF_XCMD, &sl->flags))) { + clear_bit(SLF_XCMD, &sl->flags); + clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); + spin_unlock_bh(&sl->lock); + wake_up(&sl->xcmd_wait); + return; + } + /* Now serial buffer is almost free & we can start * transmission of another packet */ sl->dev->stats.tx_packets++; @@ -379,6 +392,36 @@ static netdev_tx_t slc_xmit(struct sk_buff *skb, struct net_device *dev) * Routines looking at netdevice side. ******************************************/ +static int slcan_transmit_cmd(struct slcan *sl, const unsigned char *cmd) +{ + int ret, actual, n; + + spin_lock(&sl->lock); + if (sl->tty == NULL) { + spin_unlock(&sl->lock); + return -ENODEV; + } + + n = snprintf(sl->xbuff, sizeof(sl->xbuff), "%s", cmd); + set_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); + actual = sl->tty->ops->write(sl->tty, sl->xbuff, n); + sl->xleft = n - actual; + sl->xhead = sl->xbuff + actual; + set_bit(SLF_XCMD, &sl->flags); + spin_unlock(&sl->lock); + ret = wait_event_interruptible_timeout(sl->xcmd_wait, + !test_bit(SLF_XCMD, &sl->flags), + HZ); + clear_bit(SLF_XCMD, &sl->flags); + if (ret == -ERESTARTSYS) + return ret; + + if (ret == 0) + return -ETIMEDOUT; + + return 0; +} + /* Netdevice UP -> DOWN routine */ static int slc_close(struct net_device *dev) { @@ -542,6 +585,7 @@ static struct slcan *slc_alloc(void) sl->dev = dev; spin_lock_init(&sl->lock); INIT_WORK(&sl->tx_work, slcan_transmit); + init_waitqueue_head(&sl->xcmd_wait); slcan_devs[i] = dev; return sl; From patchwork Tue Jun 7 09:47:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2020 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 E3B2C3F08A for ; Tue, 7 Jun 2022 11:48:24 +0200 (CEST) Received: by mail-wm1-f69.google.com with SMTP id j31-20020a05600c1c1f00b0039c481c4664sf1483091wms.7 for ; Tue, 07 Jun 2022 02:48:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595304; cv=pass; d=google.com; s=arc-20160816; b=DNtpoYz9hmkaB+UQlnVJ4IUQhgbvIZJ9OLPjHTLJiMYRJ0vl9tuQHV3EIPYoIFe+0D MNrm4CNqwYqC09XN61bg2cxF48x9rHZ6XfDAN+4pPjyOUOI4GjxJpI0ra30tHNDLLQ7I J+Mi8JuWSpXnBsYHOaj/WbGRUqACfP8ro822kA+cxf06toxcfD99zFa6SFRACMYVeVgS 3V33WUxziXHe49I9AwbiyuN2W2GNbKsgiaVI2fI0W5ZYQ8Hj8TSPIA34GQHqpGFyMi8v 665xo11cBDqmXaKeZqrS+Q/FrEUrpC7Eho24zlffpvIAwpF822pmLsCwcx0y24PyQofY XCUg== 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:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9JGVbnYSDZK+psOWeb9T010b6Ilfpvi7nldKDR2QC6s=; b=m0henVhKdES1OhKmp9IFXR5f1yz2pl3umC/i1m8G1bJv8QOJO4IAlL0HbdRaFF9LoG sBPlpcGChDQAock2iw1nqj75pZyg3yDcjMd+5BfOeqehhntOInXMD0t9upB11Or/zIkh jivsgzELTc9OzvNZuhMSSSPNGyNgxvjkcIYHBm+blyNFo0WWmrq7xRBT7R/bEY4+gsuo QXMvIiPAPDEfAVvs7dcFpLj5nVIQNt5IFIaH2Wkjf6CrnWw5J3Dul4zXi3maPNVQM0uH Q9eWLQQPPP5eAAcvi6UlYeYBoprkliHQ9jE/Qdr12WL7LEAZ5DdFrRFlLsMq/Sfq7w4K 3oqw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cRCWGgSN; 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:content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=9JGVbnYSDZK+psOWeb9T010b6Ilfpvi7nldKDR2QC6s=; b=SPphjCwWgm7doF5ffhe+PvvcbRNhjv4Qx9W3CmRM3rUyPd7ana8tgfTqxh3Blj/Qep PouAV8QwnloxBhFgK6J0ZX1JeDIcT1SuLUd4bZV+QAsylLiO15Sjlp74Vr+64m1wqEQu zMYC57GzGUaIfnbJjFZM9l44RC7d+JXdoYrDg= 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: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=9JGVbnYSDZK+psOWeb9T010b6Ilfpvi7nldKDR2QC6s=; b=hioLjj4TPRFuqS4GwqRI6JVdVEAtAt2rl/Fn59oHG4e7BTiDrlDqQq/BkH2Uqd/Bkf haKY6k0xSlRrzwvHj+TdvzMmTS25ZQnBRzGysipwS9CHLa121W64dz7TQ94cp4cTYNw9 pkL1tXOR7gj9+6Y51oBtRxy0dSF57iCvGdxES9NJcMu9wtDZbEErJCtdc045ms4JChE1 vBHytO3+ISGCqDnvoipxRrTtazkbtToZDyk4pdLojiBLY7G8Zs9J34bYj2U4ihy6OzWE XsGKGpuN1ecNOEwxl//n2e279pvT5cpIVyOqsSpqtyv460pi/mlzVwyz6dLp8eq5AsgM Fdyw== X-Gm-Message-State: AOAM530A0nRhVOJYSARLIEkTsE1NN2o9qgn6nxscVVAMpYJyVgRL5E7Q NngoeE4r+n3Flfy+s6vXGNnMAuFR X-Google-Smtp-Source: ABdhPJyV2ZcOzsbGj3OuARX9JcBgQrhC/iPNxLhrRUWIAGs0BQvBooDgJqEI89AHx0Xs2sJ7fK5GzQ== X-Received: by 2002:a5d:4206:0:b0:213:bb1f:b81f with SMTP id n6-20020a5d4206000000b00213bb1fb81fmr20798144wrq.363.1654595304787; Tue, 07 Jun 2022 02:48:24 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:6dab:0:b0:212:d9db:a98 with SMTP id u11-20020a5d6dab000000b00212d9db0a98ls4153528wrs.3.gmail; Tue, 07 Jun 2022 02:48:24 -0700 (PDT) X-Received: by 2002:a5d:430d:0:b0:210:2ce0:e2a9 with SMTP id h13-20020a5d430d000000b002102ce0e2a9mr27131477wrq.627.1654595303799; Tue, 07 Jun 2022 02:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595303; cv=none; d=google.com; s=arc-20160816; b=KULYKrlpiOSlbcruQsJZk16CeFvsI8vLadj4Rp/g8rfhkxx//1rjB4srZkyfoEz4Eo NQu6i+Pb/TYllNBOzAShLq3vwuN273eCUKJuHTB1TbuXPphmRTWprfk65eGRsUx7vwjP lsc8SE4l387DFpX4CAImEtaY23IoA3+2l0jrwVeFzLsbXWoD+2UEQpYyfoZ7mSEUTfCH w9Y92C4kyZ+7lpvpmwlY79cm/AKmq6n++7S11OIydjseL65YM7aMfbh50pAmm9D2b5Q/ rcqPZhpxgJKWGqGWbrA3m7lk4E3XserMV/DeXEnP8DN883mqYlMoJ76w5dmzpx2XqO+w tcEA== 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=onYK8jf0XQfJNXTnZtrlaJoF/ojpUqhJIjTYy4RWPWI=; b=plOOdloQmDVkCUhPkSjEWm7TOOSJPlMNCviX+Hxm94uX2veK2/bCiU3VHRSrXhgn1b XhdF54EA/i9IttUvsJfBpV8RF0Cr0+Bv88GNQYrBOnI61KoHDtKNM43JcESNSQlrSURm X8ioRQByeuU1lX8IeO30abKplB2tyGIIUda4lPf1XOxwxiurs+4CfQxhadAusWUiBJux YwBVB/cVcst2s1hjBBxBoPyw1YDfm2qhdTdKiG3v3Ho1Vdz5LuF3QcqEXCY7dOmYh4bK FWgVNVNoQ7qb+GPhEszO+XsoFaSh4P6pvYQUlPQk1oIw8njF91RQXPF/FzKxIHtL5CTR Ya6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cRCWGgSN; 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 k9-20020adff289000000b0020d08586312sor9819756wro.40.2022.06.07.02.48.23 for (Google Transport Security); Tue, 07 Jun 2022 02:48:23 -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:4649:0:b0:218:4d6c:3f3f with SMTP id j9-20020a5d4649000000b002184d6c3f3fmr3510839wrs.148.1654595303518; Tue, 07 Jun 2022 02:48:23 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:23 -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 07/13] can: slcan: set bitrate by CAN device driver API Date: Tue, 7 Jun 2022 11:47:46 +0200 Message-Id: <20220607094752.1029295-8-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 Content-Type: text/plain; charset="UTF-8" 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=cRCWGgSN; 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 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: , It allows to set the bitrate via ip tool, as it happens for the other CAN device drivers. It still remains possible to set the bitrate via slcand or slcan_attach utilities. In case the ip tool is used, the driver will send the serial command to the adapter. The struct can_bittiming_const and struct can_priv::clock.freq has been set with empirical values ​​that allow you to get a correct bit timing, so that the slc_do_set_bittiming() can be called. Signed-off-by: Dario Binacchi --- DTS properties could be used to set the can.clock.freq and the can.bittiming_const variables. This way the parameters could be changed based on the type of the adapter. drivers/net/can/slcan.c | 54 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index dbd4ebdfa024..f1bf32b70c4d 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -105,6 +105,18 @@ struct slcan { static struct net_device **slcan_devs; static DEFINE_SPINLOCK(slcan_lock); +static const struct can_bittiming_const slcan_bittiming_const = { + .name = KBUILD_MODNAME, + .tseg1_min = 2, + .tseg1_max = 256, + .tseg2_min = 1, + .tseg2_max = 128, + .sjw_max = 128, + .brp_min = 1, + .brp_max = 256, + .brp_inc = 1, +}; + /************************************************************************ * SLCAN ENCAPSULATION FORMAT * ************************************************************************/ @@ -435,6 +447,7 @@ static int slc_close(struct net_device *dev) netif_stop_queue(dev); close_candev(dev); sl->can.state = CAN_STATE_STOPPED; + sl->can.bittiming.bitrate = 0; sl->rcount = 0; sl->xleft = 0; spin_unlock_bh(&sl->lock); @@ -456,7 +469,9 @@ static int slc_open(struct net_device *dev) * can.bittiming.bitrate is 0, causing open_candev() to fail. * So let's set to a fake value. */ - sl->can.bittiming.bitrate = -1; + if (sl->can.bittiming.bitrate == 0) + sl->can.bittiming.bitrate = -1UL; + err = open_candev(dev); if (err) { netdev_err(dev, "failed to open can device\n"); @@ -554,6 +569,40 @@ static void slc_sync(void) } } +static int slc_do_set_bittiming(struct net_device *dev) +{ + struct slcan *sl = netdev_priv(dev); + unsigned char cmd[SLC_MTU]; + int i, s = -1, err; + unsigned int bitrates[] = { + 10000, 20000, 50000, 100000, + 125000, 250000, 500000, 800000, + 1000000, + }; + + for (i = 0; i < ARRAY_SIZE(bitrates); i++) { + if (sl->can.bittiming.bitrate == bitrates[i]) { + s = i; + break; + } + } + + if (s < 0) { + netdev_err(dev, "invalid bitrate\n"); + return -EINVAL; + } + + snprintf(cmd, sizeof(cmd), "C\rS%d\r", s); + err = slcan_transmit_cmd(sl, cmd); + if (err) { + sl->can.bittiming.bitrate = 0; + netdev_err(sl->dev, + "failed to send bitrate command 'C\\rS%d\\r'\n", s); + } + + return err; +} + /* Find a free SLCAN channel, and link in this `tty' line. */ static struct slcan *slc_alloc(void) { @@ -583,6 +632,9 @@ static struct slcan *slc_alloc(void) /* Initialize channel control data */ sl->magic = SLCAN_MAGIC; sl->dev = dev; + sl->can.clock.freq = 24 * 1000 * 1000; + sl->can.bittiming_const = &slcan_bittiming_const; + sl->can.do_set_bittiming = slc_do_set_bittiming; spin_lock_init(&sl->lock); INIT_WORK(&sl->tx_work, slcan_transmit); init_waitqueue_head(&sl->xcmd_wait); From patchwork Tue Jun 7 09:47:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2021 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 276843F08A for ; Tue, 7 Jun 2022 11:48:27 +0200 (CEST) Received: by mail-wm1-f70.google.com with SMTP id c125-20020a1c3583000000b003978decffedsf12540170wma.5 for ; Tue, 07 Jun 2022 02:48:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595307; cv=pass; d=google.com; s=arc-20160816; b=DT3K2gTlgd3ps/7xtb2Vm01NVgYJJULfE6hcZt8PjkREPyLiER/Ov7UtfamhE9MIvh M6e5MRhtHrNMbTFnYyEAg5iC3LT+dL03T4Ax6nT3HDYt0YwNIRsgCdoKw0rRp6qq4YTq XuMmUbmlsGKj3S6ACTLVghpMPDh41FiwdbtmHvg4pnB3QbwCp2l4Bqwncca3Mm2MmkCi 40+qw0fQvWehJ56kATLteyxHGOCdiAdqEjLjMUuZZS2vFk/KBoQ9zgM+LA+gk5Rv9SP1 kXIjAbbUg0tMaYPkbtXrHaq1s1ZXV5z+r88hrZsevZDfCSSelluOnt36WBXOo6qU1vw8 Waiw== 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=c4yBXzsmJqxSalAFXVCEvDVnZaVmriB3T1+3R5lD/L4=; b=NGgjKXaybGg8z41fVp0EA/EgMxuOmiAEijYT0oUDh+9+N3UX52esiImNH2t0+Hxn5+ DxVm3LEKXyn6MKZf1jCZk1wYuGR7JNTZgyYSm8QjfLX1hxVBc1vi1V6BSQfZqmyiexWJ 9f1Ur95dTvsax72J/nGtpw0zDbtXe5a4l5qMnTqihn0bCNgCe/vnD4tOwwg6HhefIGVo ujoPn3cl/XERlGHlrPro+k9rT5s7kQKRfRnG1GcY7R+31AgqZK/W4rZmgpHyCi5zjgip pmC2r7LbGXMUImrfyydDmY956AuScvoBatVV1KNcRewdE7d+dC8vTvgwV7DTBTwN7Fkr seiw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=evbcgwrL; 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=c4yBXzsmJqxSalAFXVCEvDVnZaVmriB3T1+3R5lD/L4=; b=lwXf6qzAB+/tFe4L5D7iLaJwhycgnlnHNFDbV6nzYZdYfEuOaD53DAlJvw7nVrM7W3 bxxzX/GEG3hwDQuIL6gtliwvQYvJ7NxxJuXH92eFr0Moi8XRb697Iy4GJ2c+94NSko7Z p4lsYneW4tf/4MRvV4+5jqFB/5A+msGFmB2hg= 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=c4yBXzsmJqxSalAFXVCEvDVnZaVmriB3T1+3R5lD/L4=; b=lfKdh1fOtscknleNN2kQfp5Mm1qEH11HQP8i2EzglVCu1cwzUzsNk/WTxZEi2rGxph MsQEDHot6oL4Et/5IfR0BJhI0fmikv2otyNNSicA9ODWGHoSzvbSVhK0kVQCNTivGIct Q21Dpq/cBQykTqx6IJgxuMF2CJphEUBQK5oqPaNkzGJ99lqDuZ1MqvP3V/FbJ03QqT8c VRZ0yp9kN/XTDZBlruI+oNAYzmqcfz2THg+fS2WQ5BC5te7glX7UIcFhY3Vt1Jk/S8vA v592ulOzLcCjiVg6EB1V7xYJxY1msF3krhb8KpTt5wbMRRSpiLrkvgsX76Me+2oKiEEc vKbA== X-Gm-Message-State: AOAM531Ql0CqBR6TmZEwzjBo0yy3cIvPkETOdBBkS1lj+d27nhkG+Guf 24ZqXLkqZ6qTzZzy5xTvxabNKpOP X-Google-Smtp-Source: ABdhPJymTygIXR2ctZShY/hKGwnrm9MnOoye8sByEiVvpdKMTCtck2HipU5cbjqldRvygzsK/Q40bw== X-Received: by 2002:a05:6000:1e0a:b0:210:32e1:3b03 with SMTP id bj10-20020a0560001e0a00b0021032e13b03mr27298822wrb.642.1654595306770; Tue, 07 Jun 2022 02:48:26 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:3d8c:b0:39c:5b80:3b5c with SMTP id bi12-20020a05600c3d8c00b0039c5b803b5cls393723wmb.2.gmail; Tue, 07 Jun 2022 02:48:26 -0700 (PDT) X-Received: by 2002:a05:600c:17cf:b0:39c:4b79:78c9 with SMTP id y15-20020a05600c17cf00b0039c4b7978c9mr13508560wmo.96.1654595305743; Tue, 07 Jun 2022 02:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595305; cv=none; d=google.com; s=arc-20160816; b=BAlze7DAjm2uHLyNan7ZlA9o1VFVDujR+dQo2CKRxVFsEEPzkY6vNZdawsYgeKTqBy SHwI/3JiWjCgjskHtM8yn3NTGGZI/w3ECrguS4jep0Dw8lfEfFP5YWpV5vLvg115LdbI aMnuDP6+MpORT/dMB6EHhgEK+NEuP79FKvht1OtA7dlMhE8V4pfUqRTY51nWLg5hFRKr bNx+7fUk/Sdzx/hay0z7pZ2h+T2CPhiGImKABfvrQlSXH7mvhbPxY6wCoGL6H/rdXZLT HmRzSj3tZLDh57iaBgANVrRqRtcpH4gCWbGTZd3SJiwUTC/PGqhybjKxH+MHrs2d14XW 2VKg== 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=cXpKooudMy6rrQwP/L+KMO1DefLsV+CIObJk2wvPyQY=; b=1AQJ7CMNC1Y8yoeq49VFwtbEt16KQH3eodGnOLyNHQd6cEvAMwq4r4o/DtEw7kbZIr qdKgKsllI99BBrUlFcG+CV54U7pwwPHRfcGZQbv8ykEza/hTMQDKni8FouUaDc8cIbrO PlJyiORhLRMP4LqqXfd8/rLEdFyDEispUkrosQQrxfFQpa2Qu/hlhNUqiKjjsV1C4YFL n701XxaQXZBhAxGQm2xUel4uLx7GrzMSZ78UpETJ/xiOpie8oa8kpjZw2aV4hxskK+Hj nTZvyI9ECPkudO9ShQT5NNVwPz5Y5Z4ZvDDsXjk6vIQ8lb1o8RMprke/b0oR7df6VRvv Z7wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=evbcgwrL; 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 j5-20020a5d4645000000b002101f6cfa8esor9661733wrs.80.2022.06.07.02.48.25 for (Google Transport Security); Tue, 07 Jun 2022 02:48:25 -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:6000:15c7:b0:218:4a5f:75bf with SMTP id y7-20020a05600015c700b002184a5f75bfmr4603612wry.94.1654595305547; Tue, 07 Jun 2022 02:48:25 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:25 -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 08/13] can: slcan: send the open command to the adapter Date: Tue, 7 Jun 2022 11:47:47 +0200 Message-Id: <20220607094752.1029295-9-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=evbcgwrL; 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 open command ("O\r") to the adapter. Signed-off-by: Dario Binacchi --- drivers/net/can/slcan.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index f1bf32b70c4d..f18097c62222 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -469,8 +469,15 @@ static int slc_open(struct net_device *dev) * can.bittiming.bitrate is 0, causing open_candev() to fail. * So let's set to a fake value. */ - if (sl->can.bittiming.bitrate == 0) + if (sl->can.bittiming.bitrate == 0) { sl->can.bittiming.bitrate = -1UL; + } else { + err = slcan_transmit_cmd(sl, "O\r"); + if (err) { + netdev_err(dev, "failed to send open command 'O\\r'\n"); + return err; + } + } err = open_candev(dev); if (err) { 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); } From patchwork Tue Jun 7 09:47:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2023 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 5A67B3F08A for ; Tue, 7 Jun 2022 11:48:31 +0200 (CEST) Received: by mail-wm1-f70.google.com with SMTP id n18-20020a05600c3b9200b0039746f3d9fasf5576751wms.4 for ; Tue, 07 Jun 2022 02:48:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595311; cv=pass; d=google.com; s=arc-20160816; b=HyaUwkiLeBaoWqf8G4A9ZULsZ7jG/Qe6OB/84lmMJLt8mzjltkdXRE/NWPEg3b+q/B R2H7S2qGSyhBcFSh23c5oUqJo4msa4mKxxuv249m0tLSYwKG1VcyrOPf7qNki4ShHmNm 2JH9gPMLT1yiaPb8bmj5bTmERB93qgi6jYpj40sioYszkIkBL4gHzzyhnSiZ9tDxicDC 8MN2Bnot7l+AqZ8x4Vya/re/0t32JLz+Vi4jfSngwjgg3kGOVtalSJf9lF18fyEEucCf W+0IGc75vTJ3ezkCJkPY4z1orO1QpIjHoShyF/9w1HEW6n2HXCVhFLJHmWJmyb7wKLoA 52Qw== 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=gjMnhLGgOkT2bk0w9v9kuf//4QTmZDY6KkH5fguQ/aM=; b=CImZhZqN3pBcQQqLOZNo7flkavKHNxvXBcFCvtr4RwlU2zT/+d3YiFEghHFMOW9kMa aohdFFlfHQEmEFDOQvK5C7ZOFPLkg/MDUjarKf7gl8t/I5xDFsrd9n7KMBCfF857c1JD NzpNfkgbGaV83KPfWPz8zcsM0Rqx5mNCzxr3b1blEd/5lfcZpzih3uXrbrK4pL49yGFm ilalA5HzRxsMcRTGm6RCdjFXWh9EGkakL1YJpLwPzqpn2o7RQS48JnRv5Ne80LiSHJ2S Xg2ZgYCbVqEsLIGjICGKRm9sy5kXE7CdCqdZSFcU7TRNd7VV+l7RORohsaRaa/Zhh412 XgZA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SsiTzfOZ; 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=gjMnhLGgOkT2bk0w9v9kuf//4QTmZDY6KkH5fguQ/aM=; b=L/2w+wsAZOwRSwtEvnNXvF6kdRCh+lPlSZW+DH0ehdshETMgbk9/Xlld8kR8ICLJ6W DvihcH9D+E+HGosZFJjsx439OfGZA/KmpZazE93qFoNeJGGGfnC3QztEv36G2kkO8uTh Fi8VO+YN1ZiqPgokgfTalBjwBXCh5YAoN4IrM= 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=gjMnhLGgOkT2bk0w9v9kuf//4QTmZDY6KkH5fguQ/aM=; b=miR2o0NGCvf+SvxR1Eg5IvH6YToJWQaeIIG9p/C0ln3DGxynFgtx+IUpgm593QF2w2 5Em9KlJVp1M+Pzb6KsTt7JGlWG4DSB4W3rSgq6orGIVuQvphPM8WyPLtM1sgqaOc+k7N +Y+OTC0J7EFXz63v4GuDYS5yGlKCAVAiirHTqL7qmgCi+XHBLnO3WEpOo1ONGz+5V8bh pkHcGUaca/TPtGOgoGEG6FRRN/eeCLIxUMsioZ4yeDdXEKAi/yFmP0DfEI9E6HSkDV1F jSwuulS0Jb+KJFmt0IMHpGP+iXNgeL3AaQm64NichXziCQdYSANpGnEeSCdSZIbe9x1+ A12w== X-Gm-Message-State: AOAM5325VNagV0yGrKA5i3RrQOHlA47PWd0Wsceasp440O20kgwPrbzQ TbDc6C8cva1JtzRsbCeuZIkH8uaD X-Google-Smtp-Source: ABdhPJwbp5qxWAR+8xN3BGLdTERF/nUD9qNMx1guhPYMJgCpmi9GQ+KQlhxLWw8GzGQz6FzmsWWTpg== X-Received: by 2002:a5d:6085:0:b0:213:b9b5:d985 with SMTP id w5-20020a5d6085000000b00213b9b5d985mr23194143wrt.113.1654595311108; Tue, 07 Jun 2022 02:48:31 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:648e:0:b0:217:c8b4:52e3 with SMTP id o14-20020a5d648e000000b00217c8b452e3ls4145772wri.1.gmail; Tue, 07 Jun 2022 02:48:30 -0700 (PDT) X-Received: by 2002:a5d:6e8d:0:b0:210:2ce0:e2ae with SMTP id k13-20020a5d6e8d000000b002102ce0e2aemr26841484wrz.364.1654595309983; Tue, 07 Jun 2022 02:48:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595309; cv=none; d=google.com; s=arc-20160816; b=p0LjnUQY7gus/KC/Z8Y64z4AhYZ87/ZyrSgQ4rsQGyfCXb0tcpPqlL5a/rLtTSugGX xeb4Tin3QDXXuUAQWdqxIZaSlIbXlqayhvhA11NZt9tUCsGrB2xCL3PC88yNrLDKalOC hWfZKTTzZuTjxXljuV4cKuWTeNB0O2wazTbj++SlRGfMi0H8zFWgj8g8Oofz+QSgKLH4 GLNoVMK8m7LXQHZ7L8IDxrLC2J64m2b2mfpoPteF8RAaCSGJWYutkakyjT9/eGgh3J5p Z4jZljlL1RK2IvSVFBnZ94D2KO/5U94mgxnSsqaXJa6QM4Gtsy5gAA9s/XLlks2XfHcJ HXyg== 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=fk8bZMyNT/2KuBRASzmCZE/YrWdzGKg6dBkYG4hiWJw=; b=YZOpSYXw05BN0uH64fySRsR5Clh0GE2oGKJoBI3D2mtN1Xej+gvQcV72QnRknDpXgG iZipqlC8HgYc676hLHtPfHV3aoLmoZLepp5O8KMaUaVwAw59O8gkCeNKy/lFO2EmI3iu 5gkMDkhXNUh8KDQ1oGoOa6OIF+ND1LPkj3/amaSGInc00pHpwYwdD/hED0dBZJyBDZtA cLJgeaOFpCZNy4oDu+EFD20tBQrPzWvP+lrWfcWPVmOD0UaOcLN0FANQMJg/RNxUhvFV NfROb96BL7w4sdZYEc5O+oY3hGPvLwkv1clvAC/oaD5jdJ6297hW8YNNzR+PhQ6s4+Qd MOIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SsiTzfOZ; 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 n27-20020a05600c3b9b00b0039c1b89930bsor2250334wms.16.2022.06.07.02.48.29 for (Google Transport Security); Tue, 07 Jun 2022 02:48:29 -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:a1c:4e03:0:b0:39c:5bbc:e0d2 with SMTP id g3-20020a1c4e03000000b0039c5bbce0d2mr1050675wmh.184.1654595309817; Tue, 07 Jun 2022 02:48:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:29 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , "David S. Miller" , Eric Dumazet , Greg Kroah-Hartman , Jakub Kicinski , Jiri Slaby , Marc Kleine-Budde , Paolo Abeni , Sebastian Andrzej Siewior , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 10/13] can: slcan: move driver into separate sub directory Date: Tue, 7 Jun 2022 11:47:49 +0200 Message-Id: <20220607094752.1029295-11-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=SsiTzfOZ; 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: , This patch moves the slcan driver into a separate directory, a later patch will add more files. Signed-off-by: Dario Binacchi --- drivers/net/can/Makefile | 2 +- drivers/net/can/slcan/Makefile | 6 ++++++ drivers/net/can/{slcan.c => slcan/slcan-core.c} | 0 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 drivers/net/can/slcan/Makefile rename drivers/net/can/{slcan.c => slcan/slcan-core.c} (100%) diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile index 0af85983634c..210354df273c 100644 --- a/drivers/net/can/Makefile +++ b/drivers/net/can/Makefile @@ -5,7 +5,7 @@ obj-$(CONFIG_CAN_VCAN) += vcan.o obj-$(CONFIG_CAN_VXCAN) += vxcan.o -obj-$(CONFIG_CAN_SLCAN) += slcan.o +obj-$(CONFIG_CAN_SLCAN) += slcan/ obj-y += dev/ obj-y += rcar/ diff --git a/drivers/net/can/slcan/Makefile b/drivers/net/can/slcan/Makefile new file mode 100644 index 000000000000..2e84f7bf7617 --- /dev/null +++ b/drivers/net/can/slcan/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_CAN_SLCAN) += slcan.o + +slcan-objs := +slcan-objs += slcan-core.o diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan/slcan-core.c similarity index 100% rename from drivers/net/can/slcan.c rename to drivers/net/can/slcan/slcan-core.c From patchwork Tue Jun 7 09:47:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2024 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 7FB853F08A for ; Tue, 7 Jun 2022 11:48:33 +0200 (CEST) Received: by mail-wr1-f71.google.com with SMTP id d9-20020adfe849000000b00213375a746asf3206053wrn.18 for ; Tue, 07 Jun 2022 02:48:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595313; cv=pass; d=google.com; s=arc-20160816; b=NqFmqo7LAz17P2FvI47cEYBNWeZJ8/LgK7Q9OpqeQvJL6KvUOd/2NtxdlPVynmLax6 Ex2m9t0BSZ2WfbgtsjKsw/gj8AUOxmHxWrLpchCRQE2gOTKJPEjQlt5MdMw/t7obtvDq Sv0zViusqdpAdbTFfZxIODNqCV+fjQi7BApnVofiXwiWy7Pms4oDZjBTrp66nDXm1FaI Sr63KYZXotM8zqVCfPMKMl3rMxCiVAuxOmjZMPcX6Y4YPsrNswg/r4rokIbaGsJNT7l7 b0WPPTtawAIbK1cukhfloYb97diZbJZzoyoo+PqZyooKLoYCuXCFzHoAUbjNTcQwBOqQ pXzg== 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=U30IsEAfRAn2xuIBl/FW9hsurzj27LDbkTRGDlH0v/s=; b=SmzRNyY1ddbm/TKTjzNyNjFOr4kBYmaaZqM+t7Yxxnn3/qRvt5yh3j1q6ljUVz6Pgc 4dSHTA9m0NKbnKefoZe4DBjTKxX3Rg7koHqG4u7LNOn5mIL55p2y2DbuX1swCsINGtvd JAnZUQ3lJh59R1hsFXfKP2G7sTX7u4dqAIUaELuiKvgrkQyY0IItco/Xg0nrzaZG1dB9 qPvwHfyr+RwBQZvHIGZSadSY3fhx9baxWSlxzElSDPFi95EZnT9pUsE80PNjAHitgij2 TNQTAmlMmTX0ALHu8Zw/ddBrJKnsYBfp3nD/UddZwJjbvh2T14Ya8O7N86I/qf7tG7fp YJwA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Lk0XjM6q; 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=U30IsEAfRAn2xuIBl/FW9hsurzj27LDbkTRGDlH0v/s=; b=n19xbzlxm22+CPeUAhA5hPmqMonetN2SPSkHZI8XfxqekqKHlS7vnou4Si5sRfBSgi OO0N/GEGTFmgml/jQXa9zc7EKv94vUionwTSVXWXBIOLZGPQRv5oh6xeJ1EJOjfCSJ6q gLH1XFBH79sHogD1xoh2tRaqYkakmlTgq7FSs= 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=U30IsEAfRAn2xuIBl/FW9hsurzj27LDbkTRGDlH0v/s=; b=H4qfewTvJqsJdVw7KNZj3cPcWgh/nXiRmdj7nnyGPXDTNb0VdFUSj+G1rjTh9+SBhS s2m/DHe3LYGMkASTeKhIVqbKeSCYQgI6GUh3bMEXWjgt3uKp3FoojI72bX1y5M4AgHbJ eisH+uXwyjLJ8RxY127U4mfIrUOHCt3R2wBwMMPcXTPBrhfDOqbBEx2pxCCNTzf9rfV9 S5mZPoWMZDjtZPcz8B1OaD6RxDz81LTW02hIPzn1xcGOeGCqhGVVQ6iHJhfJonxa1e2Y q2rZi3lT0hoTtMyTvl97u7RJqEspwW6aSZjMdPxFIvVJyDSvqRS3xf76tYzLBEBeExNW aVuA== X-Gm-Message-State: AOAM531a8l1qtCrCTfdI3+fVRY8NBmTl9K4/cjsOEUO6tdKGpzWzK285 j5TPVKDXci3j8BSDvLhHd9WetXrX X-Google-Smtp-Source: ABdhPJxgceFQaL6EMlr1NT9qP66YjpofsX5G4tmJYRhJ3dJs1zoa182iOlJ2OyQvAME8KSC+aG15BQ== X-Received: by 2002:a5d:47cc:0:b0:20f:e246:d7d with SMTP id o12-20020a5d47cc000000b0020fe2460d7dmr27839323wrc.2.1654595313299; Tue, 07 Jun 2022 02:48:33 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6000:144a:b0:20f:f1e7:c71c with SMTP id v10-20020a056000144a00b0020ff1e7c71cls4153345wrx.0.gmail; Tue, 07 Jun 2022 02:48:32 -0700 (PDT) X-Received: by 2002:a5d:58c2:0:b0:210:2baa:52b8 with SMTP id o2-20020a5d58c2000000b002102baa52b8mr26745222wrf.20.1654595312280; Tue, 07 Jun 2022 02:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595312; cv=none; d=google.com; s=arc-20160816; b=U6jCfl3S4w6slbz8Jb+Zqa+ehf9WreBkjaWzXDePCstThFt5mW2h+2fMcD0m8zi24X jQQFklKpbnth1aZOvjJ06L52JIIQA+Ko974rPV+wMRje4fgCeD85y2Y2cFYOA+qfx0hB 7cHY/WFX6ONa3itgH+huZW4zaOFCUvadn7wY2tj7ELLHwOHimFDlv0rJlgv4pwm7ellL 9h4bEEktbS8YVFCZAbzyGfnxRElHQ7lvg+mnU9imFpMrREu/lIARY8uygHBRt09dtFog y+RongkwfzzucuIPNjlkAhnDIGGq+XqOviexXIiSOqc/15FqxrpasVV49f3lnUQhrAoT UPTw== 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=sRVCV675gnSBUjquD4ODK0/V3BjHMt/6L2aovdLYzzw=; b=elMFDAjq9BuPG7BrHvUMoDUOjisgm+EuLXYCpwsRe+DJfhbdZDctswLaci/WRj1Et6 O6H0NhuCPVnOJBJFeyTlq6GY4YJ4JQVWnEQQW/b1I0LArxIh01JEi7egxRlZMgzQY25G JC/+rHeGfY0OMx3862kLA0jjE1XHKvyyLnR8sAufKs70hK/Nmlp89VgOTPA3EWaSFGca uoa9kiPD+AK18EH+I7go2dDxaZCOiI5BN4IW43wNNkdpl6xG9cDSHmBiiri18+vW3oWm rO+kDk5KQyuuDMdl7Z8AWtLml0C5bJH4jd6wXoclLcWXAOflC4tUR3Hi2iXbWEaKj0+O Hiuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Lk0XjM6q; 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 a1-20020a05600c348100b003970658cad3sor6746014wmq.6.2022.06.07.02.48.32 for (Google Transport Security); Tue, 07 Jun 2022 02:48:32 -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:600c:4f85:b0:398:54fc:ea9b with SMTP id n5-20020a05600c4f8500b0039854fcea9bmr27579229wmq.17.1654595312019; Tue, 07 Jun 2022 02:48:32 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:31 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , "David S. Miller" , Eric Dumazet , Greg Kroah-Hartman , Jakub Kicinski , Jiri Slaby , Marc Kleine-Budde , Paolo Abeni , Sebastian Andrzej Siewior , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 11/13] can: slcan: add ethtool support to reset adapter errors Date: Tue, 7 Jun 2022 11:47:50 +0200 Message-Id: <20220607094752.1029295-12-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=Lk0XjM6q; 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: , This patch adds a private flag to the slcan driver to switch the "err-rst-on-open" setting on and off. "err-rst-on-open" on - Reset error states on opening command "err-rst-on-open" off - Don't reset error states on opening command (default) The setting can only be changed if the interface is down: ip link set dev can0 down ethtool --set-priv-flags can0 err-rst-on-open {off|on} ip link set dev can0 up Signed-off-by: Dario Binacchi --- drivers/net/can/slcan/Makefile | 1 + drivers/net/can/slcan/slcan-core.c | 36 +++++++++++++++ drivers/net/can/slcan/slcan-ethtool.c | 65 +++++++++++++++++++++++++++ drivers/net/can/slcan/slcan.h | 18 ++++++++ 4 files changed, 120 insertions(+) create mode 100644 drivers/net/can/slcan/slcan-ethtool.c create mode 100644 drivers/net/can/slcan/slcan.h diff --git a/drivers/net/can/slcan/Makefile b/drivers/net/can/slcan/Makefile index 2e84f7bf7617..8a88e484ee21 100644 --- a/drivers/net/can/slcan/Makefile +++ b/drivers/net/can/slcan/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_CAN_SLCAN) += slcan.o slcan-objs := slcan-objs += slcan-core.o +slcan-objs += slcan-ethtool.o diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c index d63d270d21da..b813a59534a3 100644 --- a/drivers/net/can/slcan/slcan-core.c +++ b/drivers/net/can/slcan/slcan-core.c @@ -57,6 +57,8 @@ #include #include +#include "slcan.h" + MODULE_ALIAS_LDISC(N_SLCAN); MODULE_DESCRIPTION("serial line CAN interface"); MODULE_LICENSE("GPL"); @@ -98,6 +100,8 @@ struct slcan { #define SLF_INUSE 0 /* Channel in use */ #define SLF_ERROR 1 /* Parity, etc. error */ #define SLF_XCMD 2 /* Command transmission */ + unsigned long cmd_flags; /* Command flags */ +#define CF_ERR_RST 0 /* Reset errors on open */ wait_queue_head_t xcmd_wait; /* Wait queue for commands */ /* transmission */ }; @@ -117,6 +121,28 @@ static const struct can_bittiming_const slcan_bittiming_const = { .brp_inc = 1, }; +bool slcan_err_rst_on_open(struct net_device *ndev) +{ + struct slcan *sl = netdev_priv(ndev); + + return !!test_bit(CF_ERR_RST, &sl->cmd_flags); +} + +int slcan_enable_err_rst_on_open(struct net_device *ndev, bool on) +{ + struct slcan *sl = netdev_priv(ndev); + + if (netif_running(ndev)) + return -EBUSY; + + if (on) + set_bit(CF_ERR_RST, &sl->cmd_flags); + else + clear_bit(CF_ERR_RST, &sl->cmd_flags); + + return 0; +} + /************************************************************************ * SLCAN ENCAPSULATION FORMAT * ************************************************************************/ @@ -483,6 +509,15 @@ static int slc_open(struct net_device *dev) if (sl->can.bittiming.bitrate == 0) { sl->can.bittiming.bitrate = -1UL; } else { + if (test_bit(CF_ERR_RST, &sl->cmd_flags)) { + err = slcan_transmit_cmd(sl, "F\r"); + if (err) { + netdev_err(sl->dev, + "failed to send error command 'F\\r'\n"); + return err; + } + } + err = slcan_transmit_cmd(sl, "O\r"); if (err) { netdev_err(dev, "failed to send open command 'O\\r'\n"); @@ -645,6 +680,7 @@ static struct slcan *slc_alloc(void) snprintf(dev->name, sizeof(dev->name), "slcan%d", i); dev->netdev_ops = &slc_netdev_ops; + slcan_set_ethtool_ops(dev); sl = netdev_priv(dev); /* Initialize channel control data */ diff --git a/drivers/net/can/slcan/slcan-ethtool.c b/drivers/net/can/slcan/slcan-ethtool.c new file mode 100644 index 000000000000..bf0afdc4e49d --- /dev/null +++ b/drivers/net/can/slcan/slcan-ethtool.c @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* Copyright (c) 2022 Amarula Solutions, Dario Binacchi + * + */ + +#include +#include +#include +#include +#include + +#include "slcan.h" + +static const char slcan_priv_flags_strings[][ETH_GSTRING_LEN] = { +#define SLCAN_PRIV_FLAGS_ERR_RST_ON_OPEN BIT(0) + "err-rst-on-open", +}; + +static void slcan_get_strings(struct net_device *ndev, u32 stringset, u8 *data) +{ + switch (stringset) { + case ETH_SS_PRIV_FLAGS: + memcpy(data, slcan_priv_flags_strings, + sizeof(slcan_priv_flags_strings)); + } +} + +static u32 slcan_get_priv_flags(struct net_device *ndev) +{ + u32 flags = 0; + + if (slcan_err_rst_on_open(ndev)) + flags |= SLCAN_PRIV_FLAGS_ERR_RST_ON_OPEN; + + return flags; +} + +static int slcan_set_priv_flags(struct net_device *ndev, u32 flags) +{ + bool err_rst_op_open = !!(flags & SLCAN_PRIV_FLAGS_ERR_RST_ON_OPEN); + + return slcan_enable_err_rst_on_open(ndev, err_rst_op_open); +} + +static int slcan_get_sset_count(struct net_device *netdev, int sset) +{ + switch (sset) { + case ETH_SS_PRIV_FLAGS: + return ARRAY_SIZE(slcan_priv_flags_strings); + default: + return -EOPNOTSUPP; + } +} + +static const struct ethtool_ops slcan_ethtool_ops = { + .get_strings = slcan_get_strings, + .get_priv_flags = slcan_get_priv_flags, + .set_priv_flags = slcan_set_priv_flags, + .get_sset_count = slcan_get_sset_count, +}; + +void slcan_set_ethtool_ops(struct net_device *netdev) +{ + netdev->ethtool_ops = &slcan_ethtool_ops; +} diff --git a/drivers/net/can/slcan/slcan.h b/drivers/net/can/slcan/slcan.h new file mode 100644 index 000000000000..d463c8d99e22 --- /dev/null +++ b/drivers/net/can/slcan/slcan.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 + * slcan.h - serial line CAN interface driver + * + * Copyright (C) Laurence Culhane + * Copyright (C) Fred N. van Kempen + * Copyright (C) Oliver Hartkopp + * Copyright (C) 2022 Amarula Solutions, Dario Binacchi + * + */ + +#ifndef _SLCAN_H +#define _SLCAN_H + +bool slcan_err_rst_on_open(struct net_device *ndev); +int slcan_enable_err_rst_on_open(struct net_device *ndev, bool on); +void slcan_set_ethtool_ops(struct net_device *ndev); + +#endif /* _SLCAN_H */ From patchwork Tue Jun 7 09:47:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2025 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 90AA03F08A for ; Tue, 7 Jun 2022 11:48:35 +0200 (CEST) Received: by mail-wm1-f70.google.com with SMTP id l34-20020a05600c1d2200b003973a50c1e4sf8626083wms.2 for ; Tue, 07 Jun 2022 02:48:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595315; cv=pass; d=google.com; s=arc-20160816; b=JwFH3vYph2IBN0b14o1oitU/DBGU2UMfcBwGkb07iKopmDzZ/TlpT+eTmLWEzeUty6 6WlLCpcCox07ThDiXp1VVBH0xr5JlUxpYln6qywKYmO30xtAYpk2X+Atv2ZV0MMvOQfC LyDbz8TPpMYkfhsWkVrczupxaIhhag0BFteD8mQkzceGR4maovkXLu3VoVRGOs5mY4pZ FIV2oFj4Hc9mWgApACJVpFVQ6ISmEm86heN1L/ZclfxX5jI8M8+lPrdFrZE1hShcm+kb CSCXjOgAyfyPWT2dZoJk9sFrj1nssomYD7EqfEBxmpBPD0ZsYIRBm9Ow22rtkYvdyX9g xZ8g== 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=BhH6RWwxBUzu2YEe4dsnkiUrgxCLwwypFCu76afHHOg=; b=OZ8avXD/vVGw4B22sTvCV7ypaDR4dx9rFs1puPaK5TtsnHCg+XOJYBSV195XKlAGsa N2JneUIuSZsOZnWbp9Op1tocktg0gZm8YOJCLvrfPCiO40P9aAPGW1lzBlH6g2vgxqO7 xQ2e+eLV6LpX7Ck1/6avujgGd7BrDYgwmIwvW75hx3Qr6wUvjfY2OJFAEe0O5qwTlutJ ns/vcSLUrtWs+I1OpfjnjC/h1rz1XszMvHnbmTAcsYFDKpNz7GvrwOiXaYNccxcPmLz3 7Y7iCbn3872cvWmjuwR5UEaVFGO3aLDc0RZtH6yYurAC66mprTLGbx7VrcAIY73JUfVd R7PA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HMeORKBx; 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=BhH6RWwxBUzu2YEe4dsnkiUrgxCLwwypFCu76afHHOg=; b=hCy9zn+gF3vMkrjHpK+dOeGEIpdr535PpNwHaKE8u8XAN2G9nBOTdaRiNg/3QmD69O gRVUACriZ0jpp0IlQ3k193kqFmtFOc8X3WOH/akebdA6mLnlO+ciQauFGpbjPezqKaBb Q4vKlXJFloMEyZyQvGAO8a8SOgJYqA8iDH4rc= 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=BhH6RWwxBUzu2YEe4dsnkiUrgxCLwwypFCu76afHHOg=; b=z//HY2bibaP2KQkpi56MJb8jcVOte9XgvITV+cjB4N7CEwNgfqzOFyioYzKQZ2Aw7n t04R3wSWCIqHBlvEA8WACK+4mdr9s5qwprgIbHIubnM5c67ky8WZsEViHY02XSLMvcJB jTmXRbWvIWSfpX1LKLwchsTba8hprzWFCHpQ9b9dNIT/0d5YW1RRJ/hmzTrAZizJhDl4 aHusHSJp65klSyEi0WReko1YHryS1j3sjzQlBl5JOv38z/gxtyLbhUqy+SgBZkONbM+i pmZxiFPfQ/ncCw5Un9pyfY9TTrqqNNRe2tHdXXadiFw1Y3KVsjh87ZTr6PZIwupP8bYn l1zA== X-Gm-Message-State: AOAM531/Zc60HCVFx6fE9vnx22KYbDqUNSR8S3vVlxKmBA+sk5ITZ1J5 XSZx+KXvMBHeqxYvrSg8p/CRc9CV X-Google-Smtp-Source: ABdhPJyZ/9gLreA0fLnVCwMGAP9+TXLXHHyp3C8ekc4mlVZQj2WCoQ/bo5prvl1StsbhMG6N3kEkiQ== X-Received: by 2002:a05:6000:1e04:b0:217:88ff:eb86 with SMTP id bj4-20020a0560001e0400b0021788ffeb86mr12687910wrb.351.1654595315365; Tue, 07 Jun 2022 02:48:35 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:3d8c:b0:39c:5b80:3b5c with SMTP id bi12-20020a05600c3d8c00b0039c5b803b5cls393890wmb.2.gmail; Tue, 07 Jun 2022 02:48:34 -0700 (PDT) X-Received: by 2002:a05:600c:3386:b0:39c:5b81:af9e with SMTP id o6-20020a05600c338600b0039c5b81af9emr1206532wmp.2.1654595314315; Tue, 07 Jun 2022 02:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595314; cv=none; d=google.com; s=arc-20160816; b=oP6Mp/S3y+Iu7IInOfqI0a9OMFZmmmKN94s7t7IpX6W5Qe7HyxycJNB1AXxp8YuUJM 5hrIe+8/9bVrOlxtNSjqcls9zfXHfl100OIDilDZifGi1hR2Q8X5B+3RoQJ37vWO8DQv UcrWiuq15dmbWHPa/3mhnIAHn/vN0/z6o1h3is0dqqB7XjwLhKLX1Ag1uLJvr7XifCvw 6PL15sgxUCGc7dYxaYXO8a0K1lEgGPbStBZ4idwfMo+OMVl08zrOlAChGfJWhxE0twig g7BB751NDz0+H4EkT/yS7+pCtBHFoj6XhpHQdtN7d/wAZ+xAA9usSSprC4phYAfcUx58 CwYA== 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=2VLfBpv9snTnPtrFeblfPn0318JEYJPp1U8Dhg0IAiM=; b=EhLAOyGqU3r8724W+RnQadgZmjfNkhGBHidpbJw+P5A3WmXXwL3NXOHOfaCMGcJ0bU xRmmSPPGkmkqERJ3WwjJ8xyhLpVHzz0n1OxJIdZSQFrQMe2Eec3hwYdn3RhR+Vy+c/5Z PAq1t+LxGUgR+u5qoe/zDrdtLefKMbbC0glzabKpfwaBG0Qz3eWvOUDQsaW04Abkkiwh gipFbvRyCaiJCYPhSX2+paAQXFmvHI+SKpv2SyNS24JCl66AWdkvjurKM48i1jUx8zCo lTNWO+x8ZR9t+ApReV5Ncn9SFYxpBxk47QDcvZyRlyxVizkkMT0PJI5/XTuKVdA1bvns 2W2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HMeORKBx; 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 bd7-20020a05600c1f0700b0039c4a2cf724sor2127209wmb.29.2022.06.07.02.48.34 for (Google Transport Security); Tue, 07 Jun 2022 02:48:34 -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:600c:3d05:b0:398:a78b:6a30 with SMTP id bh5-20020a05600c3d0500b00398a78b6a30mr27816891wmb.175.1654595314137; Tue, 07 Jun 2022 02:48:34 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:33 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , "David S. Miller" , Eric Dumazet , Greg Kroah-Hartman , Jakub Kicinski , Jiri Slaby , Marc Kleine-Budde , Paolo Abeni , Sebastian Andrzej Siewior , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 12/13] can: slcan: extend the protocol with error info Date: Tue, 7 Jun 2022 11:47:51 +0200 Message-Id: <20220607094752.1029295-13-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=HMeORKBx; 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: , It extends the protocol to receive the adapter CAN communication errors and forward them to the netdev upper levels. Signed-off-by: Dario Binacchi --- drivers/net/can/slcan/slcan-core.c | 104 ++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c index b813a59534a3..02e7c14de45c 100644 --- a/drivers/net/can/slcan/slcan-core.c +++ b/drivers/net/can/slcan/slcan-core.c @@ -182,8 +182,92 @@ int slcan_enable_err_rst_on_open(struct net_device *ndev, bool on) * STANDARD SLCAN DECAPSULATION * ************************************************************************/ +static void slc_bump_err(struct slcan *sl) +{ + struct net_device *dev = sl->dev; + struct sk_buff *skb; + struct can_frame *cf; + char *cmd = sl->rbuff; + bool rx_errors = false, tx_errors = false; + int i, len; + + if (*cmd != 'e') + return; + + cmd += SLC_CMD_LEN; + /* get len from sanitized ASCII value */ + len = *cmd++; + if (len >= '0' && len < '9') + len -= '0'; + else + return; + + skb = alloc_can_err_skb(dev, &cf); + if (unlikely(!skb)) + return; + + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; + for (i = 0; i < len; i++, cmd++) { + switch (*cmd) { + case 'a': + netdev_dbg(dev, "ACK error\n"); + cf->can_id |= CAN_ERR_ACK; + cf->data[3] = CAN_ERR_PROT_LOC_ACK; + tx_errors = true; + break; + case 'b': + netdev_dbg(dev, "Bit0 error\n"); + cf->data[2] |= CAN_ERR_PROT_BIT0; + tx_errors = true; + break; + case 'B': + netdev_dbg(dev, "Bit1 error\n"); + cf->data[2] |= CAN_ERR_PROT_BIT1; + tx_errors = true; + break; + case 'c': + netdev_dbg(dev, "CRC error\n"); + cf->data[2] |= CAN_ERR_PROT_BIT; + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + rx_errors = true; + break; + case 'f': + netdev_dbg(dev, "Form Error\n"); + cf->data[2] |= CAN_ERR_PROT_FORM; + rx_errors = true; + break; + case 'o': + netdev_dbg(dev, "Rx overrun error\n"); + cf->can_id |= CAN_ERR_CRTL; + cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; + dev->stats.rx_over_errors++; + dev->stats.rx_errors++; + break; + case 'O': + netdev_dbg(dev, "Tx overrun error\n"); + cf->can_id |= CAN_ERR_CRTL; + cf->data[1] = CAN_ERR_CRTL_TX_OVERFLOW; + dev->stats.tx_errors++; + break; + case 's': + netdev_dbg(dev, "Stuff error\n"); + cf->data[2] |= CAN_ERR_PROT_STUFF; + rx_errors = true; + break; + } + } + + if (rx_errors) + dev->stats.rx_errors++; + + if (tx_errors) + dev->stats.tx_errors++; + + netif_rx(skb); +} + /* Send one completely decapsulated can_frame to the network layer */ -static void slc_bump(struct slcan *sl) +static void slc_bump_frame(struct slcan *sl) { struct sk_buff *skb; struct can_frame cf, *scf; @@ -257,6 +341,24 @@ static void slc_bump(struct slcan *sl) netif_rx(skb); } +static void slc_bump(struct slcan *sl) +{ + switch (sl->rbuff[0]) { + case 'r': + fallthrough; + case 't': + fallthrough; + case 'R': + fallthrough; + case 'T': + return slc_bump_frame(sl); + case 'e': + return slc_bump_err(sl); + default: + return; + } +} + /* parse tty input stream */ static void slcan_unesc(struct slcan *sl, unsigned char s) { From patchwork Tue Jun 7 09:47:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2026 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 9B45A3F08A for ; Tue, 7 Jun 2022 11:48:37 +0200 (CEST) Received: by mail-wr1-f69.google.com with SMTP id p8-20020a5d4588000000b0021033f1f79asf3699489wrq.5 for ; Tue, 07 Jun 2022 02:48:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595317; cv=pass; d=google.com; s=arc-20160816; b=ewi1yBTw47oSMx6XpCK7nVe/zGg2EjcUu+bi3XVtLRlwjPvfjb2QMJrRmpGg+/nNP8 TXuMawCMV2DEiuM7JPEsKAqP6o7NLGVCkkfMwxgK+mm01OhKvdcMrtriM8s9PPkbQaox VCohDquiXbY29JBu745UAdFQ+hYSYN9Tqt0A8OAXsyRZeQjzJ6dtwhjGHa4RF/TOGKa3 JV66GsynSyZjSWrG/8CRmaFd3vUa1yD3WB8NFTxBgnNZSSiEIRpWxOovLcykm7BmUDtD Za6+PUESVzim5jqXChEDdSWiyula5pivOg7rjiPP7gzpY5VntgioyXCsmXsvEdz1ChMe 2uFQ== 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=W5BMzNRTTfqwBQe8iFjoq0xhQJUREc01ePItxoKW8kY=; b=aLkl5Cpto+T6fIS+840LZIYN6aDQ7ryxCUFzsr2U7yl0TeFQorlZeT926uf3eLJvVc H0mC5pHGKxKWKm/K/yNnaIyBXtIy9dllRrW4rUeAXhqQ50RujQkgZFw0X6rZLDjvA21q cgY3a12iWpvhLJDrIJgdWiYMDHU2iy1L3ZGzjI0N9oDWlVjicoO6ApBFrICu5O86IsXD ICQRbg3xrsoe6F6i1VeoTPa0lx/7+hiBGefHWRAN+YVwMTy/6STsoEFPTmunpDOOLcNV AYiT6LGErnnjkHjI0Ve5wx+vdjTZKMuU2xFmjx9vqU/6DxBIahmr9Y/Ri2cFeXviXI2n 2zBQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=rfbDySEI; 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=W5BMzNRTTfqwBQe8iFjoq0xhQJUREc01ePItxoKW8kY=; b=ZgzapmaOaRr9yuUlKA9kyBlY9x8lHKfVUHLKliyHQ4uV8c0OeS2b0f8Yj4YYSpGuJO gVxcdeC8ltleZEzwhOdHSCfoz9n6MwljH8Oh9NpNfMaWV4AwYwaf5b4EGY5hXjO31pgd T+pIdq20de+6o4wQQdHuiCTz8ER3cufN6Y9Jw= 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=W5BMzNRTTfqwBQe8iFjoq0xhQJUREc01ePItxoKW8kY=; b=soH7/klCwu/E6unIjoP7uTgufSRK8MwjF1ZUAGkjyf7SU32rxiVGSOV89tWUCjKTiH /TZMR4Hr3Tu6aWa5lyEamgUSpjDl0OkRcXj8QtmySX0LzwWwWCsMBKTY+IYE0xJXF2RT 2tCJKRCDH7a+03CYoBXkG+ex6pZJ5S0RRVm4Z4JYQnONyLon4mQ9pUuJtDQu9WT1CbgZ CYT3NmE14ThDbZajO0puEXsSPJ/r30TRML7RsyWx8MDb/+wqBjkKG00n+RM2mhyVBJJl UEZowySfY+lcK9iYKjFj3MkxjaToYe7O8XtzUUpClFbKPGF4TL1ptnYqbw45yOxzT/1z ziVg== X-Gm-Message-State: AOAM532NzReHS/ij7u8B7UeBZmqh8yuaE/z0tV6H8qTIXnqnrC3eZC12 LwwGwATCoNvFAWDoorahIOBD5EiA X-Google-Smtp-Source: ABdhPJybxYZDKEDt8/SexA8sOrOrydhMY/fBq6USqHGRhbM0HHmM/RuqjjulitOjgqYqDdNgOkQUyg== X-Received: by 2002:a05:600c:4e91:b0:397:8870:a3e9 with SMTP id f17-20020a05600c4e9100b003978870a3e9mr54368496wmq.141.1654595317371; Tue, 07 Jun 2022 02:48:37 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:3d8c:b0:39c:5b80:3b5c with SMTP id bi12-20020a05600c3d8c00b0039c5b803b5cls393931wmb.2.gmail; Tue, 07 Jun 2022 02:48:36 -0700 (PDT) X-Received: by 2002:a05:600c:4e14:b0:397:4f6e:9ce2 with SMTP id b20-20020a05600c4e1400b003974f6e9ce2mr27934928wmq.186.1654595316414; Tue, 07 Jun 2022 02:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595316; cv=none; d=google.com; s=arc-20160816; b=SqoX29JTTCUigEJnld6fv8qnbSsvdhIL9LZArTnVF5Lg7oWYgbLOwi5HUg873FklZ0 eEMDYr0Zb5A403kw+DVJeBb+z8rllOm8eY0V55FXSwJpSvD84HyJ/vVyOWRkUmIQy0Eh u1Q1gaoxJyEsILEByaDSFftidlTDVceAUH0Cx/g2Zh/sKc4IoHZDn2cyzRw5GyK6FPP3 MM2PtWagV2zShdeOBF2qAsQ4e3+iQsnyFdMuMKD0s5bQU2OIkw0zLermwyaN0fYiv15E 3DADUxmOmtxJOifqx3EOlaCkWGgm3HDCJx3lVFtwwKQp6Pmnx14u0j3pcBmyWjlGA5ox V5dw== 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=52GScXsc3r0EaHze1UuoV0GZvaNkVo4y3j7sOuEIJJg=; b=fR5GB9DUZBHRr085/xuosPoT1+sn14agau5R5s82375JdPKo9B2azlj2Ajje67n/QE BceXiY/G7YfPRC84USDgCSugIFqPiy4e2RXp3NTdDkcFQ+2thD5gDXieQPO/TKxVQ0NC sSNui9LJJrVGLmcfkPgEQy1q1DO6uOkWGIpLIrXILhuAP87LaZ+iEoWAzRZVDWy2QUId f4VofIsx1y2QE021e5PqF4HJToHQajPQyvVZjxMVlaVq+myA7aPDpYHLP79WTNGHB5cm 4njeiY3uyZQDKQqmwY9k0kvECmSuuRymv1EnhXsmsEk7ov1Qbv6Ncdy0ximE21ZBkZbT KljA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=rfbDySEI; 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 j8-20020a5d4528000000b0020fc62a0aedsor9817494wra.47.2022.06.07.02.48.36 for (Google Transport Security); Tue, 07 Jun 2022 02:48: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:a05:6000:1acc:b0:20f:e35e:450 with SMTP id i12-20020a0560001acc00b0020fe35e0450mr25901221wry.531.1654595316197; Tue, 07 Jun 2022 02:48:36 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:35 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , "David S. Miller" , Eric Dumazet , Greg Kroah-Hartman , Jakub Kicinski , Jiri Slaby , Marc Kleine-Budde , Paolo Abeni , Sebastian Andrzej Siewior , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 13/13] can: slcan: extend the protocol with CAN state info Date: Tue, 7 Jun 2022 11:47:52 +0200 Message-Id: <20220607094752.1029295-14-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=rfbDySEI; 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: , It extends the protocol to receive the adapter CAN state changes (warning, busoff, etc.) and forward them to the netdev upper levels. Signed-off-by: Dario Binacchi --- drivers/net/can/slcan/slcan-core.c | 65 ++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c index 02e7c14de45c..ab4c08a7dc81 100644 --- a/drivers/net/can/slcan/slcan-core.c +++ b/drivers/net/can/slcan/slcan-core.c @@ -78,6 +78,9 @@ MODULE_PARM_DESC(maxdev, "Maximum number of slcan interfaces"); #define SLC_CMD_LEN 1 #define SLC_SFF_ID_LEN 3 #define SLC_EFF_ID_LEN 8 +#define SLC_STATE_LEN 1 +#define SLC_STATE_BE_RXCNT_LEN 3 +#define SLC_STATE_BE_TXCNT_LEN 3 struct slcan { struct can_priv can; @@ -182,6 +185,66 @@ int slcan_enable_err_rst_on_open(struct net_device *ndev, bool on) * STANDARD SLCAN DECAPSULATION * ************************************************************************/ +static void slc_bump_state(struct slcan *sl) +{ + struct net_device *dev = sl->dev; + struct sk_buff *skb; + struct can_frame *cf; + char *cmd = sl->rbuff; + u32 rxerr, txerr; + enum can_state state, rx_state, tx_state; + + if (*cmd != 's') + return; + + cmd += SLC_CMD_LEN; + switch (*cmd) { + case 'a': + state = CAN_STATE_ERROR_ACTIVE; + break; + case 'w': + state = CAN_STATE_ERROR_WARNING; + break; + case 'p': + state = CAN_STATE_ERROR_PASSIVE; + break; + case 'f': + state = CAN_STATE_BUS_OFF; + break; + default: + return; + } + + if (state == sl->can.state) + return; + + cmd += SLC_STATE_BE_RXCNT_LEN + 1; + cmd[SLC_STATE_BE_TXCNT_LEN] = 0; + if (kstrtou32(cmd, 10, &txerr)) + return; + + *cmd = 0; + cmd -= SLC_STATE_BE_RXCNT_LEN; + if (kstrtou32(cmd, 10, &rxerr)) + return; + + skb = alloc_can_err_skb(dev, &cf); + if (unlikely(!skb)) + return; + + cf->data[6] = txerr; + cf->data[7] = rxerr; + + tx_state = txerr >= rxerr ? state : 0; + rx_state = txerr <= rxerr ? state : 0; + can_change_state(dev, cf, tx_state, rx_state); + + if (state == CAN_STATE_BUS_OFF) + can_bus_off(dev); + + netif_rx(skb); +} + static void slc_bump_err(struct slcan *sl) { struct net_device *dev = sl->dev; @@ -354,6 +417,8 @@ static void slc_bump(struct slcan *sl) return slc_bump_frame(sl); case 'e': return slc_bump_err(sl); + case 's': + return slc_bump_state(sl); default: return; }