Re: [PATCH v9 1/3] rust: add basic serial device bus abstractions

From: Markus Probst

Date: Sat May 30 2026 - 14:09:38 EST


On Sat, 2026-05-30 at 17:36 +0000, Markus Probst wrote:
>
> +#[doc(hidden)]
> +#[pin_data(PinnedDrop)]
> +pub struct PrivateData<'bound, T: Driver> {
> + sdev: &'bound Device<device::Bound>,
> + #[pin]
> + driver: UnsafeCell<MaybeUninit<T::Data<'bound>>>,
> + #[pin]
> + probe_complete: Completion,
> + error: UnsafeCell<bool>,
> +}
> +
> +#[pinned_drop]
> +impl<T: Driver> PinnedDrop for PrivateData<'_, T> {
> + fn drop(self: Pin<&mut Self>) {
> + // SAFETY: No one has exclusive access to `self.error`.
> + if !unsafe { *self.error.get() } {
> + // SAFETY:
> + // - We have exclusive access to `self.driver`.
> + // - `self.driver` is guaranteed to be initialized.
> + unsafe { (*self.driver.get()).assume_init_drop() };
> + }
> +
> + // SAFETY: `self.sdev.as_raw()` is guaranteed to be a pointer to a valid
> + // `struct serdev_device`.
> + unsafe { bindings::serdev_device_close(self.sdev.as_raw()) };
Ok, I might have sent this too early.

ignore for now. This is unsound.

Thanks
- Markus Probst

> + }
> +}
> +

Attachment: signature.asc
Description: This is a digitally signed message part