Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1140137rdf; Sat, 4 Nov 2023 07:58:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOv3QQuLncA0w1cVky6oaKxK+OCRdhNFmhpXBdO/eChcyEpu4x+1En8of2R0IKaRDbkCCI X-Received: by 2002:a05:6a00:178e:b0:68f:ecb9:5fde with SMTP id s14-20020a056a00178e00b0068fecb95fdemr24347245pfg.34.1699109901967; Sat, 04 Nov 2023 07:58:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1699109901; cv=pass; d=google.com; s=arc-20160816; b=CB9bw5tEooScXSLLhOwiu5n+Z9WE/48eu678Kup7IPK6e0VIQkSQLdQ1SZKhB3OuFl XgHmREhpCT4/6pQIyoJrt0Q7BlyTp5Hh5pfw5bNJJluKzlMj6uwTer2iJISo3W2zfK5a 3hroC19UTyYC+yeH43DZmps64BeB4r+2v9oUVw/5AROxtLawz6mEDkTv77vsiDDN3Vu0 uvVsgtLPnq+mfw3iSs3/R7LtRmHn8j+c4FPEMAwlrZNSgQTxCyytaAGjLvjvPr5XV35O xOmW9ytc8ihG+kneq6GUFgyNmmVmfWRdqFdDiN/apO6JhB33LcMzGKd246YqSkSSXDbE YC4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=q9s1hzLmxTaKH8A4FfgTU4rD6Ptfrz1EDgYULeKNc28=; fh=5hdW16im9maL8o7T5IcrZzCiNKCzxex7AHVz03qn0+Q=; b=S0c0vS66bvkigRuSjp+rQN1Sadi6yUYi1+oE63PMrmwUZWB6UQKX5SOOvi49EE1APc qAjmdw+K6WNSvqENK6MKqyw3sp4M5zgCCxhNNFHn+PL2+ngSbjvJcwC6kdQXk/Sl9OpT HIWg+Jrr5eZed/uug6JbWLoxhVKI4AUazVT8yCVZxEMn+Iu16h8RHmauVDZ3+rwcHNN6 lvGwEQhA3fVEAs7JD/4cmQu1L8qXxVOxaFmiwbTsiMw1sJkULAJFZsi5ruYWdioTgs8x HLAYCoDJw9WOSXx8OD2tzPqkRAzipe/EyQGNHF1bq3GNdYZzPONVy3ix5d4DNXdFLKVo QAng== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@garyguo.net header.s=selector1 header.b=KtfpM6U1; arc=pass (i=1 spf=pass spfdomain=garyguo.net dkim=pass dkdomain=garyguo.net dmarc=pass fromdomain=garyguo.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id jc29-20020a056a006c9d00b006c0e3332534si4180925pfb.42.2023.11.04.07.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 07:58:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@garyguo.net header.s=selector1 header.b=KtfpM6U1; arc=pass (i=1 spf=pass spfdomain=garyguo.net dkim=pass dkdomain=garyguo.net dmarc=pass fromdomain=garyguo.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8E948805D5F8; Sat, 4 Nov 2023 07:58:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232273AbjKDO6K (ORCPT + 99 others); Sat, 4 Nov 2023 10:58:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbjKDO6J (ORCPT ); Sat, 4 Nov 2023 10:58:09 -0400 Received: from GBR01-CWX-obe.outbound.protection.outlook.com (mail-cwxgbr01on2138.outbound.protection.outlook.com [40.107.121.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F854136; Sat, 4 Nov 2023 07:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IRJoJjBvsk2s4h2F7ynQJoSmcT2b6wg/N9Wgfbdq9JS5Bf+odNtDSfzE3Q5q4D99ms4t2HghIFVSG9ZP+YXPJDnvZE2ue7n5d1PfcYW8MO6fXH5iwtcTjd4ymV2CP+XYuf6ufHV9sTwFhT7eR9BRcimSvXCEMsXK70csN3eT9EqJW7SP5UZuNQmRMYAf4oMFOEnmM4QARW8h8PvteUCEpaU27PykMbC8wo6mwuxhbunLNeP7TBQeR/2pCxD2WIJRq1idplFIJJPUxfOJ+u/l0EdQ7f4VuKmL8LD0K39c+NVV266t/Z3AMC1zhfMvDXyONVbkY5JO5pUCAUgamxFnRQ== 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=q9s1hzLmxTaKH8A4FfgTU4rD6Ptfrz1EDgYULeKNc28=; b=Gnh4SnTxy+HIORU8M+QuPqUMH1g7gsaSSSHe5cGT5KT4GjaLdhVYyNSdL0n4vr2NC8Je1Iygqug0A1f48UiXT4bbG0Z5tZ3uc1boO9Dz5MghHIwm/3wUDZpUAxZWLbUWbwPrGGmN9DKvaSqliZk9vDvgAi6E4YY2FoCD1bb34K9YbzAb6S8/b0xWCmRp2pLHn/MFtHDNy+oev18Pe8AFWxAOfRp5Gr8kI0U38QT1cN0DACIJOcroEVdxaauTCMXpszGXVD+oDfjRKp/VtVAOlHHjaQ1+70V430J/yCJkjdNymIfpTbLNiVYZ/E2Xoa5kZMh5N7M2HDzKlmJweCn6YQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=garyguo.net; dmarc=pass action=none header.from=garyguo.net; dkim=pass header.d=garyguo.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garyguo.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=q9s1hzLmxTaKH8A4FfgTU4rD6Ptfrz1EDgYULeKNc28=; b=KtfpM6U1ILQO8s3f/PMHAzNjSlgqPL+wYAKqX39SwGcoz7DeSNMnty90zY7E/rQXyLONs544++mAG7mvIScBT1pTD8mTrBixmYUjp1rEKxsEIKz1lGiqLX8p4bfk4L0ySihgOp42i4/7KqSUm7931VTg4Z/I9KK8e2V171VM7bE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=garyguo.net; Received: from LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:253::10) by LO4P265MB6012.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:29e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.25; Sat, 4 Nov 2023 14:58:03 +0000 Received: from LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM ([fe80::6510:fdc7:1dc3:98c2]) by LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM ([fe80::6510:fdc7:1dc3:98c2%4]) with mapi id 15.20.6954.025; Sat, 4 Nov 2023 14:58:03 +0000 From: Gary Guo To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Martin Rodriguez Reboredo , Vincenzo Palazzo Cc: Wedson Almeida Filho , Vlastimil Babka , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] rust: bindings: rename const binding using sed Date: Sat, 4 Nov 2023 14:56:56 +0000 Message-Id: <20231104145700.2495176-1-gary@garyguo.net> X-Mailer: git-send-email 2.40.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: LO4P265CA0149.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c7::13) To LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:253::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LO2P265MB5183:EE_|LO4P265MB6012:EE_ X-MS-Office365-Filtering-Correlation-Id: fbbd5a5f-3b1a-44ac-ea67-08dbdd467212 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gGQApOaF/5BRQcq4xQq9phBEdvQmSt0K/svz9N2rZUljWknVv1I2IVTDZsexoMcNdNCkdRl4QNfefAoObvy2b50SVTFCsdyS6bqqcvD+1/xLT0dU8nzdwMtbvqUQlhZXUn8nd1fyNVSDCpmDT+UszGPV5Mt6oqfmEjfCipXpb7wntEpATr9qmKKOAqtrv//f6oPdLaoTMTdXypiguhHGBMWJTobl9ypUXVOVRGO2WtgWHJ3ddu6wZd6pnHqGAofWvrkwhzV3syq+UsFa88QyD8Dx+vh7swcDxKdykQ/Al6C9NasdjU0P4s0+0EiWZGWtWeJtkFNf38hd6UAf6U94qYM8leaFzQgiZVaHppC3il7DudcJvVqcIU79MpHKwv4pAjyWl0eKpjMlWiH48yAGvPbSK8tygbI7tnE9o/MBO4uOHiKq91mWhb5OIsCU2tiem8ePcNbu7YLXkjZXpc97qOGgWYX9WhXiA2hNa4MKfJGxxuxk5oz4vGww2PqJJothDwxuDhpU1jElN0lWQx0TKEsWUb7jodpV+HlqXfMA8PdiRaP/QCobqe7EfyAucJfoyJUr9vwROvMQxjZlt0sHedb7dm7L3k6cfMRj+/dcqYo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(376002)(136003)(346002)(39830400003)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(6666004)(6506007)(921008)(36756003)(86362001)(38100700002)(478600001)(2906002)(1076003)(6486002)(6512007)(2616005)(83380400001)(110136005)(54906003)(316002)(4326008)(8676002)(8936002)(66946007)(5660300002)(7416002)(66556008)(66476007)(41300700001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?smzAKmZDZuMXtlbVo+BkWAXH2MNQAtZ5M0Q9+ChGjdUrpli+DUtL0KLq1F2w?= =?us-ascii?Q?WjXksFdqxmFHx7sD7GyRadzUNl9dl0qZZOBDgrDyolZb/o+awzjja0xjUZLB?= =?us-ascii?Q?fbWb/XM2bZDtEp86NFYMcDqfL/xyXSGp3IkA+I02y1eGZoL747hOuTGnAHvC?= =?us-ascii?Q?MTUq5ifeS95Cr1s0bDb5Ef1ZK8RKYgVjA7us7xs8fpvXIa/v2v5TTrHt79nw?= =?us-ascii?Q?hiw7dxuEzlQMbuebj/HEf9tubnwhTX74QZ8W91EY35e8YgrF53KDcczR2kJX?= =?us-ascii?Q?YjROAvf3sbgUzFrjfA8B30CzPggKVYQHcOtK285y68F6CuU0O9NJcdh9NUbG?= =?us-ascii?Q?+aW2gmBA/RjF4nJeg3q4/VwWz1sC5yfZ0zEiy9WqfrIQZR7zJCs5jE8ErTRk?= =?us-ascii?Q?W9tfJH1lk4Hha3vOsvbWPn9VqIktXg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q?+bcGx8poinARHAR682065zqgdg8OQPVzunEEvIm3YOdu17Nj2wscmGWDVyAa?= =?us-ascii?Q?J+MrQsEjy14YvXhZ94IfTNrtahzHnJ3/Jv2lfO5EALaBgkMPGN7NRFEL4yQH?= =?us-ascii?Q?WVuvcajv7HRjZ+BMZ21qcGUK4NCVNYwZr24P5OFZ9/YnaQ/BLwghqqCoa7JU?= =?us-ascii?Q?fePWiLOoTuS/qUWJcqDfZZ5qltsMSp6wqkVdnru7KLC3mfw97PoGGr2AITpf?= =?us-ascii?Q?PBUFciTcFLbnq7jGgoXRUW4p1TWSa7Ij4nq2sRTTTInQjOY3e/igazfBVayw?= =?us-ascii?Q?+abibzft5jA0QptUoadtE13oerqnZLxdzlWg54pWI2Cx?= X-OriginatorOrg: garyguo.net X-MS-Exchange-CrossTenant-Network-Message-Id: fbbd5a5f-3b1a-44ac-ea67-08dbdd467212 X-MS-Exchange-CrossTenant-AuthSource: LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2023 14:58:03.5933 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bbc898ad-b10f-4e10-8552-d9377b823d45 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pnitynQhL1+ioTFC3ONuUbg3n0odMSWN7/VXlDVyascEDL+KZUHMM7pCHt9gD0PaeJWGulIO88mKfTK14WmY1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO4P265MB6012 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sat, 04 Nov 2023 07:58:19 -0700 (PDT) Current for consts that bindgen don't recognise, we define a helper constant with const BINDINGS_ = ; in `bindings_helper.h` and then we put pub const : = BINDINGS_; in `bindings/lib.rs`. This is fine that we currently only have 3 constants that are defined this way, but is going to be more annoying when more constants are added since every new constant needs to be defined in two places. This patch changes the way we define constant helpers to const RUST_CONST_HELPER_ = ; and then use `sed` to postprocess Rust code by generated by bindgen to remove the distinct prefix, so user of the binding crate can refer to the name directly. Reviewed-by: Benno Lossin Reviewed-by: Andreas Hindborg Reviewed-by: Martin Rodriguez Reboredo Signed-off-by: Gary Guo --- v1 -> v2: - Changed `RUST_BINDING_` to `RUST_CONST_HELPER_`. rust/Makefile | 2 ++ rust/bindings/bindings_helper.h | 6 +++--- rust/bindings/lib.rs | 3 --- rust/kernel/allocator.rs | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/rust/Makefile b/rust/Makefile index a27f35f924ec..57f7f5e5a95d 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -337,6 +337,8 @@ quiet_cmd_bindgen = BINDGEN $@ $(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \ $(shell grep -Ev '^#|^$$' $(srctree)/$(src)/bindgen_parameters) +$(obj)/bindings/bindings_generated.rs: private bindgen_target_extra = ; \ + sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const \1/g' $@ $(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \ $(src)/bindgen_parameters FORCE $(call if_changed_dep,bindgen) diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h index c91a3c24f607..bfa0fa794dae 100644 --- a/rust/bindings/bindings_helper.h +++ b/rust/bindings/bindings_helper.h @@ -14,6 +14,6 @@ #include /* `bindgen` gets confused at certain things. */ -const size_t BINDINGS_ARCH_SLAB_MINALIGN = ARCH_SLAB_MINALIGN; -const gfp_t BINDINGS_GFP_KERNEL = GFP_KERNEL; -const gfp_t BINDINGS___GFP_ZERO = __GFP_ZERO; +const size_t RUST_CONST_HELPER_ARCH_SLAB_MINALIGN = ARCH_SLAB_MINALIGN; +const gfp_t RUST_CONST_HELPER_GFP_KERNEL = GFP_KERNEL; +const gfp_t RUST_CONST_HELPER___GFP_ZERO = __GFP_ZERO; diff --git a/rust/bindings/lib.rs b/rust/bindings/lib.rs index 9bcbea04dac3..40ddaee50d8b 100644 --- a/rust/bindings/lib.rs +++ b/rust/bindings/lib.rs @@ -48,6 +48,3 @@ mod bindings_helper { } pub use bindings_raw::*; - -pub const GFP_KERNEL: gfp_t = BINDINGS_GFP_KERNEL; -pub const __GFP_ZERO: gfp_t = BINDINGS___GFP_ZERO; diff --git a/rust/kernel/allocator.rs b/rust/kernel/allocator.rs index a8f3d5be1af1..4b057e837358 100644 --- a/rust/kernel/allocator.rs +++ b/rust/kernel/allocator.rs @@ -21,7 +21,7 @@ unsafe fn krealloc_aligned(ptr: *mut u8, new_layout: Layout, flags: bindings::gf let mut size = layout.size(); - if layout.align() > bindings::BINDINGS_ARCH_SLAB_MINALIGN { + if layout.align() > bindings::ARCH_SLAB_MINALIGN { // The alignment requirement exceeds the slab guarantee, thus try to enlarge the size // to use the "power-of-two" size/alignment guarantee (see comments in `kmalloc()` for // more information). base-commit: 3857af38e57a80b15b994e19d1f4301cac796481 -- 2.40.1