]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mfd: cros_ec: spi: Calculate delay between transfers correctly
authorDavid Hendricks <dhendrix@chromium.org>
Wed, 30 Apr 2014 17:44:04 +0000 (10:44 -0700)
committerLee Jones <lee.jones@linaro.org>
Tue, 3 Jun 2014 07:11:46 +0000 (08:11 +0100)
To avoid spamming the EC we calculate the time between the previous
transfer and the current transfer and force a delay if the time delta
is too small.

However, a small miscalculation causes the delay period to be
far too short. Most noticably this impacts commands with a long
turnaround time such as EC firmware reads and writes.

Signed-off-by: David Hendricks <dhendrix@chromium.org>
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/cros_ec_spi.c

index 84af8d7a429544e7369daf66d2dbedb578cb12a1..c185eb67943fa4d77fc7aa788e9ddbee1d26ce35 100644 (file)
@@ -219,7 +219,7 @@ static int cros_ec_command_spi_xfer(struct cros_ec_device *ec_dev,
                ktime_get_ts(&ts);
                delay = timespec_to_ns(&ts) - ec_spi->last_transfer_ns;
                if (delay < EC_SPI_RECOVERY_TIME_NS)
-                       ndelay(delay);
+                       ndelay(EC_SPI_RECOVERY_TIME_NS - delay);
        }
 
        /* Transmit phase - send our message */