summaryrefslogtreecommitdiff
path: root/drivers/spi/spi.c
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-07-10 17:57:26 +0400
committerMark Brown <broonie@linaro.org>2013-07-15 14:34:51 +0400
commita2fd4f9fa3b9f051550b36c4dfa74bc32bda24ee (patch)
treeb317a65457403d0e3175cd3fa36a66b6b2627527 /drivers/spi/spi.c
parentad81f0545ef01ea651886dddac4bef6cec930092 (diff)
downloadlinux-a2fd4f9fa3b9f051550b36c4dfa74bc32bda24ee.tar.xz
spi: Support transfer speed checking in the core
Allow drivers to avoid implementing their own checks for simple rates by specifying the limits in the master structure. Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r--drivers/spi/spi.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 978dda2c5239..a52f16685d6a 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1387,6 +1387,13 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
BIT(xfer->bits_per_word - 1)))
return -EINVAL;
}
+
+ if (xfer->speed_hz && master->min_speed_hz &&
+ xfer->speed_hz < master->min_speed_hz)
+ return -EINVAL;
+ if (xfer->speed_hz && master->max_speed_hz &&
+ xfer->speed_hz > master->max_speed_hz)
+ return -EINVAL;
}
message->spi = spi;