[PATCH RFC 2/2] staging: fbtft: fix 9-bit SPI support detection

From: Stefan Wahren
Date: Mon Aug 24 2015 - 14:34:19 EST


Since bits_per_word isn't usually checked during SPI setup the 9-bit
support must be checked manually.

Signed-off-by: Stefan Wahren <stefan.wahren@xxxxxxxx>
---
drivers/staging/fbtft/fbtft-core.c | 7 +++++++
drivers/staging/fbtft/flexfb.c | 7 +++++++
2 files changed, 14 insertions(+)

diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index 3638554..bd71487 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -1438,6 +1438,13 @@ int fbtft_probe_common(struct fbtft_display *display,
if (par->spi && display->buswidth == 9) {
par->spi->bits_per_word = 9;
ret = spi_setup(par->spi);
+ if (!ret) {
+ struct spi_master *ma = par->spi->master;
+
+ if (!(ma->bits_per_word_mask & SPI_BPW_MASK(9)))
+ ret = -EINVAL;
+ }
+
if (ret) {
dev_warn(&par->spi->dev,
"9-bit SPI not available, emulating using 8-bit.\n");
diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c
index 09fd15d..a54a8d9 100644
--- a/drivers/staging/fbtft/flexfb.c
+++ b/drivers/staging/fbtft/flexfb.c
@@ -465,6 +465,13 @@ static int flexfb_probe_common(struct spi_device *sdev,
par->fbtftops.write_vmem = fbtft_write_vmem16_bus9;
sdev->bits_per_word = 9;
ret = spi_setup(sdev);
+ if (!ret) {
+ struct spi_master *ma = par->spi->master;
+
+ if (!(ma->bits_per_word_mask & SPI_BPW_MASK(9)))
+ ret = -EINVAL;
+ }
+
if (ret) {
dev_warn(dev,
"9-bit SPI not available, emulating using 8-bit.\n");
--
1.7.9.5

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