Re: [PATCH v5 12/13] spi: mxic: Use spi_mem_generic_supports_op()

Miquel Raynal
2021-12-16T08:15:28Z

Hi Boris,

boris.brezillon@collabora.com wrote on Wed, 15 Dec 2021 19:52:19 +0100:

> On Wed, 15 Dec 2021 18:44:26 +0100
> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>
> > In order to keep the series easy to review I decided to go for the
> > following approach:
> > * Introduce the spi_mem_generic_supports_op_helper() which takes a
> > capabilities structure. This helper gathers all the checks from
> > spi_mem_default_supports_op() and spi_mem_dtr_supports_op(). These
> > two helpers now call the new one with either a NULL pointer in the
> > former case, or a structure with the .dtr parameter set to true in
> > the latter.
>
> Is there a benefit adding an extra NULL check when you could make sure
> all callers pass a zero-initialized caps object when they don't support
> fancy features like DTR or ECC.

That's exactly my point, I really don't like the creation of 15 empty
and useless structures while we could just have a check. If the
controller provides no capabilities, we assure he has none. I don't
think checking "if (caps && caps->PARAM)" hurts. Anyway, if we go for
the spi_mem controller internal structure approach, we might just not
need those.

Thanks,
Miquèl