Re: [PATCH v2 2/4] serdev: add private data to serdev_device

From: Danilo Krummrich

Date: Fri Mar 06 2026 - 15:30:14 EST


On Fri Mar 6, 2026 at 8:35 PM CET, Markus Probst wrote:
> Add private data to `struct serdev_device`, as it is required by the
> rust abstraction added in the following commit
> (rust: add basic serial device bus abstractions).
>
> Signed-off-by: Markus Probst <markus.probst@xxxxxxxxx>
> ---
> include/linux/serdev.h | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/serdev.h b/include/linux/serdev.h
> index 5654c58eb73c..b591af23faf0 100644
> --- a/include/linux/serdev.h
> +++ b/include/linux/serdev.h
> @@ -33,12 +33,13 @@ struct serdev_device_ops {
>
> /**
> * struct serdev_device - Basic representation of an serdev device
> - * @dev: Driver model representation of the device.
> - * @nr: Device number on serdev bus.
> - * @ctrl: serdev controller managing this device.
> - * @ops: Device operations.
> - * @write_comp Completion used by serdev_device_write() internally
> - * @write_lock Lock to serialize access when writing data
> + * @dev: Driver model representation of the device.
> + * @nr: Device number on serdev bus.
> + * @ctrl: serdev controller managing this device.
> + * @ops: Device operations.
> + * @write_comp Completion used by serdev_device_write() internally
> + * @write_lock Lock to serialize access when writing data
> + * @private_data Private data for the device driver.

I think this is a bit misleading, as the driver's device private data is stored
in the embedded struct device. This seems to be more about having a place to
store private data of the Rust abstraction.

So, you may want to name this something along the lines of rust_private_data.
Additionally, you should make it very clear that this field must not be used by
drivers directly (i.e. C drivers could easily be tempted to abuse this).

> */
> struct serdev_device {
> struct device dev;
> @@ -47,6 +48,7 @@ struct serdev_device {
> const struct serdev_device_ops *ops;
> struct completion write_comp;
> struct mutex write_lock;
> + void *private_data;
> };
>
> static inline struct serdev_device *to_serdev_device(struct device *d)
>
> --
> 2.52.0