Skip to contentSkip to conversation

rust: auxiliary: use "kernel vertical" style for imports

PATCH In review Danilo Krummrich 4 participants 17 messages Jan 5 – Jan 7

Subsystems (4)
lore
Share & tools
lore

Danilo Krummrich

author maintainer
#0 lore raw

PATCH 1/5 rust: auxiliary: use "kernel vertical" style for imports

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

---
 rust/kernel/auxiliary.rs              | 21 ++++++++++++++++-----
 samples/rust/rust_driver_auxiliary.rs |  8 +++++---
 2 files changed, 21 insertions(+), 8 deletions(-)
rust/kernel/auxiliary.rs +16 -5
index 56f3c180e8f6..f8273cf165dc 100644
@@ -5,19 +5,30 @@
 //! C header: [`include/linux/auxiliary_bus.h`](srctree/include/linux/auxiliary_bus.h)
 
 use crate::{
-    bindings, container_of, device,
-    device_id::{RawDeviceId, RawDeviceIdIndex},
+    bindings,
+    container_of,
+    device,
+    device_id::{
+        RawDeviceId,
+        RawDeviceIdIndex, //
+    },
     devres::Devres,
     driver,
-    error::{from_result, to_result, Result},
+    error::{
+        from_result,
+        to_result, //
+    },
     prelude::*,
     types::Opaque,
-    ThisModule,
+    ThisModule, //
 };
 use core::{
     marker::PhantomData,
     mem::offset_of,
-    ptr::{addr_of_mut, NonNull},
+    ptr::{
+        addr_of_mut,
+        NonNull, //
+    },
 };
 
 /// An adapter for the registration of auxiliary drivers.
samples/rust/rust_driver_auxiliary.rs +5 -3
index 1e4fb23cfcb0..f148124fe81f 100644
@@ -6,13 +6,15 @@
 
 use kernel::{
     auxiliary,
-    device::{Bound, Core},
+    device::{
+        Bound,
+        Core, //
+    },
     devres::Devres,
     driver,
-    error::Error,
     pci,
     prelude::*,
-    InPlaceModule,
+    InPlaceModule, //
 };
 
 use core::any::TypeId;

base-commit: 7bf97992afa4e815f4ed84638340e2a93de65504

Signature · 1 line
2.52.0
author maintainer
#1 lore raw

PATCH 2/5 rust: platform: use "kernel vertical" style for imports

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

---
 rust/kernel/platform.rs              | 31 +++++++++++++++++++++-------
 samples/rust/rust_driver_platform.rs | 10 ++++++---
 2 files changed, 31 insertions(+), 10 deletions(-)
rust/kernel/platform.rs +24 -7
index bddb593cee7b..8836ac46b066 100644
@@ -5,22 +5,39 @@
 //! C header: [`include/linux/platform_device.h`](srctree/include/linux/platform_device.h)
 
 use crate::{
-    acpi, bindings, container_of,
-    device::{self, Bound},
+    acpi,
+    bindings,
+    container_of,
+    device::{
+        self,
+        Bound, //
+    },
     driver,
-    error::{from_result, to_result, Result},
-    io::{mem::IoRequest, Resource},
-    irq::{self, IrqRequest},
+    error::{
+        from_result,
+        to_result, //
+    },
+    io::{
+        mem::IoRequest,
+        Resource, //
+    },
+    irq::{
+        self,
+        IrqRequest, //
+    },
     of,
     prelude::*,
     types::Opaque,
-    ThisModule,
+    ThisModule, //
 };
 
 use core::{
     marker::PhantomData,
     mem::offset_of,
-    ptr::{addr_of_mut, NonNull},
+    ptr::{
+        addr_of_mut,
+        NonNull, //
+    },
 };
 
 /// An adapter for the registration of platform drivers.
samples/rust/rust_driver_platform.rs +7 -3
index a3044d773176..9537dc38c563 100644
@@ -66,13 +66,17 @@
     acpi,
     device::{
         self,
-        property::{FwNodeReferenceArgs, NArgs},
+        property::{
+            FwNodeReferenceArgs,
+            NArgs, //
+        },
         Core,
     },
