SPI_IOC_WR_MAX_SPEED_HZ was overwitten?

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

 



Hi

> Is it possible that the ioctl SPI_IOC_WR_MODE call can 
> overwrite the previous ioctl SPI_IOC_WR_MAX_SPEED_HZ speed setting?

Yes it is. Please take a look in spidev.c Line 488. 
In the spidev_ioctl() function at the SPI_IOC_WR_MAX_SPEED_HZ case the
spi->max_speed_hz value was always overwritten with the old "save" value
regardless if the spi_setup call was successful or not.

--Snip--  
else
	dev_dbg(&spi->dev, "%d Hz (max)\n", tmp);
spi->max_speed_hz = save;
}
break;
--snip--

Every following ioctl call will restore the wrong speed value.
 
Here is my patch to correct this:
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -480,11 +480,10 @@
 
 			spi->max_speed_hz = tmp;
 			retval = spi_setup(spi);
-			if (retval >= 0)
-				spidev->speed_hz = tmp;
+			if (retval < 0)
+				spidev->speed_hz = save;
 			else
 				dev_dbg(&spi->dev, "%d Hz (max)\n", tmp);
-			spi->max_speed_hz = save;
 		}
 		break;

Can anybody review this please?

With this patch  my program works fine with the spidev and the tool flashrom also.

Best regards,
Alexander

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux