From patchwork Thu Jun 2 16:04:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1986 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 1055D3F06D for ; Thu, 2 Jun 2022 18:04:42 +0200 (CEST) Received: by mail-ej1-f69.google.com with SMTP id n2-20020a170906724200b006fed87ccbb8sf2709561ejk.7 for ; Thu, 02 Jun 2022 09:04:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185881; cv=pass; d=google.com; s=arc-20160816; b=pLs+r0+HCfCs3Psb7l1DTW/ILA8ck4Fv3z1nMkwVds7YMFfQP9x3pa9X99DgXFl/jt Un0QyK/YyqWmKV0i48HrW29XVa22LjEadv59FeksEkUOVn3o2DgeR8ntRnvgFql10L60 NXHxMm86J4U+f8VXNaa95iu7ejn27+wKmoUMg19XEejDxQdGLUaqQNkPcFSoXhdEvC28 rNpJbXFKBqc8hZAx+BSjNbOU1j5FexZd/aSgbzW0TWKOQKGJTQT0z/N2lC2zNlOQ4Tmv RECoTtI/RDsHyqnOmpf+vRkIgYW+b4pgjSO7f5C/tqMdo98jNnrZKKYvcVrxD5kfaxA+ kuGg== 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=yctEy2Nq3M85nscL7bqITb5xeA3Kbd7u0kNVkdTNk3g=; b=BXe2Csrx7+YQw5iTs8W4fx6z3yUuHJzNqGnAB+rOVkIv0p1ryRThQtcu6PmF+yIl5b Qy+eqx0x39FVvbiCuEDU2ssQjePdbNUZO8VO7JDbKNDRi8amDICzpE268664yydehpSq r3JejeF10jdqP33zJcOMWi/4/roF8BSmzZvjBmhF1Bkn7JCswZ7753rY+nKkfym/usgI s3ImMBzXPh40ncpWWnYWfbOi2BYm5Jm67R4acVb/v2U9GGWqh30mzHjELnagyWu4z8ky PMmGlvPmVPs1mHOkWbKW7KqQyEZHVPKiTUomdmMAe6Dfj/KTLsRQPljR5RkHGd8J3FyT Vmcg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=QcjxGHdf; 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=yctEy2Nq3M85nscL7bqITb5xeA3Kbd7u0kNVkdTNk3g=; b=Ge1tLCaV5HgjeKw+nD5IYTV7SIaMN/Q6fFn4uN5ZvQsQAYpGQeEB7mkkJ7d1657kqZ 6rsqeP7oUaiAcknLpP1Z7yvToepGztpa0vC2r155PvcVHKELVQZ5TZz21D8txpPEiNBf W3Q/bOFYSUV5JCY2Xwihol+RiAMbTuZeip0bw= 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=yctEy2Nq3M85nscL7bqITb5xeA3Kbd7u0kNVkdTNk3g=; b=lW+s5Rs9/VglwFz7cFFsmw2qeVV473urHNKIOYKYybHh2yQXfs8uqnVjp8gwshgpRf F1RVuB9qXpqFZKCxf13wqAnN0mLd/mKqm4MF/nIAia3+hX+CQD9Ifvh9whbtluZOEIIz KRJKabr/g62dNCPEYjeffRjUoXD+/90Ar5AwtOxmhATb7lsBs+RAJ1RPWuQ8Qraf8xYL am4xL+lNcnEGrm/NmClYBDc8uksRvQyhTIf8WfeNRoCk5k42P6dZVGgfRP2tQzK75M4J /CYisiXt+T8BpSyYeGUOMj1fAvC9f0pGlV50fPBX2195roA+kpSy26bfoIEIT2SfKKXs eh/A== X-Gm-Message-State: AOAM533vz5BriprMupdROajPybXYMI1q2uctJdXI9PWFi53wDh2fN2hP oz9OC8kdW7txnqMQh1kcpVMwQQcd X-Google-Smtp-Source: ABdhPJxD6bQc55gC8gQUru9TYwwatw4sC5TXD343ngf2nTVLbzOCHGvyxDkoHdHB6Az9WXGpPlcJqg== X-Received: by 2002:a17:906:5055:b0:6ff:1dfb:1e2c with SMTP id e21-20020a170906505500b006ff1dfb1e2cmr4839597ejk.200.1654185881892; Thu, 02 Jun 2022 09:04:41 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:294a:b0:42b:31b9:2087 with SMTP id ed10-20020a056402294a00b0042b31b92087ls2362006edb.2.gmail; Thu, 02 Jun 2022 09:04:40 -0700 (PDT) X-Received: by 2002:a05:6402:f:b0:42e:561:a1c0 with SMTP id d15-20020a056402000f00b0042e0561a1c0mr6215659edu.309.1654185880755; Thu, 02 Jun 2022 09:04:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185880; cv=none; d=google.com; s=arc-20160816; b=pQapAg+s172HXSfI8l7xkwasw4I3EKivGYAzYfOBOL7zaJBCwrsgmgKbtPvGPABMZH bqlNSHBbn2Ka/kcOpchgP3Kg9kGCKCD7H7sb+8D1fwGCTHBfp9OsahBkd2G2z3RUhdMv OJeyeBVjtyP6WwNDcTQpgAZS1mKqdiLken9vC7F0KnL1KAcG0klDZrKrd6ZbCAJCTP6a lFBp6azgjvCq+yMZckI5s8bu3IbNhymSS4ou2q/SmsjlapRp2BBafNu+qFaDHCnBOyVa miI+bCDXyrPPIlLsgcNQ9GBr0bHXT2vi+8/eCtvYvXOrbUHJVDq5uQq9lxe/nyNY7YX/ iipg== 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=bs1pDxoqSwxHo6PhPuLte63s3qeUlbVxYb0CgUg+DU4=; b=j9buHaVlsNoKIJ6ZO+9cdA3+DXZq1tS6IyVq08NWQ1ioHWknIYewu7zSMqQuwpeWWk 6jq1TFy4WA8D7m65vliaXSZeWRl6A0kgZhhkOUnzrz7mksgHsSiUFf4eZEzrn1IUzfaj 2s5+QBacvhnEHHT0Nk6MHNM3SyuA5U1HI42d5ITN75aKNW7ypMMA755DHrJyaQe61v8t 7niLsgdwUGDVLYQxNThWSHCIfe/+VVn+bT+jtK34HsAOPD2amCpPRgJqGNo6Os3Kh1TU n6M3x6dHEZ0w3e0f+D6nMyPB89X9ZQoysGH1ivdsWWq/G2Mhy1a8xOUp480ghbEySgrz 8w9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=QcjxGHdf; 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 k1-20020a170906a38100b006f490429c54sor2558543ejz.124.2022.06.02.09.04.40 for (Google Transport Security); Thu, 02 Jun 2022 09:04:40 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:1621:b0:6fe:fc8f:21f1 with SMTP id hb33-20020a170907162100b006fefc8f21f1mr4984906ejc.359.1654185879526; Thu, 02 Jun 2022 09:04:39 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:39 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 01/13] can: slcan: use the BIT() helper Date: Thu, 2 Jun 2022 18:04:22 +0200 Message-Id: <20220602160434.225417-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=QcjxGHdf; 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 --- (no changes since v1) 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 Thu Jun 2 16:04:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1988 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 6597E3F1D5 for ; Thu, 2 Jun 2022 18:04:43 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id k21-20020aa7d2d5000000b0042dcac48313sf3787553edr.8 for ; Thu, 02 Jun 2022 09:04:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185883; cv=pass; d=google.com; s=arc-20160816; b=jC13kLdg3X/DLtpse31eyvrgc/fPxOB5oR/a4pz5fFEXqbe8+1mxlrdpHlh2z+xmSs XSibs6dnUHneB6pACpuFbcI9A9AJ/w0PTvlgdlezYC7GffAI9ChjardW1x+mxgGsRQC3 JdAP5KfRfS4ig3csecOxIHrENER97eRVEQmf/8RLaDThtg5Ysr39hwrF2YByLWHG8yRs 3N5bJmUfQmZMv60Y79vq0mdXArHZTajXqSV6SIv3NPfFfkEdEP51sVRFjnbiyMnFxhJE vO08LP7Jjn+3HOrBlpd8Ve8qUio8X2f9gZAB3RcG5qdEySmCPOqAh2b5dSQ7GMh7NIiJ jCCA== 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=SrWu90v7RwVVGIyj3J1NJ4lNaOE9C3PTcBPEpqAGb3Y=; b=fRVKsxTnP0H9H2iG1cizPTVDFKtqlDZ/+qkq2l4UjmvBDzXNSUK4UGdIDDPDq4qXLO K7KIqx/xKvjLco21cD4MQfwhuiZJtzxu53Mdq9JfqtU2zGnmwVCxBUeng47mTHCXUM4Y QScyi7LlyjsJG1OYwEkDr76gzcQTBBxTM4AMdsDdvFrUgnl8zftsR6A5VHwIyLLxDUu7 Vd6km6/JypE8Vyk1IdSw/tsfWGGeQOByzzqTSduVCOxQSr3GzOrIauxFSX+buBxe74PD wWfgCBifDQLyaX/JUuhXJ44umRXvL1kRbG6cfPAOBFDTU/Xq9VGPN32xmOsxGribb0F9 MlTw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="B1gL++/H"; 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=SrWu90v7RwVVGIyj3J1NJ4lNaOE9C3PTcBPEpqAGb3Y=; b=rqpN+amPLvm9srT03VzphWGA5tbA9c+Bl9IsYtltIgMU+V3KwCL/pZt2uC+v/KBzrP jtbyQwWjiEZBYBiJwRrJLHmF4fGGd3+pD1UJYGS88Hmzr5t0g/seD+LkXYGx4dlDQrs0 rGICT5kHhhsmo6nbz4hV1HDA9V2Fzjd9bdHMo= 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=SrWu90v7RwVVGIyj3J1NJ4lNaOE9C3PTcBPEpqAGb3Y=; b=2mrXH+cgMIrWoL7kSi7PNcLZqhk7eLnTtykvT40M9QI6B+1qr5i7iQiPBf51xm/62w As7VucAbw5P/OxrZbdzAHab7dzFQNzlodsGeBSUH3EBy4Z6H3rQge3Jah3wgsyaZlywt jJm4WLDG9kHCkLqoWsxXi/4EEcK6QhNHthMBR2P9ns1EWZcYDY1c3sQywiWvpaGM2a3j ul7/mf3+3IUTJjmwc0oBVmDIlQl/pjiufmaGV240REmlT16DkgYu3HQVPou8FkarSWWw v/d60QSrg0zcWfIylfbOXft+2by6ZGzHXSXx28TGN5TYVSDzy+lXr5iHULh7k5IMvn1s 0SZw== X-Gm-Message-State: AOAM530NxbMhlQHIAHWWkVFt83+Z1mNoCCsI7BktVYy9268BGxZt3mAE vBc9k3MeXPYBW1kPIpWEf0W3/Jlx X-Google-Smtp-Source: ABdhPJzJPXFH3RePm+qSNnpUWRggql0pb8QsRFc5TMsKgzAwddgvz232C3DH+jZFXDVQyX10wrzPOA== X-Received: by 2002:a17:907:7ba9:b0:6fe:5636:1636 with SMTP id ne41-20020a1709077ba900b006fe56361636mr5103528ejc.463.1654185883174; Thu, 02 Jun 2022 09:04:43 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:6a26:b0:70a:1088:57d1 with SMTP id qw38-20020a1709066a2600b0070a108857d1ls1684058ejc.3.gmail; Thu, 02 Jun 2022 09:04:42 -0700 (PDT) X-Received: by 2002:a17:907:72d5:b0:6fe:c343:1ace with SMTP id du21-20020a17090772d500b006fec3431acemr4932545ejc.563.1654185881122; Thu, 02 Jun 2022 09:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185880; cv=none; d=google.com; s=arc-20160816; b=gQgU0LktSx4JGJcjJTfzMPjgr4HzsRqOUH7jvoitwpjHN+IrF3lj6OgrsfTpeqgGES uj4fUNjPwbzTMggGUjSBjYQxMEniXuFhazZJBybO+6oAN5mUjU0RO+Xc5CH54dHu5gbr G5Bd67fbuoOxRVdplfPo9/GfouUDk1cANhHavxNWaaD2gS98K81+OBC7NzhmOIptiwMN NOBCrJSM2qnkSivCDGwh5X2NvG5bZXAiEUNwPIPhCfv2D6/kjhIlqO8HD2HVjsgusK2q 01kn09e4hkClTQl+8KVctDcO+RKFAqcNxcA8EwZUG4ZSrnumeuZzxKAAoZz/7PVPk9Ia 7MnQ== 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=El3W9x0OB1VE70B0Lt3SBVyO+pC/HDeoL5aPqYtLRdg=; b=aLiBQK63nF/OJFM9D5l9f9hZllgJ8KEyq3iOZBXA/jFE+/b3mieG5zfcYcu61JpS/8 zTLIx0y+Jks5W4zCimNHypFr6bEUhSqTB8EHILiNwHcN5qPaBxg4LeuNfQhkLVrtTW0E VnMH/8XMkGrLqOyZnRn9KTAV4icxppuLbo+o0I8OKG5NRHC5+3PHIYN4s+JCZFDbjyCE fyZkq63Mi1BcLT7lLChd1AmGCwbb/2WXOLTToc2MG5Ea7y2QSM4WsFlGKNVvIVLu5dYP Dy0kxlEETIgwVON4DBQDFQU/X1g15YvQDBJwwzF4nXFvR5BEvDdZ8TQUceVqTWm6jzE/ NoWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="B1gL++/H"; 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 m17-20020a50ef11000000b0042ab8bf3faesor3173902eds.52.2022.06.02.09.04.40 for (Google Transport Security); Thu, 02 Jun 2022 09:04:40 -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:6402:5409:b0:42a:a643:4eb8 with SMTP id ev9-20020a056402540900b0042aa6434eb8mr6412687edb.71.1654185880529; Thu, 02 Jun 2022 09:04:40 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:40 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 02/13] can: slcan: use netdev helpers to print out messages Date: Thu, 2 Jun 2022 18:04:23 +0200 Message-Id: <20220602160434.225417-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="B1gL++/H"; 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 --- (no changes since v1) 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 Thu Jun 2 16:04:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1987 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 390983F06D for ; Thu, 2 Jun 2022 18:04:43 +0200 (CEST) Received: by mail-ej1-f70.google.com with SMTP id au8-20020a170907092800b00707784fd7e0sf2579037ejc.22 for ; Thu, 02 Jun 2022 09:04:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185883; cv=pass; d=google.com; s=arc-20160816; b=JTn8qAWUbmVV22C2omg+OXA/IX49or2dYs2nk2eEfFi6U5b85INv/MNpSt9672ZiVi 53p3wI0QTXouhHYBA/OYTl2LkESKSVf2K3DJuXijCrs1jeileIhzUkuxzMqKByVwo1gs 18zRttA8MLT/Rlz58wFPG6bCLng46tOdxxNcd/f4HnUDV3xNyFm+oYQCHYFMrsaHkySL pym/58U1zCt1gaXnp3skDk9D8O4ZyxTWWyIa9sA7y1emDlPvmCNfc3WzrcRSE+hs1muQ phIPCRFIMyp+gWxSXmCQ+BzVZ/xSaiZ06OfTarnH6bjXNlE32fu0B6x3OvW8V2s85l5w BugA== 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=rd5fKQGrmVRcVydHoscc46oqD2f+jRXRiIdavWAgeLs=; b=QkPxjAcaKkRQ8Zwsm63u7dgWWirZqXASnu6sdVWVIVuEGIbpvyHwQ3aNko63idsdRl b6W3vzccbFslru1JH2odi21OinVjWDPwXtftF6ZM/+5KwO14bsgAm1aYNHdLgbz7xvj6 sT/YmkMLf/pa3VPkBmIa1kfisgM0u/qZm0LD0VrvwtK1Uc+cbdeezx42BqQ1/K6kZX7h ZmeWVJ4Y3JNa3yjiVj6wtVV79TZjpDCz2Q15ffNgP3xPftIoxxqPokrrm4rtJ6pzfOMK 115ER99b9PkNeTB6m6YEWSu6wgGEXEyXlEwhDSbhTC6V7l3b6HoPYlyUOGPLiM3INdys ZvfQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=l5nClT2K; 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=rd5fKQGrmVRcVydHoscc46oqD2f+jRXRiIdavWAgeLs=; b=jBPkJ/iAN7/3e2chZndPCxzXS8Orq3miIGJhSKktJLyPa9+R9f+HPjE2dRccp9uFIs x+nSA7XgXfalznoXfeWAVuFBhyjJowNvLEPl++qxnt6fDb35cJVLU6OOjySUWeI9tzAu RryVsj4iIHX3DEd/u3Ui0yRjZcsFiCr+K6l9g= 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=rd5fKQGrmVRcVydHoscc46oqD2f+jRXRiIdavWAgeLs=; b=zSxNoKaBTvuhozWIdH76m6z4ALiV8NLZxm71DM4i0antMFdFYMyz8wrnx5tarfAGwD uoDZaW27ulzrIdDjYRmmQOkiMTpqwyjjuK+gtRjBOVQqESw+MF1ORRBr9l1yIYWJvjZV lw3mjAUjg9jYvGJ2wjiBt8FULgA/yj8yvbNhXJey+AJCme2HPriiEtdpEM9w2pFWl/Yb tscFNBN8UbGKWwSr2+YWhFm573yPP4IycO/4CowbHaOii+nK/tK9QXljFWvuA+lgOOZ/ +JRYS9kqfZX/eApAo4NKfVMRBOl1RI+Xhdfmkt+5tOyDaGk7mvf3Wu7cbUHOWsirpLep gg3g== X-Gm-Message-State: AOAM531gIKBQoL6wix95oLSqnAxrUH+G5LvLAYXcApTPLkIUtYzW+972 +IIqwGiTuL10xZ/a5TIJxboY7i+E X-Google-Smtp-Source: ABdhPJxKtR3juT0s4sU60etljd4ssLcx9oYstdba3qiz5/R5ZMQ0uC1ubqmp2Qcp0i9JdUGl6bbvLA== X-Received: by 2002:a05:6402:1341:b0:42a:f7cb:44dc with SMTP id y1-20020a056402134100b0042af7cb44dcmr6286357edw.165.1654185883071; Thu, 02 Jun 2022 09:04:43 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:70cf:b0:6fe:d027:3c1f with SMTP id g15-20020a17090670cf00b006fed0273c1fls2947737ejk.2.gmail; Thu, 02 Jun 2022 09:04:42 -0700 (PDT) X-Received: by 2002:a17:907:ea1:b0:6fe:f6a5:6009 with SMTP id ho33-20020a1709070ea100b006fef6a56009mr5179921ejc.275.1654185881901; Thu, 02 Jun 2022 09:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185881; cv=none; d=google.com; s=arc-20160816; b=b4ww9Q9ebkxB6aKKwfag2Vn0GNaAVDzWwtEcTIDze9e2cY/pJRQWsm2MxmMb7U0bPQ z4ngB97F0escHun+OxcvK3pJ7fZByYrcJqC3wy/5JfIlUTMH2AfXAAS0F5aKERs/Cts7 GibxCDgRAQ6946ZWhJdglQ/gDKwP7S1om6ai+PTk8YzQ/cpwIA8csOSPvGGz0tbO2j6N Se/Dr+BvkRn/skO0V/WSdHuMjNJN+YbwPKBYKG6Pt8NWcM5EOatZinXy+i6gyh4S6P+k AEz2qCLviDLwbcOmFW3jic+jrI1Dr7sqtsAzuzRW4OPy5d5lGaxWZIL3RbEzmA+pD4Cl Z2mA== 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=kPBEgvyVQ38r5lH7fJdN35/kW0pwQ4FNxeQ+95rO0+8=; b=P/3XawvQpEjBoHvMS2xZ4GhfT05gC2qIO/OMy/2A3XW3inLotTvtvlBiSlxjHQLEzO siU5bF+WgT5FfUh1HMhfFmXUsFBQJ4DLvh6y5X95a4NnBapA00LPPZqg9gTu9DMpUhWi KoyfabT30ynR69RvYkr7TzkL5E0/LvUheHL7lauamw7dqSw5jEfsmmJAGBtO9KELQzmZ Gx+qk5s3Rjdqjt5YwzGvg+8J+JMh6tZn9y+c6NJijS4MHDl2/OJMAo6U6yywyFGGaJ3C taAeX0OOcGvCCLANr7yTHXGbp15zHcqCg/ZZir65He8rg1InoYYHEuJbFRrpQzzqwpsJ kQdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=l5nClT2K; 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 m19-20020a056402511300b0042de1ae31a6sor3179004edd.65.2022.06.02.09.04.41 for (Google Transport Security); Thu, 02 Jun 2022 09:04:41 -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:6402:3291:b0:42d:dd03:cbb1 with SMTP id f17-20020a056402329100b0042ddd03cbb1mr6137692eda.268.1654185881443; Thu, 02 Jun 2022 09:04:41 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:41 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 03/13] can: slcan: use the alloc_can_skb() helper Date: Thu, 2 Jun 2022 18:04:24 +0200 Message-Id: <20220602160434.225417-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=l5nClT2K; 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 --- (no changes since v1) 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 Thu Jun 2 16:04:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1989 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 6CBA23F06D for ; Thu, 2 Jun 2022 18:04:44 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id q12-20020a056402040c00b0042a84f9939dsf3791413edv.7 for ; Thu, 02 Jun 2022 09:04:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185884; cv=pass; d=google.com; s=arc-20160816; b=OFQNtx42791eA8vbnbW33rKh7xQCUfkIqAbv5hI0cDMRMjdxD0yEESBrU0yJw5ljRD bHHxJKVhkwUx2Y2FpQDzDl/T7yMaR1g19MIaCvUnCjK7DftCZ40bW83Rn+imvdugnuYW Ohadg5eKwuWRTWqOf+50D7pngocTrg1YAqQfTdxFEUeTRcQjsnzh5I7FEPE3OoJg9zFR 551YBTDY+B0iAMb80EObDvzsploDuXSUaIqaOelyFj30KMdVUmxsuu6uq+lS6bVSxKYr hAggpH32HcVvBG33vzDMyHXziGn5LtsXbP/RUlZANkcu9pRISoGa1m9Epk17XzyRE8te 3Rpg== 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=pvZg2TCnamYsjlfGhiDH9usy2Jsjx81fYPrNJ9Eb5vM=; b=DXUnQBVqsilB2wmY4mgmBn1Wc8KpBSsACDw4NhGCxV/my1QfmiKhJTlLe8JlNcmVjK 0nsWnGwloRTxjUTXGhUxV6yLVtvoUMMdxAJYOSz6IBIyqrAhGHA7tHMCfVI9jmov/Dzz jPmxSMmmQd9NPS0a2M2fZ0RPQVowNgFz3D5H7y+nw9p3qsMZDDl0sJxxUWjlimyxuoE2 XTFESu5kGBACDpAIyXA2nB9xeRarLk0eruOKyNCowmpfxa2Lfmqi+8UWIHT4fhHCJklS 2uwoawRG5Wqnz7jb7vTWI6g+HII6oHatYCNEa0YuVN87oywgJpQgRCFg4OU1w5V0W/fK AKiA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=p6WNLq9b; 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=pvZg2TCnamYsjlfGhiDH9usy2Jsjx81fYPrNJ9Eb5vM=; b=ALX3dlRDpcmWcwzVsVVcAR0kB/9RMYH1eIp2VxmUeIBhaa6EVrcU0vvfAx3P5802ag jiZq9kIT9MUmispWGFYZzyW6OhWD5ERMZsJYubMYGZSfuYzvZ9maCAGSDV5lJOqCCoZu J9VKJtW6AkKOF+rbu46efrCtcy7vAxKtoUzOk= 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=pvZg2TCnamYsjlfGhiDH9usy2Jsjx81fYPrNJ9Eb5vM=; b=BpPk3udd4Yn+bGv6WByt2xmalGZEGk2Q7vHB7nnN1Oddx5gcGu/HN9MOJ6gs3J0PBh WZoahFPKPSMsZmhq1RbxZUJ8yu3nFEt89liolTLOYbnL/+cBH4jDWEcVZD8cRpxTNOnx JqZgj7M5FJ/oaa1LRbCMZys1gBqHNDvkPiZz61B+fFUqvwWvarHiSCilJHARIs00hiEI wB9R6Lkd5V4lRqD8UgZgenZKxzzrS9sO+7Dx/vEvkXooj21ALGT6YyWleyH9qdes46+4 nqF+TF9j+Iw2eQmdsa2sfrYKSQgZARh6p/fb4W+pt5jw2CchL6wE1Q2v7dPcaCsZie7J bYJw== X-Gm-Message-State: AOAM532+lrbW4Cly5bOvAD9OQCrTiPjtSIZXeRO6efJSvIrodCIB8wu7 yndmqK395uxjTcKUKKX1qLO4Dosp X-Google-Smtp-Source: ABdhPJyo0Lz3i9JYlUMxAB9zd0amK9hWP4bnWao5ZfMJ+poN1r7TOI/PEpGEq0mZXHxKtSfoQbC+uQ== X-Received: by 2002:a17:907:d13:b0:6fe:ece3:64e1 with SMTP id gn19-20020a1709070d1300b006feece364e1mr4878494ejc.584.1654185884195; Thu, 02 Jun 2022 09:04:44 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:907:6e11:b0:6ff:232a:2406 with SMTP id sd17-20020a1709076e1100b006ff232a2406ls2157396ejc.0.gmail; Thu, 02 Jun 2022 09:04:43 -0700 (PDT) X-Received: by 2002:a17:906:dc8b:b0:6f9:9d73:785 with SMTP id cs11-20020a170906dc8b00b006f99d730785mr4858212ejc.688.1654185883003; Thu, 02 Jun 2022 09:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185882; cv=none; d=google.com; s=arc-20160816; b=vmcmB8OzIR5wnj5atebTjCjvlAmoNXh9C3rx/LDuRxx6iQh71XLzwZueU6UiMvgYWs I7X6KXh0eJMypEA9KeI1B4/riO66EkY8ucV08Md8rODLSZYWrkrKj+Yic9/35a7uuT7e ls84fb/gXq3GMMCPmbtDgr/OMUiG2h6x6y0S3Klv4vzgctv07N7ND44AvWrCuLYW8Wx9 fyZqcrrixqEadEkwhWNDHSmGM18wiGaBHOMjX7cp3Bc4mKaG5QmDOInTaMcCIwU7U+vV xnKkG0cHmzqrXsVfv7oFs33aJdMgXUdaxxYFuuUebLzUrpO2dMKS8Z8RLJ0bzkOXqeKA eHBg== 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=mgOBpdUKD2mVSwxb7jI9bNjFb+SOWyH320JLUpxL3kM=; b=gTJtuwlGcncQMgJq3hYeZqcH3wAnq/sK5MYicGFF79FXzMFp99Ox+Q2yVHnxRzanGH 4NAMFVEWWPq4A5I8ntJBoSNLHQFpEcH097vz5VAhvtD2fpXI12lOmD5I6lvcWKhpewpE ys2UoYRKroDEaPmYJ+EKUJc72S0OFEalfzg1yala7+azLavFPnzYWLjBHjOYfgatOTEg D/klcZfklBU8qszrUbmKhs35Anc8ZO8I9yXosoqMXLCkdEgXZTfLFO2CY3T2Jp5YQO4y bQ2oAtpzzX3kU3jduIeH9XDczgVDNeikIrg1kPGvCkEyWznUHfMsgbA4lmLqXfzSy02r jHNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=p6WNLq9b; 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 l2-20020a1709063d2200b00704dc822cffsor2682611ejf.31.2022.06.02.09.04.42 for (Google Transport Security); Thu, 02 Jun 2022 09:04:42 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:8a25:b0:6fe:ff5b:81f8 with SMTP id sc37-20020a1709078a2500b006feff5b81f8mr4921963ejc.184.1654185882391; Thu, 02 Jun 2022 09:04:42 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:41 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 04/13] can: slcan: use CAN network device driver API Date: Thu, 2 Jun 2022 18:04:25 +0200 Message-Id: <20220602160434.225417-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=p6WNLq9b; 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 --- Changes in v2: - Remove an useless check on bitrate. 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 Thu Jun 2 16:04:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1992 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id C2DDC3F06D for ; Thu, 2 Jun 2022 18:04:47 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id j4-20020aa7ca44000000b0042dd12a7bc5sf3733130edt.13 for ; Thu, 02 Jun 2022 09:04:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185887; cv=pass; d=google.com; s=arc-20160816; b=ilfJAcy9ChIxDWWl4HrnwlzOOPxV7qXY3zkvZWxyv386pcfq1OP7vwBbT107RGPnCD 6klvh/0B7/4rV9dl5M5zOpmN2ws486NcIucI0GeSxC0+MRvpDuf461MwisZ3p6IUTh6e kqOH+ui1ubob7yhKJW87rjfJiyrc+vnvEoHsKWE0KQb//XFyoDiLX2T3An4OpzLuucNe MV0yTrf5sqgUmx4XfTdJ5sGILIgiQxQyaTDK5tjSM2Vk0nHA4fIlXWhB+tAxRx4LTanU y/1gBuK+IUOJNjqfk809Vs2eUNpkud/9KJ3kwF/7zo0RXIHbaowNCvDJ5KlMxOzOyZoK hEJg== 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=UYlLUhNrcaon3PmjK0FP9xl1njqJlrMfqYJtLqA7J3c=; b=gUqB0QU183GI0p2DtVQhm2YHRrNpgBCubQ5hLRnFkgaaXZNbeVjG2Cg5NENLi8T7wV n/ywu8s4ptaKSbbo0fxLiVlTyNlnB9/6p802JS2cE9YkMHUELKdGLSQlYhajRJMjCNZl Oys9EOeT9X0k2/Q+NcHNxlXCPV9XuHbhHyndRtfoih4yiQoaCTD4VX5FD7z0GcAuI8Op 8BPMzd6y5u3PYYQ/4AyBNJQVX4Y6asQm5T0HkTSxTNKiZ0ukUGbN5aJB3aK18cpu6meQ +mhHfORZ5ULLOACu2kbq+6S/8uehg8Wy3D5/iMHFtUiaT7gqla42oaXx71SaDgGE78Z7 iDfw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Av1p1LCc; 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=UYlLUhNrcaon3PmjK0FP9xl1njqJlrMfqYJtLqA7J3c=; b=bGjCwPeBVrAeSgww5LmyIFBAdItXLGhc7ntPlZj/yvupKWqciFcirEVi4U3tv07uJ4 C/cH2dd8/gNKuv7e2DcnOymzC63+coHOV9ChiOcJ+5U1fwZEkpd0jGyGfHFVba9gRzkl y6mbZQXXCTTFSTq6Hcb3a2iCoGt+Y9xp9BRqA= 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=UYlLUhNrcaon3PmjK0FP9xl1njqJlrMfqYJtLqA7J3c=; b=p4FwGgofCw4hBqlLzG3YH9tqVrJduZET2jIJdwZEBblo9VI6+gpbI11PPjR6Qn9+WP haYue1eGe2KsZ11ci/qM3gGuaCQEq2A3FirykEpt6yPe7rKEMbSdoKYZyJKN4Dyf3Stm PQD3ZZI8N0Ac6k9ryFE7+fCasR7b0Pabv+dLgs7/b4ERA1fmnY//MJMWHFH9EYNJzM4s +isvRioUtfaUOFcvcTo5UdCEuVmmNxCM/6fgzVAhqN1Q7HcuiXe9dF6kneLbdfSLrz/V 6y+QCbUIA7O0TjvwRNSJnq0CEcp66kJs2+wrCJbx8/GgDmbt4RrFndPNLvRMbpNFkWQw JYsA== X-Gm-Message-State: AOAM532eVE7Lu0K4TfUK7XFjX67bbJzbM8hs+cQrgrzy9kb/ZDxYrjFI dgqhzKKZ0nvLtVi0pVpg8ridX1NK X-Google-Smtp-Source: ABdhPJwnXaixUn8pUW8t9bC6CXa9ST5XY2Ac6B8xWFgkJXfnKXuA4oqksn1JwX5YG+u3XDG1ZkSlVw== X-Received: by 2002:a17:906:af71:b0:70b:cc0b:1f14 with SMTP id os17-20020a170906af7100b0070bcc0b1f14mr2374992ejb.669.1654185887610; Thu, 02 Jun 2022 09:04:47 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:86ce:b0:6fe:c3bd:7a48 with SMTP id j14-20020a17090686ce00b006fec3bd7a48ls2949609ejy.8.gmail; Thu, 02 Jun 2022 09:04:46 -0700 (PDT) X-Received: by 2002:a17:907:3c09:b0:70b:442e:7e80 with SMTP id gh9-20020a1709073c0900b0070b442e7e80mr3050662ejc.593.1654185883926; Thu, 02 Jun 2022 09:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185883; cv=none; d=google.com; s=arc-20160816; b=Ebg4MijEF1IcXOv5j+YbDb+i+1uMrdUjWLjsYHIlVuJXkJ9ZerWxZdYPl6PYO4vaRh 8AWK/VUW8WfKvHfMt9FYN66FBHERyJvy4Ib4gI3K8LVHhBeKhVgSDUF3wPAv+Of864j/ cmetb3tL9YyR/F4/c/KTTlTRndaVzmRTeR2qf8EKg3ED729Wh1Au5mzQXOq77Ofu9vPE v7GxeIIpt70M3MLL+7nHSQCcMerVBfBItvQHjpBG23DgUe3tp6zSJC7ox/j5GMFzcRC1 DvwIO4AFcGXHerFKyub/LulTCe6IY0Ojlrveqllkv+A/b4WBXtDtxALZygrtsXtTKkd5 kRsw== 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=Uy2KDmBJTDvOUfwfmXyB7sLHvziPAF7lM16G9Y6QNPI=; b=T+uLLz40nLRxpO8ATZqvTLTsq1NBetf/SqoW1GdNoymhu5/z9jNfxbBjYlOLBf1o3z zUEfdY4fjCfeEZu2/YXiyo1qr+aUeFYWaX7IHoAVt3DJKyUid33JcCBjTzbsBrZ6oMUS LSb2c8FhmLhQeObthbo9HvK1aw+CLD5k5Msh89PSZXJEOGZKTw6FsShkL0czh2mxVoZC KK2kVCFrZ21bhUyIX4mC15r7VJ79t3LCljzOdQBeWvZ8Bd/vsS4Tb956ZTpQaWjIttU3 oCQB6JB+cqYgK9TH6zkUCUykKauh8czQjmggqIThOuy+cQDY8EtN973CxsUNcuA9n0NM sSDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Av1p1LCc; 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 y13-20020a056402358d00b0042dbf25b798sor3097909edc.66.2022.06.02.09.04.43 for (Google Transport Security); Thu, 02 Jun 2022 09:04:43 -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:6402:1941:b0:413:2b7e:676e with SMTP id f1-20020a056402194100b004132b7e676emr6379071edz.114.1654185883445; Thu, 02 Jun 2022 09:04:43 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:43 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 05/13] can: slcan: simplify the device de-allocation Date: Thu, 2 Jun 2022 18:04:26 +0200 Message-Id: <20220602160434.225417-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Av1p1LCc; 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 --- (no changes since v1) 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 Thu Jun 2 16:04:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1990 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 3962F3F06D for ; Thu, 2 Jun 2022 18:04:46 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id eh10-20020a0564020f8a00b0042dd9bf7c57sf3765277edb.17 for ; Thu, 02 Jun 2022 09:04:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185886; cv=pass; d=google.com; s=arc-20160816; b=eIzvz/tqoqnVdwOEDuVTDqjGJyZ6KXjJup7jUR0RMzBE2Gg6SUZxPrZ388BHfenzHP UMQCiXnIhCm1H61FpDigIkM8G/MfbaZXSCgDA6/Fg7zZamOVtGdabUoD2eJId1Lr5wvh 9XfmJzRAyrPcNLZWljZt5iNYgDIohvkeBQ5Fhr/DmeefgDXyGOcahi6TovQM60sBzYv1 +7B7CuUXv6luGHlLfdSZW8g8PiWYGFYRa6P7DtkhwvU+AqIEexnryXhKnSUZcW9YwDyi 4/+vGD/pWnROKgFresT6I2kh3AIsnSSEchAKKiBz8nvtvVUbp/wofz/5RUqOEvH166PF oVpA== 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=NPHJ0uvh1gW7ErYwjw+elHhXp4CUxSNj+j2BQYMETK4=; b=c8d6N3eN2JZNk6t8zw5St2sNhnRTVIDa3YH7rtEp6vdGywFx3ZuHZzjxy5D7W/pLum o37Fj2MOhsIUlF1Es29Ti9Rp+Wfp3MeDQ8fhlCKwOQc3cWGJ5ehgMtu7MTwqqgVp36BY XMJgS3FkRLDgTkhgCx4Br4W7Ld87r0O6UDhJGszEqn7NnlqOcWLamkXDyuJ0jWioiAT5 KIgC6TXU3EVeuU7hmclqlRIcwTtE0tAnAxSxqkdWReFrvA9tE6HVRMK3jr78CY0qUS3t Z4kLOfGdO8q4wGtf7Brec3KD1QLBhWisdjO1Uuf9gAfLJaNm0K/f1CYgIrY9mF+MfCrv 3Wjg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=d27QEBWe; 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=NPHJ0uvh1gW7ErYwjw+elHhXp4CUxSNj+j2BQYMETK4=; b=qqbcK3fTC+SlF6/SDmdEZoYVKvZjFCyA5TZgQBIvlK8aHm9UOiUCO0HWIUNFMLUM9d Dri/v09KjfmZ9k0PNvQfjl8qGRtUB/vSrAgNs9R9RzehMRX5/iP81TbZ2zheA+N69lU3 PQ6mXwasKRjaNVOZ7UqrPsEcA2h6TcN5sj50g= 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=NPHJ0uvh1gW7ErYwjw+elHhXp4CUxSNj+j2BQYMETK4=; b=MyIJQCt2jHFg1bgUcp20cRxlFKHf9zVD2Ro0ghk/q2jDYeGxLEEkljQmB+iral9X98 Dq8QGqvoHL6oHLoRlJZXBWYFN2FX7EtzCEE1A2xb/yRC9Eo/NdBN4LELX1PAiSyu7sQT fDIJr18I6GA86EgllEEouVJ4g2RJ1S476HOlPapHDNkjjmizgaxQ3nDLIckTmpSGmEss 0f6t/1wv786ZMn0y9EpNiXG4ocKXl7c6zfu4ClzBikUOH5XS9J23WNd3ZeNtJPssHO21 p4nNNgv8geBOjr9l6kwQT9y7mIWBr4zO8twlRiGJvRLXJa3L3P3r07IfTtPpKZTTlKHT INjw== X-Gm-Message-State: AOAM530DUtm8ReEsCqQYOay4I48DN3pDwjN6fmWQJVnCku9juTl5qpFw BSp3kILyMsZ3NdGI7Vnu66fUb0EN X-Google-Smtp-Source: ABdhPJwPlt9qFeDv634Fd/iMsFyMR+Ds8ok7tVA60kj4h495l0H1ylRa5SM2lNSDDysUvvWwlLIsww== X-Received: by 2002:a17:907:7b8a:b0:707:59d4:14a3 with SMTP id ne10-20020a1709077b8a00b0070759d414a3mr4906621ejc.51.1654185885971; Thu, 02 Jun 2022 09:04:45 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:6a26:b0:70a:1088:57d1 with SMTP id qw38-20020a1709066a2600b0070a108857d1ls1684122ejc.3.gmail; Thu, 02 Jun 2022 09:04:45 -0700 (PDT) X-Received: by 2002:a17:907:72d2:b0:703:9177:7d1f with SMTP id du18-20020a17090772d200b0070391777d1fmr4845528ejc.144.1654185884859; Thu, 02 Jun 2022 09:04:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185884; cv=none; d=google.com; s=arc-20160816; b=npdXIz21IJvBWdBzRVsmfoVrxUbFPAvLafbxUDjFxiYMcxrvOgUD9Gck6n3C0Nf8Ac GS5bVxZxi3GIaacTLBPCWKBwF4FcSb2+QnrHOsz/lff0MWX20y4OSj6AaBbCnismMp3y 6I1yAiz2DoBdMS5Blje19R65+wf7lL3pKT3TMPof3Qmarna3LTdMn/WLyUzSNcLBim7k RDRprj4JNDJI4G0Ic+zBDYPDl98+UbgUJ7EKiTgz8nxGueAozilya2tO6xsNdgvit16j k+0Bbt2JYrdZj13Rswd2IBAR8Cg3VnPHPgoGmYmgO9wX+CoUFUWuXVQXOK1Rd8CDfPMs 07ug== 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=UtQBA2r2SSLSOGc5ftt/ugZMK3Is2I3sXhmi4Ilvb5o=; b=MC7iYfL1DNsWfxurTW+43XP+jEVRzaTFD3HxyqFQSAL0gWiX1mI4xFc3bzoX25scy+ WCbnUQGXnZdVmeUpm7CWNx58tfwaFiiGWYww3DiMUIFnyNDo3oDl6YTljdVlYLjWnkEH cAglQlSNSyYyZ/QwHyHyXOJGqCepudXdyZaXmKP7su1bKJ32SST6TfE25blbswP0ScT7 CAuZUVWSf/4GEgQP3J92zAiu5sOjv3C/Se/xQm5jxLASkXpAGeoXO+S73eTfYYlLpGBT QeiUjGnKGTg8YEY9HolWnd657pPYkzotVIQvu0/QOznY2I+hzo+MZLFrHJ/U59BbNWhI HPcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=d27QEBWe; 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 g1-20020a170906954100b006e04f1efcb8sor2559850ejy.41.2022.06.02.09.04.44 for (Google Transport Security); Thu, 02 Jun 2022 09:04:44 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:a0c8:b0:6fe:b73c:193f with SMTP id hw8-20020a170907a0c800b006feb73c193fmr5131058ejc.11.1654185884317; Thu, 02 Jun 2022 09:04:44 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:43 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 06/13] can: slcan: allow to send commands to the adapter Date: Thu, 2 Jun 2022 18:04:27 +0200 Message-Id: <20220602160434.225417-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=d27QEBWe; 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. Signed-off-by: Dario Binacchi --- (no changes since v1) 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 Thu Jun 2 16:04:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1991 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id F08383F06D for ; Thu, 2 Jun 2022 18:04:46 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id i20-20020a50fd14000000b0042dd305d0f7sf3770888eds.18 for ; Thu, 02 Jun 2022 09:04:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185886; cv=pass; d=google.com; s=arc-20160816; b=eKncyeCKBk528Jj92P8jQYwdjF3/Ei/KBgJ0aJGALDuXtL98j+3FOmZ8kWw1HG7IvI Jpn4Kx0VQyKinY+y4NyHZJ6FIDVLW2vL3TwvWi+9kppgLJN/QjIbDI5KjFyVYJOjXHfE zJGtv+eBKTwTfNciko79Ar9jyeV4DMaAigIePDUG5plJayL97fjlYgFUbw6TTG2Fczbb buBnx5la4fJOSRf8pQLQS2p9mRij3Q9t12GL5sF1iCH/57/akF0VuVQYqnL5JXhk7ui5 DcHcRZD9ENPmgS+xdOmgpGjQgLvmoPiMImWv36smsE3kgi+yx4sxKRSI1KLtYL7unfX6 au0w== 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=GYj2oFAVOId2ZMNw0h2vZHvNkNOHBgZPFfpOhF4ydYk=; b=PsP0D5Uo8gyBiC8EFQdBFKGzjKqkfSeQyUAv8A2iXkHxfS5kORSUFmcvrrG0E3JM4v xHmv/A10Ypapec4ljrF7X1e3wpS6UjPt9DW/NmuPsGJwOSb5smcM+/22Qc+LzLlbIm1g X/XjVQBNKvM75/1rV24bGdkqbZUiOFAvNb1zC/CJf1chbrZdaq4gA3mA5nk46T69J8W1 zjZBoPYiAMW8M2XNrVBWSk2JTw0t4zbD+DGDE3SCY7BVHEHOlQnepLGX9ZUXFL7fK+BQ +4cJdukmX8X7R2QI00Ehf7kl/YXS+S6PQs/TR9UJaLAo+7bfJTdn687Os67RuSVp+6rA Hkvg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XI3Pyioz; 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=GYj2oFAVOId2ZMNw0h2vZHvNkNOHBgZPFfpOhF4ydYk=; b=UzDJZ2BUHaqGCpncGRe7udi9m2kM6sJ1dlJX8EyvPktP/DiEPmKCbk8bdRi+XpFls1 WNEDrquBz1h1sbNSRUc67kZQ2KjYjTY/qwF0sotFfFhBcCDcL/UM9DcSqRB+KJO17ijp muiJTHVTW6/IIXOO9nG25DSY4moG0suCDECZI= 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=GYj2oFAVOId2ZMNw0h2vZHvNkNOHBgZPFfpOhF4ydYk=; b=a3/FkVOuQSatkoIQlNd0JkxC4AuDs2Tvl1UWJLhTy8CdTEOzY+9q9cArlMuD6yr3KQ Q5yAscdLDtrBXSsfSI9khb3Uak/Zax6JANgwQ2VEbzP9+b3g5e57N5DF9zFK/Sp2eZ4T U3SGQKMyDSBVtHcg1+eoz8CTGTqevBXxDw/GXA5eT0flJAB2RmK2QuNeJizsEx9+Lwbv WzNDkUvIjHzCe4vnuvMjLDCvLD43I6gERAwtj50XNSQ2mN0AJIPvsXOyG6RIrp2t7+ox 5SejLIDZosW/XemUzsFxZsQmnrkHS6BUy+S/7h6+SzYesXdWTcTgeVgL7rZ8s+F/fkyf ZsrA== X-Gm-Message-State: AOAM531pFZ/mLP5Yo+Xpkn/SQiEzuK0iSIJ5uL16uLX5hl1T273R4S/5 T8z4OYouYT87gYxRq6ZruLGeyq7A X-Google-Smtp-Source: ABdhPJyR72fU4mdmT45it8BEYEaWiAgz53rRSvWxyOLT4Ph6lq+BkHN/tWKjwQIGqNixAphFnw9YmQ== X-Received: by 2002:a05:6402:2993:b0:42a:b25c:c9ce with SMTP id eq19-20020a056402299300b0042ab25cc9cemr6284323edb.0.1654185886812; Thu, 02 Jun 2022 09:04:46 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:294a:b0:42b:31b9:2087 with SMTP id ed10-20020a056402294a00b0042b31b92087ls2362369edb.2.gmail; Thu, 02 Jun 2022 09:04:46 -0700 (PDT) X-Received: by 2002:a05:6402:2945:b0:41d:aad:c824 with SMTP id ed5-20020a056402294500b0041d0aadc824mr6154092edb.364.1654185885738; Thu, 02 Jun 2022 09:04:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185885; cv=none; d=google.com; s=arc-20160816; b=PbbPqXgwNYLgM9VrIJaX0/XLwwRMo12KB9M5RYNCA9R8PfL5vyIKId7NrLaOQBdSkG d5DhcT9wn6uHTmByaUpiOzJN1Rnah+I7OgWkbiCSYMnekcY2ufPBwl65Ub4NHLgnM1vi Z3qsz1GGPYdB1eqCOgZTlJx+Sb49YUJldFyKsSL4DYixQ2QD2GTbBAiNuOku7g7QnOKo x0BtJiVcLu/r3l+ABGaS0OgYjZnmyYGjkVoZZoWxFk0urYPCgVFIWpPrRUmodRix2iGM FWidMvwE92wUC/VYSW6udB4e9nhjMylZ1PU670swj3cuOqc2ys04VOuv9Dble6BTyxhF l7/g== 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=R4QHW2dToAuu+K8yYEpwrujBtMKvPKYmSGZ7+9+CQsQ=; b=hbKUg2FoC4WPpYYkhepfDvNAgRmzQDOpsrXCOALkFbdCkJw0yUxYLxMqznTV+Yo0OP 2R3hNmHs3ZeLzZdbjuVYqxu9wmApWUfu8rFbkqHUE5hq9tUCy1Xtw08bMS7NLYKwmUeP r6QZUPvlCzz4k0CIMjLjpYpMY3JCyOUZLMY6f6eiNuNp0bqEy+seVtUqceXksdP4zfwL RiVmqTB6yR7jkt1k8C7HtgRjOQYo26gOMYsStmyQCHdqgQFTuzvJynTQJMziooWtxtVn 4CJOeg+7Fd2QkmacBVDBQH7+y+mbGBp1JCKkbtSS8i1VUqVmiXAuMmtxU1zX7pv16Hgq t7Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XI3Pyioz; 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 ce7-20020a170906b24700b006fee98076f8sor2745514ejb.23.2022.06.02.09.04.45 for (Google Transport Security); Thu, 02 Jun 2022 09:04:45 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:906:f905:b0:6fe:9242:f9ed with SMTP id lc5-20020a170906f90500b006fe9242f9edmr5090101ejb.78.1654185885308; Thu, 02 Jun 2022 09:04:45 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:44 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 07/13] can: slcan: set bitrate by CAN device driver API Date: Thu, 2 Jun 2022 18:04:28 +0200 Message-Id: <20220602160434.225417-8-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 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=XI3Pyioz; 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 --- (no changes since v1) 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 Thu Jun 2 16:04:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1993 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 23C943F1D5 for ; Thu, 2 Jun 2022 18:04:48 +0200 (CEST) Received: by mail-ej1-f71.google.com with SMTP id bt15-20020a170906b14f00b006fe9c3afbc2sf2698612ejb.17 for ; Thu, 02 Jun 2022 09:04:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185888; cv=pass; d=google.com; s=arc-20160816; b=IOTDxRcAc6Y0CZDeZcp03kdG4/Bmqa+1gqHxL/46hBD4XYU/2joSbXl6qa2xVHokuM bHovi8yABFp47ORey6vMN65UtwEDfoO9HonIjBnWjKRbksn4wPs5Opb5KjjmIyKBcWAV AFF69g67C90OKjMTgvffP2v9Y4AO9jQhZPUqXIAI2cUGP3/X7hYQXUNZpZag2kmbfBEG YsUkSr5Op2fsrm8avZpaRgv8dOj+OKxftg2ni8fboi1F48P1qKcWDMDrLTxhfoKsw7tP 4JPRVMnDP8efqxPdR0M9uJNjdj59ZkVVLdqtfAYVRvhPX+liDsn96iT0Q0adzBLa6yrf 9uSQ== 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=gXRu1B3Vr6aQRB6HppiYd3pdw3btgMng1UOrWgCWEyI=; b=ThRxrIsEUyyUF3kLXTy1PLqHmr1FZHSAgUEv+jNuREEtpeRQ4VMwqWdCpiBQOR8+wn 0E9KnU65pGrK+ov1rVs4OomCffFmgspJfXH4P7F69XDbsDG8GhAhw3ZLCztGdN1BMAra P+xPnNtSKSw4z9gvaRo9/CP5NPbbceZdr0kgmwmnDZPDEwgdKWOcsMWdF7Jbt8xm7PKL phukH0Ot6Kb7Pl6eX4XARgpX64DvLr0xv+bvGBabpU8KmIaKZq5nyPSCFbCQU8xL8EZi U0qSTuH0g6B9GjKA0L+gKjxuAQUPITZuJBv6E5E2cs13pmiipxzlj8+vXhk7G+MDWuHT oHlQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=q5UzCBl6; 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=gXRu1B3Vr6aQRB6HppiYd3pdw3btgMng1UOrWgCWEyI=; b=ZXQKIsb+loqqG/hsMXB4cxCogBwSNJNvWLWvFhG7rXIvPkqQd9k74Ex/XD/symDzXJ UjwdzWJyq2oTpyHxVUawOPRJCVdBNZiWJ3AFGfRdW5RCoMTL4HJmwSNYg4rWoXRaiw8P KDWNvqAX4veCIp9qpSDD99ZKKdQqU8qwt7R+k= 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=gXRu1B3Vr6aQRB6HppiYd3pdw3btgMng1UOrWgCWEyI=; b=RfA/tIICIpfiGFkTSj0HtuAExAjvC0tsQt/hvoqLFY0J7hXQbfRWkeP39o36VxKgMV GZnXItbVUeSQM75eeqeQ5CJf7uGIVgy5QL7iIdLVzLHI9HhTB0FUpgHNilu9sSNB/Jp6 S4cnp+tcX5jNtWDHi5iN/bmJwkjuBAt/mvJ9Qh/D9X4KdaXpCFHKeA+a9u2lp2EE9LAo CswKHAlUilQYmSNmVB5xP2yeTsQroS3l8wiZbtvPsGnuRzkpepAsD1skvaiNX4sGrQqg 6v5n6cqzqfstmwIC/OLE/UYcKRpnvtGrOVTl+wFYIjtJ92yrwnZK+XCGn/FhmB1utBN/ JtwQ== X-Gm-Message-State: AOAM533OJi98px231+il+zYYn/9DtGLjdsYH8ZHldiRZtmReDuTbvo5+ EepC8a/8tonKNbwT8yTw89i5XAYp X-Google-Smtp-Source: ABdhPJz1x0MDp1k1xLnczcyYiosNx7WSCbd6x8zHn4K6je8RuDgQoB370z5BudIHUekM5Hv4ZeXr8Q== X-Received: by 2002:a17:907:969f:b0:6ff:2027:3c8c with SMTP id hd31-20020a170907969f00b006ff20273c8cmr5098972ejc.31.1654185887944; Thu, 02 Jun 2022 09:04:47 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:5205:b0:42a:c2bb:3d7f with SMTP id s5-20020a056402520500b0042ac2bb3d7fls2363404edd.1.gmail; Thu, 02 Jun 2022 09:04:47 -0700 (PDT) X-Received: by 2002:a05:6402:5242:b0:42b:729a:f89c with SMTP id t2-20020a056402524200b0042b729af89cmr6283931edd.5.1654185886762; Thu, 02 Jun 2022 09:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185886; cv=none; d=google.com; s=arc-20160816; b=gam8HNKgQW2Og6RUL4TIKQiR+YLftm2VVwml2pKsluAfLaxLuUr10ZuFNAoTZZ3DTn SvP35iyqttvrOlKtmiT+XxLG7BWSbtdfre1dJCy0rBtAV/7tWM6JexTZsFbmMNFXqLjS yol1xmwuu/LEioGV8B6HZL7nQZXRGmNgkBeSy+vpv0vG+7qwtvHcuaREhPxw9CO2zmKD dPPngqoh+mu23MCXj4KLE6frGdvVK/LH+sKJRMCp8XFryGgDK8uQx+tFL1JaYOmfSlEt fAlcm+BcHaHoW42dTdUembfy0+WQbQ92m3ftvkzjJoTRe0iBmUR9KCy0d2VlzUZT+a42 oiNg== 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=3luMHVxzafdMhwAtVLu7Y4ClLwrUkpqcy72s1ZUJoU0=; b=WYOLPpAupFgjjKMtFolQiHJYgdxG7W66BlyFIVPPUU6tq15JqnLbIf6j7EfBdGb3CC 8K4EwB2CCQKOlNshovGRZMQ6CEWMJgMycsFRUvQiCTCwF5VLg9PMJ5NWJwtnLbd0oGuR trzk+qxdUoJ0pd7Vo8so9SOiFTMJbRUDa5GNrbL5ltnJXuwdwjrLvXyIXr8H8muCrIuC CBD4KApXrJ95SjQfE8+yvXMfeaQQiNPu02eA9Fx3lqRcRZ+ypM9VEKZJkEgzKcMiieD/ mQRUA4YX11OMPevdx1HpEroPB/Kn4ufvIu9QBrWekNbKQmEPOFlOAJJhsUWCWWkqni0x D7IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=q5UzCBl6; 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 s9-20020a170906960900b0070afac782cesor1037848ejx.5.2022.06.02.09.04.46 for (Google Transport Security); Thu, 02 Jun 2022 09:04:46 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:6d8e:b0:6fe:c382:1fab with SMTP id sb14-20020a1709076d8e00b006fec3821fabmr4878843ejc.483.1654185886241; Thu, 02 Jun 2022 09:04:46 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:45 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 08/13] can: slcan: send the open command to the adapter Date: Thu, 2 Jun 2022 18:04:29 +0200 Message-Id: <20220602160434.225417-9-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=q5UzCBl6; 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 --- Changes in v2: - Fix the spin_unlock() path in the slcan_exit(). 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 Thu Jun 2 16:04:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1994 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 5ABBD3F06D for ; Thu, 2 Jun 2022 18:04:49 +0200 (CEST) Received: by mail-ej1-f69.google.com with SMTP id s4-20020a170906500400b006feaccb3a0esf2703483ejj.11 for ; Thu, 02 Jun 2022 09:04:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185889; cv=pass; d=google.com; s=arc-20160816; b=jeA/PLvx43JPgneUZN3E7xxRzvPJGwTs20FfE1mkpsYJNiJtkSMuPp5m3Wa7Fb1Qh7 pMbEBGEYL2yi6SMo9mB5SQEOGOEUYBJ295L8aT9SjX1d3/pdrsmV2Q2i5aF1lvdhGI0f 5jn2lcS/pP+oPwO/OIXUEmqpsEArDwajAR37iV+zXmaETVGx5IUT+Z9APmmg2HKOW4jc tY/kC3ZwgqmZubjNBt475xEpsmeYFBh8EiyXi77uBKSYe/k0S+ppKPvUHB1n9qkIaiuQ NwdejRwtpJaATS3JNK1wT6NjFJIIGTIVUO7DEjbmAm0n04SocQW6Pqd7OBxLNFOf6vl8 /sqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=197GNd0qp9LLY1t3IgOssH0+cFkf1vznoyXLSEgJLQg=; b=bercIct8/BoNTc0YzjAIoK3EEb7EJi567ECGKx+pbl862f7ILUk4bANKr3YE9Zljbs 7AVtgUaeTI30O31r9mnFi8lmy1vvY/0WmWUVb3ptM7qbuGoaPBjMCibDWynq1dr3kuD7 MNAJqbso1DzaKVKRARNxMz3WThURZtX0d4IHLvBzLcYVTPg6UqZPTgyRt/VhPK/+9sDi BsujVg8yeiGjedfBv5gv2STw9Zs8waixGF61brq/OSAolIc+MDZl7rZMb8wiTGZmAU+B w4kt33oCdwfCQelUwQdiguQxQuRLE5UZYfdLu2qZ3Ai+R1OuiEyqr1ucBe8ny+X6GdEU KjWA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gHAVUrp3; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=197GNd0qp9LLY1t3IgOssH0+cFkf1vznoyXLSEgJLQg=; b=MchqNf3xU33kmPAJO0RjnZpX7j4Pym+l9c07TCTP9d2nTo2YrpEXax+H4lH7yPSdDe x3s9UCZkckrbizjr9dX6vqb1qv7jvbDAuLoNy9gNei7hkwHe0aMTPwgu1FkuZdldNt2E J4fnJkuzrj1+pMpRBRWi4/zpC60dhqPLU+PpQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=197GNd0qp9LLY1t3IgOssH0+cFkf1vznoyXLSEgJLQg=; b=gkEFWOLe57urJhD1TA6skF2gp1q4njJkrAY1sUQc0weTx5RgdJPL+fW2V/LbWx/fqs CvytIAjgV8Y82ZU1qnk6s4ObrxN6iY0LhsoAHpWg1gvoYMIduQkNo7fZ1xF70E7e/K7J kTPg3toTCgVkJbvU2ItGENRGs11YmpKRS6tIwmKOil5PKeoo7g5zmb3JGn/o3CP40eAc 3VNlNiaUV1qt0sntEZ/MeBx4ypn9NcYcR3/VHKzl6ic5SiVrid0vmapN1tSew7sAXnC/ 9ZMBFJCz+NT/hqoTaysqmvi+h8tkod+a0FSuUznzJ5NRmRmoMyY+Y/chDehZz5duy2pu M/2A== X-Gm-Message-State: AOAM532fOcDSNJiNpOrtTDEO2uq9hL/PVg5B4SNTTqxk9C7mofaCrZyL PQ286lrdkeZBPL5fQVR9n4tBp4Jm X-Google-Smtp-Source: ABdhPJxv8zcpawGSWN2bUr4iTxut3B/MOfCWyoBEKjqoA3cp4u1lxXdLq0nXiwQAKUlqZhneo6Qv4w== X-Received: by 2002:a05:6402:a41:b0:42b:e6ed:4170 with SMTP id bt1-20020a0564020a4100b0042be6ed4170mr6424205edb.344.1654185889227; Thu, 02 Jun 2022 09:04:49 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:95c1:b0:6ff:45d:c05d with SMTP id n1-20020a17090695c100b006ff045dc05dls2947711ejy.5.gmail; Thu, 02 Jun 2022 09:04:48 -0700 (PDT) X-Received: by 2002:a17:906:9b8f:b0:6ff:f3c:814d with SMTP id dd15-20020a1709069b8f00b006ff0f3c814dmr5078636ejc.381.1654185888063; Thu, 02 Jun 2022 09:04:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185888; cv=none; d=google.com; s=arc-20160816; b=g9fkoDxLzzpmuRLa4Kp4J/Aq6VDF7zEj0P8BEy4BbVroCMNXWAmlWMHy2bv0UvS8Ta oPf3RpyDFzcIjaKdO1h+39Ny/nzaq+mny7ll9rJuzM63dfoGe/vfXLd92qnAQ6EgweXb AZbTnR8XiFgEVzg+SpifpchIjDm05WvV349B2f0rEDNTcFIBj4Sxit3G2r90+teqiD5W 1U3FzJ1iW2aFG/Ogeti7tnZbc65i6f/+laZmgnC8huI/D66HmUHYCZ4Qpl6VyElaIrNx iNIOvS8WxLCIBnO0g/3qGGyG+Our+XMto1e0FTn2vS3GyPhqHstUQXXB2frfWe9pgBeB n5GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=RNI67WCvYDO9rjR6HszZMqDV7pcL71fog+WYkiNXWaI=; b=GCQ2CpCQqm+M6m1wUG9X8e30jgX+/sLOvyDWnm9GQe7bU2RzzzfKKTHNbL9KR4ncTD 2K2F60gZrDsP0IAHck5xXdqjr9yZpEksQ8O1Gua1mwbuw2MMm3nexSyOqN0zBZ/FsyAL pf/U040Siny48xKHAncHbNtyc5nyx2QUpL8suhVzU3xFybIv9dKTKyNrb6jSH/FoGBEC RewmmVGwOXVjpzozJQMIY3NU/7UovS44dk2KAQgW67E3F69ePPWLn8TREXSqa1zl6b4j WJsw/GqnBo/acmVgHx+8whDgYFO+HheDpGAI7tVaqsZ3oq6cIRhYSDl09FW/WM7Js3xu 0iSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gHAVUrp3; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id a20-20020a1709064a5400b006fed02b16bdsor2522186ejv.36.2022.06.02.09.04.48 for (Google Transport Security); Thu, 02 Jun 2022 09:04:48 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:7ea7:b0:6fe:fce4:e802 with SMTP id qb39-20020a1709077ea700b006fefce4e802mr4827382ejc.47.1654185887473; Thu, 02 Jun 2022 09:04:47 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:47 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 09/13] can: slcan: send the close command to the adapter Date: Thu, 2 Jun 2022 18:04:30 +0200 Message-Id: <20220602160434.225417-10-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gHAVUrp3; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In case the bitrate has been set via ip tool, it sends the close command ("C\r") to the adapter. Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/net/can/slcan.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index f18097c62222..d63d270d21da 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -438,9 +438,20 @@ static int slcan_transmit_cmd(struct slcan *sl, const unsigned char *cmd) static int slc_close(struct net_device *dev) { struct slcan *sl = netdev_priv(dev); + int err; spin_lock_bh(&sl->lock); if (sl->tty) { + if (sl->can.bittiming.bitrate && + sl->can.bittiming.bitrate != -1) { + spin_unlock_bh(&sl->lock); + err = slcan_transmit_cmd(sl, "C\r"); + spin_lock_bh(&sl->lock); + if (err) + netdev_warn(dev, + "failed to send close command 'C\\r'\n"); + } + /* TTY discipline is running. */ clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); } From patchwork Thu Jun 2 16:04:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1995 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 768F23F06D for ; Thu, 2 Jun 2022 18:04:50 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id i20-20020a50fd14000000b0042dd305d0f7sf3770888eds.18 for ; Thu, 02 Jun 2022 09:04:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185890; cv=pass; d=google.com; s=arc-20160816; b=Fvd62fN8H0TsvjAl/tIovtLGXNrpozH6rSuz1KAHf80evWYi3I64r5xldCDSizxAFC h/Z8xktqasIzQlglBcCK6Xj1VcSNVmLaVdWOz5XSzgVeNC24mxWBf5C7Kxt7+qQazttd YZcpotGBSEZSo2mvZI6qMewrFQMy8Bug208Mi5MSUkfE0vZc2yntOWyIK6jPTESgndp8 niqrUkMVOCON0NhP23pfF4/V4WMGAylGYznV6IHFgQNpSH8K17NkEX9X6yd0yE70w9Ak 8wb/lv4/6dqQfOMH7fGKr0YmhinuogGVN1WSJAaz4bmh2ypqP+Pm4Rto2BqSQItBT5+s eI3Q== 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=KkTio8KY8smKadcZAD04312fpzVr7gEcjG/2tHvlbTA=; b=hkROXPEUgLy0Ybq09rDoNzW+hmIeKKpM8M6+fc4Spd1o1SLGsq+/WmDmKYgR7Y33Co VOAjpTRtfZGDlaGg1fQnBYh5Pw1CMvmmdrGhNA3e9ZGgCxehXfaLQU/TobZLYYhLypIv Y6oUWq7LNPcFUpR5uG5aBhjrAV2IzfPuIfyeoIIHXvEnmaUiGAJzqEEm5kJSHprkUevT sVWlxRm6KC2o/ZlUUMu7iulBh6LXH7atBYktu5DLGMXLytwbzJta3KzCcsikHwXyCphG zP4u/QyiiybGhV2Od8S2z5A1zcmautMY/PZZAt+Uo25sAzQ2q3cOULGIDj2XD8ZcmclL tbfw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OgaD4kNz; 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=KkTio8KY8smKadcZAD04312fpzVr7gEcjG/2tHvlbTA=; b=Uw6nTP6+lCnWb3nLpZsSwLZWiHi+elVoxrOomCwAXT4cQyd2NCd6wwWRNNMu6IXLvb hxDQ5iabys8DuWB1U6xgFjJYhOiHf55Wo+s/Whiuq7cfk53fYprdQIrjKlF9RhLwuTvP n9jvrnaGXcjjPNZfk4lAzgjU8ZiAqBx8ahgxs= 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=KkTio8KY8smKadcZAD04312fpzVr7gEcjG/2tHvlbTA=; b=Dd3dffgKk8B4vyK9OyWkQlx/hhvtMv2G+fzGSXhlOe1VzI59N0RjZAL6fmdKhFzrth kOubfaDHQ90pxTH+7kzKV5TMRz/lFVNOBejRQWdzyPFWbmDr+YBZFn++w4z7VkbcMqNs VsFvN287iqqC10m5gn5FZSP9PpwAhL4IPTRqi0Z3KEzko4oTudpgSdDqUPgHLgO2dXjB GpGsoLoUfq0zWHp+LeRuqEAuBrOZAWzRWkXvp9TkAV43Y7Y0yBEI9lajO1zitgeZsAlz AC3ZiOWcfu+/rvMpptfgbOKGY8O06eQfKNR8xz+VAQQrZnAEsoohymMXso4JhZj6HSLX ZiNQ== X-Gm-Message-State: AOAM530QJZiwx9SjIN6uFaO0xOe9cQISN93wtD7DneJFiWe+2x/Eg3a4 10MYrZDN5oHEaMG0KEarkkOjZkOL X-Google-Smtp-Source: ABdhPJxLkdj84wa8veE2DRJxxJha+a4fvGTeaHc2Wrp4ZKtL5ympDwS4PZPYw4wynC6ETE8muQujAg== X-Received: by 2002:a05:6402:2790:b0:42b:7534:57c3 with SMTP id b16-20020a056402279000b0042b753457c3mr6188623ede.349.1654185890368; Thu, 02 Jun 2022 09:04:50 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:907:6e11:b0:6ff:232a:2406 with SMTP id sd17-20020a1709076e1100b006ff232a2406ls2157549ejc.0.gmail; Thu, 02 Jun 2022 09:04:49 -0700 (PDT) X-Received: by 2002:a17:906:7049:b0:70c:a5fe:d4f8 with SMTP id r9-20020a170906704900b0070ca5fed4f8mr1328991ejj.493.1654185889376; Thu, 02 Jun 2022 09:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185889; cv=none; d=google.com; s=arc-20160816; b=YZ9lhKa9FIUdS7U6jhKcCNt7d4NwsQLMCTEJGKRj2Q78PR3814uHNrVBLaZ8t6EIpH PCDQBYA78bW1lNeskaCJjGIvs4XpI4l4KIW+cj3mROow8JGWbe6zJ7pEAXYpt2XHV6iK jh01vJy/1TOLF2z7R5qEr9PjTZkgX6iBxaYsVaaDpu5ADAG7wtnJvSbgEJiRQKJH92Vy JGAmy997J1jOMmQ3LsLibne448koFQJNjb5NvJhbbX3Yx/XmYAslATsGoTtO8nKcnXFn 2P6VIYQEzbWVo4uaP7CZl1nZU/ptivfkHP7Tatlc8fYYMUyJIRTni1cB3YWZ62ba4lZY +j+g== 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=s1QllzXGCUo8JTE+hOZVBSnNVj6x3XTlbwu5/oui3J8=; b=zVdTWr+Up31lDQVERaa+sPCIFDgmfEpR25Vq/U0LjgE0Ndb45e1VL6gCkuI319oBpi 7SnXYCGQobavmY/iWxy9yDBqvyIGGBAtEpYPrhwUl+mTPUaq+8mWIbBum16Ug6SWvdkJ utYO0+bCrA+zgp5q9dICCxat59Do2zt7OPWpzIU7DCEu17JX+43am3p49I4PzNVesMfN 3Cqjyz2Yx0Ausfu7DUWu6NRTGrma90+FWltj8TYvtMcI1dx0+GDBlce8B6pjQ5TlNttw JekNoP/c5m3SxBF5XR3xbx3Rx7sUEshsPcA9Z5jtZ8BjV9nIBGsDI3qFBuZoasi8R0V2 CVtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OgaD4kNz; 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 fv33-20020a17090750a100b006e867333eeesor2579670ejc.16.2022.06.02.09.04.49 for (Google Transport Security); Thu, 02 Jun 2022 09:04:49 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:d26:b0:6ff:1670:47a1 with SMTP id gn38-20020a1709070d2600b006ff167047a1mr5068568ejc.362.1654185888672; Thu, 02 Jun 2022 09:04:48 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:48 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 10/13] can: slcan: move driver into separate sub directory Date: Thu, 2 Jun 2022 18:04:31 +0200 Message-Id: <20220602160434.225417-11-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OgaD4kNz; 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 --- (no changes since v1) 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 Thu Jun 2 16:04:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1996 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id AFA5A3F06D for ; Thu, 2 Jun 2022 18:04:51 +0200 (CEST) Received: by mail-ej1-f69.google.com with SMTP id n2-20020a170906724200b006fed87ccbb8sf2709561ejk.7 for ; Thu, 02 Jun 2022 09:04:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185891; cv=pass; d=google.com; s=arc-20160816; b=z2y39dK7hASd8b1/86AXslAGJ2OJPbW19jioyZx7XKyU2AUPBNueanQDWjPTl3WdoE B/SOExy89HnYg0l4ynL07uYaQ7FCWhK0q1qYkL5a2SMOw2LTzmqC5upCoxJTcrxdtVUS r0G2RTyueSrSM5RCO7JsC4U37dVMSQkqXv/1DHkHNizq/QlEjcf1IzcaL+TH+Kl6YOdB EKSVs+lnxSl2p/+9NKr2SdPDXtTgGS5OFQ/ebfJmHcfFta9PfTLhLQVpTHmuPwVwEf7H 3ucWbwj32f551WnaBfHqaEG9omr3++15JA7JgPkR0S5ysHNsmp+NJeTss+SZhTRXB0Su DVFg== 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=OhBEf5j3aS1DhLbNB2XUHSZu/PVvt/Cek1XJWgSSpzo=; b=ZN2NLlHh2+BdaFSd+5ZifN6lGqHLyFrD/Pr+Y++TqH3iBdYePGqPAlhNXg5PL6QoBB hibCI3KFcO8IfCFNz9B6HIqZh6sZ1l/3igLtqkHO260zCwwV8H+qW/9WO002MyGSoKi5 2VUhEa6h+7o6csDCunpyoaE+u07DMt2tbDGC3ET7nKPFl6tCNoYPUANc/sCRrJLJoFIE W6CCYEA2Y5vfaJwKQkblgsuc57qlCJ57DzXTDP1rVZQ84QMW3wHH6FK632H9avo5LFWg iBN2clzbLt0UUP47VOqBXagR0aa2zXd2SiW0iSNfQjjVts6G15auXfCOOdQ6/9g5TnH4 g9kQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=A4z4RYnS; 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=OhBEf5j3aS1DhLbNB2XUHSZu/PVvt/Cek1XJWgSSpzo=; b=pRjiU3oq33DVC14IDfAIkITX/zKHw0Fdg6Xla6kgAi2FGYjoTub5Pj0CZcoN2LzQcc 9EC1Nca6idG34xSOmiUDh+dkiaTNsotsBm3n0Zc6JtFTt11Y0nydEWvVhXvoz9TpqngP OOtUqKJ0lJQa5POf8bZVBJEeUb022hXdnyEDs= 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=OhBEf5j3aS1DhLbNB2XUHSZu/PVvt/Cek1XJWgSSpzo=; b=GRbxu8nv8gXbWMxKY5ezat2HgyIYPu3zAYS5uPeFF8mRyzJgHyGCwr72zHHGFvQ3RE 1LVuTErxKSTvtOMd2DBj2ZvwHzCQdyg7l3+bflgFGFDXqqWbBvGsMQd+mrjV1ungBLt2 a3KMrgCytTrlCOVXK0jPybyJt/D38gwNLHyq2fuWhZnTGadrkKMxV9W6OkT3KYL+0Joz nvbrirHatGfYAZjWIrBS8vLW5zxU+ZLd1uYBaE/jnTlAkJ3Yz1+SkXyDKklLJJSbgkg9 3URS9fVQk8wiaHyAqiex4m7phjNSpa6rkaL/b45U1kWBXTTEOOHgVSj+vt7bxaFyEG7V 89rQ== X-Gm-Message-State: AOAM5331tQDQy2iEMVOjGbPuL5IxNmAS0xCfevIDlVCGCZq7CUS7Hfuz 1JuAhIlYRglP8vbmqbbJBl820eHY X-Google-Smtp-Source: ABdhPJxeJOLg0NHCdvIUCdwW/SLtw1M6qmajhTrmdjkVFirUVf/1rs+QN/cCfGvun2eopaXSWTy9Og== X-Received: by 2002:a17:907:9721:b0:70c:65e7:2aa5 with SMTP id jg33-20020a170907972100b0070c65e72aa5mr1691105ejc.132.1654185891594; Thu, 02 Jun 2022 09:04:51 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:907:6e11:b0:6ff:232a:2406 with SMTP id sd17-20020a1709076e1100b006ff232a2406ls2157572ejc.0.gmail; Thu, 02 Jun 2022 09:04:50 -0700 (PDT) X-Received: by 2002:a17:906:2cc8:b0:6fd:d8d8:b8f3 with SMTP id r8-20020a1709062cc800b006fdd8d8b8f3mr5002010ejr.384.1654185890540; Thu, 02 Jun 2022 09:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185890; cv=none; d=google.com; s=arc-20160816; b=1F2QJDpgEGeOUJbwH3f+NZd0N2T5tyxkRd9Th7J2ylmvF4G7z5tXFwiJ7iOEfD7o2Q 9kP1h1r+CipTX1Dw9LMiXgvXqqc3Zk0fcT1wIpWtvUPDzg/qMUoDLj2UPSfokF/OzSGt 3bY6Itu1c1cB9yAFysqZBv17GpTQ53VrOAyhZnefBvFITCgO3inACCojpUCwe6bheybU Z0t2hj66t7oRJRBYXY0ONGIIWhn9m+zU4iAEQ4Bdj2ITlx00YsBQyYDF6CWux3rRM13t GyigVvYCCD4V+qcoHPDXG0e1MutCHFuG3iUGdehcE8BBf8R4rLNKwqaFW7ku8OTTrq9f JFJg== 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=feLSmY8BBn9mdJGH0Zp+/FP9G8mj2HRnAEuisSq/n68=; b=uT3cwpudQO7/+IpZrC2nNuUFPevdytVYNMXE4CRGN6iILsJ05Ktz/bntwo0g1lrdg5 3vlwpjBiWjxiOtCOo+A1m63dsITlNwHObUVC5UwSX58h2weDpmhEU1ffmC+Ejd4n/YmB kpEIE+3JJ4qYC3uIT0DjL1NypPdxJA425XjOSCPRESLHmQsoIzTLfjSu2EID1gQIcDDg rNHZCCA45jQFRc3B1XhXmB8O/0lTbLyTVvc0NRWAufOXFmfU5/9bGp4x/fPU+x+snGBt 5BXb9oGfYzrRMIMqV8wz7qw1rF0794MlpUr0WUXQtLbvsNbsbBYvPQ+jdDlaVSWUxr0H VAoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=A4z4RYnS; 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 wn15-20020a170907068f00b006f3ee8da511sor2585284ejb.48.2022.06.02.09.04.50 for (Google Transport Security); Thu, 02 Jun 2022 09:04:50 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:1b0c:b0:6fe:25bf:b3e5 with SMTP id mp12-20020a1709071b0c00b006fe25bfb3e5mr5001433ejc.689.1654185890053; Thu, 02 Jun 2022 09:04:50 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:49 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 11/13] can: slcan: add ethtool support to reset adapter errors Date: Thu, 2 Jun 2022 18:04:32 +0200 Message-Id: <20220602160434.225417-12-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=A4z4RYnS; 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 --- (no changes since v1) 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 Thu Jun 2 16:04:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1998 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 88CCD3F1D5 for ; Thu, 2 Jun 2022 18:04:54 +0200 (CEST) Received: by mail-ej1-f71.google.com with SMTP id kf3-20020a17090776c300b0070d149300e9sf235911ejc.15 for ; Thu, 02 Jun 2022 09:04:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185894; cv=pass; d=google.com; s=arc-20160816; b=yh4dObG86V58V9+/3MGaOPnhFBCf/VTk/qOMjK79+4c2o8uiNvjql3M3IHQF0vivzH +O4b7bQYkl1cAb1lNnuBhU60yYFHWvNUmBLL72wctGM/mhX0P8F96eg4zYMiEmW9+OY7 Atwqpovl9YSSiurarsvefhX2SQ2bWNAheTlAdzjxft5zK3z9eA4I4RQqk7BTGoaGqzfv pRhA0x3VugMyMqp/QvcETr4LlY+qR1/K2WjgR6DFWTywbKlC10BUnFPOSWtr86bS07dr 0CL8dB7nQwJp8hzWVR6z+hdiUYeFhTrm0rz0wR6hJQqfiY7aoEKg8mX5eJGshunHA67P Gbzw== 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=sd3hIMoTnmD8fwqb6G8FDJDqa/fLQl224jiJHsKvqOs=; b=Bm2l4xea3yiiFFQqk3onxy0rf+SgCz/Pg1RFBsTIJ1EI/yQ1n5KiDdIjx0z1sfJjIC Ns1ZocTyYSgjJxG6L3pg2s44dYxkGCoZwMcKpnX7qffCf5XT9f+6f8a1y1Z5ZG6kmpZ1 Zv44tXxOpoe0PknPEZkVGss5t6bPqZOMHXhXnEbu3YEtaFdEz4jpC5ax0qNBfR+OnkI3 GTwyummL5I2LiUjU+wd/wDYQakjwBEzChIvPINo2ypg919Da5NmDZwEg9Y4+L1YT1HsC uFTkDqi0kGHpi4oz0+NR++MRsg6L40kTidqyJzM8aRYdLaDtx2a16sm2upEjXc2G38XH Rb0w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=pMsGPkxE; 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=sd3hIMoTnmD8fwqb6G8FDJDqa/fLQl224jiJHsKvqOs=; b=c+J3eKfMOsGka49GZILydgALQS/bWB2/XllhUUlQHlh+21Qz+NxSXBTKH79AscA8S9 EidPq2Udia9dvgfkyTJwMDEl6SbA1oJQVHops6wmzP0qWNeLFnY0hTTzVG20FK4WxGp0 VfFLVRSZEeKpeCW1rO0NMJjZz/igT7VEJLX2s= 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=sd3hIMoTnmD8fwqb6G8FDJDqa/fLQl224jiJHsKvqOs=; b=foglIgPo/IU8xP3zpTfRnqz/0tnR8RR2gsgNfhZ0bHNzOit2ayZbb3pXFXX/uOs9af 9Zt+bvFmraPqgSJWP+RC8aucDtVZhTfY6pVTGw8w12u8Csluf52/WVUrEn0S5ZOSm/t6 HzMcrIgR0fEqHIZWT1ulY0d/XOIYP8adnbEVDA9r7tDjE+nFzcOZFLbmEwc6vx5xo96n Uw54x/TgGKIy0Xm8KvdbAIZdLiForY1k+30xOhpNxMWcl4RqCZWw0OroemCzgYnTbOji D/QrYO/dMocdMogFuCPqTIXALujX9FXBq7tsH0hzn2KtewtKMirOH7A2t2hdBm1A7Dfe 8ceg== X-Gm-Message-State: AOAM530CR8l8dfEhytaW0FRH52J3WjSEmI65c1junUv3oxr5861B+NJs K9jj3a5Yx5WmvFsm4QMudQOmBOFa X-Google-Smtp-Source: ABdhPJyc/a3KgRlDzF3EqSsabNvaBt0kdV+8nyLbtw5u2Pa7uRYb8MJ0l1LBkX67dLwByF+nhtLaxQ== X-Received: by 2002:a05:6402:2410:b0:42d:a513:5536 with SMTP id t16-20020a056402241000b0042da5135536mr6327710eda.395.1654185894318; Thu, 02 Jun 2022 09:04:54 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:86ce:b0:6fe:c3bd:7a48 with SMTP id j14-20020a17090686ce00b006fec3bd7a48ls2949768ejy.8.gmail; Thu, 02 Jun 2022 09:04:53 -0700 (PDT) X-Received: by 2002:a17:907:c20:b0:6ff:9e32:25d8 with SMTP id ga32-20020a1709070c2000b006ff9e3225d8mr5033364ejc.62.1654185891434; Thu, 02 Jun 2022 09:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185891; cv=none; d=google.com; s=arc-20160816; b=JPP+IsBSGZdx57Aren8O5PUd6WltNJPN1mgGVFM6SjHtddfKNOAyGu+MTrlJZXe4lx R4kzOi+PG9+cdEpq2IAQO9Nnc0cwZLQqjv3j62+ZDgzQn6/x9ZhULYJAdKDNqLBXWfls 4P0NsCuo7u0ATsSqTAgpZg5s49SB1WGjbAVtzI5dWvnQ+s7cxwimmZ+NPTJJ/ugDVodn 0X+NyDMBKPhNGMFLI5oVR5PT7I2KVnXeV1JDJuwTRgrkD16BtuwqwuFkP0GcJIR0mMTx Fj0+UeQUIRiQyNHWVJh3dZdoeDUjqZQlF51768YNrRfD1mjrOGd7zLz5dnrzBh+6HfB2 leDA== 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=tIMw5y3svCAj2C0qGslIPuiNzahiJeK2yVI7G04kUeQ=; b=fRfqEPHNEvjF1A2o1rTY5k5GPaOcKzM1jG50RahZ88uTUn9TzRHfvjNS/do+doVN0e OvtJ2Uy0R5qef7LruKY2NoZpCz6qFeOWZ3kLdk2jv7xY1y4ynu7t4Ip14bMZjWOnDBZ6 ek7APGwjAjcgjekaFVborWIiD3cQxYlKf6a61xApU1AGeCluy4ztLuuluxKn8yODmn/f IKryTKbn4O7jZtXpg6et6Ol0JCq+BHecdW2yKBwcfSk+bUwOu3zyHyvrfh+OpOeUNdzy bjfHV9f1xjhhFelFBTY8Uv/34D07MDatFgcPCPihsBuTHpAfKAxMUPN7so5b9W/m8GIM xH5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=pMsGPkxE; 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 ds14-20020a0564021cce00b0042ddf53fd3asor3204263edb.58.2022.06.02.09.04.51 for (Google Transport Security); Thu, 02 Jun 2022 09:04:51 -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:aa7:c852:0:b0:42d:70d8:2864 with SMTP id g18-20020aa7c852000000b0042d70d82864mr6228330edt.379.1654185891009; Thu, 02 Jun 2022 09:04:51 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:50 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 12/13] can: slcan: extend the protocol with error info Date: Thu, 2 Jun 2022 18:04:33 +0200 Message-Id: <20220602160434.225417-13-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=pMsGPkxE; 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 --- (no changes since v1) 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 Thu Jun 2 16:04:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1997 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 3824A3F06D for ; Thu, 2 Jun 2022 18:04:54 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id t5-20020a056402524500b0042deddb84c2sf3797875edd.5 for ; Thu, 02 Jun 2022 09:04:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185894; cv=pass; d=google.com; s=arc-20160816; b=IsbcNrDkzbtN99K++jYzH5aZZrj83YyQU+i9O6gLgmhVIEBoM+mHamy/k0dlm2Os8O ktuN1VPhv7GOKiWIODYY/2RXQfF4rfkogyUhhZLksyhVVp0sWKlJn173ZnPdFp5LEIx2 UeNVPX3Ff5EAjh56HHQ3lI5KpltZ78DXNw6hAF46bnaFQleA7LNzjrNofd/Z1tdaaiwg 6Bxg8TWCncnhFBwmfn6rd5Iv6ceCpq5IdQ4QmvNw9MEqO3Cl5kcYhHPgzfUJhky/k4nL Pnw6iFak+VK/suUGjwxBgm39Z+mN0qyUb8tJiurY4UUJa7NcnBSGtC8F6oUBIRkZ3g1K ImxA== 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=FXXGJ8SEbNZz+VbLvdzXVaRHuPhZowf0oL0YX5HxL5c=; b=b4kAr5XXA38aNdRI7/09Grk9QrAepArLQodOh1YVQZ1e8btoFqwLqhDDiLsZvqR8Ne X8DkKNkxmrlSJK612soDyDemP51+Lxkmfe809nZgd2sV87L6Nr0hXdCf5bEeX0yJXgwB DLgXdx363ZBCfCbvmU7Mf/OGFiv1Y2hpIKqcDMCTQFh56842RLbnYGPgB+/nfUw9ymbe CCvnMk0p4g1aRN50wkLZL0wCamm4apC5Xozom/2c7A+MDLa7BNcvvvmoa4ekTk7pZH5O 7p8rxYxN1bX6TUUcrM/TRmGeQ+fKrb9AxqpfWiHT7bX8wFyAmyyxVUUGDqIMtpV6vcMh /uug== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=e3DqoHgH; 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=FXXGJ8SEbNZz+VbLvdzXVaRHuPhZowf0oL0YX5HxL5c=; b=Z6Oy/yhFmJRFrqaGBwgu3wnoZjMATCdzl0DWASf2J7rguvDMekQ4ZRUFqRnZn4sR4g J1yYEjao9KRiIoWMWocQoY7BTXVVWGvKDLeuLXLHued5OpVYDG2eEohIcFWekyV2vNcP N9sLlrJ/8Pwf1WIgWtRNDWO88h1qykA4WEwyk= 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=FXXGJ8SEbNZz+VbLvdzXVaRHuPhZowf0oL0YX5HxL5c=; b=YZIxUVe7CLMFZNwxDD3sHEnih7ha3eN25Ow52+0v0CNvbb7/biqnu69cOcpIlSavLJ FI/VSXlkINCW342dGRzSVUc/iOx6FncNQqO+S+67zlMRrIqBQ3PHuX3AsvdkK+8w8PlV WlyQia4sJjm3hJGzkTsTtnY9h/qVGs8DoUz/D2M3Kkc04pubv5iSOOnO0MZJ9rmFxyrW qpAA8RWwBm2IJOV6E0h39iKQl9zQ0pYU6T9V29iI+3rI7QgfzSY5o3t8WZ5ofTGseDZi Ys2a01AsE9OBz8OtAGZBVP3VoxhjFSor9NP6w6oMDN7/n05NoIsuQq8xreRU3Mge+Hyv g0Uw== X-Gm-Message-State: AOAM5321K0eVSPPz/1SiqihduaOHpPODZGJ6XyGUsavdPAa5pOxtkeVV LabjCag3LHZ2UPb2sczJbx/nXtpB X-Google-Smtp-Source: ABdhPJyyTracrgz84IxZzMl5ZP60lwZdxGioae41q7KL1/Xbmz2AcJajMW6riw1ls+Yt1MTYztrdUQ== X-Received: by 2002:a17:906:c2cb:b0:703:9e51:a3ea with SMTP id ch11-20020a170906c2cb00b007039e51a3eamr4954394ejb.130.1654185894051; Thu, 02 Jun 2022 09:04:54 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:2741:b0:41f:7eee:e393 with SMTP id z1-20020a056402274100b0041f7eeee393ls2361663edd.3.gmail; Thu, 02 Jun 2022 09:04:53 -0700 (PDT) X-Received: by 2002:aa7:c457:0:b0:42d:bd18:4ef with SMTP id n23-20020aa7c457000000b0042dbd1804efmr6449603edr.112.1654185892994; Thu, 02 Jun 2022 09:04:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185892; cv=none; d=google.com; s=arc-20160816; b=uQe2lTHm1a+4iadCx8PLf4UKacQEAoK0Vow5i5PtVJoeG0+pfSI9NdYnDs0W3Y3fLw OW28nGy438vCyeCdhPDW66c/RV5Um+FS6c1UeQYx8zjj8YNMYDdWn4LZNnBzQoMoxbl9 kG9gM6z1GJepWy8IH/WU6HV2T0cRsjUibcNhfHHizqz6Hg0AR5wO3Z/8UuPcJVXxEjYg EW41l9I7IPC98hZ2SXD/HUoS6KbfN9LxczFJ9SCFzTUl6/ZdunAyengPPjPEcq/O1oSZ O/dmWd/L0XihfWDs3AWWSLsRoG6BnnxxXAUN8zoxezhWvYcSOdtvZYcqcNrG3GN1s9zX X4cg== 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=v6Qqrm//g+VUVMemYpr/urjW2orb6sFKqRMVXIOVGPs=; b=mBNq4/fVacQSxmolHOHsX/NUkxM+xBBI+qSfihsT2tsPhL47kKYJcYZOP9qyKQSbND mPPewPU2buNntkpSPTUkg+2p0MxbJQsZnhMfSWit3brNK7/uxvLFS44HtgK5Zn5RPF4u tbf5dkarPBYKvruCmzZpv9yyquDH5MjS9q12yKcy6xhfvecsXWVu0fpA1xJMxLg7rEC6 JjhD61D/p73wWh2sfkIoXdiIA2z+iOxNITUmjDOKQAvdATc0EmEg2v9j2GrQAfWfON+i 0CEbLb6uf93t8p0qP25HFRfsMcpDqEnb0+3T6pvM0Vf38PziY6yUxIhen256Ya20RceO zCkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=e3DqoHgH; 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 kb2-20020a170907924200b006feb4ab1eedsor2073369ejb.104.2022.06.02.09.04.52 for (Google Transport Security); Thu, 02 Jun 2022 09:04:52 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:6e88:b0:707:ea6b:5e15 with SMTP id sh8-20020a1709076e8800b00707ea6b5e15mr4870880ejc.57.1654185891908; Thu, 02 Jun 2022 09:04:51 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:51 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 13/13] can: slcan: extend the protocol with CAN state info Date: Thu, 2 Jun 2022 18:04:34 +0200 Message-Id: <20220602160434.225417-14-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=e3DqoHgH; 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 --- (no changes since v1) 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; }