diff options
author | Stefan Wahren <stefan.wahren@i2se.com> | 2015-08-25 17:04:11 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-09-13 12:33:58 -0400 |
commit | cabb5b2a2866829177df2f1cee70f0dd42ee6ae0 (patch) | |
tree | 2ab184760bc67873c8603b181e2eb078b6db2c35 | |
parent | d98229f0299d5d5a741873c5900159844b2b2de5 (diff) |
staging: fbtft: fix 9-bit SPI support detection
Since the result of the setup function isn't adequate to check
9-bit SPI support, we better check bits_per_word_mask. Btw this
change avoids a NULL pointer dereference with master drivers
without a separate setup function.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Acked-by: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/fbtft/fbtft-core.c | 10 | ||||
-rw-r--r-- | drivers/staging/fbtft/flexfb.c | 11 |
2 files changed, 7 insertions, 14 deletions
diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index 23392eb6799e..7f5fa3d1cab0 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c | |||
@@ -1436,15 +1436,11 @@ int fbtft_probe_common(struct fbtft_display *display, | |||
1436 | 1436 | ||
1437 | /* 9-bit SPI setup */ | 1437 | /* 9-bit SPI setup */ |
1438 | if (par->spi && display->buswidth == 9) { | 1438 | if (par->spi && display->buswidth == 9) { |
1439 | par->spi->bits_per_word = 9; | 1439 | if (par->spi->master->bits_per_word_mask & SPI_BPW_MASK(9)) { |
1440 | ret = par->spi->master->setup(par->spi); | 1440 | par->spi->bits_per_word = 9; |
1441 | if (ret) { | 1441 | } else { |
1442 | dev_warn(&par->spi->dev, | 1442 | dev_warn(&par->spi->dev, |
1443 | "9-bit SPI not available, emulating using 8-bit.\n"); | 1443 | "9-bit SPI not available, emulating using 8-bit.\n"); |
1444 | par->spi->bits_per_word = 8; | ||
1445 | ret = par->spi->master->setup(par->spi); | ||
1446 | if (ret) | ||
1447 | goto out_release; | ||
1448 | /* allocate buffer with room for dc bits */ | 1444 | /* allocate buffer with room for dc bits */ |
1449 | par->extra = devm_kzalloc(par->info->device, | 1445 | par->extra = devm_kzalloc(par->info->device, |
1450 | par->txbuf.len + (par->txbuf.len / 8) + 8, | 1446 | par->txbuf.len + (par->txbuf.len / 8) + 8, |
diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c index c763efc5de7d..3f380a0086c3 100644 --- a/drivers/staging/fbtft/flexfb.c +++ b/drivers/staging/fbtft/flexfb.c | |||
@@ -463,15 +463,12 @@ static int flexfb_probe_common(struct spi_device *sdev, | |||
463 | } | 463 | } |
464 | par->fbtftops.write_register = fbtft_write_reg8_bus9; | 464 | par->fbtftops.write_register = fbtft_write_reg8_bus9; |
465 | par->fbtftops.write_vmem = fbtft_write_vmem16_bus9; | 465 | par->fbtftops.write_vmem = fbtft_write_vmem16_bus9; |
466 | sdev->bits_per_word = 9; | 466 | if (par->spi->master->bits_per_word_mask |
467 | ret = sdev->master->setup(sdev); | 467 | & SPI_BPW_MASK(9)) { |
468 | if (ret) { | 468 | par->spi->bits_per_word = 9; |
469 | } else { | ||
469 | dev_warn(dev, | 470 | dev_warn(dev, |
470 | "9-bit SPI not available, emulating using 8-bit.\n"); | 471 | "9-bit SPI not available, emulating using 8-bit.\n"); |
471 | sdev->bits_per_word = 8; | ||
472 | ret = sdev->master->setup(sdev); | ||
473 | if (ret) | ||
474 | goto out_release; | ||
475 | /* allocate buffer with room for dc bits */ | 472 | /* allocate buffer with room for dc bits */ |
476 | par->extra = devm_kzalloc(par->info->device, | 473 | par->extra = devm_kzalloc(par->info->device, |
477 | par->txbuf.len + (par->txbuf.len / 8) + 8, | 474 | par->txbuf.len + (par->txbuf.len / 8) + 8, |