Re: [PATCH] spi: dw: Set default value if reg-io-width isn't specified

From: Serge Semin
Date: Tue Aug 08 2023 - 17:01:08 EST


On Tue, Aug 08, 2023 at 01:46:08PM +0100, Mark Brown wrote:
> On Tue, Aug 08, 2023 at 09:00:18AM +0900, Kunihiko Hayashi wrote:
> > On 2023/08/08 7:57, Serge Semin wrote:
> > > On Mon, Aug 07, 2023 at 09:16:21AM +0900, Kunihiko Hayashi wrote:
>
> > > > According to the dt-bindings, the default value of reg-io-width is 4.
> > > > However, the value becomes zero when reg-io-width isn't specified.
>
> > > This semantic is implied by the dw_read_io_reg() and dw_write_io_reg()
> > > methods. It doesn't seem like that much necessary duplicating it in the
> > > property parse procedure, if not to say - redundant.
>
> > I see. Currently since the variable reg_io_width has no other references
> > other than dw_{read, write}_io_reg(), it means the default value is taken
> > if this is zero.
>
> > So, I think we should be careful when actually using the value of
> > this variable.
>
> It does feel like a sensible robustness improvement,

I wouldn't call it "a sensible improvement" in this context, but
merely something like "a data-field/property coherency fixup".

> even if it's not
> fixing a specific issue now it might save us from future issues.

Such issues are very unlikely to happen unless somebody would try to
use the dw_spi.reg_io_width field separately from the denoted methods.
If one does, what he would have needed to make sure is that the field
always takes a correct value which would have led to this patch anyway
but at least it would have got a firm justification.

So to speak I wouldn't have bothered with merging the patch now at
least without changing the patch log which would have had to be
reduced to just the first paragraph with additional message stating
that the change just makes sure that the field is in a coherent state
with the DT-property value in order to improve the code
maintainability.

-Serge(y)