Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp351257rdb; Thu, 1 Feb 2024 10:11:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPN19+mxxidjaNkWy3hLMDr7/8cfXkhPSJrz89mFT7dJGx0r3bdWyttBTcDqp76nTYoBku X-Received: by 2002:a17:90a:5e09:b0:290:7739:b886 with SMTP id w9-20020a17090a5e0900b002907739b886mr5366607pjf.29.1706811086478; Thu, 01 Feb 2024 10:11:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706811086; cv=pass; d=google.com; s=arc-20160816; b=UuYT3irDDsY2sLY/zBtARw4ghdkwPLX4RdrYO+trIDksg2xrNoAkaOlNBdN04WBMZn NkppA7dHKyMxVrYP+BwVYz5ybs/eZU/Cl3yWRX5PWvlYTCOaqw6bv8we7llVpkuaGCN6 ydL3fGR9AW0jL036nNsBjqC8t/7dKquTUwZQ9h6QLCw0UGhOnQbXW4i3u1TsyQHYAH4G 95xsfMdc9O3azABXwn7f5+392aOwZQMyiUvcJhEWvU0bFO75M0ET+MiURXaOnCxXI081 gpikrnT5UO5ei/76nWiTheJDeTzWtkfXXGn9aMNpeNQ925yanaOgm3+SO4wsvcb23fvq R46Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from; bh=/BU9D4HcvXvKXNPcylF3xNxeKcyxIj1bNUEaYf083ys=; fh=FzMMVv+TgLqHmRNvmDNELKM7pPmYRJ2/WMjde6lvwiI=; b=YX6tUyYLEwTqyg/uzsWwy5CsgXbsfha6pxlR4uRfNBWLPd335VR4APEZO0xXGifTLI cEGiaQLFXLegSfp4BHsOUSjxie+F9BZ4Abkbehk4g8d22xjUpHSoZiygIRl6dRVrpNHi NEYqLv1wYIejDcyqtW2FfPNWviIQCJL+K9qA6eJc8w5rCIb9xb3Vcx7q2uheZdBjJsjT IvoWhfAvYzofBXxqWCtZbHqCnXvytqPH26Q/xNC/RnZgJfPekGLL7EUceZMPS5WJSjq1 mX/6+L4FKxIFenmIn7pb+hmhwpEkYJKlDPWo5oGBRJ0+Xw0ae0CSeBtn7ipt1DjfH/C2 zWHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=christina-quast.de); spf=pass (google.com: domain of linux-kernel+bounces-48662-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48662-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCVp7X/FKzd/znxwMq9mWVBVbXqIkyaDAg1+z5FYyj/To86KiCPzW0bKPZKNa096u3YmDs/LeywzVDAdJdzTblFL1GdHitjoo03eWwmxZg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p12-20020a17090ab90c00b00290eec04cfasi167105pjr.182.2024.02.01.10.11.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:11:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48662-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=christina-quast.de); spf=pass (google.com: domain of linux-kernel+bounces-48662-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48662-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D7DF829AEAD for ; Thu, 1 Feb 2024 18:11:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE2E112E1C1; Thu, 1 Feb 2024 18:07:19 +0000 (UTC) Received: from mail.someserver.de (mail.someserver.de [116.202.193.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8050884FC5; Thu, 1 Feb 2024 18:07:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.202.193.223 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810839; cv=none; b=lhmOxoCR6j9xG30P71NDE43OYBogv2Sahw1MOflrNVBGKJdHjP9u/7HaCQB40l1wMp4f/eEel5S2anzX3vgJJlwUwB8HnJh0nRBNUOsU7Soun0NS2sO2N5JALXZEdz8gayxJEcsFv9QZ+tQAjVF6aHOGJ/vYimuKbflChKlQsqo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810839; c=relaxed/simple; bh=I9yo8gFF9g6Nktp5khK01f/99bXfCpCeui/xCrTFEX0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jaeqw0/DX8LyMACjAD6mrdbcIz4pYRKBWCFCG3ZBMpXtzxZ9FtnUyN2ofn6v7Q3NXiKnBrpozmsSo97HYZF5ECKasOAPURAIUCzpbLqGmW400oBpq8qj55DrKRWncVNAg6px67UKO37LRd50tBJQ/Lw6C6KzLMagDv0SnbtIRkw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=christina-quast.de; spf=pass smtp.mailfrom=christina-quast.de; arc=none smtp.client-ip=116.202.193.223 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=christina-quast.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=christina-quast.de Received: from localhost (unknown [195.162.191.218]) by mail.someserver.de (Postfix) with ESMTPSA id 2965DA21AE; Thu, 1 Feb 2024 19:07:13 +0100 (CET) From: Christina Quast Date: Thu, 01 Feb 2024 19:06:58 +0100 Subject: [PATCH v2 1/3] DONOTMERGE: rust: prelude: add bit function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240201-rockchip-rust-phy_depend-v2-1-c5fa4faab924@christina-quast.de> References: <20240201-rockchip-rust-phy_depend-v2-0-c5fa4faab924@christina-quast.de> In-Reply-To: <20240201-rockchip-rust-phy_depend-v2-0-c5fa4faab924@christina-quast.de> To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , FUJITA Tomonori , Trevor Gross , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiko Stuebner Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, Christina Quast X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706810819; l=1166; i=contact@christina-quast.de; s=20240130; h=from:subject:message-id; bh=I9yo8gFF9g6Nktp5khK01f/99bXfCpCeui/xCrTFEX0=; b=PD/auZkWvS/a6RAELm9LZMt+cqhgGaqOca8QQUD5tdAWmf0dbh8OFZXYaJmqZgB58v2xzsXPY 6aq5k52d6jBD1X+2SRUI45jUSSAeNaaKZovXt/2kXeZa7O2MuqHekKw X-Developer-Key: i=contact@christina-quast.de; a=ed25519; pk=aoQfinjbnr265vCkIZdYteLDcmIqLBhY1m74WfFUU9E= In order to create masks easily, the define BIT() is used in C code. This commit adds the same functionality to the rust kernel. Do not merge this commit, because rust/kernel/types.rs in Rust-for-Linux already contains this functionality and will be merged into next-net soon. But this driver does not compile without this commit, so I am adding it to the patchset to get more feedback on the actual driver. Signed-off-by: Christina Quast --- rust/kernel/prelude.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs index ae21600970b3..16e483de2f27 100644 --- a/rust/kernel/prelude.rs +++ b/rust/kernel/prelude.rs @@ -38,3 +38,19 @@ pub use super::init::{InPlaceInit, Init, PinInit}; pub use super::current; + +/// Returns a `u32` number that has only the `n`th bit set. +/// +/// # Arguments +/// +/// * `n` - A `u32` that specifies the bit position (zero-based index) +/// +/// # Example +/// +/// ``` +/// let b = bit(2); +/// assert_eq!(b, 4); +#[inline] +pub const fn bit(n: u32) -> u32 { + 1 << n +} -- 2.43.0