Re: [PATCH v4 1/6] spi: Enable controllers to extend the SPI protocol with MOSI idle configuration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/19, David Lechner wrote:
> On 6/18/24 6:10 PM, Marcelo Schmitt wrote:
> 
> ...
> 
> > @@ -3928,7 +3934,8 @@ int spi_setup(struct spi_device *spi)
> >  	 * so it is ignored here.
> >  	 */
> >  	bad_bits = spi->mode & ~(spi->controller->mode_bits | SPI_CS_WORD |
> > -				 SPI_NO_TX | SPI_NO_RX);
> > +				 SPI_NO_TX | SPI_NO_RX | SPI_MOSI_IDLE_LOW |
> > +				 SPI_MOSI_IDLE_HIGH);
> 
> This looks wrong to me. Adding flags here causes them to be ignored
> rather than to be checked.
> 
> I also did a runtime check with a random driver and a SPI controller
> that does not have the flag.
> 
> 	spi->mode |= SPI_MOSI_IDLE_LOW;
> 	ret = spi_setup(spi);
> 	if (ret)
> 		return ret;
> 
> It incorrectly passes when used with this change but correctly fails
> without this change.

That's right, adding flags to bad_bits makes spi_setup() ignore those mode bits
instead of failing when they don't match.
Changed bad_bits assignment back to what it was in v3 (i.e. no change to bad_bits).
	bad_bits = spi->mode & ~(spi->controller->mode_bits | SPI_CS_WORD |
				 SPI_NO_TX | SPI_NO_RX);

> 
> >  	ugly_bits = bad_bits &
> >  		    (SPI_TX_DUAL | SPI_TX_QUAD | SPI_TX_OCTAL |
> >  		     SPI_RX_DUAL | SPI_RX_QUAD | SPI_RX_OCTAL);
> 




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux