Re: [PATCH 28/79] block: rnull: add partial I/O support for bad blocks

From: Andreas Hindborg

Date: Wed Jun 03 2026 - 05:44:49 EST


Alice Ryhl <aliceryhl@xxxxxxxxxx> writes:

> On Mon, Feb 16, 2026 at 12:35:15AM +0100, Andreas Hindborg wrote:

<cut>

>> +fn is_power_of_two<T>(value: T) -> bool
>> +where
>> + T: core::ops::Sub<T, Output = T>,
>> + T: core::ops::BitAnd<Output = T>,
>> + T: core::cmp::PartialOrd<T>,
>> + T: Copy,
>> + T: From<u8>,
>> +{
>> + (value > 0u8.into()) && (value & (value - 1u8.into())) == 0u8.into()
>> +}
>
> This is in the standard library.

But there is no trait for this, the method is defined for concrete
integer types. I would still need to define a trait and macro implement
it for all integers.

We could do this in `kernel::num`?


Best regards,
Andreas Hindborg