From patchwork Mon Dec 19 21:20:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 34782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2622930wrn; Mon, 19 Dec 2022 13:25:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXsAzeZTTjlnrr1axcIF9NjgYrntHjjTI5GDZnXDEHBFFlt/+Xmt96CtbEM7vFPTkPQhesrH X-Received: by 2002:a17:902:e549:b0:18f:9282:d8b0 with SMTP id n9-20020a170902e54900b0018f9282d8b0mr14428935plf.53.1671485123781; Mon, 19 Dec 2022 13:25:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671485123; cv=pass; d=google.com; s=arc-20160816; b=y9TDWYBL7pCfaU/BbXe7HA+NnzK9DF1jUIl1skodiROeSGCZ7xmgJaumzVo7NIxLMU 8AiEQqz3prYNr6QfzsMY7A9jXg2b1vHVH0eqUdJEbUm6u0ajogffwacjHBBCmPnCdr2M 2FVsImKXzJHsPTu3PfMoxyrrkx8JC4nD1usMVrz/m+8riJHFi9E4DiL2Sg6lVkrSBVkH 8KFKK8MSH9IwRNlMV4u/Kv0W4osZYhq9eJHdjv0SPV4XdmD68W4O7GU5s7+pzfPsHRbj 0p4La1+XkIjt7Wr9MSQEMpSPp13MCMCOJ0soWSxQKbC5wlFD2KxkB5liwrgusjd4Gi7N Rs/g== 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=ySpz1nlgcq/mVnqqCPG7zzsJF94xzgLeBnibFVWUUbs=; b=w5MS51AMMN5TP6o5aBCmMMLB2pZ1CjP0Eyj3aFJOa8j+GcVSM6GlrMLiAJHDSItjy8 HR63MJsRzBlhyl/4IEWdjish5fu34hv2PA+gUHa4CAQElFN8p1IjXTR8lbcM1Sq2Do3i euq1MeLHm1drvYL9FImjJFgdDjsYg98mlHs2oekuoxatkZ32CzcGT2XNMwo82XBThiT0 gYHXiDops7WPXxGmD/m0uoV1otznIHGJTze4BSZlWUg1XhS05mhj3Hq86FpBYcAmCXs9 i3eGRcAnoJj8a5wxDdTNOHJ22m4U6dm1Gz4qE/7CKmDJIuN0ha+d93IVL2kStSU+uOS3 d6TQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=ferSbRDn; 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 h14-20020a170902f54e00b001890c6feffasi12469269plf.568.2022.12.19.13.25.10; Mon, 19 Dec 2022 13:25:23 -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=ferSbRDn; 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 S232666AbiLSVVC (ORCPT + 99 others); Mon, 19 Dec 2022 16:21:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232552AbiLSVUz (ORCPT ); Mon, 19 Dec 2022 16:20:55 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2118.outbound.protection.outlook.com [40.107.22.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F20D764D1; Mon, 19 Dec 2022 13:20:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lnas/Ei5LpXYNSAGuaR60BOH0sdBPciffqdJcSi1REfxWVp7eRhSqhbBSKsBxPYkIMWAxszZJ4lCC+fvUR05HxqCnEiHwrAhiXrJujKvqINhmITCMxwPisHkIi6GORMEQKt4GsQ3z5eFMDJa8/EW2G+rwjfaXS72cAgM/Iq06LejoWm4ACBNV72dK4RnsrfpnzbldnLsQnqPuHLdlk0h1BnIX7E/Wi0FDjLiT4vezAOAuAmYmcgVQljCriij80PxwS7DuiQDpXMIO20SGzovURZARXGIreQNlD4YDCm1VtDgTkY/RTI4guXhuOfpfxIMnCs0I3i1OY3IisZnftMtZw== 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=ySpz1nlgcq/mVnqqCPG7zzsJF94xzgLeBnibFVWUUbs=; b=X9W5k/52LPPUx48eAnTXCbjnXBTHUQGvHNmGSyIGyYlE9aZG1tPr8iryMv3FLRYg//1CrKlZLeALo02QBVG801xaOoLlTNnW+xLViKj2nndL3RYAUQcRX2AtaQNZqPRtvD7bTP3r6P7uWS6PMA201uTf2pe6Lkf2UhHJUgnoOyyE+bgUxLg4738ltdW0rgnJ3UiAz8pcuvpH/3hCtxC7VzFohFr84aL6ciz6DRkkHztWxbzRO0I12aP2buXAUj1IcugAfQpAxmge1FYc9y2OCo1AKHWVsDILDacEKnz65I5jj7FMO9iVxKPGuiv70tikURoh1daGmA4ep33xSEqpSQ== 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=ySpz1nlgcq/mVnqqCPG7zzsJF94xzgLeBnibFVWUUbs=; b=ferSbRDnt7pMME2ZMLo995J3V3C+cuFqXe2mhv+A3kPBzV3bTOzEUiJYOeaWPrQT3w6dD2oBNzy50FVLcjEFn6VkyYQbtmAIJEp3xVZqe6EyHI3DBjsZuMnBUfoIOJuu8swj3ccqfKpX0YnE6ZVekMIdd7+uqo7if3qn/bXudsE= Received: from ZR0P278CA0053.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::22) by AM7PR03MB6232.eurprd03.prod.outlook.com (2603:10a6:20b:13b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Mon, 19 Dec 2022 21:20:50 +0000 Received: from VI1EUR06FT067.eop-eur06.prod.protection.outlook.com (2603:10a6:910:1d:cafe::99) by ZR0P278CA0053.outlook.office365.com (2603:10a6:910:1d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.20 via Frontend Transport; Mon, 19 Dec 2022 21:20:50 +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 VI1EUR06FT067.mail.protection.outlook.com (10.13.6.78) with Microsoft SMTP Server id 15.20.5924.16 via Frontend Transport; Mon, 19 Dec 2022 21:20:49 +0000 Received: from esd-s20.esd.local (debby [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id 4AD3C7C16C8; Mon, 19 Dec 2022 22:20:49 +0100 (CET) Received: by esd-s20.esd.local (Postfix, from userid 2046) id 3F9E72E1DC1; Mon, 19 Dec 2022 22:20:49 +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 1/3] can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (1) Date: Mon, 19 Dec 2022 22:20:12 +0100 Message-Id: <20221219212013.1294820-2-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221219212013.1294820-1-frank.jungclaus@esd.eu> References: <20221219212013.1294820-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1EUR06FT067:EE_|AM7PR03MB6232:EE_ X-MS-Office365-Filtering-Correlation-Id: cd797964-2040-4923-17d0-08dae206e6f4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /x5HfrvrFergW/ATbm2GhQfYnetiOiJTOpURBDZQBh9Jml4ApOLUy2Jw7KW1tOIfO9RHuRdSE3h0oit+bRZ159PXmaXTYxL35aASUDwaCh87ravkDsT7Jmn3oBO0FC1INT+KWeNy+2UvTD3NQGqv5FMpZLv8mqtyEcG7q3EcX23lXbYWS1hV41wTfmnCLDvYHjKXizThFQfojPhFuSMnmclKMsFFU2nft+N5APXVQ4E3xK1kx6s5FRpvzMl/mDE3d+WhxwsUrtZ94UQlIcZ/TYdi5O5hN0UyjkINr54pDJHL9z722ket2+CtXmmA0GUTkjy9rW7dnviGj8SM0hqLwj7rO4MPuvNep4LqXV9gCuhzSKaOBY1hziPYA294Nxda0cTYaXTthfISNswNi3wqhtVR88/ZUGB/rL8kED1QdikCQesMAy3et2i4ZEFaSKFypF2ps76T6WjIRiGvE6CqeW7wD7uB5LoUQxzw/eYyHZuirQ1hscMUXJkFqpiE8+B0tYIwqJBzFCidoGlp7hR72ZF5DvesDohgkwoaYx+Yzxmr02BGTSU4LKYskOWjDVo0gMtw++RYAPy2Z2AxCDng3IiKdJ9YyA6wgYQsIpH0GdTxLaoSz6Uyux3DwOGoMwQwW5/MQORFsKLcZJgewbNuM8Sy6xgWnaSYIgr8UiM8TP0= 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:(13230022)(4636009)(136003)(396003)(346002)(39830400003)(376002)(451199015)(36840700001)(46966006)(8936002)(8676002)(70586007)(70206006)(5660300002)(4326008)(44832011)(36860700001)(41300700001)(42186006)(316002)(40480700001)(2906002)(54906003)(110136005)(86362001)(2616005)(1076003)(356005)(83380400001)(26005)(186003)(6266002)(82310400005)(336012)(47076005)(81166007)(478600001)(36756003)(6666004);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2022 21:20:49.7846 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd797964-2040-4923-17d0-08dae206e6f4 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: VI1EUR06FT067.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR03MB6232 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?1752679185341095870?= X-GMAIL-MSGID: =?utf-8?q?1752679185341095870?= Moved the supply for cf->data[3] (bit stream position of CAN error) outside of the "switch (ecc & SJA1000_ECC_MASK){}"-statement, because this position is independent of the error type. Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device") Signed-off-by: Frank Jungclaus Reviewed-by: Vincent Mailhol --- 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 Mon Dec 19 21:27:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 34783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2624570wrn; Mon, 19 Dec 2022 13:29:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf5feYxw8sK3HnmCDDJ7YWgCth5wA35Dn0tFRLlJod4BoF66u3Ouizf03+K00dGGF/xHFhd4 X-Received: by 2002:a17:902:ab0c:b0:189:d8fb:1523 with SMTP id ik12-20020a170902ab0c00b00189d8fb1523mr47185745plb.36.1671485382333; Mon, 19 Dec 2022 13:29:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671485382; cv=pass; d=google.com; s=arc-20160816; b=ayg1lJgXUuXUXyQb5ghcjYsaOwkM2jpx6y4ZMh6KV0Eo2bDWG2ZyU7z1vUrWLaSyav lHghKlnhKDT4OMkuPcHYiCi1SJNyoXpKD21ux9UBP/+a8/3hq3QA02F2adH8cs/Q22+w lbkFCPt5BoRZRg6La77hsuRRRNxu60ML5I96+Plai/cYQdrazD2TNPJGE1HK5UX1zHaW FvGRJQ7ZFVq1635sVEg+9TUrpLvmuvUr51oBebMY/YwWfqe1NMAsi3Hu0ZIIZmjuAmpG nqroq14Z9LM8Ra/PTu5AJhizaKlXvZ6DXdfubWGt4GcAGH/AEtfvesfZWNi6w9f3yw1+ NhYA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=CLCrW5mNwfs26NWA4N8ao2qXw+YqsWSEuJb20hNJhys=; b=q3f3Ld1yri+sW3zQhbSJUTJzBidPD0zZDBgOVqFOcdIl0y8kWiBbUJjRBLopuVc2i9 RVpfawK2qHcqA4dYXliW0pTOieTwDZp31me8YX6cu0H05yAlq9bAwf5DRqqNas6+kSVz nUlH34EgUP9pg2n/6jVRUAooiJK7XYpmCU62yaeaYokwA3Db7nUuPEe4/zGJGJIAFdJK 1zPuiASt97Ezxy7+TAjyDhEWLtvyJERK0pHd0AZC2loWSCtJV0lq1b+MZ/52SwSTamjw 01BbkOPzA6f+okzBAerIwa3DXILPGZf1MgkFCZpprGnoVKUhALOHQlZyEX+1n8QIQAvo q9mw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=C5RMAIC4; 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 u5-20020a170903124500b00181dc40f516si5053609plh.146.2022.12.19.13.29.29; Mon, 19 Dec 2022 13:29:42 -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=C5RMAIC4; 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 S232840AbiLSV1y (ORCPT + 99 others); Mon, 19 Dec 2022 16:27:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232777AbiLSV1i (ORCPT ); Mon, 19 Dec 2022 16:27:38 -0500 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2121.outbound.protection.outlook.com [40.107.6.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 538BD13F09; Mon, 19 Dec 2022 13:27:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Na5J3SSkgqF1zrDNToJiSUQb8jusCRIniW2SVDT54vTIWgwimZ0RQJsp4nZHBSjp9k8IqeZ93YYTvikfyXP7/6LisryH2zRU0m7X/pLOCCCpSuccj9Wb4GiKrbKKVSQnSusykvFNkMMx8sW9iF0Psg7YcJyk/26Wa4rLiEN95Il9B8C5Kx2q26UVMwYJZK0KLwMWsJfShdjxmIJGEXEzWS5Gj/2RtgeztY43KQanc+ZmkHl4UnMH2EUeBA+5CO/imrfoAfMi1643JN0Cff8M+/snc7XdG5eOPV/3G+6qPp241LnuFIwbuNxjnVudbjXnfGQQgLuZDyP8jQjFgfs2RA== 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=CLCrW5mNwfs26NWA4N8ao2qXw+YqsWSEuJb20hNJhys=; b=G00eFTZVIABnoR9jLYtA//K7D9S/VIuQ66+/0tdZykaEAP0x3+Okka2eS6SDhBjAo7tY76Vc+uj3Bkl7+wdJ6vX2AlProh6bMlAHM4AeIUCyrhv3AxgQEdkA1Iu3vhEblOnn8iSJIUPjK+Cio3A5u7jgKbtNXdEeLCvCm+OkI1HNFmwPi1S4r80xnW3r+m6H6c4zSUQzH1fcb/LBR2gfGrgGD3OJDks8iBcbXh+S0C2harl8Qbc8+eTqKPn3vhUlYbDPJ0C9d/bCIerTBxJVnVBljG+0IuQA3j+LFpWpuR4K/P8FJEEGYFov5bTz1DK6v1QemB/e85zkrypqj8EPGw== 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=CLCrW5mNwfs26NWA4N8ao2qXw+YqsWSEuJb20hNJhys=; b=C5RMAIC4AjU4X0huCwI9A4TS7XGYzZqekXwCVOOyRo3bH9nOhGwYPdtGJcKlGh+8uE6Z5Mw6ZucOjKPZApLgVqHDLpv+pZgOIG2cM7oB9KlVqg2+1jqLPJoEbNCmISqLxYs/KoKRW++d8SXHyTrOSxQssgVnIl771IIUtZvRBY0= Received: from DB6PR07CA0187.eurprd07.prod.outlook.com (2603:10a6:6:42::17) by GV1PR03MB8710.eurprd03.prod.outlook.com (2603:10a6:150:92::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Mon, 19 Dec 2022 21:27:30 +0000 Received: from DB8EUR06FT007.eop-eur06.prod.protection.outlook.com (2603:10a6:6:42:cafe::ec) by DB6PR07CA0187.outlook.office365.com (2603:10a6:6:42::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.9 via Frontend Transport; Mon, 19 Dec 2022 21:27:29 +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 DB8EUR06FT007.mail.protection.outlook.com (10.233.252.171) with Microsoft SMTP Server id 15.20.5924.16 via Frontend Transport; Mon, 19 Dec 2022 21:27:28 +0000 Received: from esd-s20.esd.local (debby [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id 64E347C16C8; Mon, 19 Dec 2022 22:27:28 +0100 (CET) Received: by esd-s20.esd.local (Postfix, from userid 2046) id 5564B2E1DC1; Mon, 19 Dec 2022 22:27:28 +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 2/3] can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (2) Date: Mon, 19 Dec 2022 22:27:16 +0100 Message-Id: <20221219212717.1298282-1-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8EUR06FT007:EE_|GV1PR03MB8710:EE_ X-MS-Office365-Filtering-Correlation-Id: a0c61598-c893-4a4d-59fa-08dae207d4e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XpH2NmUmxbnpq67w3jmJUI5hKE3/OBt+8V5iROGekzJbq0krA6t8NFVQ//S8nzFa+QSYnnh+liz/n4TcDA76ySFEugRtJcLH8NoIulubrJuzCufoVbKUlqwC6rPBTB4ui+yeTs180eHJqHpkdyWXeJ8kujFQqnZ6PtlSqGbEv4KYmXPGPqF9tJMLzgXQZ37O9L6u9lSJuTGFMcaPyOh4AV4Kjv4qKQq/AZiWhUw86a7Rte+Gvj0tFORN2BkZmDH7Z1WLrjm/mosCj5TGLSw41HibUZKjuUzjMWtZFjLXFB9R1oI7KGJ+MhmzSw8ZFkbHZtuIJxlECKG5vHXjkIJts28G2Cw2NnVr7b0ckJpV5DwyDLZPydRQJxR03zKqZd0avEi52AhzM6WpC+BwPEDvcakIWery9q/s5ZjMONr5jWLusgntXlIlhvnSamfjgMlFy1z771PpmYVeQEA0Mk3vYjYOZsyj0dyuA7Up6Lt+06hRgtlby856fzvYD8WqCnmXa7H6ghO+Pf1wX5+peJfsdCFDNL63gPb8diO9BjTEUdvRg+Lwplzm79UNxojVmaWwzwarefWi+WOrhAObFPvDoEiZugL2PJMk2l8k50DuuR3ZnC7I1XMzIeePanmXsrOIz/QUBoU/2wAAqTF6v+k9dDXUu+ZRrqNfcibfHmm13cbzhed0exF4frZPOSVmXdBVohymZdDH9aO68qaAXOJnrg== 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:(13230022)(4636009)(396003)(346002)(39840400004)(376002)(136003)(451199015)(46966006)(36840700001)(70586007)(70206006)(86362001)(4326008)(8676002)(42186006)(316002)(36756003)(8936002)(5660300002)(2616005)(41300700001)(1076003)(82310400005)(6666004)(186003)(36860700001)(26005)(336012)(6266002)(47076005)(356005)(83380400001)(54906003)(40480700001)(81166007)(110136005)(478600001)(966005)(44832011)(2906002);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2022 21:27:28.9767 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0c61598-c893-4a4d-59fa-08dae207d4e6 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: DB8EUR06FT007.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR03MB8710 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?1752679456136986156?= X-GMAIL-MSGID: =?utf-8?q?1752679456136986156?= Started 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] . Now setting the flags for CAN_ERR_CRTL_[RT]X_WARNING and CAN_ERR_CRTL_[RT]X_PASSIVE regarding REC and TEC, when the appropriate threshold is reached. 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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c index 5e182fadd875..09745751f168 100644 --- a/drivers/net/can/usb/esd_usb.c +++ b/drivers/net/can/usb/esd_usb.c @@ -255,10 +255,18 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv, can_bus_off(priv->netdev); break; case ESD_BUSSTATE_WARN: + cf->can_id |= CAN_ERR_CRTL; + cf->data[1] = (txerr > rxerr) ? + CAN_ERR_CRTL_TX_WARNING : + CAN_ERR_CRTL_RX_WARNING; priv->can.state = CAN_STATE_ERROR_WARNING; priv->can.can_stats.error_warning++; break; case ESD_BUSSTATE_ERRPASSIVE: + cf->can_id |= CAN_ERR_CRTL; + cf->data[1] = (txerr > rxerr) ? + CAN_ERR_CRTL_TX_PASSIVE : + CAN_ERR_CRTL_RX_PASSIVE; priv->can.state = CAN_STATE_ERROR_PASSIVE; priv->can.can_stats.error_passive++; break; @@ -296,12 +304,6 @@ 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; } From patchwork Mon Dec 19 21:27:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 34784 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2624581wrn; Mon, 19 Dec 2022 13:29:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf4PjiHcqeZcG/U9bzwhjlP4t7BZneY843nf8yVebJrvYE4FjWd624+9rTwxOE++/8CHC03i X-Received: by 2002:a17:902:f114:b0:18f:aca1:b0c9 with SMTP id e20-20020a170902f11400b0018faca1b0c9mr27899254plb.53.1671485383752; Mon, 19 Dec 2022 13:29:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671485383; cv=pass; d=google.com; s=arc-20160816; b=kNXqm67iWGRTTk6qyoVMxYg3Y2UR2jEFEjiH+DeAit8UttyhedbsX1l7aX9IA6dmSE Jet5lIkz5iydQZb3BusHSv+TEkXn+pYPC4a3yuKCw5b/0TPYSKbWu4WskQ7fsC6Sdojb n0xWbG2/P1UF+F405AJt8Pd3Mk9co50yoM9KkPT8qb2x/lFXKFdlRh9XEUrqagP3GzIr LlAFKiEjQS4wtV/sLKYKJRAyGRGe0vqqGpKxLMJgySucM3EzR2woCLWpxsXHy9tDasbA p80yB8WTxRybbfw2ca0+Li0FjGOa1wzqEgkf4jlf8u2TddIoUWd8Ve21+RJ7JklXfcya Kprg== 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=PH4Epp4GyGuEC6gorfLFdD6vqnNWemsv/uQaT6+AYik=; b=0/eYHd+vKIxKkEtbdQhImkoZk7rXIjBWabqnhAT9MWb/HoAWGtBgZH6mWeu96J53I6 vkK5V/I6aMJOpQYknzWkfuDS0ScUlGV9X37A0LfZa9OgRl7/eyRkzFX0sPIEPvx9GZLt nI7/niK44h92uDRVx0S3w9FFpQKDzywEjIey94WLt5+Q109vdc21CS6sMNuQ3r7yLfqh Dl5gKoqKxWSEBZDR07NlYhM/GzOM6q+sWJQhdKlH7GlNsYSvSfAs4MgSuH4uXZDvLaLV dxRGtIX1uGUXmqcrZgSaw3clHkKiXTGff1NcLMjr5v5Y9dciSTY2iugH5qenmANSgvj/ qYWw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=CA3IFhpB; 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 n6-20020a170903110600b001868d5fc29bsi12830331plh.259.2022.12.19.13.29.30; Mon, 19 Dec 2022 13:29:43 -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=CA3IFhpB; 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 S232833AbiLSV1s (ORCPT + 99 others); Mon, 19 Dec 2022 16:27:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232772AbiLSV1g (ORCPT ); Mon, 19 Dec 2022 16:27:36 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2098.outbound.protection.outlook.com [40.107.7.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68BDF646A; Mon, 19 Dec 2022 13:27:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dFAUZGYVG46C8RhHEWX0IeFCT5fZcfMwZZdVx8VgUKelBUv23NzwiKKtnrlbNRTXDjLG/SvECkIr1WkLw17JEyB2FMPhABc/alVtMuxXbH+1rFCd2tBYcjzCzRaEX/4s4az24NMG5xJilB/Y7WADB1Ruy0ct1T7Bh2oHLLmq65Lh3UINlYf3gfhysx43GIsdDJe7McnuzeCFXiEK1zpFHk/Zzfa/sCTStUh+aKl96vg532n/XuN+MvZWZ4af+FQ8BXsvXW9uRJUUM9OSun/ZPDOTQGLHF0W4hwEyCABjO8VtUhP+gc0tbnMHEwRRlbcx5pk+2O9eXL11IvEBC2i/ZA== 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=PH4Epp4GyGuEC6gorfLFdD6vqnNWemsv/uQaT6+AYik=; b=Oiq6VM3xcn+4BpYYbv6HQgOjFtKc5TknN02f4fB1Vij2JsD6hRvCGkYP3YjETVpXRLmI6LakGGA2z+ujBoC6Zb1KG3cZFuoDMc7TUbNo6FVAgfWCKIDfMC7FCjkhTeFpoZSc9e+4QGRmURrYIX4PyD/vqHrhMGtDQNRNJ8IhAX/hflVFivAMXCWmGeDJLnqrFI2xFI1PSS6h8OI5VFY544yCXv/c+Rhx7pZVwbjPXvdjN2Jgwi4Nb/00p0fAFrodD2i65e4TcAik5aG9t/4X2kU7PUnhduEdlS0jx98Y98KwbdzPGzzxxIj+Wyzggwm3RvU12ATKrlt5WlQs2KxYrg== 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=PH4Epp4GyGuEC6gorfLFdD6vqnNWemsv/uQaT6+AYik=; b=CA3IFhpBTrIr1v0GnQD9G1dr3PwWNYe29FbJn86cdctrwGbSMHM9WNudxpXT3rP7jQwrM/D7eWZweZo5edJNzdLmTkFdynu0tFz2tLOpeDZfhCzcHCXXn3yTiSWEciidtj77pymvKFIUckHOlK5wBlnuDHmJ69lxzlP5o6lJs1M= Received: from AM5PR0402CA0018.eurprd04.prod.outlook.com (2603:10a6:203:90::28) by PAWPR03MB10089.eurprd03.prod.outlook.com (2603:10a6:102:360::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Mon, 19 Dec 2022 21:27:30 +0000 Received: from AM7EUR06FT021.eop-eur06.prod.protection.outlook.com (2603:10a6:203:90:cafe::28) by AM5PR0402CA0018.outlook.office365.com (2603:10a6:203:90::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.18 via Frontend Transport; Mon, 19 Dec 2022 21:27:30 +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 AM7EUR06FT021.mail.protection.outlook.com (10.233.255.227) with Microsoft SMTP Server id 15.20.5924.16 via Frontend Transport; Mon, 19 Dec 2022 21:27:29 +0000 Received: from esd-s20.esd.local (debby [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id 522427C16C9; Mon, 19 Dec 2022 22:27:29 +0100 (CET) Received: by esd-s20.esd.local (Postfix, from userid 2046) id 482F62E1DC1; Mon, 19 Dec 2022 22:27:29 +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 3/3] can: esd_usb: Improved decoding for ESD_EV_CAN_ERROR_EXT messages Date: Mon, 19 Dec 2022 22:27:17 +0100 Message-Id: <20221219212717.1298282-2-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221219212717.1298282-1-frank.jungclaus@esd.eu> References: <20221219212717.1298282-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM7EUR06FT021:EE_|PAWPR03MB10089:EE_ X-MS-Office365-Filtering-Correlation-Id: adeb51a5-21de-4151-4296-08dae207d570 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xRlsG70RyeU1m0paW1nmLq597/n1aNfmNJAe0NrLOfXm8xaLaU8HEvb5FAMfiQY5f6854fSHDzp8IfMwF4FbUqMGY/LM5vXsZdacVlGjvL3v5xE6mt1oCSjqOhA2+YIxIM+Vf6mSRb7Z4OJh4MQYE+SRqc4TGh7r7/HrE7+dS1z0x7uXPy9YK/9mIHvRRyWXEC6WjGjhq7WOvyPnHlrkmZBTlkhDdyHbZ8kqUjGGt/01ygvOjgNd8XjSs7kfVWwQZueIwxx4d79UIn9yZStax9JZfaJBtfF8Gn3a6Lyi/PZE1jyLuLWwLJd10CGotpXmEg2kHT8KXR0H94wD3We7leyckvGdkGS8jC7KKljfcxdrRMGPn7Wifn+F2DUmoplsT7Wxq3GFJc3qlUnfBMGC5DeBnosiFwEh4L+KKm64snrzGBqAbZtQ3p1SGiSoNvOgeg4uxFp7bYkhjH0TjgI229d0wdRh56xvbhVW3cYmFO3Mmck9KQxTd8Cp/Jpu5VCyZCy6fk798E6E1UwQ9zzOHYf+U/JR3/ku/1eaLtKQkMcnoQIviboZ49i+RJWLZOdBvsmFgS1WwCUeWmVMa+/PXDal0tNx14w8Ighr6RlTNf3BLk6skvPJYBQBv/GlICRCLqjMM/gMaruMOq0Dw01h0QlAVIKTU5ZoAZRrZ0gIwUXDQgbcxS1gAZKc6j15Uu7gbOzcUvVYp6zwGGK2Ei2hFw== 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:(13230022)(4636009)(39840400004)(396003)(346002)(136003)(376002)(451199015)(46966006)(36840700001)(36860700001)(86362001)(6666004)(2616005)(26005)(6266002)(2906002)(336012)(81166007)(186003)(966005)(36756003)(478600001)(110136005)(316002)(8936002)(44832011)(15650500001)(356005)(54906003)(40480700001)(70206006)(8676002)(82310400005)(41300700001)(1076003)(42186006)(83380400001)(5660300002)(47076005)(4326008)(70586007);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2022 21:27:29.9117 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: adeb51a5-21de-4151-4296-08dae207d570 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: AM7EUR06FT021.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR03MB10089 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?1752679457935656783?= X-GMAIL-MSGID: =?utf-8?q?1752679457935656783?= As suggested by Marc there now is 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 09745751f168..f90bb2c0ba15 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",