Skip to content

Commit f683c9b

Browse files
committed
Merge tag 'driver-core-6.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core fixes from Greg KH: "Here is a single driver core fix, and a .mailmap update. The fix is for the rust driver core bindings, turned out that the from_raw binding wasn't a good idea (don't want to pass a pointer to a reference counted object without actually incrementing the pointer.) So this change fixes it up as the from_raw binding came in in -rc1. The other change is a .mailmap update. Both have been in linux-next for a while with no reported issues" * tag 'driver-core-6.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: mailmap: update mail for Fiona Behrens rust: device: change the from_raw() function
2 parents 36c2545 + bd2b7f6 commit f683c9b

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

.mailmap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ Felix Moeller <felix@derklecks.de>
210210
Fenglin Wu <quic_fenglinw@quicinc.com> <fenglinw@codeaurora.org>
211211
Filipe Lautert <filipe@icewall.org>
212212
Finn Thain <fthain@linux-m68k.org> <fthain@telegraphics.com.au>
213+
Fiona Behrens <me@kloenk.dev>
214+
Fiona Behrens <me@kloenk.dev> <me@kloenk.de>
215+
Fiona Behrens <me@kloenk.dev> <fin@nyantec.com>
213216
Franck Bui-Huu <vagabon.xyz@gmail.com>
214217
Frank Rowand <frowand.list@gmail.com> <frank.rowand@am.sony.com>
215218
Frank Rowand <frowand.list@gmail.com> <frank.rowand@sony.com>

rust/kernel/device.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,9 @@ impl Device {
5151
///
5252
/// It must also be ensured that `bindings::device::release` can be called from any thread.
5353
/// While not officially documented, this should be the case for any `struct device`.
54-
pub unsafe fn from_raw(ptr: *mut bindings::device) -> ARef<Self> {
55-
// SAFETY: By the safety requirements, ptr is valid.
56-
// Initially increase the reference count by one to compensate for the final decrement once
57-
// this newly created `ARef<Device>` instance is dropped.
58-
unsafe { bindings::get_device(ptr) };
59-
60-
// CAST: `Self` is a `repr(transparent)` wrapper around `bindings::device`.
61-
let ptr = ptr.cast::<Self>();
62-
63-
// SAFETY: `ptr` is valid by the safety requirements of this function. By the above call to
64-
// `bindings::get_device` we also own a reference to the underlying `struct device`.
65-
unsafe { ARef::from_raw(ptr::NonNull::new_unchecked(ptr)) }
54+
pub unsafe fn get_device(ptr: *mut bindings::device) -> ARef<Self> {
55+
// SAFETY: By the safety requirements ptr is valid
56+
unsafe { Self::as_ref(ptr) }.into()
6657
}
6758

6859
/// Obtain the raw `struct device *`.

rust/kernel/firmware.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl FwFunc {
4444
///
4545
/// # fn no_run() -> Result<(), Error> {
4646
/// # // SAFETY: *NOT* safe, just for the example to get an `ARef<Device>` instance
47-
/// # let dev = unsafe { Device::from_raw(core::ptr::null_mut()) };
47+
/// # let dev = unsafe { Device::get_device(core::ptr::null_mut()) };
4848
///
4949
/// let fw = Firmware::request(c_str!("path/to/firmware.bin"), &dev)?;
5050
/// let blob = fw.data();

0 commit comments

Comments
 (0)