Re: [PATCH v3 net-next 3/8] mfd: Add Microchip ZL3073x support

Andy Shevchenko
2025-04-17T16:35:50Z

+Cc: Hans, author of the below mentioned APIs.

On Thu, Apr 17, 2025 at 06:29:01PM +0200, Ivan Vecera wrote:
> On 17. 04. 25 5:42 odp., Andy Shevchenko wrote:
> > > > Would it be acceptable for you something like this:
> > V4L2 (or media subsystem) solve the problem by providing a common helpers for
> > reading and writing tons of different registers in cameras. See the commit
> > 613cbb91e9ce ("media: Add MIPI CCI register access helper functions").
> >
> > Dunno if it helps here, though.
>
> Bingo, this approach looks very good.
>
> I can use unsigned int (32bit) to encode everything necessary:
> Bits 0..15 - register address (virtual range offset, page, offset)
> Bits 16..21 - size in bits (enough for max 48)
> Bits 22..26 - max items (32 values - enough for any indexed register)
> Bits 27..31 - stride between (up to 32 - enough per datasheet)
>
> Only thing I don't like is that MIPI CCI API uses for calls u64 as value:
>
> int cci_read(struct regmap *map, u32 reg, u64 *val, ...);
>
> This forces a caller to use u64 for every register read. I rather to use
> 'void *val' the same way as regmap_read().

You may discuss with them why they choose that and how to make that code shared
more widely if needed.

--
With Best Regards,
Andy Shevchenko