From patchwork Fri May 19 19:55:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 96603 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1490158vqo; Fri, 19 May 2023 13:07:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51xH2gjRSA8MGGPw6NeT7mXNEr2TqMVB+ZcNRlTNweZnUZvFrlxsYgaXMyVqDt7w19HCNI X-Received: by 2002:a17:90b:204:b0:24e:28c:f391 with SMTP id fy4-20020a17090b020400b0024e028cf391mr2788701pjb.27.1684526878004; Fri, 19 May 2023 13:07:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684526877; cv=pass; d=google.com; s=arc-20160816; b=NhepdourZEnT7WT9YEwZGNB2frKj8z6WdAzkWrwQzbZFvXrwGRREix1uK9lRAEaamb 8GE3KrOsK5C5d9okCWtrmdAjgr6aKD3nQS94FHk+wE4oQya9FS2ndfTAQovW1cwlAS64 ybBDLjYS3x/2jS6BuRPqF8BvV7vFTFRXcl0dYtwBivQb44c9dhR+TBNcsn7mD96qNPNO CCI7qZEWvFIjGg63eNJ4NmfjigNWOEpOJSXRO6JtyxNJV3UkLwuwf+SMjRhFyelV/VVd YrlfLfD6irxeAaiPOVquj6J5ukIgI9Ib69s7lIrbEiQ25+Yuu7jts8VgtPbGasl2BsqF hn9Q== 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=Me2bxWzFtNUGf6d4dfzlSZdH8xuQOhG6KlA10GXHAcQ=; b=qdFsxGinHK7lQteRFJKaYtwEJwmGTlMk0QqldLRFAZIU4jaAd0VhMCeEkoqz9Q30Dw xlPP7haJgSbbvIaeVd8JBMSaDNONIowDuBveY1/HLdf74XwE76NExqd+DR1LEOxCPcJg WOJuZmlyjHx9W89XsTIlTUvhAAaZGIQYsk0zqmNREF30o0pDItiGKDHSyECf/UACwRLk SZ3yuRVyvGJZyQbStw4BucTzb6fyZTjnghNVeOJNsRSRJBBW+JasBDs+B8b5E0WQmvQK gnAcbu/rFoB+VaDnPQRLXtHwOEzIEzedaNqG6f5Qn56ybQfKg1x/UNl7ciuGv5ph6lnX M0hw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=ge+PElRu; 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 9-20020a17090a08c900b00246bd5445d7si48692pjn.104.2023.05.19.13.07.23; Fri, 19 May 2023 13:07:57 -0700 (PDT) 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=ge+PElRu; 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 S231612AbjEST4a (ORCPT + 99 others); Fri, 19 May 2023 15:56:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229877AbjEST4L (ORCPT ); Fri, 19 May 2023 15:56:11 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2091.outbound.protection.outlook.com [40.107.15.91]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E8D6E40; Fri, 19 May 2023 12:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BJvWqwmz2dztfcsg6zeJwGIEKGYpbt1YYrP3JRsfPSx4CtwGBlfe5wUpsuKWy864sZdcNB50sQktXbcuINqTwFXkYqcIyFM43TpC+DquW9zKNsxeui7gFltjEVmvTge3NwZkI/6SHrXqG7+M5F1ET7f1WEY5qrfyLJsIhVpanlzH5VKlwoHymkZGGFJvVc6cdgVP7NOttWmaL4YYYXfFwmW11/tx1bHUzUwnhLXhoGnymKCP67FPmdvdz4WMceBq3t3SfLrQ6Zxl+Xs7pS7Kos/Lo+0UJUpQz6NbI+2eJDB+pCn6duIuiLj4Tx8CdIh3HxbWsJA9dsBkoHPQYwDaog== 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=Me2bxWzFtNUGf6d4dfzlSZdH8xuQOhG6KlA10GXHAcQ=; b=W2CYlsqR259/qids52Py92ErB4UxvmaKI9iwkkU1lggpl6pOElp5BzjtCTzdBhIDkfb5sRYXteXWMnovfybsY4Pp5VfaLrsNKSaddzBPfo6yPTrUCBSYiKfkjQcZ6IT6rwkhHs3AjNG2kpKMpeIYls9US0Hom+SJi7CWVFcX8zTpX56ngW9b+IX1mSRfWEjtMv/OQd7tcvob0+++PpFAeVwEqSoL9x+4csqUbkiBsJqSBfUVrftkt3RhD/Fr/fCLiNw0BUN0VW+BDLVWIO4CzsJCknaSUOlgRsHmz+Va00+75ekAPDhbP+bKik4emRmTz9gubB3tkdS0P1UmeVGOKg== 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=Me2bxWzFtNUGf6d4dfzlSZdH8xuQOhG6KlA10GXHAcQ=; b=ge+PElRuON+DUaygmkfIMU8ULedk+XwC6yUeqwvSKJRZbG1wea71Llu0xL3nAYNmk+NdlmE+TErDnngyXirv8DVS4kyo0KYGP26w1dCjDsJCabAMuVgGSjvB8J/IaG4vo/608agtemBK0jbGgAnAg/MWswpqmsmvTGbu5mVyD2I= Received: from FR0P281CA0181.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ab::8) by AS8PR03MB6824.eurprd03.prod.outlook.com (2603:10a6:20b:29c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 19:56:05 +0000 Received: from VI1EUR06FT008.eop-eur06.prod.protection.outlook.com (2603:10a6:d10:ab:cafe::b3) by FR0P281CA0181.outlook.office365.com (2603:10a6:d10:ab::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.6 via Frontend Transport; Fri, 19 May 2023 19:56:04 +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 VI1EUR06FT008.mail.protection.outlook.com (10.13.6.135) with Microsoft SMTP Server id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 19:56:04 +0000 Received: from esd-s20.esd.local (debby [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id E33B87C16C5; Fri, 19 May 2023 21:56:03 +0200 (CEST) Received: by esd-s20.esd.local (Postfix, from userid 2046) id CFA172E1802; Fri, 19 May 2023 21:56:03 +0200 (CEST) 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/6] can: esd_usb: Make use of existing kernel macros Date: Fri, 19 May 2023 21:55:55 +0200 Message-Id: <20230519195600.420644-2-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519195600.420644-1-frank.jungclaus@esd.eu> References: <20230519195600.420644-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1EUR06FT008:EE_|AS8PR03MB6824:EE_ X-MS-Office365-Filtering-Correlation-Id: 59fd30b4-15f9-4cc8-7103-08db58a3140d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MfYyye/eJ3/dAAJSFV57SWaR67SRTO8lnkC8Qv8J6aOrj8ukhLzjRUI9YdRT+FlNn67QAoItWWN4zms8pxW3RRU9Lnyv6F7d1tRQp0RtrCXG4USJHMGUGidO1saKHm9Mu1UHYi8VEbGQK2CpyiwGWoaA8h1A9EQFHtq/j3x8yJL6Jv1n9KptjJ0PzLy9zkG4MDcfSXNUj/8XWkL8VX5Lxxc+lL9U3DYrObv+kU0HQy/uw6ze2eAQi4KiRzHsqhog5ZIDxXvmeHLPJb6EkMEkCqAkfTiNVLN2t8OCftUpPV8+xwYA/U/EUxjKSBFJb/VBr8kzBCgFbNfo5+xi1OcI7Z9juZ9ES24dJc0SiNg+NRIq19oxcGgIISIdJCwNmgF+qTSF5nFlRQLyahfLnMwQq8N/MCHF/4wBZv5pPnKXnQ2Q+VYRBMrBWEAVZ4jYoyk9ED9XpYKfq9SZfPZZmYXKMk6WYh0dcBwytucyVIr2RBU8zvMYQnWnzG2oioODuVstOCW7utbojVZbTJx/aZZIlRYpLsKZ/F5tAP8OmpqbHiOcaBC39H6csa+RAlMVRrihRbR/AlXmso813z9rYVTai1SB3IzjFQCMJYLKMyb8vPWQ1P4dWRAYYnaVe3/YnrH1SO7dgcsNXjbeanTvBuiwdqihALdITCAsFH2noIitL47ywg3ofkTho0TVVsYQLFMSuvP/9spf0DsMPB9O3O9Iyg== 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:(13230028)(4636009)(396003)(376002)(136003)(346002)(39840400004)(451199021)(36840700001)(46966006)(36860700001)(83380400001)(47076005)(478600001)(966005)(336012)(6666004)(42186006)(110136005)(54906003)(2616005)(1076003)(2906002)(6266002)(186003)(26005)(8936002)(44832011)(5660300002)(36756003)(356005)(8676002)(4326008)(40480700001)(70586007)(70206006)(82310400005)(86362001)(81166007)(316002)(41300700001);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 19:56:04.1458 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59fd30b4-15f9-4cc8-7103-08db58a3140d 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: VI1EUR06FT008.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB6824 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, T_SCC_BODY_TEXT_LINE 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?1766354455390759358?= X-GMAIL-MSGID: =?utf-8?q?1766354455390759358?= Make use of existing kernel macros: - Use the unit suffixes from linux/units.h for the controller clock frequencies - Use the BIT() and the GENMASK() macro to set specific bits in some constants - Use CAN_MAX_DLEN (instead of directly using the value 8) for the maximum CAN payload length Additionally: - Spend some commenting for the previously changed constants - Add the current year to the copyright notice - While adding the header linux/units.h to the list of include files also sort that list alphabetically Suggested-by: Vincent MAILHOL Link: https://lore.kernel.org/all/CAMZ6RqLaDNy-fZ2G0+QMhUEckkXLL+ZyELVSDFmqpd++aBzZQg@mail.gmail.com/ Link: https://lore.kernel.org/all/CAMZ6RqKdg5YBufa0C+ttzJvoG=9yuti-8AmthCi4jBbd08JEtw@mail.gmail.com/ Suggested-by: Marc Kleine-Budde Link: https://lore.kernel.org/all/20230518-grower-film-ea8b5f853f3e-mkl@pengutronix.de/ Signed-off-by: Frank Jungclaus --- drivers/net/can/usb/esd_usb.c | 40 ++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c index d33bac3a6c10..32354cfdf151 100644 --- a/drivers/net/can/usb/esd_usb.c +++ b/drivers/net/can/usb/esd_usb.c @@ -3,19 +3,20 @@ * CAN driver for esd electronics gmbh CAN-USB/2 and CAN-USB/Micro * * Copyright (C) 2010-2012 esd electronic system design gmbh, Matthias Fuchs - * Copyright (C) 2022 esd electronics gmbh, Frank Jungclaus + * Copyright (C) 2022-2023 esd electronics gmbh, Frank Jungclaus */ +#include +#include +#include + #include -#include -#include #include #include +#include +#include +#include #include -#include -#include -#include - MODULE_AUTHOR("Matthias Fuchs "); MODULE_AUTHOR("Frank Jungclaus "); MODULE_DESCRIPTION("CAN driver for esd electronics gmbh CAN-USB/2 and CAN-USB/Micro interfaces"); @@ -27,8 +28,8 @@ MODULE_LICENSE("GPL v2"); #define USB_CANUSBM_PRODUCT_ID 0x0011 /* CAN controller clock frequencies */ -#define ESD_USB2_CAN_CLOCK 60000000 -#define ESD_USBM_CAN_CLOCK 36000000 +#define ESD_USB2_CAN_CLOCK (60 * MEGA) /* Hz */ +#define ESD_USBM_CAN_CLOCK (36 * MEGA) /* Hz */ /* Maximum number of CAN nets */ #define ESD_USB_MAX_NETS 2 @@ -42,20 +43,21 @@ MODULE_LICENSE("GPL v2"); #define CMD_IDADD 6 /* also used for IDADD_REPLY */ /* esd CAN message flags - dlc field */ -#define ESD_RTR 0x10 +#define ESD_RTR BIT(4) + /* esd CAN message flags - id field */ -#define ESD_EXTID 0x20000000 -#define ESD_EVENT 0x40000000 -#define ESD_IDMASK 0x1fffffff +#define ESD_EXTID BIT(29) +#define ESD_EVENT BIT(30) +#define ESD_IDMASK GENMASK(28, 0) /* esd CAN event ids */ #define ESD_EV_CAN_ERROR_EXT 2 /* CAN controller specific diagnostic data */ /* baudrate message flags */ -#define ESD_USB_UBR 0x80000000 -#define ESD_USB_LOM 0x40000000 -#define ESD_USB_NO_BAUDRATE 0x7fffffff +#define ESD_USB_LOM BIT(30) /* 0x40000000, Listen Only Mode */ +#define ESD_USB_UBR BIT(31) /* 0x80000000, User Bit Rate (controller BTR) in bits 0..27 */ +#define ESD_USB_NO_BAUDRATE GENMASK(30, 0) /* bit rate unconfigured */ /* bit timing CAN-USB/2 */ #define ESD_USB2_TSEG1_MIN 1 @@ -70,7 +72,7 @@ MODULE_LICENSE("GPL v2"); #define ESD_USB2_BRP_MIN 1 #define ESD_USB2_BRP_MAX 1024 #define ESD_USB2_BRP_INC 1 -#define ESD_USB2_3_SAMPLES 0x00800000 +#define ESD_USB2_3_SAMPLES BIT(23) /* esd IDADD message */ #define ESD_ID_ENABLE 0x80 @@ -128,7 +130,7 @@ struct rx_msg { __le32 ts; __le32 id; /* upper 3 bits contain flags */ union { - u8 data[8]; + u8 data[CAN_MAX_DLEN]; struct { u8 status; /* CAN Controller Status */ u8 ecc; /* Error Capture Register */ @@ -145,7 +147,7 @@ struct tx_msg { u8 dlc; u32 hnd; /* opaque handle, not used by device */ __le32 id; /* upper 3 bits contain flags */ - u8 data[8]; + u8 data[CAN_MAX_DLEN]; }; struct tx_done_msg { From patchwork Fri May 19 19:55:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 96602 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1489973vqo; Fri, 19 May 2023 13:07:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7btdqPzO6oNrFGj4LFZuCHvZx1hzBtK2xJ9u7D7xpLOD4aI+2kDIH2eTpPF112atsq1ix+ X-Received: by 2002:a05:6a20:e608:b0:100:85e2:26c9 with SMTP id my8-20020a056a20e60800b0010085e226c9mr3236055pzb.13.1684526862941; Fri, 19 May 2023 13:07:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684526862; cv=pass; d=google.com; s=arc-20160816; b=rqySG/USFtWML/HUKn7SOcYTT/Vfqa6/4SebAZmjy1KTupMCBzQYVnnspfuL4YCsgp 63mqmU9BFDLS/8xAk78OzY6tGCFDf2OygLf3s85gj3/+h4uAorCXgvQebivmcRaZSj03 F+/bl8AUy3sRdq6vR5kAN/FmQYfRDjuANu06ugOP2Jinme80PyTUzK693O6KF7brNSSB nIhfLkEPZGsWqUR4k/HTEOX5VQck/Xh4noGWvSUxI5ig7vO2+ySxYqvUpmAs2qm8KQIC zcUVouAPJYcQhEyRYE1tD61bGVoH5NYbJDv026rRwECZwTFE1v0Cf3hZbL4G7czPmq9T kcQA== 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=Pg5KLyGNcqquZBgTVZpaUWi1hgGzCWeIUtx4oZetMkA=; b=D+kvdIx0hYHJWtcDbJiSpkqao9hCLr5PmfedHehulOJX5jWTsXwHJYPjpIUzkz1B1i QpCduHjMQCJi2U8gNT3t6LFmz+prJKWjypLFLiI2q6BCsFWWlS7F4d/qn8/YtS8xFf80 jzY3+sLHgrZmiRHeaClCT0DfN2e2UJfpCzcLVDK1l5lAYQ8qV217DmJoezfTliOHwxox W7ymxzRuk4BKExe2Yey6iaoT3q0T3hk/W9slVycnHJilYBCvWuwCp6G2Ma7d5zCAfZTm 6MgvtOGsfbeETuP5d0zAjgMV67d6nWOVtdFN2LWIJsz3zhiK49KyXwby0MXplNhRod+J 8zLw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=IHAOHv9I; 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 x29-20020a63b21d000000b005348dd488fbsi123678pge.621.2023.05.19.13.07.04; Fri, 19 May 2023 13:07:42 -0700 (PDT) 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=IHAOHv9I; 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 S231400AbjEST4Q (ORCPT + 99 others); Fri, 19 May 2023 15:56:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbjEST4L (ORCPT ); Fri, 19 May 2023 15:56:11 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2095.outbound.protection.outlook.com [40.107.8.95]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A3271B7; Fri, 19 May 2023 12:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AUTJ9oAc5oY2lxSMdAghNgP9NsD96mRm/IvN4Qv2wz3HXmb63cJngdZiu3VpBas1KkY68NNqFan9fNE/4I29uF5hV5Kh69HzcMRKeR9bc4I1erVRAKeiLS8X7Zqo5Xg/fNCr03NpAD0T3umSdbonP8teG3I1iiv2zqFeH6qBErfqt8gw+qmh7QR0eCJ8XwvmByFIVv7YI0ShSzRFvkOSZUOzCLLMZgN79BEMkNEOdlho8HJzhooaGejviBLZuOAbS0UN1dCOumc6j4HKZJfAVTKBWqc9L4J9s9pv35jLPPsiLN7JSq+qTf7MKc8OO2cgriM95B2q/l9KKGuafPOEcA== 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=Pg5KLyGNcqquZBgTVZpaUWi1hgGzCWeIUtx4oZetMkA=; b=lfaO452Ye33V/jNEwWnEFXNCWbEINQ5UlFYh5BjGA5/TgcBuJ/hn1aZeMI8IGequzTeC7+PUpt4TL8dy03ZQBGNx/SVgoYL2AnHWyQtby4zMD8MIUyzN3IsBUSsAv5dMiLVG8aSnG09k6A3YV1OVVFkJwXVKzZtNlYtH7D7zLYtFGjWgDiyvaLPPWSO8opo9Cy7nvGhg1KU0+4Rk1E7IDEYQRTmcs/fCFG7a8bTQ5rc2HzFMwC7dPxFWegd4+25JcckcKrwTSSl+oTySN11E8wohMzsbY8P64F0/6szm+WumbkLa1FwybcM7f0RIEQ/4fhBsX4z181Lzi34q1OpZxw== 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=Pg5KLyGNcqquZBgTVZpaUWi1hgGzCWeIUtx4oZetMkA=; b=IHAOHv9IwXrcwmD2Wb1HspSWfFwCSVup4EyDrt33GpsbcyjILzcexFYUtZd+/EF2Avxsdvs8CNbPvN26Tdu/YNf8mHTVUCfQAYtbzBba+/BCiN/PesiwVb6z2KVo68mOeOuHu5rRvmu8vKaMT4jOvLJok5xiakPQaIdfNTs3zxU= Received: from DUZPR01CA0257.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b5::29) by AM7PR03MB6216.eurprd03.prod.outlook.com (2603:10a6:20b:137::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Fri, 19 May 2023 19:56:04 +0000 Received: from DB8EUR06FT018.eop-eur06.prod.protection.outlook.com (2603:10a6:10:4b5:cafe::87) by DUZPR01CA0257.outlook.office365.com (2603:10a6:10:4b5::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 19:56:04 +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 DB8EUR06FT018.mail.protection.outlook.com (10.233.252.132) with Microsoft SMTP Server id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 19:56:04 +0000 Received: from esd-s20.esd.local (jenkins.esd.local [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id E3B177C16CA; Fri, 19 May 2023 21:56:03 +0200 (CEST) Received: by esd-s20.esd.local (Postfix, from userid 2046) id D2E8B2E1804; Fri, 19 May 2023 21:56:03 +0200 (CEST) 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/6] can: esd_usb: Replace initializer macros used for struct can_bittiming_const Date: Fri, 19 May 2023 21:55:56 +0200 Message-Id: <20230519195600.420644-3-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519195600.420644-1-frank.jungclaus@esd.eu> References: <20230519195600.420644-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8EUR06FT018:EE_|AM7PR03MB6216:EE_ X-MS-Office365-Filtering-Correlation-Id: 9038160e-f3c4-45e1-0ef3-08db58a31414 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zl1pSjDI4qe8edalMysUkXm4elrHhQpQsOQ502W57LIm1u7Cl6//Ztl31HzZOWQ3+KMVxuqaKvFC67qTFK0LjL0wPL1IPvt8ZPbiK4zcDLrN+2LFF2+x3WlHMTE01Q2HrxegzViK9BEXP1M8mjojyw5S8p/ZDhGBcyZBz52VBIOl8hJ90nQr2wFX7cvU/h2mW+B9OuiGJUSKgiHWhCWa3aE7qQYm3/nRrA/y31SnvQf2RH2JZNxeLuQ/SPjSoMZO6wkKBSovzFt/tNJBVPTbxibkicN5+R+V1D4MejeM7rXVbVZ+1c6UGASPjT859JFZakom/O2YozfEud6VeTfSMGkv+BwDzWQ0acfxFg7E7z8CUqneXyo5WApPxymgKqd/bj4ecDMD6v1GMKGs3l3WX8YIvaoPwN92BsIdKC46Yhi/VgMokti2H0wMGZCoNahc3RMWUeysgM6iQ7onn/5ANQ0trdZHkp+wfJVVVrXl7LqtXVVUOtBcMts/CatmF164z5v9naDO6sLoKpMvLOd0GjduZmtaq5Y+DGirHr84kwnQmNw5cxfnD+0vbLoLYmrzW15l7HxqlG+VZQdV88qHvqDCl6xb1feKS+VAA2r82KOgcYYy7UhzfbUlEsy1QJVyAdhrAE+yK98mfwJSFTCeBe9Yyry8mFH5EBwl1I5BQm9y7YhiAF6gntgnZg6Si6wX 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:(13230028)(4636009)(136003)(396003)(376002)(346002)(39830400003)(451199021)(46966006)(36840700001)(42186006)(478600001)(70206006)(70586007)(966005)(4326008)(316002)(54906003)(110136005)(86362001)(36756003)(66574015)(26005)(2616005)(336012)(186003)(1076003)(47076005)(83380400001)(6266002)(8936002)(40480700001)(8676002)(2906002)(44832011)(5660300002)(82310400005)(6666004)(41300700001)(81166007)(356005)(36860700001);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 19:56:04.1735 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9038160e-f3c4-45e1-0ef3-08db58a31414 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: DB8EUR06FT018.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR03MB6216 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, T_SCC_BODY_TEXT_LINE 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?1766354440192053615?= X-GMAIL-MSGID: =?utf-8?q?1766354440192053615?= Replace the macros used to initialize the members of struct can_bittiming_const with direct values. Then also use those struct members to do the calculations in esd_usb2_set_bittiming(). Link: https://lore.kernel.org/all/CAMZ6RqLaDNy-fZ2G0+QMhUEckkXLL+ZyELVSDFmqpd++aBzZQg@mail.gmail.com/ Suggested-by: Vincent MAILHOL Signed-off-by: Frank Jungclaus --- drivers/net/can/usb/esd_usb.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c index 32354cfdf151..2eecf352ec47 100644 --- a/drivers/net/can/usb/esd_usb.c +++ b/drivers/net/can/usb/esd_usb.c @@ -60,18 +60,10 @@ MODULE_LICENSE("GPL v2"); #define ESD_USB_NO_BAUDRATE GENMASK(30, 0) /* bit rate unconfigured */ /* bit timing CAN-USB/2 */ -#define ESD_USB2_TSEG1_MIN 1 -#define ESD_USB2_TSEG1_MAX 16 #define ESD_USB2_TSEG1_SHIFT 16 -#define ESD_USB2_TSEG2_MIN 1 -#define ESD_USB2_TSEG2_MAX 8 #define ESD_USB2_TSEG2_SHIFT 20 -#define ESD_USB2_SJW_MAX 4 #define ESD_USB2_SJW_SHIFT 14 #define ESD_USBM_SJW_SHIFT 24 -#define ESD_USB2_BRP_MIN 1 -#define ESD_USB2_BRP_MAX 1024 -#define ESD_USB2_BRP_INC 1 #define ESD_USB2_3_SAMPLES BIT(23) /* esd IDADD message */ @@ -909,19 +901,20 @@ static const struct ethtool_ops esd_usb_ethtool_ops = { static const struct can_bittiming_const esd_usb2_bittiming_const = { .name = "esd_usb2", - .tseg1_min = ESD_USB2_TSEG1_MIN, - .tseg1_max = ESD_USB2_TSEG1_MAX, - .tseg2_min = ESD_USB2_TSEG2_MIN, - .tseg2_max = ESD_USB2_TSEG2_MAX, - .sjw_max = ESD_USB2_SJW_MAX, - .brp_min = ESD_USB2_BRP_MIN, - .brp_max = ESD_USB2_BRP_MAX, - .brp_inc = ESD_USB2_BRP_INC, + .tseg1_min = 1, + .tseg1_max = 16, + .tseg2_min = 1, + .tseg2_max = 8, + .sjw_max = 4, + .brp_min = 1, + .brp_max = 1024, + .brp_inc = 1, }; static int esd_usb2_set_bittiming(struct net_device *netdev) { struct esd_usb_net_priv *priv = netdev_priv(netdev); + const struct can_bittiming_const *btc = priv->can.bittiming_const; struct can_bittiming *bt = &priv->can.bittiming; union esd_usb_msg *msg; int err; @@ -932,7 +925,7 @@ static int esd_usb2_set_bittiming(struct net_device *netdev) if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) canbtr |= ESD_USB_LOM; - canbtr |= (bt->brp - 1) & (ESD_USB2_BRP_MAX - 1); + canbtr |= (bt->brp - 1) & (btc->brp_max - 1); if (le16_to_cpu(priv->usb->udev->descriptor.idProduct) == USB_CANUSBM_PRODUCT_ID) @@ -940,12 +933,12 @@ static int esd_usb2_set_bittiming(struct net_device *netdev) else sjw_shift = ESD_USB2_SJW_SHIFT; - canbtr |= ((bt->sjw - 1) & (ESD_USB2_SJW_MAX - 1)) + canbtr |= ((bt->sjw - 1) & (btc->sjw_max - 1)) << sjw_shift; canbtr |= ((bt->prop_seg + bt->phase_seg1 - 1) - & (ESD_USB2_TSEG1_MAX - 1)) + & (btc->tseg1_max - 1)) << ESD_USB2_TSEG1_SHIFT; - canbtr |= ((bt->phase_seg2 - 1) & (ESD_USB2_TSEG2_MAX - 1)) + canbtr |= ((bt->phase_seg2 - 1) & (btc->tseg2_max - 1)) << ESD_USB2_TSEG2_SHIFT; if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) canbtr |= ESD_USB2_3_SAMPLES; From patchwork Fri May 19 19:55:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 96601 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1483590vqo; Fri, 19 May 2023 12:58:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5rruflNoSG2AmjXIgPQj+BDFpu0trGqYGaQKKOwQBkQnvhKPkQQ6iCtQmdP9g2sPE8aYNP X-Received: by 2002:a17:902:e542:b0:1a6:e564:6044 with SMTP id n2-20020a170902e54200b001a6e5646044mr4555945plf.7.1684526324462; Fri, 19 May 2023 12:58:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684526324; cv=pass; d=google.com; s=arc-20160816; b=yE3c4sOZREZkpPXvEgCnp1AiFhkDfUcbLxesJosTmu6o1IprYSPEdSTFTOLxtRepPY 6/Ai2yBpOIefk1cAgY6SIfpkBNr0aSoe/zpcmpHH2CSxMHJpWCB3PifUvX92YUrX7V/F +jynIG1eLK3eVo/GGZ7Ot4WOBlFOiX6yjVeed0m0yu7Y29qIBlSsWqFLG3RLCMwni7lL RS8QV2obPKIBClx3zpaBAL7TkQ2nTdvTKGMvhcKeePbbPQ+E1TeFt5+xHvMNTYQghTrr IxhfRDXt/mWTaxXS26V0Lz8Jg4EhG+hMmHvk7dg8teAeOnv2gWw+vcj6AQs/Kaqa6V92 8LWw== 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=7j0jzpoGDg6DzhkpgltzqiDUi7NICciClzv4WOIhZyY=; b=MuySAtyVYPKfAkWIyj1SJJk5bKej9cE4KKrxXYurF4Im/zm2rEzSENQh1dFIfPvble 91oPupJM7gYL1eDxhvfxAIgJ4n9RQee026qwNvzTYFjmX7DR7suIVeeZJMVQZ9fBT+X2 lPJKVi5FbHgsYonbw/UmH4DiZSqP0IgIh5UeuOALi8+8Ce9UV39gTZXyu6aMCTv3SrkO gLMspkCuRyJ6UU7j62IscK4u5O6wcoQblJG7lVnHegKVPsUv6G+m1nRHTZC4+hgBWCwH o1Q8l97nCaUDMuBywb2yS8GTuV5f5D6JIfykgLH0lL9GPL7Mi46Sf4GWTZ/2nuP3qh4z eIVA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=D1ppQuUo; 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 y6-20020a17090322c600b001ab089f7329si59524plg.73.2023.05.19.12.58.07; Fri, 19 May 2023 12:58:44 -0700 (PDT) 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=D1ppQuUo; 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 S231673AbjEST4e (ORCPT + 99 others); Fri, 19 May 2023 15:56:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbjEST4P (ORCPT ); Fri, 19 May 2023 15:56:15 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2118.outbound.protection.outlook.com [40.107.105.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A48CCE42; Fri, 19 May 2023 12:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZmY6P4Bxj209077/fBzguKImVJ1qo+Ew95EGR8UTk9BAaRZ67XYMYWU+QJ0M99ZNfHu2drknuCliYlHxTQZ85ZwRC1fiADMkIuMbVTs4iWHqZCgrhBVGEkSA+uUe7AO+L+xLsZ9V02iN2bZFGr9tHSdmrDuRJJrOEalgXiF21clDjBPKvSYN1V1jrl82BVdqPwkGCCOAf4FlYJQCCvarBcuRoC4g3APmFw3zWjoh4iduupQKDnFvqMM/DpHm+2aeq/8XQRnv8Wklzmgti0COWL1aIp0YCuhzzXrmDTw6uOLOagiQXdgEJ0ZkRPlHxD3bR3NnlUN8m350ldLlgWGi3Q== 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=7j0jzpoGDg6DzhkpgltzqiDUi7NICciClzv4WOIhZyY=; b=jUH/jOaa932CtuJRsZlMzvRERBiwOHyoo5oBW9vkffYhTXp6yv8Fe5MUzex3IzxKxtQCnS+jwGMDm2WTxR4UHrGi0cc/3d+DOLMYitrCZbte3bA9lHyukDbR4gGhFOpu0phx2Nu3zjkKpIeJj18vw6pQh/fGUjs9KNSbkR6R2IFzVu+cmc5/5Pbu/ycpWqBPIxbyjUY6qmOYgiGewecevLzneGOvOnwlKchhEkWDkLzLgaA/VYyciwibdmNaodA1h6ZdMuzFqM7SmD4KGXIDUOe+uA+Ka0tS7KOHcAzTQHfz1Od3cqGrP3gJZbfNLUC6hkn5Xs0qnO9RVCTG02vBvg== 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=7j0jzpoGDg6DzhkpgltzqiDUi7NICciClzv4WOIhZyY=; b=D1ppQuUowdD7D0zD7i8kJnraX4uumOPHvgLPA4gjMSyMubwB5Pk/WkcyhQIp7rLQGiBCs2tRNXqhvsh1mPSAkc3ft1Z9mHdjf4Mu1Q1caT66HXaBBxTqmYJ20Vrs1LG+76U/5z9CXw2MNlHJByu8xIMkaFtkJ1MYhNlcGJ9AG38= Received: from FR0P281CA0200.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ad::11) by PA4PR03MB8136.eurprd03.prod.outlook.com (2603:10a6:102:2a3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 19:56:04 +0000 Received: from VI1EUR06FT053.eop-eur06.prod.protection.outlook.com (2603:10a6:d10:ad:cafe::e9) by FR0P281CA0200.outlook.office365.com (2603:10a6:d10:ad::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.6 via Frontend Transport; Fri, 19 May 2023 19:56:04 +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 VI1EUR06FT053.mail.protection.outlook.com (10.13.6.63) with Microsoft SMTP Server id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 19:56:04 +0000 Received: from esd-s20.esd.local (jenkins.esd [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id E5D1E7C16CC; Fri, 19 May 2023 21:56:03 +0200 (CEST) Received: by esd-s20.esd.local (Postfix, from userid 2046) id D716B2E1805; Fri, 19 May 2023 21:56:03 +0200 (CEST) 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/6] can: esd_usb: Use consistent prefixes for macros Date: Fri, 19 May 2023 21:55:57 +0200 Message-Id: <20230519195600.420644-4-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519195600.420644-1-frank.jungclaus@esd.eu> References: <20230519195600.420644-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1EUR06FT053:EE_|PA4PR03MB8136:EE_ X-MS-Office365-Filtering-Correlation-Id: 9721e9ac-03b5-490e-fb97-08db58a3140c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: scL/7wo6LOVf3akcl1zy4HXVdhWeqQsIVvmCR0F36YpnOXY/YBxKRD9uWEpDDuos9DUE+xFvlDzRvl61CSloU4am6m3sLI7QpexnqY0iJys+eqiPFnTFmedgAkWXQ13F+jrkOdckbaEf830o2AsLzLugHOHickKiTE1GZQMX3a3nJ6RrQ+8ckdpg8bge/moIr1JC9UeNsieNk3ZI0SF8DEH7/608hrZ14uy+1/dAUsQZ8Kt+mxzpT5G1RIZfFnmQlhH4zi/VJ5QoCptPImhpiVbhY86q7s7UTFaUi1pYfDoDuIZTIxE1ArIdFiABBJD6ujpxteqtBCRb2WY9CtQZSda/PjUoOnlSFPbv52s0pA4EG6zGievRPv2SlYX36vIDgFTUMGBxtOspBz4xebdF4gtjkd5e0poOu55Zhf5LbQu6TYt2WpGWoCxypoJawzUn14TRnkR5sV4aNOodqZzUksiMrrcRnQC9p7qF/I6/UC6g8Rgz4STShcTCSPdF6XP2FYs3GEhUSIiecwMciHTlf2jrM2MmK0S3OeDoxw+LB9JSYSvo2FqG+vcZwbYr2+Rkgq947yjbUiaSs8CnHnK/UwFuFEtTCDlP3Ik3JP/sT8LySPFMIurgp1jZqBue/LUW6mwi3mcQA4sl7rVq6NI8MqZ09CTHzU2JEp3Uc02CrZh7wIlFBGBTXX/ueotFlOnY 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:(13230028)(4636009)(376002)(39840400004)(346002)(396003)(136003)(451199021)(36840700001)(46966006)(36860700001)(36756003)(81166007)(356005)(44832011)(5660300002)(8676002)(8936002)(82310400005)(41300700001)(40480700001)(86362001)(4326008)(316002)(70206006)(70586007)(966005)(47076005)(66574015)(336012)(1076003)(26005)(110136005)(30864003)(186003)(2906002)(6666004)(478600001)(6266002)(2616005)(83380400001)(54906003)(42186006);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 19:56:04.1428 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9721e9ac-03b5-490e-fb97-08db58a3140c 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: VI1EUR06FT053.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR03MB8136 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, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1766353875013346321?= X-GMAIL-MSGID: =?utf-8?q?1766353875013346321?= Add the consistent prefix ESD_USB_ to all macros defined within esd_usb.c. For macros specific to esd CAN-USB/2 use ESD_USB_2_ as prefix. For macros specific to esd CAN-USB/Micro use ESD_USB_M_ as prefix. Change the macro ESD_USB_3_SAMPLES to ESD_USB_TRIPLE_SAMPLES to not mix up with the prefix ESD_USB_3_ which will be introduced for the CAN-USB/3 device. Link: https://lore.kernel.org/all/CAMZ6RqLaDNy-fZ2G0+QMhUEckkXLL+ZyELVSDFmqpd++aBzZQg@mail.gmail.com/ Suggested-by: Vincent MAILHOL Signed-off-by: Frank Jungclaus --- drivers/net/can/usb/esd_usb.c | 198 +++++++++++++++++----------------- 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c index 2eecf352ec47..9b0ed07911e1 100644 --- a/drivers/net/can/usb/esd_usb.c +++ b/drivers/net/can/usb/esd_usb.c @@ -23,33 +23,33 @@ MODULE_DESCRIPTION("CAN driver for esd electronics gmbh CAN-USB/2 and CAN-USB/Mi MODULE_LICENSE("GPL v2"); /* USB vendor and product ID */ -#define USB_ESDGMBH_VENDOR_ID 0x0ab4 -#define USB_CANUSB2_PRODUCT_ID 0x0010 -#define USB_CANUSBM_PRODUCT_ID 0x0011 +#define ESD_USB_ESDGMBH_VENDOR_ID 0x0ab4 +#define ESD_USB_CANUSB2_PRODUCT_ID 0x0010 +#define ESD_USB_CANUSBM_PRODUCT_ID 0x0011 /* CAN controller clock frequencies */ -#define ESD_USB2_CAN_CLOCK (60 * MEGA) /* Hz */ -#define ESD_USBM_CAN_CLOCK (36 * MEGA) /* Hz */ +#define ESD_USB_2_CAN_CLOCK (60 * MEGA) /* Hz */ +#define ESD_USB_M_CAN_CLOCK (36 * MEGA) /* Hz */ /* Maximum number of CAN nets */ #define ESD_USB_MAX_NETS 2 /* USB commands */ -#define CMD_VERSION 1 /* also used for VERSION_REPLY */ -#define CMD_CAN_RX 2 /* device to host only */ -#define CMD_CAN_TX 3 /* also used for TX_DONE */ -#define CMD_SETBAUD 4 /* also used for SETBAUD_REPLY */ -#define CMD_TS 5 /* also used for TS_REPLY */ -#define CMD_IDADD 6 /* also used for IDADD_REPLY */ +#define ESD_USB_CMD_VERSION 1 /* also used for VERSION_REPLY */ +#define ESD_USB_CMD_CAN_RX 2 /* device to host only */ +#define ESD_USB_CMD_CAN_TX 3 /* also used for TX_DONE */ +#define ESD_USB_CMD_SETBAUD 4 /* also used for SETBAUD_REPLY */ +#define ESD_USB_CMD_TS 5 /* also used for TS_REPLY */ +#define ESD_USB_CMD_IDADD 6 /* also used for IDADD_REPLY */ /* esd CAN message flags - dlc field */ #define ESD_RTR BIT(4) /* esd CAN message flags - id field */ -#define ESD_EXTID BIT(29) -#define ESD_EVENT BIT(30) -#define ESD_IDMASK GENMASK(28, 0) +#define ESD_USB_EXTID BIT(29) +#define ESD_USB_EVENT BIT(30) +#define ESD_USB_IDMASK GENMASK(28, 0) /* esd CAN event ids */ #define ESD_EV_CAN_ERROR_EXT 2 /* CAN controller specific diagnostic data */ @@ -59,35 +59,35 @@ MODULE_LICENSE("GPL v2"); #define ESD_USB_UBR BIT(31) /* 0x80000000, User Bit Rate (controller BTR) in bits 0..27 */ #define ESD_USB_NO_BAUDRATE GENMASK(30, 0) /* bit rate unconfigured */ -/* bit timing CAN-USB/2 */ -#define ESD_USB2_TSEG1_SHIFT 16 -#define ESD_USB2_TSEG2_SHIFT 20 -#define ESD_USB2_SJW_SHIFT 14 -#define ESD_USBM_SJW_SHIFT 24 -#define ESD_USB2_3_SAMPLES BIT(23) +/* bit timing esd CAN-USB */ +#define ESD_USB_2_TSEG1_SHIFT 16 +#define ESD_USB_2_TSEG2_SHIFT 20 +#define ESD_USB_2_SJW_SHIFT 14 +#define ESD_USB_M_SJW_SHIFT 24 +#define ESD_USB_TRIPLE_SAMPLES BIT(23) /* esd IDADD message */ -#define ESD_ID_ENABLE 0x80 -#define ESD_MAX_ID_SEGMENT 64 +#define ESD_USB_ID_ENABLE 0x80 +#define ESD_USB_MAX_ID_SEGMENT 64 /* SJA1000 ECC register (emulated by usb firmware) */ -#define SJA1000_ECC_SEG 0x1F -#define SJA1000_ECC_DIR 0x20 -#define SJA1000_ECC_ERR 0x06 -#define SJA1000_ECC_BIT 0x00 -#define SJA1000_ECC_FORM 0x40 -#define SJA1000_ECC_STUFF 0x80 -#define SJA1000_ECC_MASK 0xc0 +#define ESD_USB_SJA1000_ECC_SEG 0x1F +#define ESD_USB_SJA1000_ECC_DIR 0x20 +#define ESD_USB_SJA1000_ECC_ERR 0x06 +#define ESD_USB_SJA1000_ECC_BIT 0x00 +#define ESD_USB_SJA1000_ECC_FORM 0x40 +#define ESD_USB_SJA1000_ECC_STUFF 0x80 +#define ESD_USB_SJA1000_ECC_MASK 0xc0 /* esd bus state event codes */ -#define ESD_BUSSTATE_MASK 0xc0 -#define ESD_BUSSTATE_WARN 0x40 -#define ESD_BUSSTATE_ERRPASSIVE 0x80 -#define ESD_BUSSTATE_BUSOFF 0xc0 +#define ESD_USB_BUSSTATE_MASK 0xc0 +#define ESD_USB_BUSSTATE_WARN 0x40 +#define ESD_USB_BUSSTATE_ERRPASSIVE 0x80 +#define ESD_USB_BUSSTATE_BUSOFF 0xc0 -#define RX_BUFFER_SIZE 1024 -#define MAX_RX_URBS 4 -#define MAX_TX_URBS 16 /* must be power of 2 */ +#define ESD_USB_RX_BUFFER_SIZE 1024 +#define ESD_USB_MAX_RX_URBS 4 +#define ESD_USB_MAX_TX_URBS 16 /* must be power of 2 */ struct header_msg { u8 len; /* len is always the total message length in 32bit words */ @@ -156,7 +156,7 @@ struct id_filter_msg { u8 cmd; u8 net; u8 option; - __le32 mask[ESD_MAX_ID_SEGMENT + 1]; + __le32 mask[ESD_USB_MAX_ID_SEGMENT + 1]; }; struct set_baudrate_msg { @@ -180,8 +180,8 @@ union __packed esd_usb_msg { }; static struct usb_device_id esd_usb_table[] = { - {USB_DEVICE(USB_ESDGMBH_VENDOR_ID, USB_CANUSB2_PRODUCT_ID)}, - {USB_DEVICE(USB_ESDGMBH_VENDOR_ID, USB_CANUSBM_PRODUCT_ID)}, + {USB_DEVICE(ESD_USB_ESDGMBH_VENDOR_ID, ESD_USB_CANUSB2_PRODUCT_ID)}, + {USB_DEVICE(ESD_USB_ESDGMBH_VENDOR_ID, ESD_USB_CANUSBM_PRODUCT_ID)}, {} }; MODULE_DEVICE_TABLE(usb, esd_usb_table); @@ -202,8 +202,8 @@ struct esd_usb { int net_count; u32 version; int rxinitdone; - void *rxbuf[MAX_RX_URBS]; - dma_addr_t rxbuf_dma[MAX_RX_URBS]; + void *rxbuf[ESD_USB_MAX_RX_URBS]; + dma_addr_t rxbuf_dma[ESD_USB_MAX_RX_URBS]; }; struct esd_usb_net_priv { @@ -211,7 +211,7 @@ struct esd_usb_net_priv { atomic_t active_tx_jobs; struct usb_anchor tx_submitted; - struct esd_tx_urb_context tx_contexts[MAX_TX_URBS]; + struct esd_tx_urb_context tx_contexts[ESD_USB_MAX_TX_URBS]; struct esd_usb *usb; struct net_device *netdev; @@ -226,7 +226,7 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv, struct net_device_stats *stats = &priv->netdev->stats; struct can_frame *cf; struct sk_buff *skb; - u32 id = le32_to_cpu(msg->rx.id) & ESD_IDMASK; + u32 id = le32_to_cpu(msg->rx.id) & ESD_USB_IDMASK; if (id == ESD_EV_CAN_ERROR_EXT) { u8 state = msg->rx.ev_can_err_ext.status; @@ -255,15 +255,15 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv, priv->old_state = state; - switch (state & ESD_BUSSTATE_MASK) { - case ESD_BUSSTATE_BUSOFF: + switch (state & ESD_USB_BUSSTATE_MASK) { + case ESD_USB_BUSSTATE_BUSOFF: new_state = CAN_STATE_BUS_OFF; can_bus_off(priv->netdev); break; - case ESD_BUSSTATE_WARN: + case ESD_USB_BUSSTATE_WARN: new_state = CAN_STATE_ERROR_WARNING; break; - case ESD_BUSSTATE_ERRPASSIVE: + case ESD_USB_BUSSTATE_ERRPASSIVE: new_state = CAN_STATE_ERROR_PASSIVE; break; default: @@ -285,14 +285,14 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv, cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; - switch (ecc & SJA1000_ECC_MASK) { - case SJA1000_ECC_BIT: + switch (ecc & ESD_USB_SJA1000_ECC_MASK) { + case ESD_USB_SJA1000_ECC_BIT: cf->data[2] |= CAN_ERR_PROT_BIT; break; - case SJA1000_ECC_FORM: + case ESD_USB_SJA1000_ECC_FORM: cf->data[2] |= CAN_ERR_PROT_FORM; break; - case SJA1000_ECC_STUFF: + case ESD_USB_SJA1000_ECC_STUFF: cf->data[2] |= CAN_ERR_PROT_STUFF; break; default: @@ -300,11 +300,11 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv, } /* Error occurred during transmission? */ - if (!(ecc & SJA1000_ECC_DIR)) + if (!(ecc & ESD_USB_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; + cf->data[3] = ecc & ESD_USB_SJA1000_ECC_SEG; } if (skb) { @@ -331,7 +331,7 @@ static void esd_usb_rx_can_msg(struct esd_usb_net_priv *priv, id = le32_to_cpu(msg->rx.id); - if (id & ESD_EVENT) { + if (id & ESD_USB_EVENT) { esd_usb_rx_event(priv, msg); } else { skb = alloc_can_skb(priv->netdev, &cf); @@ -340,11 +340,11 @@ static void esd_usb_rx_can_msg(struct esd_usb_net_priv *priv, return; } - cf->can_id = id & ESD_IDMASK; + cf->can_id = id & ESD_USB_IDMASK; can_frame_set_cc_len(cf, msg->rx.dlc & ~ESD_RTR, priv->can.ctrlmode); - if (id & ESD_EXTID) + if (id & ESD_USB_EXTID) cf->can_id |= CAN_EFF_FLAG; if (msg->rx.dlc & ESD_RTR) { @@ -371,7 +371,7 @@ static void esd_usb_tx_done_msg(struct esd_usb_net_priv *priv, if (!netif_device_present(netdev)) return; - context = &priv->tx_contexts[msg->txdone.hnd & (MAX_TX_URBS - 1)]; + context = &priv->tx_contexts[msg->txdone.hnd & (ESD_USB_MAX_TX_URBS - 1)]; if (!msg->txdone.status) { stats->tx_packets++; @@ -383,7 +383,7 @@ static void esd_usb_tx_done_msg(struct esd_usb_net_priv *priv, } /* Release context */ - context->echo_index = MAX_TX_URBS; + context->echo_index = ESD_USB_MAX_TX_URBS; atomic_dec(&priv->active_tx_jobs); netif_wake_queue(netdev); @@ -418,7 +418,7 @@ static void esd_usb_read_bulk_callback(struct urb *urb) msg = (union esd_usb_msg *)(urb->transfer_buffer + pos); switch (msg->hdr.cmd) { - case CMD_CAN_RX: + case ESD_USB_CMD_CAN_RX: if (msg->rx.net >= dev->net_count) { dev_err(dev->udev->dev.parent, "format error\n"); break; @@ -427,7 +427,7 @@ static void esd_usb_read_bulk_callback(struct urb *urb) esd_usb_rx_can_msg(dev->nets[msg->rx.net], msg); break; - case CMD_CAN_TX: + case ESD_USB_CMD_CAN_TX: if (msg->txdone.net >= dev->net_count) { dev_err(dev->udev->dev.parent, "format error\n"); break; @@ -448,7 +448,7 @@ static void esd_usb_read_bulk_callback(struct urb *urb) resubmit_urb: usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1), - urb->transfer_buffer, RX_BUFFER_SIZE, + urb->transfer_buffer, ESD_USB_RX_BUFFER_SIZE, esd_usb_read_bulk_callback, dev); retval = usb_submit_urb(urb, GFP_ATOMIC); @@ -557,7 +557,7 @@ static int esd_usb_setup_rx_urbs(struct esd_usb *dev) if (dev->rxinitdone) return 0; - for (i = 0; i < MAX_RX_URBS; i++) { + for (i = 0; i < ESD_USB_MAX_RX_URBS; i++) { struct urb *urb = NULL; u8 *buf = NULL; dma_addr_t buf_dma; @@ -569,7 +569,7 @@ static int esd_usb_setup_rx_urbs(struct esd_usb *dev) break; } - buf = usb_alloc_coherent(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL, + buf = usb_alloc_coherent(dev->udev, ESD_USB_RX_BUFFER_SIZE, GFP_KERNEL, &buf_dma); if (!buf) { dev_warn(dev->udev->dev.parent, @@ -582,7 +582,7 @@ static int esd_usb_setup_rx_urbs(struct esd_usb *dev) usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1), - buf, RX_BUFFER_SIZE, + buf, ESD_USB_RX_BUFFER_SIZE, esd_usb_read_bulk_callback, dev); urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; usb_anchor_urb(urb, &dev->rx_submitted); @@ -590,7 +590,7 @@ static int esd_usb_setup_rx_urbs(struct esd_usb *dev) err = usb_submit_urb(urb, GFP_KERNEL); if (err) { usb_unanchor_urb(urb); - usb_free_coherent(dev->udev, RX_BUFFER_SIZE, buf, + usb_free_coherent(dev->udev, ESD_USB_RX_BUFFER_SIZE, buf, urb->transfer_dma); goto freeurb; } @@ -612,7 +612,7 @@ static int esd_usb_setup_rx_urbs(struct esd_usb *dev) } /* Warn if we've couldn't transmit all the URBs */ - if (i < MAX_RX_URBS) { + if (i < ESD_USB_MAX_RX_URBS) { dev_warn(dev->udev->dev.parent, "rx performance may be slow\n"); } @@ -647,14 +647,14 @@ static int esd_usb_start(struct esd_usb_net_priv *priv) * the number of the starting bitmask (0..64) to the filter.option * field followed by only some bitmasks. */ - msg->hdr.cmd = CMD_IDADD; - msg->hdr.len = 2 + ESD_MAX_ID_SEGMENT; + msg->hdr.cmd = ESD_USB_CMD_IDADD; + msg->hdr.len = 2 + ESD_USB_MAX_ID_SEGMENT; msg->filter.net = priv->index; - msg->filter.option = ESD_ID_ENABLE; /* start with segment 0 */ - for (i = 0; i < ESD_MAX_ID_SEGMENT; i++) + msg->filter.option = ESD_USB_ID_ENABLE; /* start with segment 0 */ + for (i = 0; i < ESD_USB_MAX_ID_SEGMENT; i++) msg->filter.mask[i] = cpu_to_le32(0xffffffff); /* enable 29bit extended IDs */ - msg->filter.mask[ESD_MAX_ID_SEGMENT] = cpu_to_le32(0x00000001); + msg->filter.mask[ESD_USB_MAX_ID_SEGMENT] = cpu_to_le32(0x00000001); err = esd_usb_send_msg(dev, msg); if (err) @@ -683,8 +683,8 @@ static void unlink_all_urbs(struct esd_usb *dev) usb_kill_anchored_urbs(&dev->rx_submitted); - for (i = 0; i < MAX_RX_URBS; ++i) - usb_free_coherent(dev->udev, RX_BUFFER_SIZE, + for (i = 0; i < ESD_USB_MAX_RX_URBS; ++i) + usb_free_coherent(dev->udev, ESD_USB_RX_BUFFER_SIZE, dev->rxbuf[i], dev->rxbuf_dma[i]); for (i = 0; i < dev->net_count; i++) { @@ -693,8 +693,8 @@ static void unlink_all_urbs(struct esd_usb *dev) usb_kill_anchored_urbs(&priv->tx_submitted); atomic_set(&priv->active_tx_jobs, 0); - for (j = 0; j < MAX_TX_URBS; j++) - priv->tx_contexts[j].echo_index = MAX_TX_URBS; + for (j = 0; j < ESD_USB_MAX_TX_URBS; j++) + priv->tx_contexts[j].echo_index = ESD_USB_MAX_TX_URBS; } } } @@ -760,7 +760,7 @@ static netdev_tx_t esd_usb_start_xmit(struct sk_buff *skb, msg = (union esd_usb_msg *)buf; msg->hdr.len = 3; /* minimal length */ - msg->hdr.cmd = CMD_CAN_TX; + msg->hdr.cmd = ESD_USB_CMD_CAN_TX; msg->tx.net = priv->index; msg->tx.dlc = can_get_cc_dlc(cf, priv->can.ctrlmode); msg->tx.id = cpu_to_le32(cf->can_id & CAN_ERR_MASK); @@ -769,15 +769,15 @@ static netdev_tx_t esd_usb_start_xmit(struct sk_buff *skb, msg->tx.dlc |= ESD_RTR; if (cf->can_id & CAN_EFF_FLAG) - msg->tx.id |= cpu_to_le32(ESD_EXTID); + msg->tx.id |= cpu_to_le32(ESD_USB_EXTID); for (i = 0; i < cf->len; i++) msg->tx.data[i] = cf->data[i]; msg->hdr.len += (cf->len + 3) >> 2; - for (i = 0; i < MAX_TX_URBS; i++) { - if (priv->tx_contexts[i].echo_index == MAX_TX_URBS) { + for (i = 0; i < ESD_USB_MAX_TX_URBS; i++) { + if (priv->tx_contexts[i].echo_index == ESD_USB_MAX_TX_URBS) { context = &priv->tx_contexts[i]; break; } @@ -809,7 +809,7 @@ static netdev_tx_t esd_usb_start_xmit(struct sk_buff *skb, atomic_inc(&priv->active_tx_jobs); /* Slow down tx path */ - if (atomic_read(&priv->active_tx_jobs) >= MAX_TX_URBS) + if (atomic_read(&priv->active_tx_jobs) >= ESD_USB_MAX_TX_URBS) netif_stop_queue(netdev); err = usb_submit_urb(urb, GFP_ATOMIC); @@ -859,18 +859,18 @@ static int esd_usb_close(struct net_device *netdev) return -ENOMEM; /* Disable all IDs (see esd_usb_start()) */ - msg->hdr.cmd = CMD_IDADD; - msg->hdr.len = 2 + ESD_MAX_ID_SEGMENT; + msg->hdr.cmd = ESD_USB_CMD_IDADD; + msg->hdr.len = 2 + ESD_USB_MAX_ID_SEGMENT; msg->filter.net = priv->index; - msg->filter.option = ESD_ID_ENABLE; /* start with segment 0 */ - for (i = 0; i <= ESD_MAX_ID_SEGMENT; i++) + msg->filter.option = ESD_USB_ID_ENABLE; /* start with segment 0 */ + for (i = 0; i <= ESD_USB_MAX_ID_SEGMENT; i++) msg->filter.mask[i] = 0; if (esd_usb_send_msg(priv->usb, msg) < 0) netdev_err(netdev, "sending idadd message failed\n"); /* set CAN controller to reset mode */ msg->hdr.len = 2; - msg->hdr.cmd = CMD_SETBAUD; + msg->hdr.cmd = ESD_USB_CMD_SETBAUD; msg->setbaud.net = priv->index; msg->setbaud.rsvd = 0; msg->setbaud.baud = cpu_to_le32(ESD_USB_NO_BAUDRATE); @@ -928,27 +928,27 @@ static int esd_usb2_set_bittiming(struct net_device *netdev) canbtr |= (bt->brp - 1) & (btc->brp_max - 1); if (le16_to_cpu(priv->usb->udev->descriptor.idProduct) == - USB_CANUSBM_PRODUCT_ID) - sjw_shift = ESD_USBM_SJW_SHIFT; + ESD_USB_CANUSBM_PRODUCT_ID) + sjw_shift = ESD_USB_M_SJW_SHIFT; else - sjw_shift = ESD_USB2_SJW_SHIFT; + sjw_shift = ESD_USB_2_SJW_SHIFT; canbtr |= ((bt->sjw - 1) & (btc->sjw_max - 1)) << sjw_shift; canbtr |= ((bt->prop_seg + bt->phase_seg1 - 1) & (btc->tseg1_max - 1)) - << ESD_USB2_TSEG1_SHIFT; + << ESD_USB_2_TSEG1_SHIFT; canbtr |= ((bt->phase_seg2 - 1) & (btc->tseg2_max - 1)) - << ESD_USB2_TSEG2_SHIFT; + << ESD_USB_2_TSEG2_SHIFT; if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) - canbtr |= ESD_USB2_3_SAMPLES; + canbtr |= ESD_USB_TRIPLE_SAMPLES; msg = kmalloc(sizeof(*msg), GFP_KERNEL); if (!msg) return -ENOMEM; msg->hdr.len = 2; - msg->hdr.cmd = CMD_SETBAUD; + msg->hdr.cmd = ESD_USB_CMD_SETBAUD; msg->setbaud.net = priv->index; msg->setbaud.rsvd = 0; msg->setbaud.baud = cpu_to_le32(canbtr); @@ -994,7 +994,7 @@ static int esd_usb_probe_one_net(struct usb_interface *intf, int index) int err = 0; int i; - netdev = alloc_candev(sizeof(*priv), MAX_TX_URBS); + netdev = alloc_candev(sizeof(*priv), ESD_USB_MAX_TX_URBS); if (!netdev) { dev_err(&intf->dev, "couldn't alloc candev\n"); err = -ENOMEM; @@ -1006,8 +1006,8 @@ static int esd_usb_probe_one_net(struct usb_interface *intf, int index) init_usb_anchor(&priv->tx_submitted); atomic_set(&priv->active_tx_jobs, 0); - for (i = 0; i < MAX_TX_URBS; i++) - priv->tx_contexts[i].echo_index = MAX_TX_URBS; + for (i = 0; i < ESD_USB_MAX_TX_URBS; i++) + priv->tx_contexts[i].echo_index = ESD_USB_MAX_TX_URBS; priv->usb = dev; priv->netdev = netdev; @@ -1019,10 +1019,10 @@ static int esd_usb_probe_one_net(struct usb_interface *intf, int index) CAN_CTRLMODE_BERR_REPORTING; if (le16_to_cpu(dev->udev->descriptor.idProduct) == - USB_CANUSBM_PRODUCT_ID) - priv->can.clock.freq = ESD_USBM_CAN_CLOCK; + ESD_USB_CANUSBM_PRODUCT_ID) + priv->can.clock.freq = ESD_USB_M_CAN_CLOCK; else { - priv->can.clock.freq = ESD_USB2_CAN_CLOCK; + priv->can.clock.freq = ESD_USB_2_CAN_CLOCK; priv->can.ctrlmode_supported |= CAN_CTRLMODE_3_SAMPLES; } @@ -1085,7 +1085,7 @@ static int esd_usb_probe(struct usb_interface *intf, } /* query number of CAN interfaces (nets) */ - msg->hdr.cmd = CMD_VERSION; + msg->hdr.cmd = ESD_USB_CMD_VERSION; msg->hdr.len = 2; msg->version.rsvd = 0; msg->version.flags = 0; From patchwork Fri May 19 19:55:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 96599 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1483064vqo; Fri, 19 May 2023 12:57:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6EpOr2u8Wmcvugc4aeQjNBFanlu23RpPr4Z2yRccizNpDJ5dPxxumaxPkVW8R46gUSdA/+ X-Received: by 2002:a05:6a20:1442:b0:105:9ca9:56aa with SMTP id a2-20020a056a20144200b001059ca956aamr3601741pzi.0.1684526257511; Fri, 19 May 2023 12:57:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684526257; cv=pass; d=google.com; s=arc-20160816; b=PsTe7z685+pCwoCak330PaLrDQxm8UZ8JlwYwkYBX94RI5Wta9NWeYbMbV0rFM2rjQ Ad/sBuZLUg++wS8eKgrWxajWzQs18tfpbBU4WrDrxYz0GQ55AHtofeLdRv+ZORlciOkx FH6gRqiM1p2AbJedO4MGGRsDyWsDX/tf7eRPadGZj6UiknO5KRUiex98KVxbmrXOXvzL xX2UDd3vGScEHMMQga5OLMOLXme+x9I+jLTdhkZw8qXG/CBjKHyJ1sp69+QwEMzLU7VT fkZu61NilQ/+rqkmP2oxePUdQOjjnTXn2qCVUPdJk8CEIHG/x6OAL4RCZ+BNp/dr5/1M q6zg== 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=yWPaKPvPmfPPuYmV9azX+/2AGvu/iMDViKWdkbJgO+8=; b=l0ALTPAzmvl622NxFQFtNnjEUXoDTm8z0671Ms4o6KTMANw4CGTK4Eb5czlpgomlml sGlsKPEje2hbArBVYh8rT/ryIg93VwEVjFugQbrnR/dgdRdzszHODskYk9rbswQo9KxR +WC/pXbICJ7RlILA8TlXTQLx62lP9GtqaQowGpiILx5OTKi3AKk34fUteJ18ZQNMrnwY a8SZXdkbSV4ArF1hHbngEA2V0eqTR3a/jGP5s9uIye8Cjg/IDwcVMpNFa4qPH0nE9koE /0paaJewpF4imDv9wQc++0CtmWhDKiRTnIV0LpAfJZQkSmnOftlpaoA3AAZOkf6albGm RlEQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=f7xR8R5g; 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 w65-20020a17090a6bc700b0025330a420ffsi16105pjj.186.2023.05.19.12.57.25; Fri, 19 May 2023 12:57:37 -0700 (PDT) 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=f7xR8R5g; 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 S231396AbjEST4U (ORCPT + 99 others); Fri, 19 May 2023 15:56:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbjEST4L (ORCPT ); Fri, 19 May 2023 15:56:11 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2117.outbound.protection.outlook.com [40.107.20.117]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DEBF1BC; Fri, 19 May 2023 12:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HUVpHJua0Z7fsZMfpfBnoncnSX+gxhb+mmCww+rUxr3I5hRH4TbHWH36gPpgb9Cxob2/fzoam95jK5QB4EypsxhoBrzz0/Ko6mEGIgYEIn/qPnju+HFWWWlKwZMP2Wa/4pUkaLfxJZH59Q+b13m/+ObnckfXRvyWaYv6LUna8WsHDispsb7fxtjfUUzmRm7PhJCd0CgSEUnu5nNX0NA/DOi8tzm2SaH4bczZsrlLY+3+OGV730geg5INodQEBYHb6EQy8hletJwbmSexbTUAFE0q/UZXMawOaZgzR489ORUlIWDQVel/Qy9GvSFZzInzo50EqB2JdLJjRpsj/D0fNg== 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=yWPaKPvPmfPPuYmV9azX+/2AGvu/iMDViKWdkbJgO+8=; b=TFMmBAMwyclIjBce/D4Q1+aws77yahpuWVuli8Rq43LKd7C1w+YVu/NHNaiGW6d+l8K7K7gY5z8mYCufA6KQbuxjVlFwpd1fh9fX8WTePbm414zkE9mx/LLKFCcWVI3CmhUkgMXRQgD3B/mCe3a++EpmrLSdlJsgyJsRQjqc5hzAka55v9l/uZPE/jkhqA6/gdTL5NFGHKX1gSmSMd29AfjtrjsCeXJwFB0HzrpZjUWLywvEnrIElz0+fXSk7bCPldVjsilNkwfn/dlhCMGb6kMEWDhI/r1l7+Bblb348wDtQwh2E6yMaLUax75RlbrQ3SR9c+pne9PvZWXr8UIwYQ== 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=yWPaKPvPmfPPuYmV9azX+/2AGvu/iMDViKWdkbJgO+8=; b=f7xR8R5gLrA4pRyb2s8+cUUBxvBswWvNOroP7pwXTpgJut14Gv0qkwffjhmkapogI6FkFPtsBQbX6yDS9F1FBSMKxIYrMiiaCIN9nXP23SCcxv8X436F0j+y4uPYBzvYnSzXoDiZnzMFi1QtTdEOLm9zLFlhf0GimXn0+rwnrqo= Received: from FR3P281CA0198.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a5::20) by DBBPR03MB6988.eurprd03.prod.outlook.com (2603:10a6:10:1f5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 19:56:05 +0000 Received: from VI1EUR06FT018.eop-eur06.prod.protection.outlook.com (2603:10a6:d10:a5:cafe::b6) by FR3P281CA0198.outlook.office365.com (2603:10a6:d10:a5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.14 via Frontend Transport; Fri, 19 May 2023 19:56:05 +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 VI1EUR06FT018.mail.protection.outlook.com (10.13.6.215) with Microsoft SMTP Server id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 19:56:04 +0000 Received: from esd-s20.esd.local (debby [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id E4CE97C16CB; Fri, 19 May 2023 21:56:03 +0200 (CEST) Received: by esd-s20.esd.local (Postfix, from userid 2046) id DAEC52E1806; Fri, 19 May 2023 21:56:03 +0200 (CEST) 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 4/6] can: esd_usb: Prefix all structures with the device name Date: Fri, 19 May 2023 21:55:58 +0200 Message-Id: <20230519195600.420644-5-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519195600.420644-1-frank.jungclaus@esd.eu> References: <20230519195600.420644-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1EUR06FT018:EE_|DBBPR03MB6988:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f0f8acf-6dbf-4e33-627d-08db58a3143f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nZfsljIpssm+1i0kBvS8FYtMh9dBxHap9CWeD+6AyCtQOEPqts2bQFvD1fKGtTxBWZ/ib0zQC8mI94wBicpj70iiJMKvvjEWLIEURbRF07tPJ2wPL+dei/yanLQgFajedbxJHVsznCBTGBPzAT5juI/suPES8bqXVvi6CWVXfSep92lT/4AE+lqgTbB88rz8uZY5MZCUurnuRkMefx6kRaKAyKaFB9AqsdpobAglnVfJb3Xs5SWCZyxYKdhGQXyf+Q3+KO6WWEdTbV21UIw5aee8uHRPE6VtZjmOaEVLNm11Fwip8AqcgZdFBuiiOnLPzp3RniiRBV2wGeq0MchnhilcrWeeNaaGSXKwi8J+rW8iWK6QGluIk/uBOTzNKPg9arwgCoEBKUXgskx0Z1LoFjtk40rV3dR5JSgTHb3QxXkk2qcq3HbozgTczfPwQZTXhO3MaNnEkXIO3JTkZ4PtKUdjaMbcccwk9R8IhN3j7p+YCG2lVBdztcFPeUFYcob2WxR3HBlvYoYLmARs5BlW55AyXJIiTspPwtGXLUh3GS0UVweoELe2ZaPDFhB3Te2yANTfKq6WoLavXxoCtk1666F3Uc4aleakPc/iNVf79xOs2dv8qYhB0VfcObOjHLkYIFe1sgz20QheplcPC3xu+tAWkIwJ6YzD7gxDOdpJEj4DKjVWakvw6T3SvWDoowgZ25G4Zt4ew1vCbj7JxhpSG12MQGa/ZcJfXEON97WjASQ= 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:(13230028)(4636009)(346002)(136003)(376002)(396003)(39840400004)(451199021)(46966006)(36840700001)(82310400005)(40480700001)(43170500006)(336012)(2616005)(44832011)(8676002)(1076003)(26005)(5660300002)(8936002)(36756003)(86362001)(2906002)(83380400001)(47076005)(66574015)(36860700001)(41300700001)(478600001)(4326008)(316002)(110136005)(6266002)(186003)(70586007)(70206006)(42186006)(54906003)(966005)(356005)(6666004)(81166007);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 19:56:04.4887 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f0f8acf-6dbf-4e33-627d-08db58a3143f 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: VI1EUR06FT018.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB6988 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, T_SCC_BODY_TEXT_LINE 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?1766353804651327588?= X-GMAIL-MSGID: =?utf-8?q?1766353804651327588?= Prefix all the structures with the device name. For commonly used structures make use of (the module name) esd_usb_. For esd CAN-USB/2 and CAN-USB/Micro specific structures use esd_usb_2_ and esd_usb_m. Link: https://lore.kernel.org/all/CAMZ6RqLaDNy-fZ2G0+QMhUEckkXLL+ZyELVSDFmqpd++aBzZQg@mail.gmail.com/ Suggested-by: Vincent MAILHOL Signed-off-by: Frank Jungclaus --- drivers/net/can/usb/esd_usb.c | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c index 9b0ed07911e1..24eebb7ee5f1 100644 --- a/drivers/net/can/usb/esd_usb.c +++ b/drivers/net/can/usb/esd_usb.c @@ -89,13 +89,13 @@ MODULE_LICENSE("GPL v2"); #define ESD_USB_MAX_RX_URBS 4 #define ESD_USB_MAX_TX_URBS 16 /* must be power of 2 */ -struct header_msg { +struct esd_usb_header_msg { u8 len; /* len is always the total message length in 32bit words */ u8 cmd; u8 rsvd[2]; }; -struct version_msg { +struct esd_usb_version_msg { u8 len; u8 cmd; u8 rsvd; @@ -103,7 +103,7 @@ struct version_msg { __le32 drv_version; }; -struct version_reply_msg { +struct esd_usb_version_reply_msg { u8 len; u8 cmd; u8 nets; @@ -114,7 +114,7 @@ struct version_reply_msg { __le32 ts; }; -struct rx_msg { +struct esd_usb_rx_msg { u8 len; u8 cmd; u8 net; @@ -132,7 +132,7 @@ struct rx_msg { }; }; -struct tx_msg { +struct esd_usb_tx_msg { u8 len; u8 cmd; u8 net; @@ -142,7 +142,7 @@ struct tx_msg { u8 data[CAN_MAX_DLEN]; }; -struct tx_done_msg { +struct esd_usb_tx_done_msg { u8 len; u8 cmd; u8 net; @@ -151,7 +151,7 @@ struct tx_done_msg { __le32 ts; }; -struct id_filter_msg { +struct esd_usb_id_filter_msg { u8 len; u8 cmd; u8 net; @@ -159,7 +159,7 @@ struct id_filter_msg { __le32 mask[ESD_USB_MAX_ID_SEGMENT + 1]; }; -struct set_baudrate_msg { +struct esd_usb_set_baudrate_msg { u8 len; u8 cmd; u8 net; @@ -169,14 +169,14 @@ struct set_baudrate_msg { /* Main message type used between library and application */ union __packed esd_usb_msg { - struct header_msg hdr; - struct version_msg version; - struct version_reply_msg version_reply; - struct rx_msg rx; - struct tx_msg tx; - struct tx_done_msg txdone; - struct set_baudrate_msg setbaud; - struct id_filter_msg filter; + struct esd_usb_header_msg hdr; + struct esd_usb_version_msg version; + struct esd_usb_version_reply_msg version_reply; + struct esd_usb_rx_msg rx; + struct esd_usb_tx_msg tx; + struct esd_usb_tx_done_msg txdone; + struct esd_usb_set_baudrate_msg setbaud; + struct esd_usb_id_filter_msg filter; }; static struct usb_device_id esd_usb_table[] = { @@ -899,8 +899,8 @@ static const struct ethtool_ops esd_usb_ethtool_ops = { .get_ts_info = ethtool_op_get_ts_info, }; -static const struct can_bittiming_const esd_usb2_bittiming_const = { - .name = "esd_usb2", +static const struct can_bittiming_const esd_usb_2_bittiming_const = { + .name = "esd_usb_2", .tseg1_min = 1, .tseg1_max = 16, .tseg2_min = 1, @@ -911,7 +911,7 @@ static const struct can_bittiming_const esd_usb2_bittiming_const = { .brp_inc = 1, }; -static int esd_usb2_set_bittiming(struct net_device *netdev) +static int esd_usb_2_set_bittiming(struct net_device *netdev) { struct esd_usb_net_priv *priv = netdev_priv(netdev); const struct can_bittiming_const *btc = priv->can.bittiming_const; @@ -1026,8 +1026,8 @@ static int esd_usb_probe_one_net(struct usb_interface *intf, int index) priv->can.ctrlmode_supported |= CAN_CTRLMODE_3_SAMPLES; } - priv->can.bittiming_const = &esd_usb2_bittiming_const; - priv->can.do_set_bittiming = esd_usb2_set_bittiming; + priv->can.bittiming_const = &esd_usb_2_bittiming_const; + priv->can.do_set_bittiming = esd_usb_2_set_bittiming; priv->can.do_set_mode = esd_usb_set_mode; priv->can.do_get_berr_counter = esd_usb_get_berr_counter; From patchwork Fri May 19 19:55:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 96605 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1492688vqo; Fri, 19 May 2023 13:12:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7XRMDVXsKS9tEbQywn9gsTIDn4vbUcUf4/E09Hohc/hNcD3+WTXagpijKvwfqopxLaNfLw X-Received: by 2002:a05:6a20:9144:b0:ff:df0d:a6fb with SMTP id x4-20020a056a20914400b000ffdf0da6fbmr4622980pzc.28.1684527135204; Fri, 19 May 2023 13:12:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684527135; cv=pass; d=google.com; s=arc-20160816; b=yLYvp3J0fQYlV5TTcaRxG2TjpmvUqDSK1abKxfdG7jDr39Qwhvl6g/XlgesyBUVBbV YoLZseL7zSyQop6qvLl/DXJJZVo4tLkvkvBa68eS3Y/qgOrh66MXf3l124qy5uh4z5PO CnXnCoxrwmJ1gz8AhvxFUoJHrGFeLj54nINfF0Ut31DNb3NOXR7X56+c2EANzqNa0p5Q OfECUJ8tHJGBdqNUig9iryjcEiI3Scm+2U3Xk13Q1GPNjLcZh+9d0VfS7aU0KzW/kstY rNLn1XIXcFNgtQqQDX+ZY+tBtEwPrb249cqb7kN1DWHkbROH9tvdI7bi09nGFkojJWpD qveg== 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=7u7MfbXXxyu+oHfti46b3fZL16UY7l36bKmbY8pMT6Q=; b=P9cTFMT8Y6KqYZqEZhQgKpwVGI54wGAtbux0edaE2XIUq7A2+OewfUFUyM+sn+tbyC yZs5WzhgutcCmUpCLKc21RSD/K4Oh7pRm3jQRys8l+41+jkXORFCR4X9xKYoqulzf2YQ EmI/CvN982bESUkKNpKu2CEXyIn3d/Xlj6F6U7fNuGqy7yWrclfs0jGSfYWdeyo4gMze Ozf4XFUIMXBpBYQSCtj1hwHgL+ceg1g2eCLSCu3qhBoNLIqomVtgn57/CiJjTzZ0fSSh vVc1QnFdDUcRnhHaxOwo22L+epboxpjn2NDANI/8VpwLWuqBt80cWIxX9DwFVAXm3+C6 h6xA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=KiBjCYOh; 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 x29-20020a63b21d000000b005348dd488fbsi123678pge.621.2023.05.19.13.11.48; Fri, 19 May 2023 13:12:15 -0700 (PDT) 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=KiBjCYOh; 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 S231518AbjEST42 (ORCPT + 99 others); Fri, 19 May 2023 15:56:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230114AbjEST4M (ORCPT ); Fri, 19 May 2023 15:56:12 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2139.outbound.protection.outlook.com [40.107.6.139]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E285F1B4; Fri, 19 May 2023 12:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jn6XX/OZYFQe1Rfjdm0oKgDpIMIAkvoOiw3h7brbWfvkRr4XcmwovvwYy+XYubaj1PNKb3mwsKfpGgh7a9FxIY8OdbatTf9ui0YZiCMpLg5ku2cSCXqF0gI2BE5aPs5Axt8gLtA+URbtgQQe6OOLd0KTxpR/EC7xvkGjGlro22UF/LF498ZuuyEB8YsC1AMvOaBKNuPTJOmr3kznht0HzPBjn/8lIu620YowcoT5B5OJw3dqIVLDZ6XNqcbejHEdeD19QlvaTcNfi9bAtF6wbn/oMUh+bp2wEGwGNCMr8AgsFh7TOjqGQ1UQHZujyzAfo93EwruxFdP9O+xdmRymfw== 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=7u7MfbXXxyu+oHfti46b3fZL16UY7l36bKmbY8pMT6Q=; b=fSWNYS2DlJILTYvmvIptCIu+tOL8a0WxUiw+107sMVn9CraZp8jeXG2G/EVxPiVKzPFr8j4o//pX9V+I4r3uYz7roJOrLCdvu54RnQvr+qUql0WfkwrqcDdQGdFvmMLYtoygaEJx8ebYqb5TnrkK706aGslhJZYtUwKoPeeVeJQPjgSS0oOdTynCn1YzDSPwAfHrMlrkKcKHssqGEKpGGhvICf5D0VWwt59aRacfQknvZTsqaY3+78bteaBypOeqFrmj8bOQ1mFIEhe/YsrGb/lnktV1pS73BuSZ3fMfP7HQdeFrcWgsYh85jrMYVRc8Jb5bW1xRl4DNx1GAR7vl/g== 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=7u7MfbXXxyu+oHfti46b3fZL16UY7l36bKmbY8pMT6Q=; b=KiBjCYOhY6/gIy7SCRf/fQjUFyyWzzym/MRnFet2hX5zLaNa7bGA4qZY27vUyb7Ibmz90HR4L2JZq5k5Ryr6WnhoL0tBpVE799d1GXad945qkspKo/adjRQ55V3gT6iu0qq9YHEmN1M9giuKIK5XYB3jV/eEQ8aVkKQRszB3daA= Received: from FR3P281CA0174.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::17) by DB9PR03MB8282.eurprd03.prod.outlook.com (2603:10a6:10:309::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19; Fri, 19 May 2023 19:56:05 +0000 Received: from VI1EUR06FT049.eop-eur06.prod.protection.outlook.com (2603:10a6:d10:a0:cafe::af) by FR3P281CA0174.outlook.office365.com (2603:10a6:d10:a0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.7 via Frontend Transport; Fri, 19 May 2023 19:56:05 +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 VI1EUR06FT049.mail.protection.outlook.com (10.13.6.72) with Microsoft SMTP Server id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 19:56:05 +0000 Received: from esd-s20.esd.local (jenkins.esd [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id E69A47C16CD; Fri, 19 May 2023 21:56:03 +0200 (CEST) Received: by esd-s20.esd.local (Postfix, from userid 2046) id DF0D72E1807; Fri, 19 May 2023 21:56:03 +0200 (CEST) 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 5/6] can: esd_usb: Replace hardcoded message length given to USB commands Date: Fri, 19 May 2023 21:55:59 +0200 Message-Id: <20230519195600.420644-6-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519195600.420644-1-frank.jungclaus@esd.eu> References: <20230519195600.420644-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1EUR06FT049:EE_|DB9PR03MB8282:EE_ X-MS-Office365-Filtering-Correlation-Id: 50b0d34f-c5ec-4652-025a-08db58a3149d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 43gQtSN//dtmBFPPqBF3Qm+4URxBv1TPBWdRHRKbcfoeoBZn/8s4vq5U3UOfLnpxpjzBa7cng0JP1KWucy8PSfdQ2/HYPjHDVIkLRAj2VfAsfL6dIFLcjqyZa7r3bZPB0JjvYoG9I6cvFU0kpGf91XII+mm9mJcBxY/IIWCfD+3qgWmQOQjt7a+SeOQeI1hVWxfmeCBNb9q0PzajE/tMidfIoVHRhC6ENTs5AuCWic8oXS2o9ZFB1NWZqz7bMcNa+vOL6oEukzL1UWGu9vaa6PwcqMsczM090EriscW1aATkmB1NON/cy3a7JkKHjrxEvuvJFcZN+kw+6u1JbNVP/sUbR8oHFbTjoIRg2SE0AyxIF73Lsds5T/3yc+S/dW9y19Pemdfw1K2y8sINqjtymiqJjyMrZHm5j/UksNC3B4PmjDwJXIlFah1mdTO11rsikBGHpLhr1oqt9Wi3rWXJHWgI6ZLZz9W5O2fIAIM4KVaPks/pNoGJYFG+5EXhb735VEWGYPK5zlwscTLZQr7beGufCZ4vQg+8jTtJiORmezayKFbtvo/MC+bX2nr9T8hUpy5aAMg0bAG/Anv4WLu0WaV9vwYHMwY1QKw1BRa1MJYWkvY/jCLe1CKtu7KmVq0AFQ6aBkjoYHmGfaCXNHk5oo+pv59hwa7+XY6xU0cmDRlhvU2Rt+lPxyENy/I/A2MRgXu8kR5EXuOnJ9tAarx9xh5EJb88NsFhN3OahOsPg/M= 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:(13230028)(4636009)(136003)(396003)(376002)(346002)(39840400004)(451199021)(36840700001)(46966006)(2906002)(316002)(15650500001)(42186006)(478600001)(41300700001)(8936002)(8676002)(4326008)(110136005)(54906003)(5660300002)(44832011)(6666004)(70586007)(70206006)(966005)(26005)(1076003)(81166007)(186003)(6266002)(356005)(83380400001)(36860700001)(40480700001)(47076005)(43170500006)(36756003)(2616005)(82310400005)(86362001)(336012);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 19:56:05.0867 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 50b0d34f-c5ec-4652-025a-08db58a3149d 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: VI1EUR06FT049.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB8282 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, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1766354725102931460?= X-GMAIL-MSGID: =?utf-8?q?1766354725102931460?= Replace all hardcoded values supplied to the len element of esd_usb_msg (and its siblings) by more readable expressions, based on sizeof(), offsetof(), etc. Also spend documentation / comments that the len element of esd_usb_msg is in multiples of 32bit words and not in bytes. Link: https://lore.kernel.org/all/CAMZ6RqLaDNy-fZ2G0+QMhUEckkXLL+ZyELVSDFmqpd++aBzZQg@mail.gmail.com/ Suggested-by: Vincent MAILHOL Signed-off-by: Frank Jungclaus --- drivers/net/can/usb/esd_usb.c | 40 ++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c index 24eebb7ee5f1..a6a3ecb6eac6 100644 --- a/drivers/net/can/usb/esd_usb.c +++ b/drivers/net/can/usb/esd_usb.c @@ -90,13 +90,13 @@ MODULE_LICENSE("GPL v2"); #define ESD_USB_MAX_TX_URBS 16 /* must be power of 2 */ struct esd_usb_header_msg { - u8 len; /* len is always the total message length in 32bit words */ + u8 len; /* total message length in 32bit words */ u8 cmd; u8 rsvd[2]; }; struct esd_usb_version_msg { - u8 len; + u8 len; /* total message length in 32bit words */ u8 cmd; u8 rsvd; u8 flags; @@ -104,7 +104,7 @@ struct esd_usb_version_msg { }; struct esd_usb_version_reply_msg { - u8 len; + u8 len; /* total message length in 32bit words */ u8 cmd; u8 nets; u8 features; @@ -115,7 +115,7 @@ struct esd_usb_version_reply_msg { }; struct esd_usb_rx_msg { - u8 len; + u8 len; /* total message length in 32bit words */ u8 cmd; u8 net; u8 dlc; @@ -133,7 +133,7 @@ struct esd_usb_rx_msg { }; struct esd_usb_tx_msg { - u8 len; + u8 len; /* total message length in 32bit words */ u8 cmd; u8 net; u8 dlc; @@ -143,7 +143,7 @@ struct esd_usb_tx_msg { }; struct esd_usb_tx_done_msg { - u8 len; + u8 len; /* total message length in 32bit words */ u8 cmd; u8 net; u8 status; @@ -152,15 +152,15 @@ struct esd_usb_tx_done_msg { }; struct esd_usb_id_filter_msg { - u8 len; + u8 len; /* total message length in 32bit words */ u8 cmd; u8 net; u8 option; - __le32 mask[ESD_USB_MAX_ID_SEGMENT + 1]; + __le32 mask[ESD_USB_MAX_ID_SEGMENT + 1]; /* +1 for 29bit extended IDs */ }; struct esd_usb_set_baudrate_msg { - u8 len; + u8 len; /* total message length in 32bit words */ u8 cmd; u8 net; u8 rsvd; @@ -438,7 +438,7 @@ static void esd_usb_read_bulk_callback(struct urb *urb) break; } - pos += msg->hdr.len << 2; + pos += msg->hdr.len * sizeof(u32); /* convert to # of bytes */ if (pos > urb->actual_length) { dev_err(dev->udev->dev.parent, "format error\n"); @@ -532,7 +532,7 @@ static int esd_usb_send_msg(struct esd_usb *dev, union esd_usb_msg *msg) return usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 2), msg, - msg->hdr.len << 2, + msg->hdr.len * sizeof(u32), /* convert to # of bytes */ &actual_length, 1000); } @@ -648,7 +648,7 @@ static int esd_usb_start(struct esd_usb_net_priv *priv) * field followed by only some bitmasks. */ msg->hdr.cmd = ESD_USB_CMD_IDADD; - msg->hdr.len = 2 + ESD_USB_MAX_ID_SEGMENT; + msg->hdr.len = sizeof(struct esd_usb_id_filter_msg) / sizeof(u32); /* # of 32bit words */ msg->filter.net = priv->index; msg->filter.option = ESD_USB_ID_ENABLE; /* start with segment 0 */ for (i = 0; i < ESD_USB_MAX_ID_SEGMENT; i++) @@ -759,7 +759,8 @@ static netdev_tx_t esd_usb_start_xmit(struct sk_buff *skb, msg = (union esd_usb_msg *)buf; - msg->hdr.len = 3; /* minimal length */ + /* minimal length as # of 32bit words */ + msg->hdr.len = offsetof(struct esd_usb_tx_msg, data) / sizeof(u32); msg->hdr.cmd = ESD_USB_CMD_CAN_TX; msg->tx.net = priv->index; msg->tx.dlc = can_get_cc_dlc(cf, priv->can.ctrlmode); @@ -774,7 +775,8 @@ static netdev_tx_t esd_usb_start_xmit(struct sk_buff *skb, for (i = 0; i < cf->len; i++) msg->tx.data[i] = cf->data[i]; - msg->hdr.len += (cf->len + 3) >> 2; + /* round up, then divide by 4 to add the payload length as # of 32bit words */ + msg->hdr.len += DIV_ROUND_UP(cf->len, sizeof(u32)); for (i = 0; i < ESD_USB_MAX_TX_URBS; i++) { if (priv->tx_contexts[i].echo_index == ESD_USB_MAX_TX_URBS) { @@ -797,7 +799,7 @@ static netdev_tx_t esd_usb_start_xmit(struct sk_buff *skb, msg->tx.hnd = 0x80000000 | i; /* returned in TX done message */ usb_fill_bulk_urb(urb, dev->udev, usb_sndbulkpipe(dev->udev, 2), buf, - msg->hdr.len << 2, + msg->hdr.len * sizeof(u32), /* convert to # of bytes */ esd_usb_write_bulk_callback, context); urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; @@ -860,7 +862,7 @@ static int esd_usb_close(struct net_device *netdev) /* Disable all IDs (see esd_usb_start()) */ msg->hdr.cmd = ESD_USB_CMD_IDADD; - msg->hdr.len = 2 + ESD_USB_MAX_ID_SEGMENT; + msg->hdr.len = sizeof(struct esd_usb_id_filter_msg) / sizeof(u32);/* # of 32bit words */ msg->filter.net = priv->index; msg->filter.option = ESD_USB_ID_ENABLE; /* start with segment 0 */ for (i = 0; i <= ESD_USB_MAX_ID_SEGMENT; i++) @@ -869,7 +871,7 @@ static int esd_usb_close(struct net_device *netdev) netdev_err(netdev, "sending idadd message failed\n"); /* set CAN controller to reset mode */ - msg->hdr.len = 2; + msg->hdr.len = sizeof(struct esd_usb_set_baudrate_msg) / sizeof(u32); /* # of 32bit words */ msg->hdr.cmd = ESD_USB_CMD_SETBAUD; msg->setbaud.net = priv->index; msg->setbaud.rsvd = 0; @@ -947,7 +949,7 @@ static int esd_usb_2_set_bittiming(struct net_device *netdev) if (!msg) return -ENOMEM; - msg->hdr.len = 2; + msg->hdr.len = sizeof(struct esd_usb_set_baudrate_msg) / sizeof(u32); /* # of 32bit words */ msg->hdr.cmd = ESD_USB_CMD_SETBAUD; msg->setbaud.net = priv->index; msg->setbaud.rsvd = 0; @@ -1086,7 +1088,7 @@ static int esd_usb_probe(struct usb_interface *intf, /* query number of CAN interfaces (nets) */ msg->hdr.cmd = ESD_USB_CMD_VERSION; - msg->hdr.len = 2; + msg->hdr.len = sizeof(struct esd_usb_version_msg) / sizeof(u32); /* # of 32bit words */ msg->version.rsvd = 0; msg->version.flags = 0; msg->version.drv_version = 0; From patchwork Fri May 19 19:56:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 96600 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1483090vqo; Fri, 19 May 2023 12:57:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7zwjA+OlEgncoxghuXtv1ZQ3IHYV299Q2Asrb1ISyieimMSsgKoC3cIQTosZe8NVracNPn X-Received: by 2002:a05:6a00:1a15:b0:638:7e00:3737 with SMTP id g21-20020a056a001a1500b006387e003737mr4137856pfv.23.1684526260935; Fri, 19 May 2023 12:57:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684526260; cv=pass; d=google.com; s=arc-20160816; b=HN5MWPpOG/1wKCzHNnKjRL5j2wNhEW4GSDB8ZUQJhfj3/pgZrjxKOylBvv1D2IHfJo CTCBdlqCeatrYyEeB81UzKYkMPhyPhCKAVbNwjYc3KU0SCjaoGK+svGkoTJ9ufRaPwIj R7aSLByrSHJzLzT6JgX4fCVHNssNaojaUevW7TVaLPZ2hIjIYiPyyLW5myR4QdsvONre rjgKdh2tlNjmYI2jqkE3ntPI0yXke1CH6QPXh87+x6gKQhzdySFdgwrLr4E58q0IKquA Gm24w6aUGjp4z0edfMfA23EYDAYtnm+ETlIcch8NhHBPhlzv29yLDGUY4lb2gV5St3GT 8hlA== 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=/QWpBiDRmFm4yjR+LObQ0bmAXofs8H1x/5P3UBkH2oQ=; b=sLrkWWZhT96gp3mz21wANg1eoUnniw/6uNH5U6SxygToalM2TPgNBS4babW5yOc7fU DaveDlP++D5L2j1B72Uagt1WgqorUXCYB6exyn1eE6+zxodGf774Qko8EEts6Pi8VIGV AJf2EXkh8pUNukoOwmSOeFV7DaAT39/j6cjiiWyTyi2LNnHQJFEZG4NQjKqIWgOQKVmJ 8R0gTwn6mQOqn0GK9IAz72ZLMgE65fe+Pv+nGHCOMSAvjjx1nj1HQ8lmi1xUKrkYKWNm 1U7JEWDwsNMcUT/+MW3mCi7ANtnUVwyb1B0ono8Ow0EmQqy0peogVMFl6fpztzXekSmH OHaw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=aKVE3X99; 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 bs193-20020a6328ca000000b00530878c1824si126183pgb.348.2023.05.19.12.57.28; Fri, 19 May 2023 12:57:40 -0700 (PDT) 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=aKVE3X99; 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 S231499AbjEST4Y (ORCPT + 99 others); Fri, 19 May 2023 15:56:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230157AbjEST4M (ORCPT ); Fri, 19 May 2023 15:56:12 -0400 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2138.outbound.protection.outlook.com [40.107.13.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8D8CE46; Fri, 19 May 2023 12:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b+r6YVTWc5cDvrzoD2wSWAxf51iFBc1gBLmO1RG9DnCztypLhUXyOPP8Wl7TFvv1iS3rhBioS4bgIDowLKsEINwdsStFCma6rIcivfkqBVfbNbirRusUaLAYk1UY2377DucseZ5SwMX1nYMcrxT9y/XaRx3DWInaQ2H3bou/a5rehBNLZb8qDK4vYTpys3vc5d1Lk8wnqzRNztlH+aniI0zlxV2/SwBfkW4nabFSTIh6OqWaFhy4TPChbjlWc2WfaJPZnDhV1tuwS504qn2CmfJFcGQy3CowYWss54DsqT6T/DWNd6mPbnohKwly8k3axocJn/RgPUjHdkjtEffGhg== 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=/QWpBiDRmFm4yjR+LObQ0bmAXofs8H1x/5P3UBkH2oQ=; b=gtpRwKShScmkK2u78Hpx9+JjXdtWaWymT8zruRZAmYqtAvEfmIJnARlSqOKw7U0baDWwWzPQX79Ka0K1hRV4+lhdNpoWDZ6eUC0unH1tNbkf00uGU//DToD/T7yJAr2z4jRAwK/JH69/RtrALuCbWm2opJbKMvvtkgB43MkcxCYZks8v1eDbVQaAy/3QP1GJsrxdn3IPuvi8N+bzbTn1cUSkz7qoqaKWQzty1Q2EXii5rzTzqxy1KnTeCEfzbWb01zcRGCYlSV1HPk5p/SbjmpdN9mEZbfWpar/sd0RP20v2nZ9LDCs1IbxQqpZgKlgDW3wDngyPSQsKn8GX7vyIuw== 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=/QWpBiDRmFm4yjR+LObQ0bmAXofs8H1x/5P3UBkH2oQ=; b=aKVE3X99P3DW7+TvDSRtlTKm679dcSuelu6rH2cWqshJETLHfUJUlQuiszRfl7JZ4HGULzriOiazsBd1aJFlR4Sc5KtCnj58Jr+tt9npiktErtn5t+ATPAvenQx9sZp6QUagDKjGVwAFs6yHCCL4UL3tYdkQI/YrgFZIOxV8fpM= Received: from FR0P281CA0002.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:15::7) by DU0PR03MB9518.eurprd03.prod.outlook.com (2603:10a6:10:41d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Fri, 19 May 2023 19:56:05 +0000 Received: from VI1EUR06FT054.eop-eur06.prod.protection.outlook.com (2603:10a6:d10:15:cafe::2f) by FR0P281CA0002.outlook.office365.com (2603:10a6:d10:15::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.6 via Frontend Transport; Fri, 19 May 2023 19:56:05 +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 VI1EUR06FT054.mail.protection.outlook.com (10.13.6.124) with Microsoft SMTP Server id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 19:56:05 +0000 Received: from esd-s20.esd.local (jenkins.esd.local [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id E70DE7C16CE; Fri, 19 May 2023 21:56:03 +0200 (CEST) Received: by esd-s20.esd.local (Postfix, from userid 2046) id E32DD2E1808; Fri, 19 May 2023 21:56:03 +0200 (CEST) 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 6/6] can: esd_usb: Don't bother the user with nonessential log message Date: Fri, 19 May 2023 21:56:00 +0200 Message-Id: <20230519195600.420644-7-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519195600.420644-1-frank.jungclaus@esd.eu> References: <20230519195600.420644-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1EUR06FT054:EE_|DU0PR03MB9518:EE_ X-MS-Office365-Filtering-Correlation-Id: 5bb73f85-4aea-4492-a684-08db58a314ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uC9cQuz7k9cLJtN4QD3Rc+Rwjkkq7R9fvWjAeZoc4FBcxpftiRUZsv4w5WnDzsUvMfcBsE5HItb5aqJiaOhasaa4H9VZK1xxC+Cx0OVC+9uBvNBi3k9YSOK7ymP4sguPrvL/JDm6NUczm++7uQSkUPZG6fzth2TmrllSdltTY48fBVmJY1ObSK8Rv07NY+OIsRotJ5KGqjeuXY9QOcoFa91H06CpS8jO+Qe2YSOqXJ6Mp/DUSjJIhfVxnBtai3lEeVcGkYOltjJUrA9NNeymRsI2U2cZRpR7Vc24SxBfu0fO8EZS83HUqgNJr2so2fGtfNha8qGCrpKDQQu97XQdXuK/pVdJ+bbKYXJ9ofTv+5mDupamOd+v9OYRaEMFs7cV+8mA8vnkUcUOqCdOBhjMVkcMomW+V40Ry+C2gYXYPJD0GPZ3OWR+uUadrrC6p9omKD4RC57QO9vQOyFMWTe1iRTiGZ9gku0Dfetzc/PyYMMeeu/T7aBhx6si7TFygkSXuqTih/eBwLotE2/fix9OvlA1lgIvIsS1A2nMe48C+Ldb6yjXIrY9NCF5rynb5zTC45RcCw7JiDGLcdXpESdGj1Oa9p45Im2zaacyW7G494KWypJhKDRliJ/qHZy7riI96YU2FoyjxyTjgt2nwtQFdaYCjy5Dq0nQuWBgD8PQ04S1JqVf0+WpjYqXF6nJGsES9by/xs3U58ZwEtLBEUrGNQ== 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:(13230028)(4636009)(376002)(136003)(39840400004)(346002)(396003)(451199021)(46966006)(36840700001)(36756003)(478600001)(86362001)(316002)(54906003)(110136005)(966005)(70586007)(4326008)(70206006)(42186006)(4744005)(356005)(82310400005)(8936002)(5660300002)(336012)(15650500001)(40480700001)(8676002)(2906002)(41300700001)(44832011)(81166007)(36860700001)(2616005)(26005)(6266002)(47076005)(1076003)(83380400001)(186003);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 19:56:05.4120 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5bb73f85-4aea-4492-a684-08db58a314ce 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: VI1EUR06FT054.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB9518 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, T_SCC_BODY_TEXT_LINE 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?1766353808597443258?= X-GMAIL-MSGID: =?utf-8?q?1766353808597443258?= Replace a netdev_info(), emitting an informational message about the BTR value to be send to the controller, with a debug message by means of netdev_dbg(). Link: https://lore.kernel.org/all/20230509-superglue-hazy-38108aa66bfa-mkl@pengutronix.de/ Suggested-by: Marc Kleine-Budde Suggested-by: Vincent MAILHOL Signed-off-by: Frank Jungclaus --- drivers/net/can/usb/esd_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c index a6a3ecb6eac6..4c0da3ff3a9d 100644 --- a/drivers/net/can/usb/esd_usb.c +++ b/drivers/net/can/usb/esd_usb.c @@ -955,7 +955,7 @@ static int esd_usb_2_set_bittiming(struct net_device *netdev) msg->setbaud.rsvd = 0; msg->setbaud.baud = cpu_to_le32(canbtr); - netdev_info(netdev, "setting BTR=%#x\n", canbtr); + netdev_dbg(netdev, "setting BTR=%#x\n", canbtr); err = esd_usb_send_msg(priv->usb, msg);