* [PATCH v2 1/5] rust: miscdevice: use vertical import style
2026-05-20 2:40 [PATCH v2 0/5] rust: use vertical import style and remove redundant imports Alvin Sun
@ 2026-05-20 2:40 ` Alvin Sun
2026-05-20 2:57 ` Onur Özkan
2026-05-20 2:40 ` [PATCH v2 2/5] samples: rust_misc_device: " Alvin Sun
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Alvin Sun @ 2026-05-20 2:40 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich
Cc: rust-for-linux, linux-block, Alvin Sun
Convert `use` imports to vertical layout for better readability and
maintainability.
Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
---
rust/kernel/miscdevice.rs | 34 ++++++++++++++++++++++++++++------
1 file changed, 28 insertions(+), 6 deletions(-)
diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
index c3c2052c92069..05a6b6b9770f2 100644
--- a/rust/kernel/miscdevice.rs
+++ b/rust/kernel/miscdevice.rs
@@ -11,16 +11,38 @@
use crate::{
bindings,
device::Device,
- error::{to_result, Error, Result, VTABLE_DEFAULT_ERROR},
- ffi::{c_int, c_long, c_uint, c_ulong},
- fs::{File, Kiocb},
- iov::{IovIterDest, IovIterSource},
+ error::{
+ to_result,
+ Error,
+ Result,
+ VTABLE_DEFAULT_ERROR, //
+ },
+ ffi::{
+ c_int,
+ c_long,
+ c_uint,
+ c_ulong, //
+ },
+ fs::{
+ File,
+ Kiocb, //
+ },
+ iov::{
+ IovIterDest,
+ IovIterSource, //
+ },
mm::virt::VmaNew,
prelude::*,
seq_file::SeqFile,
- types::{ForeignOwnable, Opaque},
+ types::{
+ ForeignOwnable,
+ Opaque, //
+ },
+};
+use core::{
+ marker::PhantomData,
+ pin::Pin, //
};
-use core::{marker::PhantomData, pin::Pin};
/// Options for creating a misc device.
#[derive(Copy, Clone)]
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2 1/5] rust: miscdevice: use vertical import style
2026-05-20 2:40 ` [PATCH v2 1/5] rust: miscdevice: use vertical import style Alvin Sun
@ 2026-05-20 2:57 ` Onur Özkan
0 siblings, 0 replies; 11+ messages in thread
From: Onur Özkan @ 2026-05-20 2:57 UTC (permalink / raw)
To: Alvin Sun
Cc: Arnd Bergmann, Greg Kroah-Hartman, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich, rust-for-linux,
linux-block, Onur Özkan
On Wed, 20 May 2026 10:40:08 +0800
Alvin Sun <alvin.sun@linux.dev> wrote:
> Convert `use` imports to vertical layout for better readability and
> maintainability.
>
> Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
Reviewed-by: Onur Özkan <work@onurozkan.dev>
> ---
> rust/kernel/miscdevice.rs | 34 ++++++++++++++++++++++++++++------
> 1 file changed, 28 insertions(+), 6 deletions(-)
>
> diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
> index c3c2052c92069..05a6b6b9770f2 100644
> --- a/rust/kernel/miscdevice.rs
> +++ b/rust/kernel/miscdevice.rs
> @@ -11,16 +11,38 @@
> use crate::{
> bindings,
> device::Device,
> - error::{to_result, Error, Result, VTABLE_DEFAULT_ERROR},
> - ffi::{c_int, c_long, c_uint, c_ulong},
> - fs::{File, Kiocb},
> - iov::{IovIterDest, IovIterSource},
> + error::{
> + to_result,
> + Error,
> + Result,
> + VTABLE_DEFAULT_ERROR, //
> + },
> + ffi::{
> + c_int,
> + c_long,
> + c_uint,
> + c_ulong, //
> + },
> + fs::{
> + File,
> + Kiocb, //
> + },
> + iov::{
> + IovIterDest,
> + IovIterSource, //
> + },
> mm::virt::VmaNew,
> prelude::*,
> seq_file::SeqFile,
> - types::{ForeignOwnable, Opaque},
> + types::{
> + ForeignOwnable,
> + Opaque, //
> + },
> +};
> +use core::{
> + marker::PhantomData,
> + pin::Pin, //
> };
> -use core::{marker::PhantomData, pin::Pin};
>
> /// Options for creating a misc device.
> #[derive(Copy, Clone)]
>
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/5] samples: rust_misc_device: use vertical import style
2026-05-20 2:40 [PATCH v2 0/5] rust: use vertical import style and remove redundant imports Alvin Sun
2026-05-20 2:40 ` [PATCH v2 1/5] rust: miscdevice: use vertical import style Alvin Sun
@ 2026-05-20 2:40 ` Alvin Sun
2026-05-20 2:58 ` Onur Özkan
2026-05-20 2:40 ` [PATCH v2 3/5] rust: miscdevice: remove redundant imports Alvin Sun
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Alvin Sun @ 2026-05-20 2:40 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich
Cc: rust-for-linux, linux-block, Alvin Sun
Convert `use` imports to vertical layout for better readability and
maintainability.
Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
---
samples/rust/rust_misc_device.rs | 34 ++++++++++++++++++++++++++++------
1 file changed, 28 insertions(+), 6 deletions(-)
diff --git a/samples/rust/rust_misc_device.rs b/samples/rust/rust_misc_device.rs
index 87a1fe63533ae..41e26c825060b 100644
--- a/samples/rust/rust_misc_device.rs
+++ b/samples/rust/rust_misc_device.rs
@@ -97,14 +97,36 @@
use kernel::{
device::Device,
- fs::{File, Kiocb},
- ioctl::{_IO, _IOC_SIZE, _IOR, _IOW},
- iov::{IovIterDest, IovIterSource},
- miscdevice::{MiscDevice, MiscDeviceOptions, MiscDeviceRegistration},
+ fs::{
+ File,
+ Kiocb, //
+ },
+ ioctl::{
+ _IO,
+ _IOC_SIZE,
+ _IOR,
+ _IOW, //
+ },
+ iov::{
+ IovIterDest,
+ IovIterSource, //
+ },
+ miscdevice::{
+ MiscDevice,
+ MiscDeviceOptions,
+ MiscDeviceRegistration, //
+ },
new_mutex,
prelude::*,
- sync::{aref::ARef, Mutex},
- uaccess::{UserSlice, UserSliceReader, UserSliceWriter},
+ sync::{
+ aref::ARef,
+ Mutex, //
+ },
+ uaccess::{
+ UserSlice,
+ UserSliceReader,
+ UserSliceWriter, //
+ },
};
const RUST_MISC_DEV_HELLO: u32 = _IO('|' as u32, 0x80);
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2 2/5] samples: rust_misc_device: use vertical import style
2026-05-20 2:40 ` [PATCH v2 2/5] samples: rust_misc_device: " Alvin Sun
@ 2026-05-20 2:58 ` Onur Özkan
0 siblings, 0 replies; 11+ messages in thread
From: Onur Özkan @ 2026-05-20 2:58 UTC (permalink / raw)
To: Alvin Sun
Cc: Arnd Bergmann, Greg Kroah-Hartman, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich, rust-for-linux,
linux-block, Onur Özkan
On Wed, 20 May 2026 10:40:09 +0800
Alvin Sun <alvin.sun@linux.dev> wrote:
> Convert `use` imports to vertical layout for better readability and
> maintainability.
>
> Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
Reviewed-by: Onur Özkan <work@onurozkan.dev>
> ---
> samples/rust/rust_misc_device.rs | 34 ++++++++++++++++++++++++++++------
> 1 file changed, 28 insertions(+), 6 deletions(-)
>
> diff --git a/samples/rust/rust_misc_device.rs b/samples/rust/rust_misc_device.rs
> index 87a1fe63533ae..41e26c825060b 100644
> --- a/samples/rust/rust_misc_device.rs
> +++ b/samples/rust/rust_misc_device.rs
> @@ -97,14 +97,36 @@
>
> use kernel::{
> device::Device,
> - fs::{File, Kiocb},
> - ioctl::{_IO, _IOC_SIZE, _IOR, _IOW},
> - iov::{IovIterDest, IovIterSource},
> - miscdevice::{MiscDevice, MiscDeviceOptions, MiscDeviceRegistration},
> + fs::{
> + File,
> + Kiocb, //
> + },
> + ioctl::{
> + _IO,
> + _IOC_SIZE,
> + _IOR,
> + _IOW, //
> + },
> + iov::{
> + IovIterDest,
> + IovIterSource, //
> + },
> + miscdevice::{
> + MiscDevice,
> + MiscDeviceOptions,
> + MiscDeviceRegistration, //
> + },
> new_mutex,
> prelude::*,
> - sync::{aref::ARef, Mutex},
> - uaccess::{UserSlice, UserSliceReader, UserSliceWriter},
> + sync::{
> + aref::ARef,
> + Mutex, //
> + },
> + uaccess::{
> + UserSlice,
> + UserSliceReader,
> + UserSliceWriter, //
> + },
> };
>
> const RUST_MISC_DEV_HELLO: u32 = _IO('|' as u32, 0x80);
>
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 3/5] rust: miscdevice: remove redundant imports
2026-05-20 2:40 [PATCH v2 0/5] rust: use vertical import style and remove redundant imports Alvin Sun
2026-05-20 2:40 ` [PATCH v2 1/5] rust: miscdevice: use vertical import style Alvin Sun
2026-05-20 2:40 ` [PATCH v2 2/5] samples: rust_misc_device: " Alvin Sun
@ 2026-05-20 2:40 ` Alvin Sun
2026-05-20 2:59 ` Onur Özkan
2026-05-20 2:40 ` [PATCH v2 4/5] rust: block: mq: use vertical import style Alvin Sun
2026-05-20 2:40 ` [PATCH v2 5/5] rust: block: mq: remove redundant imports and format Alvin Sun
4 siblings, 1 reply; 11+ messages in thread
From: Alvin Sun @ 2026-05-20 2:40 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich
Cc: rust-for-linux, linux-block, Alvin Sun
Drop `Error`, `Result`, `Pin`, `c_int`, `c_long`, `c_uint`, and
`c_ulong` imports already provided by `kernel::prelude`.
Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
---
rust/kernel/miscdevice.rs | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
index 05a6b6b9770f2..83ce50def5ac9 100644
--- a/rust/kernel/miscdevice.rs
+++ b/rust/kernel/miscdevice.rs
@@ -13,16 +13,8 @@
device::Device,
error::{
to_result,
- Error,
- Result,
VTABLE_DEFAULT_ERROR, //
},
- ffi::{
- c_int,
- c_long,
- c_uint,
- c_ulong, //
- },
fs::{
File,
Kiocb, //
@@ -39,10 +31,7 @@
Opaque, //
},
};
-use core::{
- marker::PhantomData,
- pin::Pin, //
-};
+use core::marker::PhantomData;
/// Options for creating a misc device.
#[derive(Copy, Clone)]
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2 3/5] rust: miscdevice: remove redundant imports
2026-05-20 2:40 ` [PATCH v2 3/5] rust: miscdevice: remove redundant imports Alvin Sun
@ 2026-05-20 2:59 ` Onur Özkan
0 siblings, 0 replies; 11+ messages in thread
From: Onur Özkan @ 2026-05-20 2:59 UTC (permalink / raw)
To: Alvin Sun
Cc: Arnd Bergmann, Greg Kroah-Hartman, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich, rust-for-linux,
linux-block, Onur Özkan
On Wed, 20 May 2026 10:40:10 +0800
Alvin Sun <alvin.sun@linux.dev> wrote:
> Drop `Error`, `Result`, `Pin`, `c_int`, `c_long`, `c_uint`, and
> `c_ulong` imports already provided by `kernel::prelude`.
>
> Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
Reviewed-by: Onur Özkan <work@onurozkan.dev>
> ---
> rust/kernel/miscdevice.rs | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
> index 05a6b6b9770f2..83ce50def5ac9 100644
> --- a/rust/kernel/miscdevice.rs
> +++ b/rust/kernel/miscdevice.rs
> @@ -13,16 +13,8 @@
> device::Device,
> error::{
> to_result,
> - Error,
> - Result,
> VTABLE_DEFAULT_ERROR, //
> },
> - ffi::{
> - c_int,
> - c_long,
> - c_uint,
> - c_ulong, //
> - },
> fs::{
> File,
> Kiocb, //
> @@ -39,10 +31,7 @@
> Opaque, //
> },
> };
> -use core::{
> - marker::PhantomData,
> - pin::Pin, //
> -};
> +use core::marker::PhantomData;
>
> /// Options for creating a misc device.
> #[derive(Copy, Clone)]
>
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 4/5] rust: block: mq: use vertical import style
2026-05-20 2:40 [PATCH v2 0/5] rust: use vertical import style and remove redundant imports Alvin Sun
` (2 preceding siblings ...)
2026-05-20 2:40 ` [PATCH v2 3/5] rust: miscdevice: remove redundant imports Alvin Sun
@ 2026-05-20 2:40 ` Alvin Sun
2026-05-20 2:59 ` Onur Özkan
2026-05-20 2:40 ` [PATCH v2 5/5] rust: block: mq: remove redundant imports and format Alvin Sun
4 siblings, 1 reply; 11+ messages in thread
From: Alvin Sun @ 2026-05-20 2:40 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich
Cc: rust-for-linux, linux-block, Alvin Sun
Convert `use` imports to vertical layout for better readability and
maintainability.
Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
---
rust/kernel/block/mq/gen_disk.rs | 21 +++++++++++++++++----
rust/kernel/block/mq/operations.rs | 17 +++++++++++++----
rust/kernel/block/mq/request.rs | 12 +++++++++---
rust/kernel/block/mq/tag_set.rs | 24 +++++++++++++++++++-----
4 files changed, 58 insertions(+), 16 deletions(-)
diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
index 912cb805caf51..6f599f654f37f 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -7,14 +7,27 @@
use crate::{
bindings,
- block::mq::{Operations, TagSet},
- error::{self, from_err_ptr, Result},
- fmt::{self, Write},
+ block::mq::{
+ Operations,
+ TagSet, //
+ },
+ error::{
+ self,
+ from_err_ptr,
+ Result, //
+ },
+ fmt::{
+ self,
+ Write, //
+ },
prelude::*,
static_lock_class,
str::NullTerminatedFormatter,
sync::Arc,
- types::{ForeignOwnable, ScopeGuard},
+ types::{
+ ForeignOwnable,
+ ScopeGuard, //
+ },
};
/// A builder for [`GenDisk`].
diff --git a/rust/kernel/block/mq/operations.rs b/rust/kernel/block/mq/operations.rs
index 8ad46129a52c4..187b0b7791db9 100644
--- a/rust/kernel/block/mq/operations.rs
+++ b/rust/kernel/block/mq/operations.rs
@@ -6,11 +6,20 @@
use crate::{
bindings,
- block::mq::{request::RequestDataWrapper, Request},
- error::{from_result, Result},
+ block::mq::{
+ request::RequestDataWrapper,
+ Request, //
+ },
+ error::{
+ from_result,
+ Result, //
+ },
prelude::*,
- sync::{aref::ARef, Refcount},
- types::ForeignOwnable,
+ sync::{
+ aref::ARef,
+ Refcount, //
+ },
+ types::ForeignOwnable, //
};
use core::marker::PhantomData;
diff --git a/rust/kernel/block/mq/request.rs b/rust/kernel/block/mq/request.rs
index ce3e30c81cb5e..4e0579660e906 100644
--- a/rust/kernel/block/mq/request.rs
+++ b/rust/kernel/block/mq/request.rs
@@ -9,13 +9,19 @@
block::mq::Operations,
error::Result,
sync::{
- aref::{ARef, AlwaysRefCounted},
+ aref::{
+ ARef,
+ AlwaysRefCounted, //
+ },
atomic::Relaxed,
- Refcount,
+ Refcount, //
},
types::Opaque,
};
-use core::{marker::PhantomData, ptr::NonNull};
+use core::{
+ marker::PhantomData,
+ ptr::NonNull, //
+};
/// A wrapper around a blk-mq [`struct request`]. This represents an IO request.
///
diff --git a/rust/kernel/block/mq/tag_set.rs b/rust/kernel/block/mq/tag_set.rs
index dae9df408a862..c1fd3e047af50 100644
--- a/rust/kernel/block/mq/tag_set.rs
+++ b/rust/kernel/block/mq/tag_set.rs
@@ -8,13 +8,27 @@
use crate::{
bindings,
- block::mq::{operations::OperationsVTable, request::RequestDataWrapper, Operations},
- error::{self, Result},
+ block::mq::{
+ operations::OperationsVTable,
+ request::RequestDataWrapper,
+ Operations, //
+ },
+ error::{
+ self,
+ Result, //
+ },
prelude::try_pin_init,
- types::Opaque,
+ types::Opaque, //
+};
+use core::{
+ convert::TryInto,
+ marker::PhantomData, //
+};
+use pin_init::{
+ pin_data,
+ pinned_drop,
+ PinInit, //
};
-use core::{convert::TryInto, marker::PhantomData};
-use pin_init::{pin_data, pinned_drop, PinInit};
/// A wrapper for the C `struct blk_mq_tag_set`.
///
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2 4/5] rust: block: mq: use vertical import style
2026-05-20 2:40 ` [PATCH v2 4/5] rust: block: mq: use vertical import style Alvin Sun
@ 2026-05-20 2:59 ` Onur Özkan
0 siblings, 0 replies; 11+ messages in thread
From: Onur Özkan @ 2026-05-20 2:59 UTC (permalink / raw)
To: Alvin Sun
Cc: Arnd Bergmann, Greg Kroah-Hartman, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich, rust-for-linux,
linux-block, Onur Özkan
On Wed, 20 May 2026 10:40:11 +0800
Alvin Sun <alvin.sun@linux.dev> wrote:
> Convert `use` imports to vertical layout for better readability and
> maintainability.
>
> Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
Reviewed-by: Onur Özkan <work@onurozkan.dev>
> ---
> rust/kernel/block/mq/gen_disk.rs | 21 +++++++++++++++++----
> rust/kernel/block/mq/operations.rs | 17 +++++++++++++----
> rust/kernel/block/mq/request.rs | 12 +++++++++---
> rust/kernel/block/mq/tag_set.rs | 24 +++++++++++++++++++-----
> 4 files changed, 58 insertions(+), 16 deletions(-)
>
> diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
> index 912cb805caf51..6f599f654f37f 100644
> --- a/rust/kernel/block/mq/gen_disk.rs
> +++ b/rust/kernel/block/mq/gen_disk.rs
> @@ -7,14 +7,27 @@
>
> use crate::{
> bindings,
> - block::mq::{Operations, TagSet},
> - error::{self, from_err_ptr, Result},
> - fmt::{self, Write},
> + block::mq::{
> + Operations,
> + TagSet, //
> + },
> + error::{
> + self,
> + from_err_ptr,
> + Result, //
> + },
> + fmt::{
> + self,
> + Write, //
> + },
> prelude::*,
> static_lock_class,
> str::NullTerminatedFormatter,
> sync::Arc,
> - types::{ForeignOwnable, ScopeGuard},
> + types::{
> + ForeignOwnable,
> + ScopeGuard, //
> + },
> };
>
> /// A builder for [`GenDisk`].
> diff --git a/rust/kernel/block/mq/operations.rs b/rust/kernel/block/mq/operations.rs
> index 8ad46129a52c4..187b0b7791db9 100644
> --- a/rust/kernel/block/mq/operations.rs
> +++ b/rust/kernel/block/mq/operations.rs
> @@ -6,11 +6,20 @@
>
> use crate::{
> bindings,
> - block::mq::{request::RequestDataWrapper, Request},
> - error::{from_result, Result},
> + block::mq::{
> + request::RequestDataWrapper,
> + Request, //
> + },
> + error::{
> + from_result,
> + Result, //
> + },
> prelude::*,
> - sync::{aref::ARef, Refcount},
> - types::ForeignOwnable,
> + sync::{
> + aref::ARef,
> + Refcount, //
> + },
> + types::ForeignOwnable, //
> };
> use core::marker::PhantomData;
>
> diff --git a/rust/kernel/block/mq/request.rs b/rust/kernel/block/mq/request.rs
> index ce3e30c81cb5e..4e0579660e906 100644
> --- a/rust/kernel/block/mq/request.rs
> +++ b/rust/kernel/block/mq/request.rs
> @@ -9,13 +9,19 @@
> block::mq::Operations,
> error::Result,
> sync::{
> - aref::{ARef, AlwaysRefCounted},
> + aref::{
> + ARef,
> + AlwaysRefCounted, //
> + },
> atomic::Relaxed,
> - Refcount,
> + Refcount, //
> },
> types::Opaque,
> };
> -use core::{marker::PhantomData, ptr::NonNull};
> +use core::{
> + marker::PhantomData,
> + ptr::NonNull, //
> +};
>
> /// A wrapper around a blk-mq [`struct request`]. This represents an IO request.
> ///
> diff --git a/rust/kernel/block/mq/tag_set.rs b/rust/kernel/block/mq/tag_set.rs
> index dae9df408a862..c1fd3e047af50 100644
> --- a/rust/kernel/block/mq/tag_set.rs
> +++ b/rust/kernel/block/mq/tag_set.rs
> @@ -8,13 +8,27 @@
>
> use crate::{
> bindings,
> - block::mq::{operations::OperationsVTable, request::RequestDataWrapper, Operations},
> - error::{self, Result},
> + block::mq::{
> + operations::OperationsVTable,
> + request::RequestDataWrapper,
> + Operations, //
> + },
> + error::{
> + self,
> + Result, //
> + },
> prelude::try_pin_init,
> - types::Opaque,
> + types::Opaque, //
> +};
> +use core::{
> + convert::TryInto,
> + marker::PhantomData, //
> +};
> +use pin_init::{
> + pin_data,
> + pinned_drop,
> + PinInit, //
> };
> -use core::{convert::TryInto, marker::PhantomData};
> -use pin_init::{pin_data, pinned_drop, PinInit};
>
> /// A wrapper for the C `struct blk_mq_tag_set`.
> ///
>
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 5/5] rust: block: mq: remove redundant imports and format
2026-05-20 2:40 [PATCH v2 0/5] rust: use vertical import style and remove redundant imports Alvin Sun
` (3 preceding siblings ...)
2026-05-20 2:40 ` [PATCH v2 4/5] rust: block: mq: use vertical import style Alvin Sun
@ 2026-05-20 2:40 ` Alvin Sun
2026-05-20 2:59 ` Onur Özkan
4 siblings, 1 reply; 11+ messages in thread
From: Alvin Sun @ 2026-05-20 2:40 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich
Cc: rust-for-linux, linux-block, Alvin Sun
Drop `Result`, `Pin`, `pin_data`, `pinned_drop`, `PinInit`, and
`try_pin_init` imports already provided by `kernel::prelude`.
Simplify `error` imports and flatten parameters formatting.
Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
---
rust/kernel/block/mq/gen_disk.rs | 7 +++----
rust/kernel/block/mq/operations.rs | 5 +----
rust/kernel/block/mq/request.rs | 2 +-
rust/kernel/block/mq/tag_set.rs | 22 ++++------------------
4 files changed, 9 insertions(+), 27 deletions(-)
diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
index 6f599f654f37f..a2c45bde75a7c 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -12,9 +12,8 @@
TagSet, //
},
error::{
- self,
from_err_ptr,
- Result, //
+ to_result, //
},
fmt::{
self,
@@ -67,7 +66,7 @@ pub fn rotational(mut self, rotational: bool) -> Self {
/// and that it is a power of two.
pub fn validate_block_size(size: u32) -> Result {
if !(512..=bindings::PAGE_SIZE as u32).contains(&size) || !size.is_power_of_two() {
- Err(error::code::EINVAL)
+ Err(EINVAL)
} else {
Ok(())
}
@@ -177,7 +176,7 @@ pub fn build<T: Operations>(
// operation, so we will not race.
unsafe { bindings::set_capacity(gendisk, self.capacity_sectors) };
- crate::error::to_result(
+ to_result(
// SAFETY: `gendisk` points to a valid and initialized instance of
// `struct gendisk`.
unsafe {
diff --git a/rust/kernel/block/mq/operations.rs b/rust/kernel/block/mq/operations.rs
index 187b0b7791db9..0343069b373c7 100644
--- a/rust/kernel/block/mq/operations.rs
+++ b/rust/kernel/block/mq/operations.rs
@@ -10,10 +10,7 @@
request::RequestDataWrapper,
Request, //
},
- error::{
- from_result,
- Result, //
- },
+ error::from_result,
prelude::*,
sync::{
aref::ARef,
diff --git a/rust/kernel/block/mq/request.rs b/rust/kernel/block/mq/request.rs
index 4e0579660e906..d10fb7627c870 100644
--- a/rust/kernel/block/mq/request.rs
+++ b/rust/kernel/block/mq/request.rs
@@ -7,7 +7,7 @@
use crate::{
bindings,
block::mq::Operations,
- error::Result,
+ prelude::*,
sync::{
aref::{
ARef,
diff --git a/rust/kernel/block/mq/tag_set.rs b/rust/kernel/block/mq/tag_set.rs
index c1fd3e047af50..df3f90bfbb817 100644
--- a/rust/kernel/block/mq/tag_set.rs
+++ b/rust/kernel/block/mq/tag_set.rs
@@ -4,8 +4,6 @@
//!
//! C header: [`include/linux/blk-mq.h`](srctree/include/linux/blk-mq.h)
-use core::pin::Pin;
-
use crate::{
bindings,
block::mq::{
@@ -13,22 +11,14 @@
request::RequestDataWrapper,
Operations, //
},
- error::{
- self,
- Result, //
- },
- prelude::try_pin_init,
+ error::to_result,
+ prelude::*,
types::Opaque, //
};
use core::{
convert::TryInto,
marker::PhantomData, //
};
-use pin_init::{
- pin_data,
- pinned_drop,
- PinInit, //
-};
/// A wrapper for the C `struct blk_mq_tag_set`.
///
@@ -47,11 +37,7 @@ pub struct TagSet<T: Operations> {
impl<T: Operations> TagSet<T> {
/// Try to create a new tag set
- pub fn new(
- nr_hw_queues: u32,
- num_tags: u32,
- num_maps: u32,
- ) -> impl PinInit<Self, error::Error> {
+ pub fn new(nr_hw_queues: u32, num_tags: u32, num_maps: u32) -> impl PinInit<Self, Error> {
let tag_set: bindings::blk_mq_tag_set = pin_init::zeroed();
let tag_set: Result<_> = core::mem::size_of::<RequestDataWrapper>()
.try_into()
@@ -77,7 +63,7 @@ pub fn new(
// SAFETY: we do not move out of `tag_set`.
let tag_set: &mut Opaque<_> = unsafe { Pin::get_unchecked_mut(tag_set) };
// SAFETY: `tag_set` is a reference to an initialized `blk_mq_tag_set`.
- error::to_result( unsafe { bindings::blk_mq_alloc_tag_set(tag_set.get())})
+ to_result( unsafe { bindings::blk_mq_alloc_tag_set(tag_set.get())})
}),
_p: PhantomData,
})
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2 5/5] rust: block: mq: remove redundant imports and format
2026-05-20 2:40 ` [PATCH v2 5/5] rust: block: mq: remove redundant imports and format Alvin Sun
@ 2026-05-20 2:59 ` Onur Özkan
0 siblings, 0 replies; 11+ messages in thread
From: Onur Özkan @ 2026-05-20 2:59 UTC (permalink / raw)
To: Alvin Sun
Cc: Arnd Bergmann, Greg Kroah-Hartman, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich, rust-for-linux,
linux-block, Onur Özkan
On Wed, 20 May 2026 10:40:12 +0800
Alvin Sun <alvin.sun@linux.dev> wrote:
> Drop `Result`, `Pin`, `pin_data`, `pinned_drop`, `PinInit`, and
> `try_pin_init` imports already provided by `kernel::prelude`.
>
> Simplify `error` imports and flatten parameters formatting.
>
> Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
Reviewed-by: Onur Özkan <work@onurozkan.dev>
> ---
> rust/kernel/block/mq/gen_disk.rs | 7 +++----
> rust/kernel/block/mq/operations.rs | 5 +----
> rust/kernel/block/mq/request.rs | 2 +-
> rust/kernel/block/mq/tag_set.rs | 22 ++++------------------
> 4 files changed, 9 insertions(+), 27 deletions(-)
>
> diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
> index 6f599f654f37f..a2c45bde75a7c 100644
> --- a/rust/kernel/block/mq/gen_disk.rs
> +++ b/rust/kernel/block/mq/gen_disk.rs
> @@ -12,9 +12,8 @@
> TagSet, //
> },
> error::{
> - self,
> from_err_ptr,
> - Result, //
> + to_result, //
> },
> fmt::{
> self,
> @@ -67,7 +66,7 @@ pub fn rotational(mut self, rotational: bool) -> Self {
> /// and that it is a power of two.
> pub fn validate_block_size(size: u32) -> Result {
> if !(512..=bindings::PAGE_SIZE as u32).contains(&size) || !size.is_power_of_two() {
> - Err(error::code::EINVAL)
> + Err(EINVAL)
> } else {
> Ok(())
> }
> @@ -177,7 +176,7 @@ pub fn build<T: Operations>(
> // operation, so we will not race.
> unsafe { bindings::set_capacity(gendisk, self.capacity_sectors) };
>
> - crate::error::to_result(
> + to_result(
> // SAFETY: `gendisk` points to a valid and initialized instance of
> // `struct gendisk`.
> unsafe {
> diff --git a/rust/kernel/block/mq/operations.rs b/rust/kernel/block/mq/operations.rs
> index 187b0b7791db9..0343069b373c7 100644
> --- a/rust/kernel/block/mq/operations.rs
> +++ b/rust/kernel/block/mq/operations.rs
> @@ -10,10 +10,7 @@
> request::RequestDataWrapper,
> Request, //
> },
> - error::{
> - from_result,
> - Result, //
> - },
> + error::from_result,
> prelude::*,
> sync::{
> aref::ARef,
> diff --git a/rust/kernel/block/mq/request.rs b/rust/kernel/block/mq/request.rs
> index 4e0579660e906..d10fb7627c870 100644
> --- a/rust/kernel/block/mq/request.rs
> +++ b/rust/kernel/block/mq/request.rs
> @@ -7,7 +7,7 @@
> use crate::{
> bindings,
> block::mq::Operations,
> - error::Result,
> + prelude::*,
> sync::{
> aref::{
> ARef,
> diff --git a/rust/kernel/block/mq/tag_set.rs b/rust/kernel/block/mq/tag_set.rs
> index c1fd3e047af50..df3f90bfbb817 100644
> --- a/rust/kernel/block/mq/tag_set.rs
> +++ b/rust/kernel/block/mq/tag_set.rs
> @@ -4,8 +4,6 @@
> //!
> //! C header: [`include/linux/blk-mq.h`](srctree/include/linux/blk-mq.h)
>
> -use core::pin::Pin;
> -
> use crate::{
> bindings,
> block::mq::{
> @@ -13,22 +11,14 @@
> request::RequestDataWrapper,
> Operations, //
> },
> - error::{
> - self,
> - Result, //
> - },
> - prelude::try_pin_init,
> + error::to_result,
> + prelude::*,
> types::Opaque, //
> };
> use core::{
> convert::TryInto,
> marker::PhantomData, //
> };
> -use pin_init::{
> - pin_data,
> - pinned_drop,
> - PinInit, //
> -};
>
> /// A wrapper for the C `struct blk_mq_tag_set`.
> ///
> @@ -47,11 +37,7 @@ pub struct TagSet<T: Operations> {
>
> impl<T: Operations> TagSet<T> {
> /// Try to create a new tag set
> - pub fn new(
> - nr_hw_queues: u32,
> - num_tags: u32,
> - num_maps: u32,
> - ) -> impl PinInit<Self, error::Error> {
> + pub fn new(nr_hw_queues: u32, num_tags: u32, num_maps: u32) -> impl PinInit<Self, Error> {
> let tag_set: bindings::blk_mq_tag_set = pin_init::zeroed();
> let tag_set: Result<_> = core::mem::size_of::<RequestDataWrapper>()
> .try_into()
> @@ -77,7 +63,7 @@ pub fn new(
> // SAFETY: we do not move out of `tag_set`.
> let tag_set: &mut Opaque<_> = unsafe { Pin::get_unchecked_mut(tag_set) };
> // SAFETY: `tag_set` is a reference to an initialized `blk_mq_tag_set`.
> - error::to_result( unsafe { bindings::blk_mq_alloc_tag_set(tag_set.get())})
> + to_result( unsafe { bindings::blk_mq_alloc_tag_set(tag_set.get())})
> }),
> _p: PhantomData,
> })
>
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread