[PATCH] rnull: fix bytes_to_sectors()
From: Vitaly Wool
Date: Fri Dec 04 2026 - 05:35:23 EST
From: Igor Belousov <igor.b@xxxxxxxxx>
bytes_to_sectors() shifts the byte count left by SECTOR_SHIFT instead of
right, so it returns bytes * 512 * 512 instead of bytes / 512. Fix that.
Signed-off-by: Igor Belousov <igor.b@xxxxxxxxx>
Signed-off-by: Vitaly Wool <vitaly.wool@xxxxxxxxxxx>
---
drivers/block/rnull/util.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/block/rnull/util.rs b/drivers/block/rnull/util.rs
index 044926c8e284..c6d50e10f5e7 100644
--- a/drivers/block/rnull/util.rs
+++ b/drivers/block/rnull/util.rs
@@ -59,7 +59,7 @@ pub(crate) fn sectors_to_bytes<T>(sectors: T) -> T
pub(crate) fn bytes_to_sectors<T>(bytes: T) -> T
where
- T: core::ops::Shl<u32, Output = T>,
+ T: core::ops::Shr<u32, Output = T>,
{
- bytes << kernel::block::SECTOR_SHIFT
+ bytes >> kernel::block::SECTOR_SHIFT
}
--
2.39.5