Re: [PATCH net v2] net: phy: spi_ks8995: Do not overwrite SPI mode flags

From: Andy Shevchenko
Date: Tue Nov 10 2020 - 11:30:42 EST


On Tue, Nov 10, 2020 at 4:20 PM Sven Van Asbroeck <thesven73@xxxxxxxxx> wrote:
>
> From: Sven Van Asbroeck <thesven73@xxxxxxxxx>
>
> This driver makes sure the underlying SPI bus is set to "mode 0"
> by assigning SPI_MODE_0 to spi->mode. Which overwrites all other
> SPI mode flags.
>
> In some circumstances, this can break the underlying SPI bus driver.
> For example, if SPI_CS_HIGH is set on the SPI bus, the driver
> will clear that flag, which results in a chip-select polarity issue.
>
> Fix by changing only the SPI_MODE_N bits, i.e. SPI_CPHA and SPI_CPOL.

I see that this is a fix for backporing, but maybe you can send a
patches on top of this to:
1) introduce
#define SPI_MODE_MASK (SPI_CPHA | SPI_CPOL)

> + /* use SPI_MODE_0 without changing any other mode flags */
> + spi->mode &= ~(SPI_CPHA | SPI_CPOL);

2)
spi->mode &= ~SPI_MODE_MASK;

> + spi->mode |= SPI_MODE_0;

?

--
With Best Regards,
Andy Shevchenko