Skip to contentSkip to conversation

rust: use vertical import style in miscdevice

PATCH Superseded Alvin Sun 2 participants 5 messages May 19

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Alvin Sun

author
#0 lore raw

cover rust: use vertical import style in miscdevice

Reformat use imports to vertical style for readability and to reduce merge conflicts when imports are added or removed.

---
Alvin Sun (2):
rust: miscdevice: use vertical import style
samples: rust_misc_device: use vertical import style

 rust/kernel/miscdevice.rs        | 34 ++++++++++++++++++++++++++++------
 samples/rust/rust_misc_device.rs | 34 ++++++++++++++++++++++++++++------
 2 files changed, 56 insertions(+), 12 deletions(-)

---
base-commit: 5200f5f493f79f14bbdc349e402a40dfb32f23c8
change-id: 20260519-miscdev-use-format-9ab7e83b1c11

Best regards,

Signature · 1 line
Alvin Sun <[email protected]>
author
#1 lore raw

PATCH 1/2 rust: miscdevice: use vertical import style

Convert use imports to vertical layout for better readability and maintainability.

---
 rust/kernel/miscdevice.rs | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
rust/kernel/miscdevice.rs +28 -6
index c3c2052c92069..05a6b6b9770f2 100644
@@ -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)]
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/2] rust: miscdevice: use vertical import style

Quoted 3 lines · Alvin Sun

Convert use imports to vertical layout for better readability and maintainability.

A bunch of these are already available through the prelude, so I would suggest taking the chance to clean those up too, possibly in a separate commit.

Thanks!

Cheers,
Miguel

author
#3 lore raw

Re: [PATCH 1/2] rust: miscdevice: use vertical import style

Quoted 6 lines · Miguel Ojeda
Quoted 2 lines · Alvin Sun

Convert use imports to vertical layout for better readability and maintainability.

A bunch of these are already available through the prelude, so I would suggest taking the chance to clean those up too, possibly in a separate commit.

I'm working on it.

Best regards,
Alvin

Quoted 5 lines

Thanks!

Cheers,
Miguel

author
#4 lore raw

PATCH 2/2 samples: rust_misc_device: use vertical import style

In reply to Alvin Sun

Convert use imports to vertical layout for better readability and maintainability.

---
 samples/rust/rust_misc_device.rs | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
samples/rust/rust_misc_device.rs +28 -6
index 87a1fe63533ae..41e26c825060b 100644
@@ -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);
Signature · 1 line
2.43.0