Re: [PATCH] spi: spidev: Don't mangle max_speed_hz in underlying spi device

From: Mark Brown
Date: Tue Nov 11 2014 - 13:01:17 EST


On Tue, Nov 11, 2014 at 07:53:59AM -0600, Thor Thayer wrote:
> Hi Mark,

Please delete irrelevant context from mails, it makes it much easier to
find any new content you've added.

> On 11/08/2014 04:29 AM, Mark Brown wrote:

> > if (retval < 0)
> >- spi->max_speed_hz = save;
> >+ spidev->speed_hz = tmp;
> > else
> > dev_dbg(&spi->dev, "%d Hz (max)\n", tmp);
> >+ spi->max_speed_hz = save;

> I think the test should be if (retval >= 0) otherwise the value is only
> updated on an error. With this change, I was able to successfully change the
> SPI speed without affecting the max speed. This was tested using
> spidev_test.c on a Altera Cyclone V which includes the DesignWare SPI IP
> (spi-dw.c).

Yup, misleading code.

> > if (status == 0)
> > spi_set_drvdata(spi, spidev);
> > else

> The echo command calls spidev_write() directly. Although the speed can't be
> specified in the echo command, it did prompt me to look at that path.

> In that case I think we'd need to add the .speed_hz element in
> spidev_sync_write() and spidev_sync_read().
> struct spi_transfer t = {
> .rx_buf = spidev->rx_buffer,
> .len = len,
> .speed_hz = spidev->speed_hz,
> };

Yup, looks that way.

Attachment: signature.asc
Description: Digital signature