-    of, platform,
+    of,
+    platform,
     prelude::*,
     str::CString,
-    sync::aref::ARef,
+    sync::aref::ARef, //
 };
 
 struct SampleDriver {
Signature · 1 line
2.52.0
maintainer Reviewed-by on v1 2/5
#2 lore raw

Re: [PATCH 2/5] rust: platform: use "kernel vertical" style for imports

Quoted 9 lines · Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

author maintainer
#3 lore raw

Re: [PATCH 2/5] rust: platform: use "kernel vertical" style for imports

In reply to Danilo Krummrich
Quoted 9 lines · Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

Applied to driver-core-testing, thanks!

author maintainer
#4 lore raw

PATCH 3/5 rust: driver-core: use "kernel vertical" style for imports

In reply to Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

---
 rust/kernel/device.rs | 14 +++++++++++---
 rust/kernel/devres.rs | 25 +++++++++++++++++++------
 rust/kernel/driver.rs | 12 ++++++++----
 3 files changed, 38 insertions(+), 13 deletions(-)
rust/kernel/device.rs +11 -3
index a13f6ee24b09..ec9b0945b74c 100644
@@ -5,12 +5,20 @@
 //! C header: [`include/linux/device.h`](srctree/include/linux/device.h)
 
 use crate::{
-    bindings, fmt,
+    bindings,
+    fmt,
     prelude::*,
     sync::aref::ARef,
-    types::{ForeignOwnable, Opaque},
+    types::{
+        ForeignOwnable,
+        Opaque, //
+    }, //
+};
+use core::{
+    any::TypeId,
+    marker::PhantomData,
+    ptr, //
 };
-use core::{any::TypeId, marker::PhantomData, ptr};
 
 use crate::str::CStrExt as _;
 
rust/kernel/devres.rs +19 -6
index 835d9c11948e..db02f8b1788d 100644
@@ -8,13 +8,26 @@
 use crate::{
     alloc::Flags,
     bindings,
-    device::{Bound, Device},
-    error::{to_result, Error, Result},
-    ffi::c_void,
+    device::{
+        Bound,
+        Device, //
+    },
+    error::to_result,
     prelude::*,
-    revocable::{Revocable, RevocableGuard},
-    sync::{aref::ARef, rcu, Completion},
-    types::{ForeignOwnable, Opaque, ScopeGuard},
+    revocable::{
+        Revocable,
+        RevocableGuard, //
+    },
+    sync::{
+        aref::ARef,
+        rcu,
+        Completion, //
+    },
+    types::{
+        ForeignOwnable,
+        Opaque,
+        ScopeGuard, //
+    },
 };
 
 use pin_init::Wrapper;
rust/kernel/driver.rs +8 -4
index 9beae2e3d57e..866d5d76ca7e 100644
@@ -90,10 +90,14 @@
 //! [`pci::Driver`]: kernel::pci::Driver
 //! [`platform::Driver`]: kernel::platform::Driver
 
-use crate::error::{Error, Result};
-use crate::{acpi, device, of, str::CStr, try_pin_init, types::Opaque, ThisModule};
-use core::pin::Pin;
-use pin_init::{pin_data, pinned_drop, PinInit};
+use crate::{
+    acpi,
+    device,
+    of,
+    prelude::*,
+    types::Opaque,
+    ThisModule, //
+};
 
 /// The [`RegistrationOps`] trait serves as generic interface for subsystems (e.g., PCI, Platform,
 /// Amba, etc.) to provide the corresponding subsystem specific implementation to register /
Signature · 1 line
2.52.0
maintainer Reviewed-by on v1 3/5
#5 lore raw

Re: [PATCH 3/5] rust: driver-core: use "kernel vertical" style for imports

Quoted 9 lines · Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

author maintainer
#6 lore raw

Re: [PATCH 3/5] rust: driver-core: use "kernel vertical" style for imports

In reply to Danilo Krummrich
Quoted 9 lines · Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

Applied to driver-core-testing, thanks!

author maintainer
#7 lore raw

PATCH 4/5 rust: usb: use "kernel vertical" style for imports

In reply to Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

---
@Greg: If you agree I will take this through the driver-core tree. I will have driver-core patches building on top of this.

---
 rust/kernel/usb.rs              | 21 +++++++++++++++------
 samples/rust/rust_driver_usb.rs | 10 +++++++++-
 2 files changed, 24 insertions(+), 7 deletions(-)
rust/kernel/usb.rs +15 -6
index d10b65e9fb6a..99b07b5ac491 100644
@@ -6,14 +6,23 @@
 //! C header: [`include/linux/usb.h`](srctree/include/linux/usb.h)
 
 use crate::{
-    bindings, device,
-    device_id::{RawDeviceId, RawDeviceIdIndex},
+    bindings,
+    device,
+    device_id::{
+        RawDeviceId,
+        RawDeviceIdIndex, //
+    },
     driver,
-    error::{from_result, to_result, Result},
+    error::{
+        from_result,
+        to_result, //
+    },
     prelude::*,
-    str::CStr,
-    types::{AlwaysRefCounted, Opaque},
-    ThisModule,
+    types::{
+        AlwaysRefCounted,
+        Opaque, //
+    },
+    ThisModule, //
 };
 use core::{
     marker::PhantomData,
samples/rust/rust_driver_usb.rs +9 -1
index 4eaad14867b2..ab72e99e1274 100644
@@ -3,7 +3,15 @@
 
 //! Rust USB driver sample.
 
-use kernel::{device, device::Core, prelude::*, sync::aref::ARef, usb};
+use kernel::{
+    device::{
+        self,
+        Core, //
+    },
+    prelude::*,
+    sync::aref::ARef,
+    usb, //
+};
 
 struct SampleDriver {
     _intf: ARef<usb::Interface>,
Signature · 1 line
2.52.0
reviewer Reviewed-by on v1 4/5
#8 lore raw

Re: [PATCH 4/5] rust: usb: use "kernel vertical" style for imports

Quoted 80 lines · Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

---
@Greg: If you agree I will take this through the driver-core tree. I will have driver-core patches building on top of this.
---
rust/kernel/usb.rs | 21 +++++++++++++++------
samples/rust/rust_driver_usb.rs | 10 +++++++++-

2 files changed, 24 insertions(+), 7 deletions(-)
rust/kernel/usb.rs +15 -6
index d10b65e9fb6a..99b07b5ac491 100644
@@ -6,14 +6,23 @@
 //! C header: [`include/linux/usb.h`](srctree/include/linux/usb.h)
 
 use crate::{
-    bindings, device,
-    device_id::{RawDeviceId, RawDeviceIdIndex},
+    bindings,
+    device,
+    device_id::{
+        RawDeviceId,
+        RawDeviceIdIndex, //
+    },
    driver,
-    error::{from_result, to_result, Result},
+    error::{
+        from_result,
+        to_result, //
+    },
    prelude::*,
-    str::CStr,
-    types::{AlwaysRefCounted, Opaque},
-    ThisModule,
+    types::{
+        AlwaysRefCounted,
+        Opaque, //
+    },
+    ThisModule, //
 };
 use core::{
    marker::PhantomData,
samples/rust/rust_driver_usb.rs +9 -1
index 4eaad14867b2..ab72e99e1274 100644
@@ -3,7 +3,15 @@
 
 //! Rust USB driver sample.
 
-use kernel::{device, device::Core, prelude::*, sync::aref::ARef, usb};
+use kernel::{
+    device::{
+        self,
+        Core, //
+    },
+    prelude::*,
+    sync::aref::ARef,
+    usb, //
+};
 
 struct SampleDriver {
    _intf: ARef<usb::Interface>,
Signature · 1 line
2.52.0

OOC: can rustfmt do this, or is it a manual process for the time being?

#9 lore raw

Re: [PATCH 4/5] rust: usb: use "kernel vertical" style for imports

Quoted 2 lines · Daniel Almeida

OOC: can rustfmt do this, or is it a manual process for the time being?

It does it if you add the //, but adding the // is manual, i.e. it will do what you want but you have to trigger it by having the //:

https://docs.kernel.org/rust/coding-guidelines.html#imports

The goal is that rustfmt does exactly this, but without having to write the // (and without needing/adding the // itself).

I hope that helps!

Cheers,
Miguel

author maintainer
#10 lore raw

Re: [PATCH 4/5] rust: usb: use "kernel vertical" style for imports

In reply to Danilo Krummrich
Quoted 5 lines · Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

Quoted 7 lines

While at it, drop unnecessary imports covered by prelude::*.

---
@Greg: If you agree I will take this through the driver-core tree. I will have driver-core patches building on top of this.

Nevermind, I don't need it in the driver-core tree after all. :)

maintainer
#11 lore raw

Re: [PATCH 4/5] rust: usb: use "kernel vertical" style for imports

Quoted 8 lines · Danilo Krummrich
Quoted 7 lines · Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

Quoted 7 lines
Quoted 5 lines

---
@Greg: If you agree I will take this through the driver-core tree. I will have driver-core patches building on top of this.

Nevermind, I don't need it in the driver-core tree after all. :)

Ok, I'll take it through the usb one now, thanks.

greg k-h

author maintainer
#12 lore raw

PATCH 5/5 rust: faux: use "kernel vertical" style for imports

In reply to Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

---
 rust/kernel/faux.rs | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
rust/kernel/faux.rs +11 -2
index 7fe2dd197e37..43b4974f48cd 100644
@@ -6,8 +6,17 @@
 //!
 //! C header: [`include/linux/device/faux.h`](srctree/include/linux/device/faux.h)
 
-use crate::{bindings, device, error::code::*, prelude::*};
-use core::ptr::{addr_of_mut, null, null_mut, NonNull};
+use crate::{
+    bindings,
+    device,
+    prelude::*, //
+};
+use core::ptr::{
+    addr_of_mut,
+    null,
+    null_mut,
+    NonNull, //
+};
 
 /// The registration of a faux device.
 ///
Signature · 1 line
2.52.0
maintainer Reviewed-by on v1 5/5
#13 lore raw

Re: [PATCH 5/5] rust: faux: use "kernel vertical" style for imports

Quoted 40 lines · Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

---
 rust/kernel/faux.rs | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
rust/kernel/faux.rs +11 -2
index 7fe2dd197e37..43b4974f48cd 100644
@@ -6,8 +6,17 @@
 //!
 //! C header: [`include/linux/device/faux.h`](srctree/include/linux/device/faux.h)
 
-use crate::{bindings, device, error::code::*, prelude::*};
-use core::ptr::{addr_of_mut, null, null_mut, NonNull};
+use crate::{
+    bindings,
+    device,
+    prelude::*, //
+};
+use core::ptr::{
+    addr_of_mut,
+    null,
+    null_mut,
+    NonNull, //
+};
 
 /// The registration of a faux device.
 ///
Signature · 1 line
2.52.0
author maintainer
#14 lore raw

Re: [PATCH 5/5] rust: faux: use "kernel vertical" style for imports

In reply to Danilo Krummrich
Quoted 9 lines · Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

Applied to driver-core-testing, thanks!

maintainer Reviewed-by on v1 1/5
#15 lore raw
In reply to Danilo Krummrich
Quoted 5 lines · Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

Quoted 8 lines

While at it, drop unnecessary imports covered by prelude::*.

---
 rust/kernel/auxiliary.rs              | 21 ++++++++++++++++-----
 samples/rust/rust_driver_auxiliary.rs |  8 +++++---
 2 files changed, 21 insertions(+), 8 deletions(-)
author maintainer
#16 lore raw
In reply to Danilo Krummrich
Quoted 9 lines · Danilo Krummrich

Convert all imports to use "kernel vertical" style.

With this, subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

While at it, drop unnecessary imports covered by prelude::*.

Applied to driver-core-testing, thanks!