[PATCH v2 4/6] rust: auxiliary: Support accessing raw aux pointer

Matthew Maurer posted 6 patches 5 days, 4 hours ago
[PATCH v2 4/6] rust: auxiliary: Support accessing raw aux pointer
Posted by Matthew Maurer 5 days, 4 hours ago
While it's preferable to add bindings in the kernel crate rather than
using raw pointers where possible, access to the raw aux pointer is
required to pass it to C interfaces provided by a driver.

Signed-off-by: Matthew Maurer <mmaurer@google.com>
---
 rust/kernel/auxiliary.rs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/rust/kernel/auxiliary.rs b/rust/kernel/auxiliary.rs
index 93c0db1f66555c97ec7dc58825e97c47c0154e54..1a88277f0fd9ea5ff32cc534dfe5682009de94c2 100644
--- a/rust/kernel/auxiliary.rs
+++ b/rust/kernel/auxiliary.rs
@@ -237,7 +237,11 @@ pub struct Device<Ctx: device::DeviceContext = device::Normal>(
 );
 
 impl<Ctx: device::DeviceContext> Device<Ctx> {
-    fn as_raw(&self) -> *mut bindings::auxiliary_device {
+    /// Returns the underlying auxiliary device
+    ///
+    /// Prefer to add bindings in the kernel crate for any use other than calling driver-specific
+    /// functions.
+    pub fn as_raw(&self) -> *mut bindings::auxiliary_device {
         self.0.get()
     }
 

-- 
2.53.0.rc2.204.g2597b5adb4-goog
Re: [PATCH v2 4/6] rust: auxiliary: Support accessing raw aux pointer
Posted by Danilo Krummrich 5 days, 4 hours ago
On Tue Feb 3, 2026 at 4:46 PM CET, Matthew Maurer wrote:
> While it's preferable to add bindings in the kernel crate rather than
> using raw pointers where possible, access to the raw aux pointer is
> required to pass it to C interfaces provided by a driver.
>
> Signed-off-by: Matthew Maurer <mmaurer@google.com>
> ---
>  rust/kernel/auxiliary.rs | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/rust/kernel/auxiliary.rs b/rust/kernel/auxiliary.rs
> index 93c0db1f66555c97ec7dc58825e97c47c0154e54..1a88277f0fd9ea5ff32cc534dfe5682009de94c2 100644
> --- a/rust/kernel/auxiliary.rs
> +++ b/rust/kernel/auxiliary.rs
> @@ -237,7 +237,11 @@ pub struct Device<Ctx: device::DeviceContext = device::Normal>(
>  );
>  
>  impl<Ctx: device::DeviceContext> Device<Ctx> {
> -    fn as_raw(&self) -> *mut bindings::auxiliary_device {
> +    /// Returns the underlying auxiliary device

"Returns a pointer to the underlying `struct auxiliary_device`."

> +    ///
> +    /// Prefer to add bindings in the kernel crate for any use other than calling driver-specific
> +    /// functions.

I'm not sure I understand the message of this comment, but I'd probably just
drop it, the above should be enough.

> +    pub fn as_raw(&self) -> *mut bindings::auxiliary_device {
>          self.0.get()
>      }