From patchwork Tue Feb 14 16:02:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 57093 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3066594wrn; Tue, 14 Feb 2023 08:13:21 -0800 (PST) X-Google-Smtp-Source: AK7set9UWdfM2olM3SCFMXdMiEOtj3bxY0X0dG7R9xIWRsNRtgsxnnOSfPQsLq0ZULFeco2lLDPQ X-Received: by 2002:a17:90b:3904:b0:233:ee50:d26d with SMTP id ob4-20020a17090b390400b00233ee50d26dmr3130394pjb.4.1676391201430; Tue, 14 Feb 2023 08:13:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676391201; cv=pass; d=google.com; s=arc-20160816; b=tD+p1SpvihVN0nscY+hJlEYNIymtaiJdnzOytn+CmjB9zVwS5LSEosxukaXDDQ0S24 L9B4a/yvJxT4nOS22P4pqGYQkRWadXqqJ/5OjOMMugEU4KRPyAX7m6ChAvjCb6uG7+JE YReF4coKU+AH+bebHAkxfpza/hpBOMvpCMaP9KF0LghNuObfNjx7EZl+HKRSUlMv0zGT vfqlFzPYCorjNy4Y4aTeddUE3MUrTc1U7ydUhz2/s3wt/7OFnMARBqNs7r0/D2LBtKjQ wF8bb8J4gF4R8MPP3vcYoOiicwD/19mgy3P3Ca4DZ5KHqPW5h0zpJ8Wz+J5c0+yh8FPK PWEA== 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=kwGnzY+wItMUr+e7809AGC4ypeS4PwXRjrVTNHyfvjnVUmQV6OfCQWdI5CQ7UXMTBb SgwtclwkwYPiKNkzhW9s8B3+MLm+C6rJKRSan29B/ildPUqUMnfueTpMwDgkBbjgjZLx MrAVou4l6sNqaeIS/BdJ6LOsN6sx8/sJVsITcB42TEiRgB/rOFNobotBY5xrOvvoKxl4 lIQkYAyf5LTUEeBiXbFgVwl301R2uEqWg96eyRxYGH5f33qRPses3WYR8AjTTfwivq+9 K32cIM9MN+PFnQU2Afm6VxMcTRgHS9/w5ZlxrdjgBiWiMMUjmsvpe2yogtiUk57j1/Rf psvw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b="iSs/czP2"; 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 gq15-20020a17090b104f00b002340e488cc5si4649519pjb.96.2023.02.14.08.13.08; Tue, 14 Feb 2023 08:13:21 -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="iSs/czP2"; 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 S229508AbjBNQDs (ORCPT + 99 others); Tue, 14 Feb 2023 11:03:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbjBNQDr (ORCPT ); Tue, 14 Feb 2023 11:03:47 -0500 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2119.outbound.protection.outlook.com [40.107.105.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26A502132; Tue, 14 Feb 2023 08:03:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cmcNzuCm6Bry52pBstqhMeBsISyMBuXYUt9wHfK488l5FeP/2mllZIEJ/W+4EYQwCL3P+fSswbdMNQjBeTzlJsbu36zoUWvsU8umlYnCZRgVAJneinUax7ufAj9vF67aUPp/fYTJrkYuJBYeSVpvu8B1G2oNJYBABev+moQyN11ctumURDasvDZaMmjk6Lbo+ahGwDZSyHZFKNNs32eM81W5fiCNbAL2QGAxK2alHaWNng+M1eF46K42m+E/y2TVwzF7uvB3Qwz4qzMXMehFq9FnWjcvho/ofr7b4nPlWJL2WfCWpZbqus1Lf6IaqsuW/MI2RF6sJ8Om7fqXdMLvaA== 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=b/12WeyBJJ21Nj6OiH+zJ8E6vqAVnx5adWJYtyofhUcS7EeoE+8TVM1ImGbGaiH3qVktxwnYnmvJN5AiuecZ8SuJgiEaUG5DBGYiAvPj7eu4fobnvgXZ4nSRqKRaGJDmn0iaVOk1qKPcRzTn43QIFXYS+KuknDF7H8Jveh+/YiAb1n5QlNSd50tkl016Ie4H4u00gy+3e6ttw4C1EDom1EJDfWQX3Zu1v8nec0mDuFk0w80LCycBQ2yKcUZ9nfm084+SN2sAC3wh9ZW0HststRjAeS2nky7Z6uYMqOXJN4djxCjR8gjLxzaSjlipxXLVt8RZ0W4Y4UuHCiWayBWabw== 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=iSs/czP2qlcXaPys0uLva5TJDgeubW8pKIKlKeeEeNInlfWFBKNTWEJczSxlN1/owdI3Gn90p+Idj9p6UPuI/34VFbjxVfArkPLmILLxt4UFiTgqwm5yyGVy/YIiKTMkc36wsLs7GjVIysD8mHfoCq7i8n7+0kn+me245k5AsxA= Received: from AM5PR0701CA0022.eurprd07.prod.outlook.com (2603:10a6:203:51::32) by AS2PR03MB9049.eurprd03.prod.outlook.com (2603:10a6:20b:5f0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23; Tue, 14 Feb 2023 16:03:10 +0000 Received: from AM7EUR06FT049.eop-eur06.prod.protection.outlook.com (2603:10a6:203:51:cafe::8) by AM5PR0701CA0022.outlook.office365.com (2603:10a6:203:51::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10 via Frontend Transport; Tue, 14 Feb 2023 16:03:10 +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 AM7EUR06FT049.mail.protection.outlook.com (10.233.255.201) with Microsoft SMTP Server id 15.20.6086.24 via Frontend Transport; Tue, 14 Feb 2023 16:03:10 +0000 Received: from esd-s20.esd.local (jenkins.esd.local [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id 6A8977C1635; Tue, 14 Feb 2023 17:03:10 +0100 (CET) Received: by esd-s20.esd.local (Postfix, from userid 2046) id 5F1652E0125; Tue, 14 Feb 2023 17:03:10 +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 v2 1/3] can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (1) Date: Tue, 14 Feb 2023 17:02:21 +0100 Message-Id: <20230214160223.1199464-2-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230214160223.1199464-1-frank.jungclaus@esd.eu> References: <20230214160223.1199464-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM7EUR06FT049:EE_|AS2PR03MB9049:EE_ X-MS-Office365-Filtering-Correlation-Id: f9121bc2-4c5f-4f9e-cee2-08db0ea4f856 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cmFw5xy9Ua969J4Vv/9ezup/o4bzi7nHpbhoHlEKo5vqdSIsfVbFHRqRTdOjJGJbkKow4UkrlAVM740FfS3anJM/z5XedULvg6dVTZ5FHtAEfB/eoRaaCUJYhdY3Kz2QiZklc5Qg0mrReMGqaNvn7PPDuNEQAhJikBDV+n30eVLUEuRJ3JNdnDdD/vI5G9BqHiy+z9W5tUB6T9dWg6vCTpIGyIj4Zcl1jnhyrdU3jNZ8dmqeduiXxeCCFAIIBGc7FggSh5b6QdKNaFpyLjR2Mjm2dxjpvTLSZOwSvsWOlct/thezYYKt/K3al9eA0bMSn9vBtU7c6wUFs7sok//CJIc0mTJvHZNmhdjyViMeJ4OvgJxwXyZo7W42bTqUm7O8Z0WWYD9jr1x/KPnDVFmXeRrB4d04yk7cFQ2EPnh9eWlsQ9sFN5ClpDqsllboypmmEYfAgi/YkGpILOx/N3OswP47q40+O5TdMT9BZOy7tqXgkeo144/GIqzee6jK9RR30kuJXo5W+A0TJgvFR7O7ljeToiYIjlb9dUTCORveKp3Tn5ymmPKHSfZuxyBnICjebC9k/29zM1hI2+Mvb5I6j0SsOtUyfCInAaRIJPWUk49GJo985RocH9521GNWoxURdfvWtwYiD9gI1FtENm8eT/uPWDKcctwAEOVa/VmWYLU= 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)(376002)(346002)(136003)(396003)(39840400004)(451199018)(36840700001)(46966006)(36756003)(47076005)(2616005)(336012)(83380400001)(356005)(36860700001)(81166007)(82310400005)(40480700001)(186003)(8936002)(2906002)(41300700001)(44832011)(5660300002)(6666004)(6266002)(26005)(1076003)(8676002)(4326008)(316002)(86362001)(110136005)(42186006)(54906003)(70206006)(70586007)(478600001);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2023 16:03:10.6139 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9121bc2-4c5f-4f9e-cee2-08db0ea4f856 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: AM7EUR06FT049.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR03MB9049 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?1757823580671244462?= X-GMAIL-MSGID: =?utf-8?q?1757823580671244462?= 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 --- 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 Tue Feb 14 16:18:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 57101 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3070854wrn; Tue, 14 Feb 2023 08:20:01 -0800 (PST) X-Google-Smtp-Source: AK7set83YDeRBnkNul6gytnk1ldgN7tORqGVfg2ewMKnwdXTVDrms7dsHo0x47bBYdBdDYKtZkEO X-Received: by 2002:a17:906:bc8e:b0:8b1:2c37:ae97 with SMTP id lv14-20020a170906bc8e00b008b12c37ae97mr2488453ejb.43.1676391600868; Tue, 14 Feb 2023 08:20:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676391600; cv=pass; d=google.com; s=arc-20160816; b=wWC4wAtIqgtzqnql8Y9fSHFpaSJ6bwgQscxiJn2ATFfROKRrWxeRLX35fmlM/1KD/B qzImsp3KgEVeCIyZxUiV9T7+l8S88FG/8z+lAVicvjxjlKyuWCF6bCjjxtBKLyVG8mSZ 8xGisTOnWMCqQUYYJralOm8uR7nuaH46iqKTfpNh88tP6B6P9wBPBcL+5iByttHaoOWn AZp07ATfcn5SanMDCF1YRgilyj1ycOgm63RwgGI3XzaZoTRdNkDKUG/Aps9rPQIh5UTD 4iyY/5hxl3gI2sE6Ytm/cxfJi3UwrJDUylZWvpL7mL7aztrQfKCWo+vU8AId7/m6VN58 3yWg== 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=e4kumhiStEu6LLlD0QyS45kJikls69CkihJ3IuvsdLg=; b=j8fLOcJXXOZF5yjzJrwSyEuEYKsPxIS+3npfZ89Bz7nhp0V5C0ufuTEn3JQ2gcwt/R RR0ov4QKEVVhn/soIEY4RRPyI59AE5vJtpInu+j2nXopcodYV9Qh4zgIDsuNCK0fvy4N ek0HdDxRwIeF6R4bGJEh333rDVNb8wPLNKRR349T4WqEC/Y7LvW1+QSL+rTxh4cn37Y/ KPZgWKiRh2s1qNg7q7bfasmqHcBcz3R03W77kJnMLSeog97PbGBXYKvwe5eEZE0QJRWs t2Gp/FzentdikbArPzleqyp6e4s0aEeFjTGh47A4ZXDEx5wVc/D2wrjrmnnqOInstf1f 6WWQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=Ks9+aPvj; 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 mt23-20020a170907619700b0087858b74a0bsi10999743ejc.983.2023.02.14.08.19.36; Tue, 14 Feb 2023 08:20:00 -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=Ks9+aPvj; 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 S231934AbjBNQSf (ORCPT + 99 others); Tue, 14 Feb 2023 11:18:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229842AbjBNQSd (ORCPT ); Tue, 14 Feb 2023 11:18:33 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2112.outbound.protection.outlook.com [40.107.22.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C45027ED8; Tue, 14 Feb 2023 08:18:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hqRPgyDGWw1yozyQKoiOcEG+xuuY+rW9ORYC+zhwJ79dEW57t/lmWrU1S+wtrxB2K6UTHUWJ54cKRMnWyT3RHPVr0W8OFamC+mnhtPGrkDswKTFTAN7sU2kEsANDaeidxS7fkL6/6SMwCYUKDenzqkafhTig2mVTcgVfQ8hqZ5UpyH7XW/v2d4krCEQ98XY6s9/e4h+SNxUvtXyHm6pZinJ5aGD7ByXEeIdYzF/Em1fxVOwvgFn41ZcuyPEWvLuSTUpEm4/9u4cwDse7eUq09dA0QU2RuoP4Vl9efmHsw2RQrRpwvqAwrb9X+l+zBFTiKnlj/P8l2TJly1BGjWM5+A== 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=e4kumhiStEu6LLlD0QyS45kJikls69CkihJ3IuvsdLg=; b=Ky7zgMSaX1pf5RSfhfSY0GtuicrXbsEwA6ecsi2Iv6E92sK9f35sfXyv5xkmnAqb2sQeS4e2qhEVzGDi3+LH8ywhynEdegtpCWqiIz8LAOhWOZf7qIgGRkD2QJSyebMdGZzYlhKxF8vnlyABI0ZAbQPWh66cxAVMzxNWl85+LwxGiQxiNbdUYlKPZASTKioCFSoNMADcCGUayHecUCMVDQ6EnvF7FDKI0RYaDzrRgy6ZXzLM65Kpc5asWDLFU08hD9x2k7+o3j+GqREZAL9S1flCd/iVzGhtwa9DA3xytJwbfHJqPb+sdLGE+08WsnZpMhfpEKJJnAp0vmahgz5IYw== 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=e4kumhiStEu6LLlD0QyS45kJikls69CkihJ3IuvsdLg=; b=Ks9+aPvjyYQEzidn4vMN52CV13Qdk/CYbMmYPCLq4ODQd2q2RYJMk1XMMb1V/A2H89vIl8n2aMlgCZ3Bc0gFmgThHxddqsBPZC6Fv6nWIKUaG3KSScHBl9wXfFR68DsT0A8pQIxreiLo5H4V14/acQB7N4T9vZrYH6UgcxPeimY= Received: from ZR2P278CA0008.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:50::11) by AS8PR03MB6807.eurprd03.prod.outlook.com (2603:10a6:20b:23f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23; Tue, 14 Feb 2023 16:18:28 +0000 Received: from VI1EUR06FT067.eop-eur06.prod.protection.outlook.com (2603:10a6:910:50:cafe::41) by ZR2P278CA0008.outlook.office365.com (2603:10a6:910:50::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.24 via Frontend Transport; Tue, 14 Feb 2023 16:18:28 +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.6086.24 via Frontend Transport; Tue, 14 Feb 2023 16:18:27 +0000 Received: from esd-s20.esd.local (jenkins.esd [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id A5C967C1635; Tue, 14 Feb 2023 17:18:27 +0100 (CET) Received: by esd-s20.esd.local (Postfix, from userid 2046) id 9E49B2E0125; Tue, 14 Feb 2023 17:18:27 +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 v2 2/3] can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (2) Date: Tue, 14 Feb 2023 17:18:24 +0100 Message-Id: <20230214161824.1245097-1-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230214160223.1199464-1-frank.jungclaus@esd.eu> References: <20230214160223.1199464-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1EUR06FT067:EE_|AS8PR03MB6807:EE_ X-MS-Office365-Filtering-Correlation-Id: e08eed1f-02dd-4116-ee49-08db0ea71b24 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZGvQvlToyELUZN+f+yNN9sEvQh5kyiAnZGbo9PtkhUHsL9bON8K+w1EaNDkijTKIV0jqh77TP76iNOEncL/WJtH0v+1ndttUHjbr5V0Z7MK649XRN7gjYIm/nJV2Narav5TVpo1/HOqLAe0nOBaYYghYUd00M+rQWKVgIku/sZgywE/RoOMzKGJaSXXDxc5r+iUhGPObhldgKBElxe7B8mkrW7Tdo/tmsQ8Dv2HxB3MFnRFbHvJ6fw0m/yKlwtq9Ge5iVKeLbZ0SYhOEarpcsFrTQkyfHTbfSxuzgheZVHia0wTyLhRGisbhl+XtrBUF+PWlozj2WLcectretneLnRsEyGK/4VkUJb2AX1HglUSdT/L5JRsV/iLCvs+gJDeK17TeO0FU0WhRUCdmcnfJe6cmqmkfpBQ9HCman35wPU+P6cxX5AtPAPMUqLldF7uvc0xon8cSgpwd5lafyJzoMWvIxeLib/DuJOHp47mfBD0KDer7UuR0nDo0vkBn0ZIhRoL7UfbVjTreaLio/N7j0cci2c7WtgS+fEQQ+ryLOifmBzj3UW2yS3H1DAc8LnDYW+pWmzi9em/dnuNqAl7ZhVhVDGEEz7uggYjkBOr2fCTUiObvWxuUEba8kaYgUNFW3kdmP4spXMh0WOOPQDYVZr8ZU7C7FI4dT3w5Wb4Kb0o= 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)(39840400004)(376002)(396003)(136003)(451199018)(46966006)(36840700001)(2906002)(70586007)(336012)(42186006)(41300700001)(83380400001)(8936002)(54906003)(8676002)(5660300002)(478600001)(6666004)(4326008)(186003)(26005)(966005)(2616005)(47076005)(110136005)(70206006)(6266002)(356005)(40480700001)(36756003)(316002)(1076003)(86362001)(44832011)(36860700001)(81166007)(82310400005);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2023 16:18:27.9852 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e08eed1f-02dd-4116-ee49-08db0ea71b24 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: AS8PR03MB6807 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?1757823999091345737?= X-GMAIL-MSGID: =?utf-8?q?1757823999091345737?= 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] . 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 Tue Feb 14 16:18:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 57102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3070971wrn; Tue, 14 Feb 2023 08:20:14 -0800 (PST) X-Google-Smtp-Source: AK7set/SxlEdJQfBlS6HKwcZyjoUM7AQOxJpzoDA+Ql/tJ4IatuuyfICZ+2CYwVoCj2TAV/eS12h X-Received: by 2002:a17:906:edaf:b0:879:9c05:f5e8 with SMTP id sa15-20020a170906edaf00b008799c05f5e8mr3617102ejb.62.1676391614179; Tue, 14 Feb 2023 08:20:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676391614; cv=pass; d=google.com; s=arc-20160816; b=c9FEL+6pbhmRZdF45Uq7Wr/pxFfpCiRr6m9mMA0A9Z2ySbtLor/52lK9pQwvlkih48 EDiD8o4dZ27d722OY3yHzgJFspvds0cuNKNR8ZgTItxvmiL8RzaBK+ugWg8cEbUy1pLz rYp9GFfqhKkfaBbJTpFC3k6CP0f0bJ2S9NM4jN9nYUKaZyeVon4Fo20XfrPNLxJ2gyHL e5quUS9hl9tpxFsh/SANZhJcN3/UX7O7ljOBcucINVpExKVFAbNpxTV0izfAOV0J4U84 xe1MIJQw9fgxTBD3SvCUvsGLU05zyo7laGPh5pnlqS6k+653YgmqWlL+xWWRt5EOWBQW WB+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=8JYZGgm1XYD1xLyWkBS3yOFOgCougyjas/xb0RdkIG4=; b=KDMkD+oM3o0I/aG3X8cOhArD/tt88uXjQAnusfW9/CiQY/dSupl5d1gOfdz8LF5FSz uzUb8DKKh1LcFhGonhMsAeqXl4PSX9YjbYJ8eHkgaWGRMbCPN2epUAJU2i1+Jzivxq4+ 83084Pobidf01ohmP6EroPGuGgrLd8BOUfhCOD1ur5dzk2S0hZNHrbnc8tAeBLG4yv9V rfTYnDD2CBW4m9xTm7x0mvH4+19OEYDYdnfOFxHMU0LzHITzJl5GfTgJkRhCLO+3hO7d gjA5JD1LZjv7SUgPH44M0ptqaHpZSC5P3vq5SrHX4Uta7iWavGst2VrJO0N4t5tCazSM x6Cg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=saWMhAuX; 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 v12-20020a17090610cc00b008b133f7b522si2271369ejv.614.2023.02.14.08.19.51; Tue, 14 Feb 2023 08:20:14 -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=saWMhAuX; 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 S231269AbjBNQTE (ORCPT + 99 others); Tue, 14 Feb 2023 11:19:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232226AbjBNQS6 (ORCPT ); Tue, 14 Feb 2023 11:18:58 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2127.outbound.protection.outlook.com [40.107.104.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40CE61F5EE; Tue, 14 Feb 2023 08:18:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ePPgbbiKCSfhpt7N2GXknBAhVzEwBe0XvK2YIZRJndS/S3DxIqpT+gd2CLv+B9dSYo3j/wXnsKJhn/JcRw3PGe+Dr1jTcviPqakAYY0lIiHS9Pj0PXyCWcnVNjnlLI/OQWIxhSvs5S49aDone80+y4vhXkGyV7FP1KNTwWpkKlwG/6JTXXMW6caitb75S+T/nTQeFQBqJnsJnBuzHjsoYgE8Ug46i/+3qkehImM+BRymT3V5hF4TTQAshg3HqJ8eypc+SzxcxRG0qWjWnAjpa0h9JgBl7IOoJg/PKPeMxeba6Wfjj5qrXJnfS1PDfoNdWIlyxbw87XfnySYlzjJCSQ== 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=8JYZGgm1XYD1xLyWkBS3yOFOgCougyjas/xb0RdkIG4=; b=asTEoVqQiEayeKhSbMjnOA9GD00aDbhn+9g2OePa7NA8IVJzNLJm2vMyyBJAZB5pXAxef/dKSW+yFpcpLXJ94Kz4SRB52YpKcn6mBInaPgxy97bPADAjcLjDq/L7ZTl43c7fQhLoOZmtTOgnqXQOrK5imPPmZ7eHnUyAhP7bxuJ7FQ5tkLJf8KGZLQNiZKDaO21pOZrLWQu6ZtfnFI9DG0QKU3A1G6gmePYs7cpd3lT6UT8wo5Qq1glgiNw8zN9REdidGRJngey8kaZtQpdTI8OIFjCCN7LVm6BubGXoSAhWbTj/rlGdmP8KVkGeo71kvEGlD4vdTNfR5MpuZMfY3Q== 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=8JYZGgm1XYD1xLyWkBS3yOFOgCougyjas/xb0RdkIG4=; b=saWMhAuXKRnCUKRDbxqie1THvDAQ3BuZZM2JjMQhl41lqnMiEP4QoRPxT7CgtyHutTK01FC3/N38c+ASHgsVKC+v67zadJrJuunyEn+2bGkWy3m3bY95T3we/gghzHVVt4k6qwyxajnrmf+lYE1akiLIs7oBqS9fO42XF7OhXKg= Received: from AM6PR0202CA0072.eurprd02.prod.outlook.com (2603:10a6:20b:3a::49) by DU0PR03MB8291.eurprd03.prod.outlook.com (2603:10a6:10:31f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Tue, 14 Feb 2023 16:18:37 +0000 Received: from VI1EUR06FT035.eop-eur06.prod.protection.outlook.com (2603:10a6:20b:3a:cafe::de) by AM6PR0202CA0072.outlook.office365.com (2603:10a6:20b:3a::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26 via Frontend Transport; Tue, 14 Feb 2023 16:18:37 +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 VI1EUR06FT035.mail.protection.outlook.com (10.13.7.54) with Microsoft SMTP Server id 15.20.6086.24 via Frontend Transport; Tue, 14 Feb 2023 16:18:36 +0000 Received: from esd-s20.esd.local (debby [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id 919187C1635; Tue, 14 Feb 2023 17:18:36 +0100 (CET) Received: by esd-s20.esd.local (Postfix, from userid 2046) id 856C72E0125; Tue, 14 Feb 2023 17:18:36 +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 v2 3/3] can: esd_usb: Improved decoding for ESD_EV_CAN_ERROR_EXT messages Date: Tue, 14 Feb 2023 17:18:35 +0100 Message-Id: <20230214161835.1245274-1-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230214160223.1199464-1-frank.jungclaus@esd.eu> References: <20230214160223.1199464-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1EUR06FT035:EE_|DU0PR03MB8291:EE_ X-MS-Office365-Filtering-Correlation-Id: 0abe7c21-0f2e-4fd0-3feb-08db0ea7206f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZqrFiRxULjtF/N0oh2zDZz6Lo4IunAxCkhh/ASAY1NsQze6aWj/pp1BGiYUDjlskvGO71D8fOUqw7YTz10lchJyr6UbjOSEL8G4AAiRQN24iul6MwvzSSqf9McDmDc8lMK1CA//YkJD9IAPE2lV/qj4thVtPnGf11s5BsW+YTiCF41uUdUstnv/tohjGLoJUImiZD+XYR1Cwqhc4wl1wXvHaNZ0CEL/8hLMIB471XfltDuyc38AZykt4UQ5NWdzb8C/rGx3AqJl39M2lHtsTkJV4LeAmbE9GirgEg6T0Rz6oYt+vhGxPp45to2DB/f2MLYhdWdP+FEzrc+zpnRVlgPIQuMTWAoMZCVqheOOJEhxJob5DJF+h7qCCl5AbSQKMSVPkp16mArA8yMpnuGzrKWmW7Fw/ao4vV+A6I+FTRCPOFSXlpNXY8NCT7afSo8U0Jaj+52xZgYrHnnNx0nU547TGmtJxhEC3zSR0c0AeVslhR26bUfxL9WuY1jGkola10tX/QCfNc6FavD85PsEbsJXniFqHdE4Wl66mGlNt0gOs0eHiWe6NtD3MMnZNDR9x3pmYhS5D2bgVvJKNVpLGN475Y2dhcoi15uM62U+25YVVz94I5eyNVBO/U9dqBkd68oH8chmGuBOTwkGWUL4g1nTO73FmGRlDTV1o2ZZA8xc= 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)(376002)(396003)(346002)(136003)(451199018)(36840700001)(46966006)(356005)(2616005)(110136005)(54906003)(316002)(40480700001)(2906002)(47076005)(478600001)(966005)(336012)(42186006)(15650500001)(83380400001)(26005)(6266002)(44832011)(8936002)(86362001)(41300700001)(186003)(5660300002)(70206006)(70586007)(36756003)(82310400005)(81166007)(8676002)(1076003)(36860700001)(4326008);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2023 16:18:36.8608 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0abe7c21-0f2e-4fd0-3feb-08db0ea7206f 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: VI1EUR06FT035.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8291 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_NONE,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?1757824013153727364?= X-GMAIL-MSGID: =?utf-8?q?1757824013153727364?= 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 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",