From patchwork Thu Feb 16 19:04:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 58213 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp482912wrn; Thu, 16 Feb 2023 11:18:17 -0800 (PST) X-Google-Smtp-Source: AK7set/QRe+RELzmF4uqFL8OrC/QkrfUFYmGg0KcG8lq2Ok46uy+H4lhovXuv75Yv3DgEOMuE/Ri X-Received: by 2002:a17:906:f217:b0:8b0:fc14:bbcb with SMTP id gt23-20020a170906f21700b008b0fc14bbcbmr6890020ejb.42.1676575096939; Thu, 16 Feb 2023 11:18:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676575096; cv=pass; d=google.com; s=arc-20160816; b=m99g8Ufg8KxjI4aKSb3//bKzipu2fzAxdPVaK8Ab4KSxE4hxFhfmTY9Mmc7cEJPPq6 M/LNyFhUU20I7hh2mfgdm7J/orFDNRJgCcLzrGSp42c7GolS8HcP2Zv/ZHTrlNW7pATL dM6/nnu7zigN/rXj/crCBagMMeQ9TaNdxKIAz88zZUSvf2/UkKkxvBaJBckkyArJCYFe Qc3dR3pBNou8SUUF+pkQkKGyVyPBzp9i6OL52unUK1DMPW/CKdNaNWQ55Vtt12KYcziv h+3Xw5r16oB5xUlkjsqdnvmtgFwsGojeNSkImG0ecJxYbLfmj1u8j3Hha59fMvym6tiT IEIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b4xNZXOC847rRbcRynunWhQwNs149/QXtpGCFyXtcH0=; b=M7unZiDX1UovTT3gPKsANC8Zrr066NLYDL3YZQPwtY/PghppCB4AkLzhkiLW6tACC4 czIz2e4zjbgcyzp4EqXnVfpA+SnQ2S1ynZU03KVTbJ0IML+Q3Wad7L1h/YYTZRMhuwce GOgX36dNdtHNhRk5vWOdaBsVA/YAQY0KOrv8LMZO9O/DgzbGV7W/+7T7c2JEVm5qwDjk 923j6eeV3HQuoWHPX0skFpOF5C7TFPaVlOywb0BIE7SegDtK6+ZEp6qv4eMhxZwPSwCP l0AaM5UEf49UJDOVWNHAPD76hG7DwQkmmlgstsckXSUzCi4Z/uw+DE2kTC1zZhDzhGDm owXw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=LVpKwOVB; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eu17-20020a170907299100b008b17fe8a06bsi240138ejc.70.2023.02.16.11.17.53; Thu, 16 Feb 2023 11:18:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=LVpKwOVB; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229802AbjBPTFN (ORCPT + 99 others); Thu, 16 Feb 2023 14:05:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229489AbjBPTFC (ORCPT ); Thu, 16 Feb 2023 14:05:02 -0500 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2094.outbound.protection.outlook.com [40.107.241.94]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E87ED505E7; Thu, 16 Feb 2023 11:04:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aQyYdRo9u3P+HRDx5QFNBfuktumqUMZpEW11zd2EHP54mtNZzyFmMBVtA4X4PWx1tQzkTEjP0wHGcOwTke+ATGxco0ARV28bXBc5bqJpTJk/2AXDv8VmQlUg1AsBp6LXz0vPSmNa4Oq0nExBLAt9buCa9dYfbYprMjM3aZ18uyNh2YzJf8lzFRVQOieZlToipPe4ksxRO0JJQ+Ie/u5lRgWe/Oh141v5UAdiH5/hXFXZd5rmBWkdvSXCXCl7V8P4bJeDysH/fqbCjpD32xFsGx5yd5qGGYoJ+5rKPZz+j/uPYyKfkM1X20iMeffwVz7rm4wvV4Zpd1Z9sBeTQ278Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=b4xNZXOC847rRbcRynunWhQwNs149/QXtpGCFyXtcH0=; b=dW9hTMTk1RD128oSVV17vFl5qscqEzVgFGAS/uNf/q1xb3+KE+dh3yGCvtUVUU88oFhsqTgFj9ZxCZCgJjgI7N9+YBtS9thsWahi+REtakUaMMSVOW8qdwanMnucasFTlRt0Czr6cTKBaLqWcplxUW+stDaaVNowTclwaNDloStSdCkxlo8qlEk/NMKU11ZNS4xFqV0hwJ92dLXqo3rZi5aR0sGCIxNocsflXjuRDQoLV55o1P3NoWri1oY3qWHBW15+gsoSrdJEpMTjvbuDbnccp+yh+RFJy27p4Wo5E71hf4C43GZvjs+HnVwHXoJYWH5cE0WWUDiZ8UT8qv1diw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 80.151.164.27) smtp.rcpttodomain=esd.eu smtp.mailfrom=esd.eu; dmarc=none action=none header.from=esd.eu; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=esdhannover.onmicrosoft.com; s=selector1-esdhannover-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b4xNZXOC847rRbcRynunWhQwNs149/QXtpGCFyXtcH0=; b=LVpKwOVBd+4TM8lQ9VK/0ccMeS1qaqIL5hFudUShlLa8U77E1EUtYUKFGM+Y29nVj5mpkp1jogYHXN5lv8beotaknOTEs9wSoqsdXCFdPdaE+alLReHSDoQ49zX2ACTjKPfDbBdZw02WhAcq18d0pys6b9Cz3+7aedO5e+e77yo= Received: from AM5P194CA0021.EURP194.PROD.OUTLOOK.COM (2603:10a6:203:8f::31) by DB9PR03MB7626.eurprd03.prod.outlook.com (2603:10a6:10:2bd::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.13; Thu, 16 Feb 2023 19:04:54 +0000 Received: from VI1EUR06FT012.eop-eur06.prod.protection.outlook.com (2603:10a6:203:8f:cafe::3b) by AM5P194CA0021.outlook.office365.com (2603:10a6:203:8f::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26 via Frontend Transport; Thu, 16 Feb 2023 19:04:54 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 80.151.164.27) smtp.mailfrom=esd.eu; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=esd.eu; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning esd.eu discourages use of 80.151.164.27 as permitted sender) Received: from esd-s7.esd (80.151.164.27) by VI1EUR06FT012.mail.protection.outlook.com (10.13.6.164) with Microsoft SMTP Server id 15.20.6086.24 via Frontend Transport; Thu, 16 Feb 2023 19:04:53 +0000 Received: from esd-s20.esd.local (jenkins.esd [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id 80A7E7C16C8; Thu, 16 Feb 2023 20:04:53 +0100 (CET) Received: by esd-s20.esd.local (Postfix, from userid 2046) id 726612E447F; Thu, 16 Feb 2023 20:04:53 +0100 (CET) From: Frank Jungclaus To: linux-can@vger.kernel.org, Marc Kleine-Budde , Wolfgang Grandegger , Vincent Mailhol Cc: =?utf-8?q?Stefan_M=C3=A4tje?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Frank Jungclaus Subject: [PATCH v3 1/3] can: esd_usb: Move mislocated storage of SJA1000_ECC_SEG bits in case of a bus error Date: Thu, 16 Feb 2023 20:04:48 +0100 Message-Id: <20230216190450.3901254-2-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230216190450.3901254-1-frank.jungclaus@esd.eu> References: <20230216190450.3901254-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1EUR06FT012:EE_|DB9PR03MB7626:EE_ X-MS-Office365-Filtering-Correlation-Id: 5400aec8-b850-4788-f372-08db1050b002 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5w3mxrEOS6dDDC8B/J1x9ZIxvAHkFZoqxE8up4TfBaz8XRkT8sLWiMQiFdL1I16oWbA0VEOKq79Z3PizeGaP91qrNKavXt2RagEtoubkO+o/R/iqYoawnhoCylqe9qKK5lewKSKyVwHopV3NxsdIEFMmrwWZ+KNsBZ2KI0l8RbMww456O62V0Wssu7q0xjhF6XY/Ms/lkr/RSREiZVqphAFUosl5+BhOeBLmkCJrP/ZRpRPvmI+NOWZl57SJfevAEyHi2bAUuP1LQCa9zfrezx2mNaDAN1mzXAuMrjA6KQZo+W98CN7vovIEuUpBGFyBOIxco1X0Wrfb/vL8saE6MtYy4Epd5VG1y8GvvCaC1iB47/1LIr/2TSSudYVj78ArKu5lPx10raENNv4dxyGWOlurwVR23Ar/LWK9jUiaUVDSY7X6Q1F6hAv4e/zCMW9XAdUfWjtCsbh5F22TgjIdGxkPa3UBvQztC1srF1zHDCsVmByEGPjB+AyrTGS1KjOdecRdhLOLEJmylsqadci1Jk7cy+ttlcU745G9neJPxsbvglqj37zKCSLMR6FYT7jw+rieOHFsm6fq/AyC+OT69eF/ajeKEoJpl+wzFarWW/OdrEXqA0B7xVC6R8ogPAS4/aGqGdTfxNzmuq0h2c/kdiMbsaN++x2sKWJM/tBcilw= X-Forefront-Antispam-Report: CIP:80.151.164.27;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:esd-s7.esd;PTR:p5097a41b.dip0.t-ipconnect.de;CAT:NONE;SFS:(13230025)(4636009)(396003)(346002)(39840400004)(136003)(376002)(451199018)(36840700001)(46966006)(86362001)(336012)(2616005)(8936002)(186003)(6266002)(47076005)(26005)(36860700001)(83380400001)(81166007)(70206006)(42186006)(54906003)(70586007)(8676002)(4326008)(41300700001)(316002)(40480700001)(356005)(110136005)(1076003)(6666004)(82310400005)(478600001)(36756003)(2906002)(44832011)(5660300002);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2023 19:04:53.8531 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5400aec8-b850-4788-f372-08db1050b002 X-MS-Exchange-CrossTenant-Id: 5a9c3a1d-52db-4235-b74c-9fd851db2e6b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5a9c3a1d-52db-4235-b74c-9fd851db2e6b;Ip=[80.151.164.27];Helo=[esd-s7.esd] X-MS-Exchange-CrossTenant-AuthSource: VI1EUR06FT012.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7626 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758016409131483990?= X-GMAIL-MSGID: =?utf-8?q?1758016409131483990?= Move the supply for cf->data[3] (bit stream position of CAN error), in case of a bus- or protocol-error, outside of the "switch (ecc & SJA1000_ECC_MASK){}"-statement, because this bit stream position is independent of the error type. Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device") Signed-off-by: Frank Jungclaus --- drivers/net/can/usb/esd_usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c index 42323f5e6f3a..5e182fadd875 100644 --- a/drivers/net/can/usb/esd_usb.c +++ b/drivers/net/can/usb/esd_usb.c @@ -286,7 +286,6 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv, cf->data[2] |= CAN_ERR_PROT_STUFF; break; default: - cf->data[3] = ecc & SJA1000_ECC_SEG; break; } @@ -294,6 +293,9 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv, if (!(ecc & SJA1000_ECC_DIR)) cf->data[2] |= CAN_ERR_PROT_TX; + /* Bit stream position in CAN frame as the error was detected */ + cf->data[3] = ecc & SJA1000_ECC_SEG; + if (priv->can.state == CAN_STATE_ERROR_WARNING || priv->can.state == CAN_STATE_ERROR_PASSIVE) { cf->data[1] = (txerr > rxerr) ? From patchwork Thu Feb 16 19:04:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 58212 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp482407wrn; Thu, 16 Feb 2023 11:17:03 -0800 (PST) X-Google-Smtp-Source: AK7set/6u5fEA4n7GbOhaoJWmXvx5vNtgto8lCXfL5H1kLzn8b4myfzIrwQ3ms9Of43C4VgNdmAP X-Received: by 2002:a17:906:2c18:b0:883:3c6e:23eb with SMTP id e24-20020a1709062c1800b008833c6e23ebmr7153509ejh.42.1676575023374; Thu, 16 Feb 2023 11:17:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676575023; cv=pass; d=google.com; s=arc-20160816; b=ctVYKscYvATEvgj4HXOLeSqUCK6cv0NbJeAtqWB7dEM0doRNvzPlXIE+knTbJKIdjU N/kifDEHoxtWZ/One9DgZhVyzLRTzOvO8VQyTt6i0k3niuzO5ibkMmFV9BjDnGIBFdry ENuRTgbKy0TRSqGFFlPsyolaggd8RevRMm65MBv4AHAjRWwH/LUr9JkMZKReNCNFTNeb aKaeKL9uEKzEfLhRTdGvkvS00VzFvn4Nx0v9b2cRk7g84Oj2KqkKOfPF0A+JL4B6bhLl ZqFikIEjUF6kUf4CZuWqAaZkPGXsRwCrjTF326XGQNRKH0LIvokobLDodOGyw+pKdrq1 Cung== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5p9oaC9ysELqUQEUHCq7WcRrA5JWUMDVBZ3g6GDdMSY=; b=paJHMLCGBVNjQUmjMDZq3n1yvakhAaaw7PR1fYtElmQ6k91B0PFASbGzQ48KEQmU97 rKBL4X0QViYM2QFRwMiG3bfnMe4bjuxePe2IgSOMa/V/8lKXgw3AwuuyTl604Jk/CSno rRBx/58VtDYENnGnzoCvhTtWhQTsKNPjZyDJsqYEY94OKStjwjbhxI3hiDGK4pfBetv7 WfZ5cskxw8NF1rtGWV5WAnkOp8dAYTe8HXFdHDOTVN0GvS4Hi5KK6mSGd8zifyvVNFh5 pW/8TM2rpSOnyUyXrHWD6cMmKfSoqbM45tIj7T73rr9r9jnYO9lx4WQjsIkZZeQALVCu GFUA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=npSmvLkS; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 20-20020a170906005400b008b14cb2b84fsi3513000ejg.55.2023.02.16.11.16.40; Thu, 16 Feb 2023 11:17:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=npSmvLkS; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230130AbjBPTFH (ORCPT + 99 others); Thu, 16 Feb 2023 14:05:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229999AbjBPTFA (ORCPT ); Thu, 16 Feb 2023 14:05:00 -0500 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2131.outbound.protection.outlook.com [40.107.249.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42180505D8; Thu, 16 Feb 2023 11:04:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C4gBsM1tXz/J/s+N6k2YMIS9vZQg1uirvrpofEKC9FhmUaxDNeDx5ecLTDr8vjBNipOqJ1yA3ljkPBXTP+mI5zpJ+3K0TCuBc0Q9nYsyMXH3U7O2DikfQBlUEkmcXuTj0yS4wX2mVU4tfVQYgRFt5t1A7pgjq4JmyArheChDWukwgpV7M/v1KnBXhuFqKuOInfiQhVXPhtEUUV35Bq9sqvMXHf3NfUaS+MJ5IT23Pl3AYeIeZSWJ+k0MAiTN16JoEQD2eWa21e4hmC/coyo9lPb1jjGfUMwol9Uf/nW9ZTWM+gd1obGh+0o8WVyfoU1721hOcsDhFEi2CbWquRF0EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5p9oaC9ysELqUQEUHCq7WcRrA5JWUMDVBZ3g6GDdMSY=; b=DHRmrWrsCw8yqFZl38zG+n7ANPMu6Ubv86BhkExrhDeHmoBAYJmpJb3UZO39PVYAY6R/VR/BRskQABifqMXpfEuG2Q3f/41PDsVzMM5Dd+at6+DIvjHO3wYksRQLQcl5kzPw2SnjDpxC9LdshqRvICOTDYe2bjeO80n0hqhatv4ktBkrDsIpE9DYRqSUkVBp96FTn5DKsWspb9T9FHRmlgwdSigYw67T9L6QpsFa5aXvOQvg7qkTcg+Vkzn0w/I+wZw9/ILTZNtsl5w6tmJbCVUrWnpTGVc3s86z0GeEotfKqVfjjuHugXVX9yDvXkwoEETAcYiK/u8mpTarugAuQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 80.151.164.27) smtp.rcpttodomain=esd.eu smtp.mailfrom=esd.eu; dmarc=none action=none header.from=esd.eu; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=esdhannover.onmicrosoft.com; s=selector1-esdhannover-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5p9oaC9ysELqUQEUHCq7WcRrA5JWUMDVBZ3g6GDdMSY=; b=npSmvLkS01CQa1p6vOT3kUPuAKhHbUve2TEzTs4IF64mF2pGWHhYQ3eAt78Elt7zdKI+0w+zNdVeeK1nbnMYi9EElheXDNGNr2EgDUPmqULeAsh4QDPhKzUBAmfgl8varBtHGuIk5BFNrMCJdMJ7QSRhFGPWtuTtHumA7dnQTdk= Received: from FR3P281CA0180.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::13) by GV1PR03MB9870.eurprd03.prod.outlook.com (2603:10a6:150:3d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.24; Thu, 16 Feb 2023 19:04:54 +0000 Received: from VI1EUR06FT024.eop-eur06.prod.protection.outlook.com (2603:10a6:d10:a0:cafe::48) by FR3P281CA0180.outlook.office365.com (2603:10a6:d10:a0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.13 via Frontend Transport; Thu, 16 Feb 2023 19:04:54 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 80.151.164.27) smtp.mailfrom=esd.eu; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=esd.eu; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning esd.eu discourages use of 80.151.164.27 as permitted sender) Received: from esd-s7.esd (80.151.164.27) by VI1EUR06FT024.mail.protection.outlook.com (10.13.7.235) with Microsoft SMTP Server id 15.20.6086.24 via Frontend Transport; Thu, 16 Feb 2023 19:04:54 +0000 Received: from esd-s20.esd.local (debby [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id 83C067C16CA; Thu, 16 Feb 2023 20:04:53 +0100 (CET) Received: by esd-s20.esd.local (Postfix, from userid 2046) id 763EB2E4481; Thu, 16 Feb 2023 20:04:53 +0100 (CET) From: Frank Jungclaus To: linux-can@vger.kernel.org, Marc Kleine-Budde , Wolfgang Grandegger , Vincent Mailhol Cc: =?utf-8?q?Stefan_M=C3=A4tje?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Frank Jungclaus Subject: [PATCH v3 2/3] can: esd_usb: Make use of can_change_state() and relocate checking skb for NULL Date: Thu, 16 Feb 2023 20:04:49 +0100 Message-Id: <20230216190450.3901254-3-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230216190450.3901254-1-frank.jungclaus@esd.eu> References: <20230216190450.3901254-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1EUR06FT024:EE_|GV1PR03MB9870:EE_ X-MS-Office365-Filtering-Correlation-Id: 52ea519a-7b09-401f-7609-08db1050b026 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z4ahGyqAIfu5aN/6b1SgAjP3LRZiiWFs1RElbP/qmwETA3vYkixEEGboOwVyPoRaDiYkNpK9cbpo6GehWgs0lLhRlOsypOwlZYjDMDRiM9gBoGOeo4jzEPF8uQEIpNJ1IRsw9MpROsqNmfGkdEXUwUj2aos1FI0qUPQJ5dCSJpozJQjHNDeBz1A3b7QTBFIjqP9hauVr/SodyoyFE2F4TzC4QKeb+HflghxeCiYHJ8AkETcEhQ6C7Vn//NVEWcE56jRqDUUktJgM8ajFtc8oR6IYfGD1w9MDlhnVcsWElK2KgzOrtbfDBihk6KitAKRAsna3lEL8mAvBOo3oNM29yiA6jyNS3dBS1IcrzDde32sMXKul2geAymgMct1qgjbObTikbCaFg02GbRoRZGwZyumbJWG2O7WJ5u3vMyUxSpe6FRThPLgVuhGqJj9ONRWC4IChHZsd5EqvJHDJtdchZkhJnYCUb92RB4l0P4GONn2oqtyaLUpu8z8Q1gCA0l2Tss2KHQ4OCgDxNvCX14ivarml0ywTsJaCMcANv0XVHCVNkauSlZLpD2qFLnQZ1ihzDPKFGkiFTFifwfSyfYIWuTQHhF+cLx9Mf28C6swjFebzvTAhS8D05pThsju1uQMl2ateaf3WlBIVzx9jTOvqJtzwYrLEi4sNnPhVbWZIZWBlcA7mkAlsKZCZXiL/tmwq X-Forefront-Antispam-Report: CIP:80.151.164.27;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:esd-s7.esd;PTR:p5097a41b.dip0.t-ipconnect.de;CAT:NONE;SFS:(13230025)(4636009)(39840400004)(136003)(376002)(346002)(396003)(451199018)(36840700001)(46966006)(6266002)(2906002)(8676002)(356005)(83380400001)(81166007)(70586007)(8936002)(36756003)(41300700001)(1076003)(966005)(5660300002)(26005)(70206006)(36860700001)(47076005)(40480700001)(336012)(186003)(316002)(82310400005)(86362001)(54906003)(42186006)(110136005)(4326008)(44832011)(6666004)(2616005)(478600001);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2023 19:04:54.0858 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52ea519a-7b09-401f-7609-08db1050b026 X-MS-Exchange-CrossTenant-Id: 5a9c3a1d-52db-4235-b74c-9fd851db2e6b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5a9c3a1d-52db-4235-b74c-9fd851db2e6b;Ip=[80.151.164.27];Helo=[esd-s7.esd] X-MS-Exchange-CrossTenant-AuthSource: VI1EUR06FT024.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR03MB9870 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758016331562453564?= X-GMAIL-MSGID: =?utf-8?q?1758016331562453564?= Start a rework initiated by Vincents remarks "You should not report the greatest of txerr and rxerr but the one which actually increased." [1] and "As far as I understand, those flags should be set only when the threshold is reached" [2] . Therefore make use of can_change_state() to (among others) set the flags CAN_ERR_CRTL_[RT]X_WARNING and CAN_ERR_CRTL_[RT]X_PASSIVE, maintain CAN statistic counters for error_warning, error_passive and bus_off. Relocate testing alloc_can_err_skb() for NULL to the end of esd_usb_rx_event(), to have things like can_bus_off(), can_change_state() working even in out of memory conditions. Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device") Signed-off-by: Frank Jungclaus Link: [1] https://lore.kernel.org/all/CAMZ6RqKGBWe15aMkf8-QLf-cOQg99GQBebSm+1wEzTqHgvmNuw@mail.gmail.com/ Link: [2] https://lore.kernel.org/all/CAMZ6Rq+QBO1yTX_o6GV0yhdBj-RzZSRGWDZBS0fs7zbSTy4hmA@mail.gmail.com/ --- drivers/net/can/usb/esd_usb.c | 50 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c index 5e182fadd875..578b25f873e5 100644 --- a/drivers/net/can/usb/esd_usb.c +++ b/drivers/net/can/usb/esd_usb.c @@ -239,41 +239,42 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv, msg->msg.rx.dlc, state, ecc, rxerr, txerr); skb = alloc_can_err_skb(priv->netdev, &cf); - if (skb == NULL) { - stats->rx_dropped++; - return; - } if (state != priv->old_state) { + enum can_state tx_state, rx_state; + enum can_state new_state = CAN_STATE_ERROR_ACTIVE; + priv->old_state = state; switch (state & ESD_BUSSTATE_MASK) { case ESD_BUSSTATE_BUSOFF: - priv->can.state = CAN_STATE_BUS_OFF; - cf->can_id |= CAN_ERR_BUSOFF; - priv->can.can_stats.bus_off++; + new_state = CAN_STATE_BUS_OFF; can_bus_off(priv->netdev); break; case ESD_BUSSTATE_WARN: - priv->can.state = CAN_STATE_ERROR_WARNING; - priv->can.can_stats.error_warning++; + new_state = CAN_STATE_ERROR_WARNING; break; case ESD_BUSSTATE_ERRPASSIVE: - priv->can.state = CAN_STATE_ERROR_PASSIVE; - priv->can.can_stats.error_passive++; + new_state = CAN_STATE_ERROR_PASSIVE; break; default: - priv->can.state = CAN_STATE_ERROR_ACTIVE; + new_state = CAN_STATE_ERROR_ACTIVE; txerr = 0; rxerr = 0; break; } - } else { + + if (new_state != priv->can.state) { + tx_state = (txerr >= rxerr) ? new_state : 0; + rx_state = (txerr <= rxerr) ? new_state : 0; + can_change_state(priv->netdev, cf, + tx_state, rx_state); + } + } else if (skb) { priv->can.can_stats.bus_error++; stats->rx_errors++; - cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR | - CAN_ERR_CNT; + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; switch (ecc & SJA1000_ECC_MASK) { case SJA1000_ECC_BIT: @@ -295,21 +296,20 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv, /* Bit stream position in CAN frame as the error was detected */ cf->data[3] = ecc & SJA1000_ECC_SEG; - - if (priv->can.state == CAN_STATE_ERROR_WARNING || - priv->can.state == CAN_STATE_ERROR_PASSIVE) { - cf->data[1] = (txerr > rxerr) ? - CAN_ERR_CRTL_TX_PASSIVE : - CAN_ERR_CRTL_RX_PASSIVE; - } - cf->data[6] = txerr; - cf->data[7] = rxerr; } priv->bec.txerr = txerr; priv->bec.rxerr = rxerr; - netif_rx(skb); + if (skb) { + cf->can_id |= CAN_ERR_CNT; + cf->data[6] = txerr; + cf->data[7] = rxerr; + + netif_rx(skb); + } else { + stats->rx_dropped++; + } } } From patchwork Thu Feb 16 19:04:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 58211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp482143wrn; Thu, 16 Feb 2023 11:16:24 -0800 (PST) X-Google-Smtp-Source: AK7set/i9VT8v4QpobW0gcmWDosE0ZO1Ill+OhvF64Q/8cKd6F1FQCoFMEcSGc7lplvWCCc0PKJh X-Received: by 2002:a17:906:4750:b0:885:8f79:d6d7 with SMTP id j16-20020a170906475000b008858f79d6d7mr6206323ejs.61.1676574984620; Thu, 16 Feb 2023 11:16:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676574984; cv=pass; d=google.com; s=arc-20160816; b=J3RHeirgvXnZgXhTD0QaRiiqjI2/vygfySYPuBrzdCC4gkkzQCDj5GVgaLP812nY/p 4oppOxKc5Ui8Ic/rg/YlTE4kU1b8I2xEO8TRpeNXu7n/lx0aCxtwMxy5SEmWWK8x0RcM uTBw+/zgssPcU59Qu7RkM6GDq0jAs8BP5uenGGI7tjSINONYhq3okG5WgsSOZugAVqZU FTQvKCquvwwgwsJvnKSRWdOv397cidzlhziDKxRI12C2VJ893CBTTrhzHqWD/L0G6xu4 SdYnkPibzt5A7MRd2Nk2K7FEUbgIWsnu46FbH+H7dtAt35t75nECRmDczC8DFuhFZHdn pWfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zj0xEqtN+H4EOpEipAM2uHPkvagu++x98/5zi+k5RMQ=; b=oPK1WOx/6YBVKiV4OD5Gs/2Z3o3tJRUw/rUp77mKaTHq8+qJXtWfuoVDtm5x9we3uH ZJTRTDVoSrZegA+NUHStAkFuukWXu59/XoCzqSL5ibkRF4oV2ycGfEM6KCa8LH48obZa dQS4W1Du7LsocE+jrhJ6KCUGn4nPFOOe3mhzJjEFgQPH7RlyIOZ8nBYFMXdW7zlXTFEA 0I9Ir6jEDbTjZvlMWX255A0CcGjEl/Z68Yi/EO7jJpjmHR8HqvH42Eyfxg8ueC6nktvx XWL1RrvJRJ508PAFKExQewn8sbtC7POBZMnhijYIm8C79dAYSPouw91t+3iJgTI9+Fm7 fymA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=W7esTjcT; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 27-20020a170906021b00b008b17de4b0bfsi523702ejd.14.2023.02.16.11.16.01; Thu, 16 Feb 2023 11:16:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=W7esTjcT; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230093AbjBPTFC (ORCPT + 99 others); Thu, 16 Feb 2023 14:05:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229507AbjBPTFA (ORCPT ); Thu, 16 Feb 2023 14:05:00 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2134.outbound.protection.outlook.com [40.107.14.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9C63505CB; Thu, 16 Feb 2023 11:04:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T1qeiCicgnJ/IrOPaZXTdhuHhEbAzjAx4hI1p6+GbcszcHQmA4QSsgbP0I/t5Q8HdipP5ELpcb0n6BbnKxtadI3VwD1C4Trf7DXuK/sl+o+VI6IlSkqKxYuiyRy/u9DkqRjJ8SBxi87Ef9e9BB3Vc0vIpW4Sn2JcStkxA8y5WkmxZUVlCOe7I0ucc/OKNTRBvpm7shxOupHq+49Z1/DMKGpldfJ4xWezTO1tkXQLKBg8I2T/ckoBBMjhfQ92gEwP6I81fjJA0aTVra1bTP7hVh+buIy8jn7jKIufWPIZCkhFZYZBwMvpXzeiaf5zPW5Z0u5m/CS23fa/Q7CcqfLWxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zj0xEqtN+H4EOpEipAM2uHPkvagu++x98/5zi+k5RMQ=; b=QENOYB611p39e3lgHleKwPPha8/ATuGpnxRQMLaaEpSltE//EKWNJQMBQIc9PUlupMoiCmOxgNQ2nBW8ZLv30LR3I3qxy6OYHEF7MVpEaKiyO4tH0Mvt0SpZOTdJSdt4FwDwHArgDjZoiymzIRpSOUHpTzsWNfMBaxOIWRUtJq4gIQvfzTupGlTThqJcZ6lmnSYJIBLebensVQD+578vS7XZeePyKwgqZtKttALOi85S6RDYyHmhFg17pN8ZuiQzDrpbhNCzzvnTaebJOdWmeROvE3NQDPaaMkamV57ndg0zUyA8vaYHeUp7aixuE+sS0DUwnpH6CDivGqnkAxExaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 80.151.164.27) smtp.rcpttodomain=esd.eu smtp.mailfrom=esd.eu; dmarc=none action=none header.from=esd.eu; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=esdhannover.onmicrosoft.com; s=selector1-esdhannover-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zj0xEqtN+H4EOpEipAM2uHPkvagu++x98/5zi+k5RMQ=; b=W7esTjcT4g/XcKqqRILOwx5+gvf1EfvCLTvBoYYDS2yu/rBMCzuYD/oxhgQL89/QhgIXkfYqCNBdvLvPU8cEdudBkHMxOHjaYqe47Q4lQPlMAsBmSzPyy73JxlAhTISQDnccf1a/1rWP/sj2GxE2nEKx0uTle7iGEuB6CoX/JsQ= Received: from AS9PR05CA0321.eurprd05.prod.outlook.com (2603:10a6:20b:491::14) by DB3PR03MB10129.eurprd03.prod.outlook.com (2603:10a6:10:43c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.24; Thu, 16 Feb 2023 19:04:54 +0000 Received: from AM7EUR06FT054.eop-eur06.prod.protection.outlook.com (2603:10a6:20b:491:cafe::5a) by AS9PR05CA0321.outlook.office365.com (2603:10a6:20b:491::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.13 via Frontend Transport; Thu, 16 Feb 2023 19:04:54 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 80.151.164.27) smtp.mailfrom=esd.eu; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=esd.eu; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning esd.eu discourages use of 80.151.164.27 as permitted sender) Received: from esd-s7.esd (80.151.164.27) by AM7EUR06FT054.mail.protection.outlook.com (10.233.255.151) with Microsoft SMTP Server id 15.20.6111.13 via Frontend Transport; Thu, 16 Feb 2023 19:04:53 +0000 Received: from esd-s20.esd.local (jenkins.esd.local [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id 828A67C16C9; Thu, 16 Feb 2023 20:04:53 +0100 (CET) Received: by esd-s20.esd.local (Postfix, from userid 2046) id 7BE462E4482; Thu, 16 Feb 2023 20:04:53 +0100 (CET) From: Frank Jungclaus To: linux-can@vger.kernel.org, Marc Kleine-Budde , Wolfgang Grandegger , Vincent Mailhol Cc: =?utf-8?q?Stefan_M=C3=A4tje?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Frank Jungclaus Subject: [PATCH v3 3/3] can: esd_usb: Improve readability on decoding ESD_EV_CAN_ERROR_EXT messages Date: Thu, 16 Feb 2023 20:04:50 +0100 Message-Id: <20230216190450.3901254-4-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230216190450.3901254-1-frank.jungclaus@esd.eu> References: <20230216190450.3901254-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM7EUR06FT054:EE_|DB3PR03MB10129:EE_ X-MS-Office365-Filtering-Correlation-Id: 280cbcd3-5b1d-4a27-6aed-08db1050b005 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oVntUMeOFbVyd5KtrZckguUpnRgokem2xJWsHBgY7ZFmG65LAC+4p7VMVl+FU85PT65MZ6S8uUDD6cVHXAlcnAF5dUVTKlby2bgmPXoNxzenz3Xg3y3JR8iVt2rZLw9OZWTqQi8TVOZ3jJRDHCO+04gx8sRyeClZz388wjB9K7IC/G1UTMO02NERG3FiFyTkaILkjNRoEvIb4dJk27b5IShJGgHowbzt0fLmyTXG1W3bR7+EF+iJNFn5f3rw72tRGKw+ga5V0SJhngVb9rr9UbpZEipIGv7f2J3ZT60PkqCzU4Pjm5fpg51ahRULPqlV6X9xLFS7Qhqh+FBsly06NHLvBInXtBMVci2rPaC0+q8NgK7646lCDjEd/E/CO0zxQqAIGV0WNzNlB0RKq5trLO4nnRK5R2RQonfNyi0PGpeLbjVg0e1Etx63ReW0+XnJ6wCTjgBcMe+hVW+xmC4UY+dSm+elTvHQe7ajPfq8xbuFW5qXvlfMsbUOI3WpIvVOjBP3s4xPosaDr196ZcYqs/89cL60nqDEI0gSpCRHIRdds/ooI+OOydIq8MzYuZRCTSaRgFhJ56yDj8t5gfTmeoruZS1HQvGL4Fa+qMBo4ku8BmFAqRIv0yLS2aVUK5If5n5mG2ZlHOp/7MI/S/C7qfCdAxCc09u0YGir2AANE3I= X-Forefront-Antispam-Report: CIP:80.151.164.27;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:esd-s7.esd;PTR:p5097a41b.dip0.t-ipconnect.de;CAT:NONE;SFS:(13230025)(4636009)(346002)(39830400003)(376002)(396003)(136003)(451199018)(46966006)(36840700001)(36756003)(186003)(44832011)(2906002)(15650500001)(5660300002)(2616005)(26005)(6266002)(83380400001)(47076005)(356005)(336012)(478600001)(36860700001)(42186006)(4326008)(70206006)(70586007)(8936002)(8676002)(81166007)(41300700001)(40480700001)(1076003)(86362001)(82310400005)(966005)(316002)(54906003)(110136005);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2023 19:04:53.9005 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 280cbcd3-5b1d-4a27-6aed-08db1050b005 X-MS-Exchange-CrossTenant-Id: 5a9c3a1d-52db-4235-b74c-9fd851db2e6b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5a9c3a1d-52db-4235-b74c-9fd851db2e6b;Ip=[80.151.164.27];Helo=[esd-s7.esd] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT054.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR03MB10129 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758016291077017794?= X-GMAIL-MSGID: =?utf-8?q?1758016291077017794?= As suggested by Marc introduce a union plus a struct ev_can_err_ext for easier decoding of an ESD_EV_CAN_ERROR_EXT event message (which simply is a rx_msg with some dedicated data). Suggested-by: Marc Kleine-Budde Link: https://lore.kernel.org/linux-can/20220621071152.ggyhrr5sbzvwpkpx@pengutronix.de/ Signed-off-by: Frank Jungclaus --- drivers/net/can/usb/esd_usb.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c index 578b25f873e5..55b36973952d 100644 --- a/drivers/net/can/usb/esd_usb.c +++ b/drivers/net/can/usb/esd_usb.c @@ -127,7 +127,15 @@ struct rx_msg { u8 dlc; __le32 ts; __le32 id; /* upper 3 bits contain flags */ - u8 data[8]; + union { + u8 data[8]; + struct { + u8 status; /* CAN Controller Status */ + u8 ecc; /* Error Capture Register */ + u8 rec; /* RX Error Counter */ + u8 tec; /* TX Error Counter */ + } ev_can_err_ext; /* For ESD_EV_CAN_ERROR_EXT */ + }; }; struct tx_msg { @@ -229,10 +237,10 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv, u32 id = le32_to_cpu(msg->msg.rx.id) & ESD_IDMASK; if (id == ESD_EV_CAN_ERROR_EXT) { - u8 state = msg->msg.rx.data[0]; - u8 ecc = msg->msg.rx.data[1]; - u8 rxerr = msg->msg.rx.data[2]; - u8 txerr = msg->msg.rx.data[3]; + u8 state = msg->msg.rx.ev_can_err_ext.status; + u8 ecc = msg->msg.rx.ev_can_err_ext.ecc; + u8 rxerr = msg->msg.rx.ev_can_err_ext.rec; + u8 txerr = msg->msg.rx.ev_can_err_ext.tec; netdev_dbg(priv->netdev, "CAN_ERR_EV_EXT: dlc=%#02x state=%02x ecc=%02x rec=%02x tec=%02x\n",