Re: [PATCH v2 1/7] spmi: Implement spmi_subdevice_alloc_and_add() and devm variant
From: Jonathan Cameron
Date: Tue Jul 29 2025 - 14:44:46 EST
> >> +/**
> >> + * struct spmi_subdevice - Basic representation of an SPMI sub-device
> >> + * @sdev: Sub-device representation of an SPMI device
> >> + * @devid: Platform Device ID of an SPMI sub-device
> >> + */
> >> +struct spmi_subdevice {
> >> + struct spmi_device sdev;
> >
> > Having something called a subdevice containing an instance of a device
> > does seem a little odd. Maybe the spmi_device naming is inappropriate after
> > this patch?
> >
>
> A SPMI Sub-Device is a SPMI Device on its own, but one that is child of a device.
>
> Controller -> Device -> Sub-Device
>
> Before this version, I initially added devid to spmi_device, but that felt wrong
> because:
> 1. Sub-devices are children of devices (though, still also devices themselves)
> 2. The devid field would be useless in "main" SPMI devices (struct spmi_device)
> and would not only waste (a very small amount of) memory for each device but,
> more importantly, would confuse people with an unused field there.
>
> So, this defines a SPMI Sub-Device as an extension of a SPMI Device, where:
> - Device has controller-device numbers
> - Sub-device has controller-device.subdev_id numbers.
>
> I don't really see any cleaner way of defining this, but I am completely open to
> any idea :-)
I was thinking it was a specialization at the same level as the old spmi_device
(not it's child). As a child this is fine.
Just showing my complete lack of knowledge of the SPMI code :)
Jonathan
>
> Cheers,
> Angelo
>
>