Re: [PATCH v12 5/7] nvmem: core: Rework layouts to become regular devices

From: Miquel Raynal
Date: Wed Oct 11 2023 - 06:33:46 EST


Hi Greg,

gregkh@xxxxxxxxxxxxxxxxxxx wrote on Sat, 7 Oct 2023 18:31:00 +0200:

> On Thu, Oct 05, 2023 at 05:59:05PM +0200, Miquel Raynal wrote:
> > --- a/drivers/nvmem/internals.h
> > +++ b/drivers/nvmem/internals.h
> > @@ -28,8 +28,30 @@ struct nvmem_device {
> > nvmem_reg_read_t reg_read;
> > nvmem_reg_write_t reg_write;
> > struct gpio_desc *wp_gpio;
> > + struct device *layout_dev;
> > struct nvmem_layout *layout;
> > void *priv;
> > };
>
> Wait, is this now 2 struct device in the same structure? Which one is
> the "real" owner of this structure? Why is a pointer to layout_dev
> needed here as a "struct device" and not a real "struct
> nvmem_layout_device" or whatever it's called?
>
> > struct nvmem_layout {
> > - const char *name;
> > - const struct of_device_id *of_match_table;
> > + struct device *dev;
>
> Shouldn't this be a "real" struct device and not just a pointer? If
> not, what does this point to? Who owns the reference to it?

Good point, I've initially tried to create the simplest possible bus,
but you're right it will be nicer if the layout device structure
carries the 'struct device'. I've added a bit of infrstracture but it
looks better, thanks for the suggestion.

Thanks,
Miquèl