Commit 1e180614 authored by Shankari Anand's avatar Shankari Anand Committed by Danilo Krummrich
Browse files

rust: driver-core: Update ARef and AlwaysRefCounted imports from sync::aref



Update call sites in the driver-core files and its related samples
to import `ARef` and `AlwaysRefCounted` from `sync::aref`
instead of `types`.

This aligns with the ongoing effort to move `ARef` and
`AlwaysRefCounted` to sync.

Suggested-by: default avatarBenno Lossin <lossin@kernel.org>
Link: https://github.com/Rust-for-Linux/linux/issues/1173


Signed-off-by: default avatarShankari Anand <shankari.ak0208@gmail.com>
Link: https://lore.kernel.org/r/20250814104615.355106-1-shankari.ak0208@gmail.com


Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
parent b6a37d1d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -245,7 +245,7 @@ extern "C" fn release(dev: *mut bindings::device) {
kernel::impl_device_context_into_aref!(Device);

// SAFETY: Instances of `Device` are always reference-counted.
unsafe impl crate::types::AlwaysRefCounted for Device {
unsafe impl crate::sync::aref::AlwaysRefCounted for Device {
    fn inc_ref(&self) {
        // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
        unsafe { bindings::get_device(self.as_ref().as_raw()) };
+4 −3
Original line number Diff line number Diff line
@@ -6,7 +6,8 @@

use crate::{
    bindings,
    types::{ARef, ForeignOwnable, Opaque},
    sync::aref::ARef,
    types::{ForeignOwnable, Opaque},
};
use core::{fmt, marker::PhantomData, ptr};

@@ -292,7 +293,7 @@ pub fn fwnode(&self) -> Option<&property::FwNode> {
kernel::impl_device_context_into_aref!(Device);

// SAFETY: Instances of `Device` are always reference-counted.
unsafe impl crate::types::AlwaysRefCounted for Device {
unsafe impl crate::sync::aref::AlwaysRefCounted for Device {
    fn inc_ref(&self) {
        // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
        unsafe { bindings::get_device(self.as_raw()) };
@@ -411,7 +412,7 @@ macro_rules! impl_device_context_deref {
#[macro_export]
macro_rules! __impl_device_context_into_aref {
    ($src:ty, $device:tt) => {
        impl ::core::convert::From<&$device<$src>> for $crate::types::ARef<$device> {
        impl ::core::convert::From<&$device<$src>> for $crate::sync::aref::ARef<$device> {
            fn from(dev: &$device<$src>) -> Self {
                (&**dev).into()
            }
+2 −2
Original line number Diff line number Diff line
@@ -13,8 +13,8 @@
    ffi::c_void,
    prelude::*,
    revocable::{Revocable, RevocableGuard},
    sync::{rcu, Completion},
    types::{ARef, ForeignOwnable, Opaque, ScopeGuard},
    sync::{aref::ARef, rcu, Completion},
    types::{ForeignOwnable, Opaque, ScopeGuard},
};

use pin_init::Wrapper;
+3 −2
Original line number Diff line number Diff line
@@ -13,7 +13,8 @@
    io::{Io, IoRaw},
    irq::{self, IrqRequest},
    str::CStr,
    types::{ARef, Opaque},
    sync::aref::ARef,
    types::Opaque,
    ThisModule,
};
use core::{
@@ -544,7 +545,7 @@ pub fn set_master(&self) {
impl crate::dma::Device for Device<device::Core> {}

// SAFETY: Instances of `Device` are always reference-counted.
unsafe impl crate::types::AlwaysRefCounted for Device {
unsafe impl crate::sync::aref::AlwaysRefCounted for Device {
    fn inc_ref(&self) {
        // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
        unsafe { bindings::pci_dev_get(self.as_raw()) };
+1 −1
Original line number Diff line number Diff line
@@ -468,7 +468,7 @@ pub fn optional_irq_by_name(&self, name: &CStr) -> Result<IrqRequest<'_>> {
impl crate::dma::Device for Device<device::Core> {}

// SAFETY: Instances of `Device` are always reference-counted.
unsafe impl crate::types::AlwaysRefCounted for Device {
unsafe impl crate::sync::aref::AlwaysRefCounted for Device {
    fn inc_ref(&self) {
        // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
        unsafe { bindings::get_device(self.as_ref().as_raw()) };
Loading