Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1212413

[PATCH RFC 1/2] staging: fbtft: replace master->setup() with spi_setup()

From Stefan Wahren <stefan.wahren@i2se.com>
Newsgroups linux.kernel
Subject [PATCH RFC 1/2] staging: fbtft: replace master->setup() with spi_setup()
Date 2015-08-24 20:40 +0200
Message-ID <q14P1-7rq-29@gated-at.bofh.it> (permalink)
References <q14P0-7rq-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Calling the setup of the SPI master directly causes a NULL pointer
dereference with master drivers without a separate setup function.
This problem is reproduceable on ARM MXS platform.

So fix this issue by using spi_setup() instead.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/staging/fbtft/fb_uc1611.c    |    2 +-
 drivers/staging/fbtft/fb_watterott.c |    4 ++--
 drivers/staging/fbtft/fbtft-core.c   |    4 ++--
 drivers/staging/fbtft/flexfb.c       |    4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/fbtft/fb_uc1611.c b/drivers/staging/fbtft/fb_uc1611.c
index 32f3a9d..5cafa50 100644
--- a/drivers/staging/fbtft/fb_uc1611.c
+++ b/drivers/staging/fbtft/fb_uc1611.c
@@ -76,7 +76,7 @@ static int init_display(struct fbtft_par *par)
 
 	/* Set CS active high */
 	par->spi->mode |= SPI_CS_HIGH;
-	ret = par->spi->master->setup(par->spi);
+	ret = spi_setup(par->spi);
 	if (ret) {
 		dev_err(par->info->device, "Could not set SPI_CS_HIGH\n");
 		return ret;
diff --git a/drivers/staging/fbtft/fb_watterott.c b/drivers/staging/fbtft/fb_watterott.c
index 88fb2c0..8eae6ef 100644
--- a/drivers/staging/fbtft/fb_watterott.c
+++ b/drivers/staging/fbtft/fb_watterott.c
@@ -169,7 +169,7 @@ static int init_display(struct fbtft_par *par)
 	/* enable SPI interface by having CS and MOSI low during reset */
 	save_mode = par->spi->mode;
 	par->spi->mode |= SPI_CS_HIGH;
-	ret = par->spi->master->setup(par->spi); /* set CS inactive low */
+	ret = spi_setup(par->spi); /* set CS inactive low */
 	if (ret) {
 		dev_err(par->info->device, "Could not set SPI_CS_HIGH\n");
 		return ret;
@@ -180,7 +180,7 @@ static int init_display(struct fbtft_par *par)
 	par->fbtftops.reset(par);
 	mdelay(1000);
 	par->spi->mode = save_mode;
-	ret = par->spi->master->setup(par->spi);
+	ret = spi_setup(par->spi);
 	if (ret) {
 		dev_err(par->info->device, "Could not restore SPI mode\n");
 		return ret;
diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index 23392eb..3638554 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -1437,12 +1437,12 @@ int fbtft_probe_common(struct fbtft_display *display,
 	/* 9-bit SPI setup */
 	if (par->spi && display->buswidth == 9) {
 		par->spi->bits_per_word = 9;
-		ret = par->spi->master->setup(par->spi);
+		ret = spi_setup(par->spi);
 		if (ret) {
 			dev_warn(&par->spi->dev,
 				"9-bit SPI not available, emulating using 8-bit.\n");
 			par->spi->bits_per_word = 8;
-			ret = par->spi->master->setup(par->spi);
+			ret = spi_setup(par->spi);
 			if (ret)
 				goto out_release;
 			/* allocate buffer with room for dc bits */
diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c
index c763efc..09fd15d 100644
--- a/drivers/staging/fbtft/flexfb.c
+++ b/drivers/staging/fbtft/flexfb.c
@@ -464,12 +464,12 @@ static int flexfb_probe_common(struct spi_device *sdev,
 			par->fbtftops.write_register = fbtft_write_reg8_bus9;
 			par->fbtftops.write_vmem = fbtft_write_vmem16_bus9;
 			sdev->bits_per_word = 9;
-			ret = sdev->master->setup(sdev);
+			ret = spi_setup(sdev);
 			if (ret) {
 				dev_warn(dev,
 					"9-bit SPI not available, emulating using 8-bit.\n");
 				sdev->bits_per_word = 8;
-				ret = sdev->master->setup(sdev);
+				ret = spi_setup(sdev);
 				if (ret)
 					goto out_release;
 				/* allocate buffer with room for dc bits */
-- 
1.7.9.5

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

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH RFC 0/2] staging: fbtft: fix 9-bit SPI support Stefan Wahren <stefan.wahren@i2se.com> - 2015-08-24 20:40 +0200
  [PATCH RFC 1/2] staging: fbtft: replace master->setup() with spi_setup() Stefan Wahren <stefan.wahren@i2se.com> - 2015-08-24 20:40 +0200

csiph-web