Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: cros_ec: spi: Fix end of transfer on devices with no spi-msg-delay

cros_ec_spi makes the assumption that a 0-length message will put the
spi chip select back to normal (non cs_toggle mode). This used to be
the case back on kernel-3.8 on the spi-s3c64xx driver but doesn't
appear to be true anymore. It seems like it was a pretty questionable
assumption to begin with, so let's fix the code to be more robust. We
know that a message with a single 0-length segment _will_ put things
back in order. Change cros_ec_spi to handle this.

This wasn't a problem on the main user of cros_ec_spi upstream (tegra)
because it specified 'google,cros-ec-spi-msg-delay'.

Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Doug Anderson and committed by
Lee Jones
96758059 c03842d8

+7 -11
+7 -11
drivers/mfd/cros_ec_spi.c
··· 266 266 dev_err(ec_dev->dev, "spi transfer failed: %d\n", ret); 267 267 } 268 268 269 - /* turn off CS */ 269 + /* 270 + * Turn off CS, possibly adding a delay to ensure the rising edge 271 + * doesn't come too soon after the end of the data. 272 + */ 270 273 spi_message_init(&msg); 271 - 272 - if (ec_spi->end_of_msg_delay) { 273 - /* 274 - * Add delay for last transaction, to ensure the rising edge 275 - * doesn't come too soon after the end of the data. 276 - */ 277 - memset(&trans, 0, sizeof(trans)); 278 - trans.delay_usecs = ec_spi->end_of_msg_delay; 279 - spi_message_add_tail(&trans, &msg); 280 - } 274 + memset(&trans, 0, sizeof(trans)); 275 + trans.delay_usecs = ec_spi->end_of_msg_delay; 276 + spi_message_add_tail(&trans, &msg); 281 277 282 278 final_ret = spi_sync(ec_spi->spi, &msg); 283 279 ktime_get_ts(&ts);