On Sun, 2026-09-06 at 18:20 +0200, Danilo Krummrich wrote: > On Sun Sep 6, 2026 at 5:55 PM CEST, Markus Probst wrote: > > @@ -200,10 +203,14 @@ extern "C" fn receive_buf_callback( > > // INVARIANT: `sdev` is valid for the duration of `receive_buf_callback()`. > > let sdev = unsafe { &*sdev.cast::>() }; > > > > - // SAFETY: `receive_buf_callback` is only ever called after a successful call to > > - // `probe_callback`, hence it's guaranteed that `Device::set_drvdata()` has been called > > - // and stored a `Pin>>`. > > - let private_data = unsafe { sdev.as_ref().drvdata_borrow::>() }; > > + // SAFETY: > > + // - `receive_buf_callback` is only ever called after a successful call to `probe_callback`, > > + // hence it's guaranteed that `Device::set_drvdata()` has been called and stored a > > + // `Pin>>`. > > + // - `unbind_callback` calls `serdev_device_pause_rx` before accessing the driver data, > > + // which guarantees that this function will not overlap with it. Thus we have exclusive > > + // access. > > + let private_data = unsafe { sdev.as_ref().drvdata_borrow_mut::>() }; > > This would break the driver core's lifetime design. Any kind of registration > (such as class device, auxiliary, IRQ, etc.) may borrow fields from the bus > device private data. The whole design is based on the guarantee that we never > construct a mutable reference of the bus device private data. Thanks for the info. That explains why unbind doesn't provide a mutable reference on platform drivers either. I will drop the 2 patches in the next revision. Thanks - Markus Probst