From patchwork Wed May 17 19:22:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 95512 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp7259vqo; Wed, 17 May 2023 12:37:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6yftPBcbmMG/GQnOVex+aJ4HrMGJCY1fjhW2DiavMUVorsNmi9QZIxbTjXSudFFhrMEkfu X-Received: by 2002:a17:902:f812:b0:1ae:4c3b:bb0b with SMTP id ix18-20020a170902f81200b001ae4c3bbb0bmr4847848plb.5.1684352227690; Wed, 17 May 2023 12:37:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684352227; cv=pass; d=google.com; s=arc-20160816; b=C9ZBz/VmI/jI8/zTt2EkifBp2o1bciAwXHA9KI2aFUOkvk8teXldy47g8yal6G7gi3 QSmTkoNAc+NHhTxYle7cHFmNyLyCGiSWZq1TfPJOaLJOLT4IQGLaXSt+EouUMgczTxD3 4sN1gk0jSLLDEB48SITUJ40tVi0VxlRB2vrXK1uefjC7qpxlTtQdSC9oehlP1VZc7zxi 8rh5LbEikOOyOpF4iFGIIIaulhfLM99ynhqhBrxtbHp6cS5F6cwMzS0dxF7fg2LF9BjL O/UjcKH/Hqwv76amnJHI3yIk3v0rY+BWIND03ll2vyzj4pkFDame2v4m8CNSTfZiZojU 3uAQ== 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=mE66U+LU5IRRSdyP0mQyFle6mq28ayesMbND/NnSxeI=; b=pMbYuz0OHGWn9IIXbGZ3Lifc9KF/H3Csc0o6h/uGNsS5lFkFTaVDpvLAlN6Xc7grrB QaEAMTeS7uocWMWXFPw/CYk7pslVFL5NS7ZDzveUiyahjrRkWnMmHDynY7JK26N+zswW bHM4H6dXLfszZJEF5IZm20T3L60CvXAwJ4E9TOO1yHiVreepPc8/oHwbtIqNlR9JYiPx CA68174QRg/i73UgbuNSmiK0HHApHfa4FTpL2arUNSUIwmyPT+vbUHDwA1piGcBiowbN ZbG7fIGuMXRoqB8Q4lQv3TJ3MN5VI7GRp5WR1o1Edh/MgHg7VDJcQxgJEgxG6ozNqC/L Nl9Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=rWNOutRY; 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 p1-20020a170902e74100b001a80ddd372csi22531620plf.43.2023.05.17.12.36.53; Wed, 17 May 2023 12:37:07 -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=rWNOutRY; 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 S229982AbjEQTXT (ORCPT + 99 others); Wed, 17 May 2023 15:23:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbjEQTXL (ORCPT ); Wed, 17 May 2023 15:23:11 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2091.outbound.protection.outlook.com [40.107.21.91]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84BE159D3; Wed, 17 May 2023 12:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ln6das9Ry0Bv5+utlbUlA/nRpRBi9/LdWckZyTxIWqr4A9XVmV8SGBh8fR6TBK30rUrnhAPY3paeK0IqT/J7CaIvwZgSa2WIck8A4CTHJ0eihrfAghGVZ4oE+Zcv6VjKJcZw61eWn85cFahgwIg0M03zawxtMJPCfru9YD836UbMvqCGBzwC+z50qEj6SosTbrTm7n7QO1fqVVS9GlPDDZrwl6OSxXv8iEx0RPQAFnkrCn4aeI3L6HQUXI/zazo18kHxC2MNv/D2uY9N8iuAZjVUabuBeMcgRxrw1Y9ANGX199V7eD7Qq54tJ7sZtUqABFCyVxN2kVGlB+hpDrwHHQ== 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=mE66U+LU5IRRSdyP0mQyFle6mq28ayesMbND/NnSxeI=; b=UqgVRpPO1RufxLhxUAh2eTLVCoxKM74dtg0v6pZzCXaPyzQa05aR04vTZAHV2qS8MAyhrQGyFFKpNVHkTbUIYRFFNyn1XVa3zS3F85St5pG5KwOEUtk931hdLFEHZAhplmWGx6bCpYei34k7j0TzSDbEHHdSf9qSE6Y6MAPDgCFqp3CsFd2iWtPKOsxgRe5LEylJ0ccdqr6Asp57tZY6wnP9s0GY2HR0uj88kkHgo4c/nQ2Kx0zEJ64Kg6WlFEh3BTaHhkqpmiC8YdfjPNmGq3yAsZaNfhQK00YjPvdV3SuTJd3NrPcy3qu6KlVubRPcKMGXWc6MpTJ0x8UHswuMPw== 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=mE66U+LU5IRRSdyP0mQyFle6mq28ayesMbND/NnSxeI=; b=rWNOutRYTAtjwxf0pLKhbTnR01Rh1SkiWj+3nJORHWCED1u4L7HjMwL1DkAipaJYt0mpLNM5ReluiwWK0kFIjrp3n7Sp0yhtayiLuxefMhAXlIuntPcT67AVubhm8rAdIModAG6gZfPw6h1vnC9OXRsM3oKIK66Ry+KvsGJrwkU= Received: from DB6PR0202CA0043.eurprd02.prod.outlook.com (2603:10a6:4:a5::29) by PAWPR03MB10135.eurprd03.prod.outlook.com (2603:10a6:102:343::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Wed, 17 May 2023 19:22:56 +0000 Received: from DB8EUR06FT020.eop-eur06.prod.protection.outlook.com (2603:10a6:4:a5:cafe::96) by DB6PR0202CA0043.outlook.office365.com (2603:10a6:4:a5::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.34 via Frontend Transport; Wed, 17 May 2023 19:22:56 +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 DB8EUR06FT020.mail.protection.outlook.com (10.233.253.6) with Microsoft SMTP Server id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 19:22:56 +0000 Received: from esd-s20.esd.local (jenkins.esd [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id DD08B7C16C5; Wed, 17 May 2023 21:22:55 +0200 (CEST) Received: by esd-s20.esd.local (Postfix, from userid 2046) id CFDAC2E1802; Wed, 17 May 2023 21:22:55 +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 1/6] can: esd_usb: Make use of existing kernel macros Date: Wed, 17 May 2023 21:22:46 +0200 Message-Id: <20230517192251.2405290-2-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230517192251.2405290-1-frank.jungclaus@esd.eu> References: <20230517192251.2405290-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8EUR06FT020:EE_|PAWPR03MB10135:EE_ X-MS-Office365-Filtering-Correlation-Id: 07925482-eb81-412e-5413-08db570c1e5e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C3KapAIPw9vnLoup7EEsXVfq7zQURJewJggkkPKd4+fqYGYtFYeMqtK161vuFfh/VC6qd2qbkzyHWyljZFxxNc9YXh86kObFnmKIj8x77/XxL+n8SBVAnE9ahLJd7hWPVNn9W7IYu+xxAxCq59mx+q7DzKTmf2k3O19laaoCfMUBIr3KLm+S1n/3SY89SdRzEH/ur0HZLV/CIrVcbx7ZGnpM7K46UZekGxyBYDHL3ygUmKFKw9KUWG/2va2ZScAX25rTbBb8eFQ7zDMOOPQOb1ab6ibNA1AYsOpCELpkpqUz7mp7+jIz2jBvaf4QV4QpgI5unG7JgZXMl6BrOJAH6e8vIg7UpCYjGXHYxMhB31tO7xlI53roFLFftjk/u+IjZVoApCki/5ddiO009RYGJmrpzxIlvYaYzPyRNr1gYxvON2NORkCWXkQGBuYWAIOlNpQ9TfA1gq6+usY3mhCRe1PKzGkzc93QB5P1Y1++DVUvzuPXEREhW3wjxooVU0fLkmcnHGiIh8QKdNWAbBg4dNFLnt0Gh50Iiu9eEhlduWv0BfC8uhT09Tgitd5sImvQt/IRS9eBme6HLdNjEcTdGQE6aebWbzpNv3/tNLpe4AzBnEVXnXgS7tqoxNLai6E2XcSsGeM7pTSkeUH+4INnTszwegFilj6nMgLNM9DCwl/co+3MIMi9efbB0kXbsSSfGBeIuzfmbcpNw+j6u99Uug== 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)(376002)(396003)(136003)(39840400004)(451199021)(36840700001)(46966006)(36756003)(86362001)(110136005)(54906003)(42186006)(966005)(4326008)(70586007)(316002)(70206006)(478600001)(6666004)(356005)(82310400005)(2906002)(8936002)(5660300002)(41300700001)(8676002)(40480700001)(44832011)(81166007)(336012)(36860700001)(26005)(6266002)(186003)(2616005)(83380400001)(47076005)(1076003);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 19:22:56.2685 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07925482-eb81-412e-5413-08db570c1e5e 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: DB8EUR06FT020.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR03MB10135 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=no 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?1766171321432881903?= X-GMAIL-MSGID: =?utf-8?q?1766171321432881903?= As suggested by Vincent Mailhol make use of existing kernel macros: - Use the unit suffixes from linux/units.h for the controller clock frequencies - Use the BIT() 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/ Signed-off-by: Frank Jungclaus --- drivers/net/can/usb/esd_usb.c | 38 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c index d33bac3a6c10..042dda98b3db 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) /* 0x10 */ + /* esd CAN message flags - id field */ -#define ESD_EXTID 0x20000000 -#define ESD_EVENT 0x40000000 -#define ESD_IDMASK 0x1fffffff +#define ESD_EXTID BIT(29) /* 0x20000000 */ +#define ESD_EVENT BIT(30) /* 0x40000000 */ +#define ESD_IDMASK 0x1fffffff /* 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 0x7fffffff /* bit rate unconfigured */ /* bit timing CAN-USB/2 */ #define ESD_USB2_TSEG1_MIN 1 @@ -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 Wed May 17 19:22:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 95504 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2561vqo; Wed, 17 May 2023 12:27:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Iz4kBMlZGhL2+jU9XOFbnq7+Kq9FPg+Qp+x0Vcnf1AlY4dNquxIljkACLcJYePFuqLtWb X-Received: by 2002:a17:903:11c3:b0:1ab:160c:526d with SMTP id q3-20020a17090311c300b001ab160c526dmr48576273plh.22.1684351645359; Wed, 17 May 2023 12:27:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684351645; cv=pass; d=google.com; s=arc-20160816; b=kOc5wSoxewrGCVkwEljQl8JoqKuRgLNsNZcsbKCYVFb6Cd07q10bx3goy7F5cu5mVw L4cKYQqzhqZ0OC5VlpOe/BEplNgjvDfnv7/kVew+w/YcsfBYkAV94yHuVSY2AffEGWla XEJj8VCSGi1Jby14d0ToQ/1PWKDw4yBxNMcBbL2p3w3j3POBeVh5D3agu/F8L5nV45M/ 2SFJJZ1P+snab6kJug2Gb1e18vuyirIfpCOlbqrpfFBovOAb/FabLhJqBYyo6uDM8MEv PCAtdmot0sTjg219C0AfK5jdhoJBJpDA/Z0QWQhBrB3fjjmojPIZODHHfhiPnp+ZsrT8 smtQ== 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=horHWuD8f8DxBUMvfRNXeJlSNKc3GL59fOr/axIf0g8=; b=Dm/pDekIYdggJbltIQjKxBDf1CjznlklsxeUn/rtLdgjE/wdHePqx23aY4f8kp1iiH b35hgWWtK3h7QYqfOZflrqr1dUu31g/GoSL0fyKx51Qj4vx/wv/Nq+7Phe5F9ShzxyX3 RsB4vKjSwRXE0VV6YpgYqanIRrGlT87/UpXuZ9gxRmORr0lMF+f7iCqZccu8YAPlHUrb I+4Nn8SjRXppP3nKi1HYp9FfiHVO/Nr0wVg2xBl6SM9QUnZbrhaDMYFluk+LOgMYNHOw iaR/oiWnnvX0HfFZv7Wp8XyvXIftz5JtVnFVm30/7IN759/uGa+uN08FPfSGkj1IxWuT YQOw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=b2cJ2Z1X; 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 j65-20020a636e44000000b005304a8af2adsi19748403pgc.392.2023.05.17.12.27.11; Wed, 17 May 2023 12:27:25 -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=b2cJ2Z1X; 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 S230103AbjEQTXN (ORCPT + 99 others); Wed, 17 May 2023 15:23:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbjEQTXL (ORCPT ); Wed, 17 May 2023 15:23:11 -0400 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2101.outbound.protection.outlook.com [40.107.249.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B18CE213D; Wed, 17 May 2023 12:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KjxqSBOebbgTYWGZHwnZPFsGq3V0IFhkR0CrQ916+cJ2tw5JDOfDYXFwmd+WpH+ytWHNtOkNl8vizLI7CIjmmr8yASA5WzZoQLFr3ji83tpu1zSDKhpE9xkdfzR61rAw8knintjREhqj0RrNHnByIbp4v0u1JSvPocW5qBA90QDijkG1Ssaak5zDpLKGK0yA4nBJYL2iAxWyII7pIsvSnG2Wc4w+4kUg+1IIMtGJewekh4CGbf9XsFNRfli1oyIeeE+I5sIPt0lnSD3Na0nI2ZDpLZZz3kmo7hsTSOHqnpdu8LlySUo9qpkoiSRmnUpH5S/T179oJWTtU3/yhnmkOg== 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=horHWuD8f8DxBUMvfRNXeJlSNKc3GL59fOr/axIf0g8=; b=V1DNf468IOOml1juPczcl0PXAoS1BZ2yrdP75thN85HRhTt5tuisTVWpNlGaCbnZ+DlAnvRfLCmtMP/YVynqTZ2IknQk2eMYue1n7FLdtspxzLUSBI0g6LkFTgcfE04iKOhCCmE5IqoYhX91AAbDhjwoFyQBr8CWIfGB2yYNgJgiA56ID0gySwXo024rv2eZ1wMTHEQdA0jeaQBH7LiSjrlkMQLS3oAnM5yyxNCot7ZM+oBVmXkKTr8rwkw1Edj7QNRsmJ3s+0nz1aUpkuhWHt+A6LvZDja3CvFTIhWZCD+x40vEMVh2JDmXaTdVF9mmZGoBIfvP3UjuizXAOj6oMA== 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=horHWuD8f8DxBUMvfRNXeJlSNKc3GL59fOr/axIf0g8=; b=b2cJ2Z1X6pWBYo0H5GWinahFxLjA1p1Jf8c4+cD9X6to0EXFSXJNV70/1qme/w3ZMeZJJ7UThEsN1JoROmE7v27qGDHixc9qxwgyzRtF/P5MC3FEJPszTmtpWIDyZn+MltXWlf5pm35xII/nHRUPHu6gFnBVJwVNjbe6PwqSIa8= Received: from AS8PR04CA0058.eurprd04.prod.outlook.com (2603:10a6:20b:312::33) by DB8PR03MB6140.eurprd03.prod.outlook.com (2603:10a6:10:135::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Wed, 17 May 2023 19:22:56 +0000 Received: from AM7EUR06FT058.eop-eur06.prod.protection.outlook.com (2603:10a6:20b:312:cafe::a3) by AS8PR04CA0058.outlook.office365.com (2603:10a6:20b:312::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 19:22:56 +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 AM7EUR06FT058.mail.protection.outlook.com (10.233.254.161) with Microsoft SMTP Server id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 19:22:56 +0000 Received: from esd-s20.esd.local (debby [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id DFBAC7C16CB; Wed, 17 May 2023 21:22:55 +0200 (CEST) Received: by esd-s20.esd.local (Postfix, from userid 2046) id D35D52E1804; Wed, 17 May 2023 21:22:55 +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 2/6] can: esd_usb: Replace initializer macros used for struct can_bittiming_const Date: Wed, 17 May 2023 21:22:47 +0200 Message-Id: <20230517192251.2405290-3-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230517192251.2405290-1-frank.jungclaus@esd.eu> References: <20230517192251.2405290-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM7EUR06FT058:EE_|DB8PR03MB6140:EE_ X-MS-Office365-Filtering-Correlation-Id: 45921b95-17e2-40f3-3177-08db570c1e3b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8pHjqK++phOyEhXMGQWS04POoxuQZQtnC+hq8V8Eds5RCpCMe4TIEWuTIkTaBgzoVTdmSwPKukzoqXjuTFFB/ycJQV4L+wWi9HjtCrmVtk68LE2/wsMQO2NHv7Hnpmvw8ZW/lSzp6g1Mq6WC05/2B4rOWAirZoHc8HfzR/eqVsQdv5FO9XY7/7wyEtYS3IXSUAdi0m2izxiJHfZtgvD3ovRQ0oqpOK9iWd1W/SxHZIMpv3MGR9ahL96kHptaYN7RWscN+Cr6aLRzjup7Y2IXFJwY9j7j2YVoJ7WA7cuiIH5XmOaV33GMPmrGKq3iAzdiV1WKHD19Lj3oMpsJkCnPsO6DE5AMxeKZORcykB42yOGIe0QoEaPlTpwp642AXUpAGi7dzrLgWxUC7cL/r7bngTxrbsWf8UbM3JmcFpEvqs5KbRQHZkk9CrKU4vQGaD7F7iS7xTWuOR3McdAWJL2Xjw578MkakoM7JEDUc2RbI8lQ4VNd2t8nuhRVhtcqAbdLgNNfQRmNYIDi3IP2nKCsbOAwWINeNakQndHmni062UGJx/6HwrFchHtlc4cUH/+5+IgTjSombK6XqLaoTT3HQgFlrXgaBQuNkH9MMndRx1Go1GGxmh/Lq0ar8j3BwdoyR8Fw2z4EXAiqyRCh1fthxV7lY8P2f/uQMNUicx+sywyXAr4G59slvNsCE6V80x2m 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)(396003)(346002)(39840400004)(451199021)(46966006)(36840700001)(4326008)(54906003)(42186006)(70586007)(110136005)(70206006)(478600001)(2906002)(6266002)(8676002)(6666004)(966005)(8936002)(40480700001)(316002)(82310400005)(5660300002)(26005)(1076003)(44832011)(41300700001)(86362001)(81166007)(356005)(36756003)(336012)(83380400001)(2616005)(186003)(66574015)(36860700001)(47076005);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 19:22:56.0695 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45921b95-17e2-40f3-3177-08db570c1e3b 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: AM7EUR06FT058.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR03MB6140 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=no 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?1766170711154661523?= X-GMAIL-MSGID: =?utf-8?q?1766170711154661523?= As suggested by Vincent Mailhol 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 042dda98b3db..194aa1cf37b5 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 0x7fffffff /* 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 0x00800000 /* 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 Wed May 17 19:22:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 95506 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2749vqo; Wed, 17 May 2023 12:27:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5PCmHZEkt+TwxdeHUoY8AyIjTsF3W87LXraL4W+6TEkZtyeqKMES3t22ljpNboGlBGz5u5 X-Received: by 2002:a17:903:244d:b0:1a5:2540:729 with SMTP id l13-20020a170903244d00b001a525400729mr53109516pls.56.1684351667543; Wed, 17 May 2023 12:27:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684351667; cv=pass; d=google.com; s=arc-20160816; b=AZrbGYqutqOnOwGbvmwC9hZf7x2b40t16raAxzIQ4a+hSF/Fy/1W8F3QlYqm/USN9x n99Zc1WyiV0MsIav24jyaeCIdaFzMSmPVmJIqFnKFirlJMMgHmgbKkvl8PuzqYZdWWgO sbdniLryNKyfJwhcUy7p12mssOjfwnLyD38uY8Ps1BRw/+5YttsAP2pibmQEm9pjGwbQ z3wdhTcWw1ruYliJfVFKCxZzZTCU8Yt2UZhSkAJ7GL4LibbBDZb0YcUgbiQ2xqgc+raf zX0g2yNKZ3h64VUe9CllOahxhMeRUPyBaDo/+oXcy0WvhEPQ5sx/DuX7d/sbwH7ng5DR B+CQ== 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=9mzkXC7OnBgzvVyTbbnxcK11B2UZs1EiM9aJqS0nfAg=; b=JU13xfbnbioKxb5aXTUNCLzMEn3u9oxZ0j6odQYbBGb+G/G3JhQxBF1wb1lZbox7uJ +iNOhWGucg+gowzNXfeYZf3DDO0NCs2DaEayNE4EpI7doDrKs3ZgY1zr9YFmFgTCOQbw kQeTN1HykftHoTADkCIK1w3slsOSs8z3ACs/8j+MrnFCoe9GnQSw23B3rqRZcYn4u7v+ 2EiEbKGoPOZPeJFSFv+sM1ANZHqa1jQrxmEPnkcLwE1ApzBAMdBX3W4DFP4yrT0A1MUh ieNxLl87kJ7otlZrQToCFFJBzm3VHttz+rNJ+izcKcxelOT+NLpdy9bDPIeMm4Nb+lOu Ipsg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b="DJ/To+S6"; 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 a24-20020a170902b59800b001ac3f74f488si20663468pls.79.2023.05.17.12.27.35; Wed, 17 May 2023 12:27:47 -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="DJ/To+S6"; 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 S230140AbjEQTX0 (ORCPT + 99 others); Wed, 17 May 2023 15:23:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230090AbjEQTXO (ORCPT ); Wed, 17 May 2023 15:23:14 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2104.outbound.protection.outlook.com [40.107.21.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6408A2119; Wed, 17 May 2023 12:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H/o5uUR4LtySj1hqHfeaZCxOJmP3RlXGTdq72fCqfRtioLl4ABuaxiPqV3h4JuQoJcg353Jv7fTxlzS6ooJraDLnWzdQb3EO070yMqSpQaYybe1SF9Nus6XjairQNpsHsE6BuA1Mvz2S42FnICcxl4vqmj4IKBMMCWzpagwAtJON2+0BpxpnDXhBPqwgOTp57KD2ZXnJAV5/yzxPR0578oNA2pTxOcAI9AzCu42w9rFi8wq9NSFhS+QH7LOZUU1pgTawCqAf86x8lrdWdSugKckdHPHeHDOTjJHQJZC0fr4LI5WvwJcqHpps9zLuhg5GtiZmL6Wx+Lx/LFmjY98uEw== 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=9mzkXC7OnBgzvVyTbbnxcK11B2UZs1EiM9aJqS0nfAg=; b=iieDzUL6I2pKm3oFho/lbRO0LffNcUFSdaPcLpJZEqC2PWSOirOdW2HcnT9/Vqa4z9fQTI82knu2O7+qqOe140FZ4PipijtClOR4t+y0elqBLs4jVbbeguj48Ly5jM/WB6TAgEi+DZrjVgxHZNbkSZgkkRVyNgVW+XYTxO7fgPxlEAY7nDdd9LESORXR5c7PgPgHa9TwVZMrx8jj20dGUJYw+zloeN8oKZESI3hWepHO4BCEnXXartdCqk9PmFXw0qU7/kDsZgY9GA4rvf0p0fhCSqQlHRbKnKCShashr7rojJJY6XyhfT+hVNR/RFuZzwQ+5puR/F/HANvk8BHZ7w== 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=9mzkXC7OnBgzvVyTbbnxcK11B2UZs1EiM9aJqS0nfAg=; b=DJ/To+S6eNl9Uyf2UpgYlNF50v+SyO6lNfSFdunDY9Y7SF1Ig6KnXwNCFPaiuNX64iZLom2S/QvWnntRkBa5GJn3Q9L/DTXoSmofuOugTWLWlVFzbV+t2TDsiRYaeQa5lz8IJmRcZ4d1IOYOiEewPzlLIdxuI8T4swkG3JxeRno= Received: from DUZPR01CA0011.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::19) by DU0PR03MB9055.eurprd03.prod.outlook.com (2603:10a6:10:47f::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Wed, 17 May 2023 19:22:56 +0000 Received: from DB8EUR06FT027.eop-eur06.prod.protection.outlook.com (2603:10a6:10:3c3:cafe::e7) by DUZPR01CA0011.outlook.office365.com (2603:10a6:10:3c3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33 via Frontend Transport; Wed, 17 May 2023 19:22:56 +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 DB8EUR06FT027.mail.protection.outlook.com (10.233.253.49) with Microsoft SMTP Server id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 19:22:56 +0000 Received: from esd-s20.esd.local (jenkins.esd.local [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id DF0437C16CA; Wed, 17 May 2023 21:22:55 +0200 (CEST) Received: by esd-s20.esd.local (Postfix, from userid 2046) id D720C2E1805; Wed, 17 May 2023 21:22:55 +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 3/6] can: esd_usb: Use consistent prefixes for macros Date: Wed, 17 May 2023 21:22:48 +0200 Message-Id: <20230517192251.2405290-4-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230517192251.2405290-1-frank.jungclaus@esd.eu> References: <20230517192251.2405290-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8EUR06FT027:EE_|DU0PR03MB9055:EE_ X-MS-Office365-Filtering-Correlation-Id: b99daa0b-69f4-4f1d-3298-08db570c1e7d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dHphiIcizK0Kbo3hQGIN2V7EMqNQcnjGFvbDLZtA1bqQbsbD35Q0/TFinWuB5+givlZzqh2NDnYcWtVDGfBt9EuMoRbL3Uf9y0fJB8dBR7EmVQ8hFemoaZb27bzV2vZordPioA7Cf+xzBOo4MuiSEjqPZSLqSwMO0kaptsuYShklga8Mm1LUEt6YYrQklREBnXni/6JrYqW6JlhA4NYPrrKU/1ZVPdc4A4M8UF2/tq2+8TxkkiAhed6gPI7JOOnayBX6xoXBl1BIH3IvT8nYD3uDuBjvtvlsG70lL8wssI32oTUNnTpzOxwDZA+eEuCCyy8uSyx8mtQzZP6xDXlZOhvz0McqsG8SuuoaKtAh/IgEBFymzazLCPmNoEsF1QbxpHQmJ0EsKK/+qhqrbbr54uAkWWnS3gR+dwj48iRUypC4eGpgHlpYG/6SiWgSnD4cmUWH4A5IRdhtpbY5R1GNK5ndlJlenXFPLBNdeKCl9drkCDUUReN8YLLINHSw1FHMO/Vo9AZyMVeaxWxCrr3cWvsxtijM3fV91sBifOqc70nGy6NbEDpD8wQtihkYqeMyw+FbhVK/sYy39WFB0qMaTDwGSgEPA2Sl2yWtThdjuscfDnwmgWurBGEge46FNLv87r78CC/rYwD4dSD4TJCuUkMlvK9NdoSe2rcLP+CUB3M0afTidVsQGCLKLIlKDgXS 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)(136003)(376002)(39840400004)(346002)(451199021)(46966006)(36840700001)(83380400001)(6266002)(47076005)(478600001)(26005)(1076003)(2616005)(66574015)(336012)(186003)(966005)(36860700001)(356005)(81166007)(8676002)(8936002)(82310400005)(2906002)(41300700001)(36756003)(4326008)(316002)(40480700001)(6666004)(86362001)(42186006)(110136005)(44832011)(30864003)(70206006)(5660300002)(54906003)(70586007);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 19:22:56.4708 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b99daa0b-69f4-4f1d-3298-08db570c1e7d 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: DB8EUR06FT027.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB9055 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR,URIBL_BLOCKED autolearn=no 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?1766170734179503441?= X-GMAIL-MSGID: =?utf-8?q?1766170734179503441?= Initiated by a comment from Vincent Mailhol 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. 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 194aa1cf37b5..23a568bfcdc2 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) /* 0x10 */ /* esd CAN message flags - id field */ -#define ESD_EXTID BIT(29) /* 0x20000000 */ -#define ESD_EVENT BIT(30) /* 0x40000000 */ -#define ESD_IDMASK 0x1fffffff +#define ESD_USB_EXTID BIT(29) /* 0x20000000 */ +#define ESD_USB_EVENT BIT(30) /* 0x40000000 */ +#define ESD_USB_IDMASK 0x1fffffff /* 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 0x7fffffff /* 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 0x00800000 +/* 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_3_SAMPLES 0x00800000 /* 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_3_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 Wed May 17 19:22:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 95516 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp9581vqo; Wed, 17 May 2023 12:42:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7BaUyW0NTfoAlqD8zXbTveHbPMW1zV3Un2iZKEI3Da8e9API8WcSTcGA/6MF2PFaBR8wz2 X-Received: by 2002:a05:6a21:9993:b0:102:c96b:f147 with SMTP id ve19-20020a056a21999300b00102c96bf147mr4106465pzb.17.1684352524998; Wed, 17 May 2023 12:42:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684352524; cv=pass; d=google.com; s=arc-20160816; b=ByQRxqahzUdIdn5i/SGw4wCal/A54zI5j54wm509F5s9XZqgQRRqrrDEh4aa8wslaE AN28yQZkwfVd7U8IefV67wePKuEACDO7svi8voYBJcLB3Cb8lE7SgEY7cBYD0xcmTyvo GjHK/kg0LDTg71B+u0o/epAom1roMukbbo1kEmMEo7gCuHrMPh0S9nVwRKsDamcDcJCx fTB0P/X89XgfWznz/1vgcdQ+134nNuDykY31GeKWu/D/3SVoCsPtEgwkNNtMCRpAfR5K w0PuolGxF23iIFtzJPGsmLN6lc+i1AAAZrNQ8xa/ABVlROGjZgjngc01q/MgtleaGbfK ftdA== 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=BIBaIuCZHHN+URf33tUXG+aW7GVOm8HnxPLxte2Sxh8=; b=g6p/mIyYQGJz+69nFLc55SZLx6/DhMKFgeRilIqQ5LwYrOItRrGt9nnoiozms9+tmq PMupk2jwaL4YWJhXL6UWlMi0ul/gCraz9VA3mLwECe3TFPbGagitOVqiO7SrPsr99Dp8 2sxDrguLh0EzB5zD3mL9zEmhrwSjDBp3wHi0HJVruUwsxPkzYyhq66rWS8kuft0R1NIX +hD14L8cIkYSsA1hD7SzV3KXA5ZGmD6SCM4x4yGDVJaGi3gIxosAORwW2OSIDxtj/jev 72MEWWZwB9+miAprHwt5Z70qHso8noSxJzNk9tem6m/OiRYQVg9BJXcr63RQfm3jLuwE lvjQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=rLGLXd51; 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 c136-20020a63358e000000b0051f179c48e7si12507426pga.866.2023.05.17.12.41.26; Wed, 17 May 2023 12:42:04 -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=rLGLXd51; 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 S230092AbjEQTXX (ORCPT + 99 others); Wed, 17 May 2023 15:23:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230093AbjEQTXL (ORCPT ); Wed, 17 May 2023 15:23:11 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2092.outbound.protection.outlook.com [40.107.8.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78C8D55B3; Wed, 17 May 2023 12:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eYzy5kZNLP3m7FuzFjwEiBR1wTbDYT+3tuB86xG2GdBaSRNfNDq3fym6rWScU2yR0Zc/9qfLWp1JJstEgOKX90PMUt3LAOCzowil6GYmKEwLQl5kvZhIwFIVnAEmYp/QjvbkQXkBWUqeGIW1HSvFVOZjeIZYXUnxz9NXHHYNsY2Cyz1t1jucfzObTDYt7CMWE90rxjTsN1CnBrYhcdH/+mTxVBXldNELgX7m7s7h8Dv7YS2KnzKQ3UJMCLeW4Xctkz31czOx+5JxGhdV344Kf3gf7NU3E2DjUlChW4UcGoY9dzfsVd2COd9eiv7VhmWHy2XrhIhp4YhteW8WrIMcgA== 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=BIBaIuCZHHN+URf33tUXG+aW7GVOm8HnxPLxte2Sxh8=; b=R283vVGX6pJbg9scP8Ib9W1gLop5TKFkMnsAJKFM2jXrWxqZwQ5yaphJxGFfdy3YQQTj3OdypgLRwQxxURXawsOif1m/vhRLPKS0fW4oFggcaonJSa6qKaYNLgj2+ZdzUl/Rj0hlsYIqpL+ZKhFSSklSJJ6k54aFxtVDFvHRkk8hsyOJD7lsFHMzSY0mUJY37bJUz3o2R87/MLfXwlaGopuux2DB8derToMw87qn/Hpk7LPbZXdUcW9k4GOJRdJM+U5sLAlZsNfrq9MF29qHd0P6hrFpAAc7ib5xLVAG3Gl84mq2NBzxUQEBgWQ7VOiSHWV+6NukRlEHoqdbrRnDpQ== 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=BIBaIuCZHHN+URf33tUXG+aW7GVOm8HnxPLxte2Sxh8=; b=rLGLXd51an1Qbl4HBi6B1UaokH1XmH4AbzF7z7A+HBkBwFAUHKWt7CqB7z0hHfiUWSK1P7tmhQGjrQ1SjEdtH9ZkXu5RaMxlBM34byQXcOY63Vs6n5OlCqS56E+CPPVqFHmoom+GGilEyX98c/iKBl78YuXiij1MpzB22eIwX7I= Received: from AS9PR06CA0012.eurprd06.prod.outlook.com (2603:10a6:20b:462::34) by AS8PR03MB7816.eurprd03.prod.outlook.com (2603:10a6:20b:34e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Wed, 17 May 2023 19:22:57 +0000 Received: from AM7EUR06FT010.eop-eur06.prod.protection.outlook.com (2603:10a6:20b:462:cafe::45) by AS9PR06CA0012.outlook.office365.com (2603:10a6:20b:462::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 19:22:57 +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 AM7EUR06FT010.mail.protection.outlook.com (10.233.255.222) with Microsoft SMTP Server id 15.20.6411.18 via Frontend Transport; Wed, 17 May 2023 19:22:57 +0000 Received: from esd-s20.esd.local (jenkins.esd [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id E1D547C16CD; Wed, 17 May 2023 21:22:55 +0200 (CEST) Received: by esd-s20.esd.local (Postfix, from userid 2046) id DAD5B2E1806; Wed, 17 May 2023 21:22:55 +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 4/6] can: esd_usb: Prefix all structures with the device name Date: Wed, 17 May 2023 21:22:49 +0200 Message-Id: <20230517192251.2405290-5-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230517192251.2405290-1-frank.jungclaus@esd.eu> References: <20230517192251.2405290-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM7EUR06FT010:EE_|AS8PR03MB7816:EE_ X-MS-Office365-Filtering-Correlation-Id: 03e5afbb-336e-40a8-9e24-08db570c1ed7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IGPS6w5hGrJgrkCyJ+0Kp6VUc9ty9jbuMGSbjpf9ZmtYfrOGofv/HUx5PMRvSAqi5comWfoP/af7e4JXhu4mWBQgpIKTW5/WPxuE4NG838+tGB0mvM37yn1bXkxDcQId63jg4KQWlUeLXryMeCdkhAJM4CgRPyT13NEySB+aIDDkhq78/KO3zdt9yvgj/X5LdtNrwzWmoRregJn6W2iqRE6SyiCeoZy2wAvEgdKRZRZzin2MWvDIBV/t0ZgSFL0NeYqwHXKwy4V/nAvbVXe4k8C/49o3WChuaGuYknJkAkKuB28GsvIvpFL+RWkvAnm1Js4zQbAtvQ74SOq9Qbv17IgxI1QkmuAi9Fea0J44dW60a/vdaNv4nZwdd4N9Oe4FoR/I9/sJJE6klZ2+9iSiEGud1LzIC0HWfXSCVqKhYW1AWuOIz9hmRPNb16hxIdjTA0T9QsN12xdvm8tVRnI2EXBgrZVZJyOiINcXQhB8iGlEqGb8GadXViIhcdvRH+KaVNSVTZPF+k40JWhiOEbNDM6Qj2JmXVZy82Go1E0wbBH+Ju5BkDekFMi7e/6ewNPBGP0S5QAh6wbafvGKNs7XfPR9LSq9hX5V/66EFwaRRG5qDcCWHv1r3yIt1Qp9LrI3p3wuWipw1xDddLN0vNikWOn8JtFhu+WpSg/JL/dAJdsa4/OPw99f5b75JjoN4ud1ut2s30+ImI3lgZgBCVcwNH4roYwqLM9jfXJvtx0SpnE= 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)(39840400004)(136003)(376002)(346002)(451199021)(36840700001)(46966006)(83380400001)(6266002)(186003)(26005)(1076003)(36756003)(40480700001)(6666004)(36860700001)(43170500006)(336012)(966005)(2616005)(4326008)(316002)(47076005)(66574015)(2906002)(70206006)(82310400005)(70586007)(8936002)(8676002)(86362001)(44832011)(5660300002)(41300700001)(54906003)(42186006)(478600001)(110136005)(81166007)(356005);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 19:22:57.0790 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 03e5afbb-336e-40a8-9e24-08db570c1ed7 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: AM7EUR06FT010.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB7816 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=no 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?1766171633110847149?= X-GMAIL-MSGID: =?utf-8?q?1766171633110847149?= As suggested by Vincent Mailhol 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 23a568bfcdc2..1a51a8541bdd 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 Wed May 17 19:22:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 95505 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2618vqo; Wed, 17 May 2023 12:27:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7zWqcKLvcDJYnumKVOACu+S1/jmRyhqXjFE4y5JGwdb7TOTNGr3PAuOeSkMSUVbkT5JafQ X-Received: by 2002:a05:6a20:7283:b0:106:5dff:5ded with SMTP id o3-20020a056a20728300b001065dff5dedmr13183126pzk.8.1684351651652; Wed, 17 May 2023 12:27:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684351651; cv=pass; d=google.com; s=arc-20160816; b=hnKpXY7VxYbD3n2m7qHkUVfjxk5gYooCxpy+f2axslIh8v0gGodvwAN4vWLuhXfHoU 5QIqFndZo2YB/rrH5dhca7oRmKQEHi+FwO76FEwfIvXJRZr/V1oKBh7bybPiK+x6EauJ yN/NIsplghZxdzouofQVuwcV7yrDz/2CcZTMvVcxWM9frEZ/cSrXA0ZQgRTdtG40WuSB eYjRvlZO87wJEa5ykpp3iyM10KvDxHgyGj6UB+HZcSUXhA4yfkR6UwAm6P2aNN08jUT+ AbNuyq2USBiz1gOQPKXzi1ccyzjkF9nVu4xh2c2hDOE+wuKGHafAM7GtR12mUZ1F1Apc 7bgg== 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=JQcvexl/oTObPkA5NZsRh+F1iG6lKA3Khz5eprQn41Y=; b=Q514ezN2F1PQ9gPOWLO6NONu09Vyk3Pw+2c4YU9kAOZBHKZoLU8qxxWJqB6yiPYvV5 vcsmKT92HalFDhPhrtN8l5aOF1hM518cMhTSbtIhPx8bzKvhvMi/q8alrJ5XV3rOPy2K vHvgRolpFysz0pd3McPuPspvE6reowWbv6lvnNTHUZ58ZnLIusWlp21nsncVj//5qH5D utaz1YKdUW/+0jluFlVsQDQO4CXS2TkBzoGdCXIDwASP6eN2gRN5XlobZ9aht2Qe0Opr hm4RwW9FH9FhGHqkXeE8qqIuilh9EVbLCFrFYQlW5EvSNpFCKBZXQw+O39HryBPmQOoF fnEg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=FxxlVInN; 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 m9-20020a654389000000b00513af1fa0b5si20681412pgp.797.2023.05.17.12.27.19; Wed, 17 May 2023 12:27:31 -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=FxxlVInN; 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 S230114AbjEQTXQ (ORCPT + 99 others); Wed, 17 May 2023 15:23:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230083AbjEQTXL (ORCPT ); Wed, 17 May 2023 15:23:11 -0400 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2130.outbound.protection.outlook.com [40.107.241.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 583A655A9; Wed, 17 May 2023 12:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OU/aGNvbNelVtWUwluaBxNNf3WWB7w7DbUUYSYhF/4vCx4WN9HPOWsUFohlJ9th6pOHUyVyvZgNdeyBcKyxX/rbLJ8j8exr1jHfwT95c2LaI3mwB3sBe4e0wX4LvlXWFX2bdsRRX8kPP213qveAOSN99mL6RyKJBN1j2RYtgp8zGGJlMXStXMlnCBSFzTaeqDLvA6sh5PfveLyVfShbb8lz8OUrCEqhBZ9QogSddC3hmx9KVuA58FglfdOg43I474KoDXN/AP62UqwlBVW7+3MCnWWtyDyFlgq5TVc9kOSat6nWzbXEGmyoQFvFeaL3TQ89EwH5DD+jryx1EBvRe7w== 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=JQcvexl/oTObPkA5NZsRh+F1iG6lKA3Khz5eprQn41Y=; b=PIOnGCn05L8zndZqyPVlrOGba8fMGcfyOR0N2Zl5l5+tIuHeEJXoRmZO0xQNRqmR7GLTvYMgpa0Snpdr3LknlPa8+/pkeE/6fIe0qijQ9D/6UAtIeiZcPXuvrtRceaHOFh/5Ap7+OeRT7sDdzDaUT9Z2Kwcsud593iotNAMftckRnvMJJrSDQlWg+g99eZ8FtIJ/iZkavsDbfslXHgrliUhoWOhZb1RssrBpDZ8Pw/a8IzuN7Puya43P0R3j/f8av2sqF4uC1hqtg8WBRA6Z6sAMVu0VhuiZpccBbsKu+JbTdjosYsc2Fr8qKuD2jlsSy03zDrAxVaT+IDuqdnl1DA== 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=JQcvexl/oTObPkA5NZsRh+F1iG6lKA3Khz5eprQn41Y=; b=FxxlVInNjfzWVpmIdJK0p+DigB39hkMTjZV5W+YRNxQdqA/Yojpog8sH+rj4SkMJnsDCjTJ8ohqVIaH2QXaIJ7vgJ5wipgcc+z1cJFDGGbYOj3QVn+WW0shAON7aSIvlaIY48WPBEzThlw9RgzR7gkC1xJPYdp/gndXPagPEmlI= Received: from DB8PR06CA0058.eurprd06.prod.outlook.com (2603:10a6:10:120::32) by DU2PR03MB8123.eurprd03.prod.outlook.com (2603:10a6:10:2f2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Wed, 17 May 2023 19:22:56 +0000 Received: from DB8EUR06FT040.eop-eur06.prod.protection.outlook.com (2603:10a6:10:120:cafe::5b) by DB8PR06CA0058.outlook.office365.com (2603:10a6:10:120::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.34 via Frontend Transport; Wed, 17 May 2023 19:22:56 +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 DB8EUR06FT040.mail.protection.outlook.com (10.233.253.37) with Microsoft SMTP Server id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 19:22:56 +0000 Received: from esd-s20.esd.local (debby [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id E147C7C16CC; Wed, 17 May 2023 21:22:55 +0200 (CEST) Received: by esd-s20.esd.local (Postfix, from userid 2046) id DE95D2E1801; Wed, 17 May 2023 21:22:55 +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 5/6] can: esd_usb: Replace hardcoded message length given to USB commands Date: Wed, 17 May 2023 21:22:50 +0200 Message-Id: <20230517192251.2405290-6-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230517192251.2405290-1-frank.jungclaus@esd.eu> References: <20230517192251.2405290-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8EUR06FT040:EE_|DU2PR03MB8123:EE_ X-MS-Office365-Filtering-Correlation-Id: df7e7d4e-bb66-4592-1404-08db570c1e62 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IycrqSvzW/X6R0RL/kIgFOv6KoOvCBT87+awgZ4pIXseC6N4uGM3id5nmJ6tPt3aNzfQ2/B+Yi+GufYLf9n1TFQPfNR+5ZkxDq6XbZrVn/7zh3yty9V5jRWKXkHuFal0h8agfv83Jhr2iv5KQirNX7yvIad80KoztD2ya65eVvQvqTcn+jmJk/LcybkOfRsF/8vEVH898Ht7b7vE9M4IT8tjsfWgHQ8Wps9zhsUTQ7gJLBP7FDoWmfdoY7q84d9QWSI0d9SvLNQx6xl0+9y7LvA07hga66X96prhve8I3x+IsHsbCwCRJaxxp7+dM0UdF0MMqcwU2Jedoi7J9qsfkrwAaorybBgm0gsUWggICpLRqWhH2a94/qVLeslV/SRjn39Z25qZP5gCgoSVQNJUQfP/1sXKsV9XlRnWZ6cBhFgm2yK9Z7Hy3eDqgoDet6RA59fmf2rB5D9mB46RtV8Y3rvN5yOTDf/jEcYzbHrFUwaOso6SNbijK2zACFLdU/VJ/JiLX31cK7pQWDq9S8vua14TVZaQDpNlPy42+1m4ITiIBkG/7gDjKFbeQYeE5QaxKUr2xo77K3v05emJSOCVMxfM7xamWb/CfhfviQdpTAvrwVLvk398zQSWqzC1r+oD2IRKTetXzaDj3jF197T4UmlgzzCpthi2Nvc9FWFcGb0idP9dvx9ACMwtXGbmRdKu7JkGQCChRkgtRdBItrZOD437HxcmRLqkl9wlt8x+nZ4= 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)(39830400003)(136003)(376002)(396003)(451199021)(36840700001)(46966006)(5660300002)(41300700001)(336012)(36756003)(2906002)(47076005)(36860700001)(43170500006)(83380400001)(2616005)(15650500001)(81166007)(86362001)(82310400005)(356005)(1076003)(26005)(186003)(6266002)(44832011)(8676002)(8936002)(40480700001)(70586007)(70206006)(478600001)(6666004)(966005)(42186006)(54906003)(316002)(4326008)(110136005);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 19:22:56.2931 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df7e7d4e-bb66-4592-1404-08db570c1e62 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: DB8EUR06FT040.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR03MB8123 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR,URIBL_BLOCKED autolearn=no 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?1766170717232795287?= X-GMAIL-MSGID: =?utf-8?q?1766170717232795287?= Initiated by comments from Vincent Mailhol 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 1a51a8541bdd..9053a338eb88 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 Wed May 17 19:22:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Jungclaus X-Patchwork-Id: 95507 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2798vqo; Wed, 17 May 2023 12:27:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5IQtYGbZfVBLgG7o1I6hqdBW9HzjF+d3okzv+g/wP68nZgB9ARklaKY4CECnqYu20yXR8U X-Received: by 2002:a17:90a:e89:b0:252:a0dc:7950 with SMTP id 9-20020a17090a0e8900b00252a0dc7950mr854249pjx.2.1684351674161; Wed, 17 May 2023 12:27:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684351674; cv=pass; d=google.com; s=arc-20160816; b=scGnWnJNd8+RSwueNWl9mi6wY4+NBtFbMcgn3B5mzIzuS3wUxXfkcm5X/79nLiFlf3 tWftu9/mYzwKW5CiYd8EuX2VLsMYF6Jt8XFoVZ3+zoAH4RpzLMIFpvlVhulHuldvTISZ QYupI5S8wUxH2NDXUQq2jJmGamvfxpjdmdwfxpGOVQYgt9IoX3K/55+SvdV8M57x3iZJ 1T+idHvfiYdCA++UYp1u+TRPihH0Cy6VR5aBEIfo2K1dJ5sZ8Fee3aluTVWoZkUPZaCF Jf3U2wv+5wm/3+ScAgscuNqMAWJN+jAMNKutM1M3ujWP86BLGz2MRILafzis1MookaIE NTyw== 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=1sKspe6hRay20hMky2zp3NpwEURiCoflHTDXOqADBNw=; b=u8WtcITYS/J+c3aayGdbHxA1+LCtOOcJhNHUhzUvMokKoYhWXCmsLh5woh/Nvl8Eyr /PU7v6TWPlTpXnyW+91gmWjQ/2kVM7XiRKLz3Y1y8a8FmJt5dCcvEHn8f1x60AX+c97L vZWUJKPIHVydvHzBY42ffaEeWOeev3g+Mi7szJpZxo5WzadrQyjtasp0BHyV4HOqpFJJ cWElNXkXhtlLhQZ0T51MKVRRZqRzK5RiyGwJOPrZF3TE5Fe4TTPAgoErjmxDvu/bCPE1 LNcDpDfiIqXz/BC1d0Nl/5XNR2ysOlAIgdPDAEP4AiXnEO8nyvbqhXMrrd7YNSk5V7W8 aMrw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@esdhannover.onmicrosoft.com header.s=selector1-esdhannover-onmicrosoft-com header.b=WD98Kg1r; 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 pg2-20020a17090b1e0200b0024e26f10834si2778643pjb.0.2023.05.17.12.27.41; Wed, 17 May 2023 12:27:54 -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=WD98Kg1r; 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 S230164AbjEQTXf (ORCPT + 99 others); Wed, 17 May 2023 15:23:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbjEQTXP (ORCPT ); Wed, 17 May 2023 15:23:15 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2112.outbound.protection.outlook.com [40.107.8.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82AA9170E; Wed, 17 May 2023 12:23:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FCfc7hkdBtNRTqXfPSXvWVO2j82omUHa861o+NIR6z4NaJcwx0xMYQDOH+VqxTPBd4NAgG0uPgIrR9U7FXT51A908Gk6glhqrmtzBRJT5t4X80DKTFn8VS7hmySXz7KLJoABG+NJmhw9kcEYM1CobEVcHKvgbKTYXT64fExVjVhnxr6IYz3He6So0qtWdas/YXlTmjf5YEixhwbqaDz3B4a51NfoVO4cEWsXx9Jbm0+rLQibeqs1g+7Npm02KZuvPkR4u6wPa3wcydf9WAMFtqy/V5rhXg85KLcteM6BIhNHQrBkAJl8PNEcGpUlqCJ64fCH5C+I+H9UM+hZmGuN/w== 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=1sKspe6hRay20hMky2zp3NpwEURiCoflHTDXOqADBNw=; b=llUWfSItqvhIM+bGveqU9anZ5VlrIHdF0X0ouvkJprOYdyUOxaJvKz1ioINXUMb1Q/m4Uxv3mLvpUAxv1H8YNyWqP5a0zBSCg1hTja+RY67PoYMtaWfCnQP4bBa/ZXRLPkxriWOjb0nLNbeKMD9f+ovhmYetN6ke61QDLMVqX/Uj0aqE3oBcx9bR2XDXwAokxvtbIFI3oPcJgegygoL+dizrVzTbduaJnwq4lWcLEgIGVHjauzpMhzQsAHirzZTjkcazoLmYX7uczrNALhSBpq+Afy6xiZ2+/q5gBr8W5Q1fl+lgNVMHku7U2+zqHlB1WFxjcqiZYYrxOWTiW4F2aw== 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=1sKspe6hRay20hMky2zp3NpwEURiCoflHTDXOqADBNw=; b=WD98Kg1rUrLp7reEPpz7CVXCdtjIbzQjGKypPWqCZwxpG7UQg0ROcdG16vqQl6HG3EqkN0jOLBRHCktEtmfrvEDF6J41+MBdzVVHGo9qzZeS8qLR9QRamrjLz/8zjbiry06fDnXZXIPyObywjGAxIg2LbH0HOiCNhpJUoP5tNPg= Received: from DBBPR09CA0028.eurprd09.prod.outlook.com (2603:10a6:10:d4::16) by PAVPR03MB9847.eurprd03.prod.outlook.com (2603:10a6:102:31b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30; Wed, 17 May 2023 19:22:57 +0000 Received: from DB8EUR06FT044.eop-eur06.prod.protection.outlook.com (2603:10a6:10:d4:cafe::9f) by DBBPR09CA0028.outlook.office365.com (2603:10a6:10:d4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33 via Frontend Transport; Wed, 17 May 2023 19:22:57 +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 DB8EUR06FT044.mail.protection.outlook.com (10.233.253.24) with Microsoft SMTP Server id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 19:22:56 +0000 Received: from esd-s20.esd.local (jenkins.esd.local [10.0.0.190]) by esd-s7.esd (Postfix) with ESMTPS id E59C87C16CE; Wed, 17 May 2023 21:22:55 +0200 (CEST) Received: by esd-s20.esd.local (Postfix, from userid 2046) id E2B0E2E1801; Wed, 17 May 2023 21:22:55 +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 6/6] can: esd_usb: Don't bother the user with nonessential log message Date: Wed, 17 May 2023 21:22:51 +0200 Message-Id: <20230517192251.2405290-7-frank.jungclaus@esd.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230517192251.2405290-1-frank.jungclaus@esd.eu> References: <20230517192251.2405290-1-frank.jungclaus@esd.eu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8EUR06FT044:EE_|PAVPR03MB9847:EE_ X-MS-Office365-Filtering-Correlation-Id: f6bff02e-5d47-487a-ae22-08db570c1ec5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +oNUHNtQ08g6Lzd1/mF2yCy+cQXW/8XM1RLYOY4ZD7IcSokNz/gRBDAwvw5UCj+F0/jVVI60MTnwCVwXStz6QXX35b8t8YmpSopvBavEkx3hDQsG6oWvYQLdjPadyoYzBpybgKNrbbk2d/AS5e4ED1F7Yfs4jwPB6N5g1EMs8IwoKsCLbkPuRVSYw7YR3VuCSfEDy+RnhaRq4NZiJUxLxl9oy9cN84asxtka0AxFtc80lc6lVIxtvDgXXxnSECMMe4VXYTnydL+7ZvN6ta5SXXZoS257QFdQU5VEvHCN9RyvDbROKXZL7Y8oXv4QJ0yjxk/zkhN+4Db8shRlFa2kr3QmkyEnND5VQ2WO+GUbUhxhhJyn1r1ygCec6hWqiSLhktPncKCCLMWPTgmyUos1w3JeYiGBGiKiBzzTQWJWxBtfSrF/r1v/+GqOGY51kv8sFlbHfoI6uaUPod+UFrdDevHlevnCmtyPcZaPfmifsGiD6fG3IfxCIN/qrfWGGfuWQOP0Xj/diJmZGA12J7YfEGyULdmkCeZ6lrDGkjzbMPvZfeOHrHPgfR163MnQBX0No3dQa1yylcAh6Pr/hLkSl8D9uxRbqWLPcVXykBrhmsRNXnrBAsZbjYSCNKnXGxzcQggaI4iq0NLsv462Q+cLbB2X67QUU12xH3GvMXkAJbS87dM8/noKiVkrLONqHuF8/cxzN34q2ILHVWtsyFUGxg== 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)(39840400004)(136003)(346002)(376002)(396003)(451199021)(46966006)(36840700001)(36756003)(42186006)(86362001)(70586007)(54906003)(110136005)(316002)(478600001)(70206006)(966005)(4326008)(82310400005)(81166007)(40480700001)(15650500001)(8676002)(8936002)(2906002)(44832011)(2616005)(6666004)(356005)(41300700001)(5660300002)(36860700001)(336012)(186003)(1076003)(26005)(47076005)(6266002)(83380400001);DIR:OUT;SFP:1102; X-OriginatorOrg: esd.eu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 19:22:56.9459 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f6bff02e-5d47-487a-ae22-08db570c1ec5 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: DB8EUR06FT044.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR03MB9847 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=no 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?1766170740800773114?= X-GMAIL-MSGID: =?utf-8?q?1766170740800773114?= Initiated by a comment from Vincent Mailhol and suggested by Marc Kleine-Budde 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 9053a338eb88..38212330cf50 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);