From: Greg KH <gregkh@linuxfoundation.org>
To: Danilo Krummrich <dakr@kernel.org>
Cc: abdiel.janulgue@gmail.com, daniel.almeida@collabora.com,
robin.murphy@arm.com, a.hindborg@kernel.org, ojeda@kernel.org,
alex.gaynor@gmail.com, boqun.feng@gmail.com, gary@garyguo.net,
bjorn3_gh@protonmail.com, lossin@kernel.org,
aliceryhl@google.com, tmgross@umich.edu, bhelgaas@google.com,
kwilczynski@kernel.org, rafael@kernel.org,
rust-for-linux@vger.kernel.org, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] rust: dma: add DMA addressing capabilities
Date: Wed, 16 Jul 2025 11:15:39 +0200 [thread overview]
Message-ID: <2025071627-outlet-slacker-9382@gregkh> (raw)
In-Reply-To: <20250710194556.62605-3-dakr@kernel.org>
On Thu, Jul 10, 2025 at 09:45:44PM +0200, Danilo Krummrich wrote:
> +/// Returns a bitmask with the lowest `n` bits set to `1`.
> +///
> +/// For `n` in `0..=64`, returns a mask with the lowest `n` bits set.
> +/// For `n > 64`, returns `u64::MAX` (all bits set).
> +///
> +/// # Examples
> +///
> +/// ```
> +/// use kernel::dma::dma_bit_mask;
> +///
> +/// assert_eq!(dma_bit_mask(0), 0);
> +/// assert_eq!(dma_bit_mask(1), 0b1);
> +/// assert_eq!(dma_bit_mask(64), u64::MAX);
> +/// assert_eq!(dma_bit_mask(100), u64::MAX); // Saturates at all bits set.
> +/// ```
> +pub const fn dma_bit_mask(n: usize) -> u64 {
> + match n {
> + 0 => 0,
> + 1..=64 => u64::MAX >> (64 - n),
> + _ => u64::MAX,
> + }
> +}
This is just the C macro DMA_BIT_MASK(), right? If so, can that be said
here somewhere? Or, how about turning DMA_BIT_MASK() into an inline
function which could then be just called by the rust code directly
instead?
Just a minor thing, but it stood out to me here.
thanks,
greg k-h
next prev parent reply other threads:[~2025-07-16 9:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-10 19:45 [PATCH 0/5] dma::Device trait and DMA mask Danilo Krummrich
2025-07-10 19:45 ` [PATCH 1/5] rust: dma: implement `dma::Device` trait Danilo Krummrich
2025-07-10 19:45 ` [PATCH 2/5] rust: dma: add DMA addressing capabilities Danilo Krummrich
2025-07-11 19:35 ` Joel Fernandes
2025-07-11 19:54 ` Danilo Krummrich
2025-07-11 23:40 ` Joel Fernandes
2025-07-11 20:14 ` Miguel Ojeda
2025-07-11 23:45 ` Joel Fernandes
2025-07-16 3:18 ` Alexandre Courbot
2025-07-16 8:04 ` Danilo Krummrich
2025-07-16 8:12 ` Alexandre Courbot
2025-07-16 9:15 ` Greg KH [this message]
2025-07-16 10:08 ` Danilo Krummrich
2025-07-16 10:20 ` Alice Ryhl
2025-07-10 19:45 ` [PATCH 3/5] rust: pci: implement the `dma::Device` trait Danilo Krummrich
2025-07-10 19:45 ` [PATCH 4/5] rust: platform: " Danilo Krummrich
2025-07-10 19:45 ` [PATCH 5/5] rust: samples: dma: set DMA mask Danilo Krummrich
2025-07-14 13:00 ` [PATCH 0/5] dma::Device trait and " Abdiel Janulgue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2025071627-outlet-slacker-9382@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=a.hindborg@kernel.org \
--cc=abdiel.janulgue@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=robin.murphy@arm.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.