[PATCH 04/10] Staging: fbtft: Use a helper function to set write_register op

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use a helper function to set the correct write_register function, based
on the width of the registers.

Signed-off-by: Fabio Falzoi <fabio.falzoi84@xxxxxxxxx>
---
 drivers/staging/fbtft/flexfb.c | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c
index 25b394d..dae092a 100644
--- a/drivers/staging/fbtft/flexfb.c
+++ b/drivers/staging/fbtft/flexfb.c
@@ -363,6 +363,25 @@ static int flexfb_chip_init(const struct device *dev)
 	return -EINVAL;
 }
 
+static int flexfb_set_regwrite_func(const struct device *dev,
+				    struct fbtft_par *par)
+{
+	switch (regwidth) {
+	case 8:
+		par->fbtftops.write_register = fbtft_write_reg8_bus8;
+		break;
+	case 16:
+		par->fbtftops.write_register = fbtft_write_reg16_bus8;
+		break;
+	default:
+		dev_err(dev, "argument 'regwidth': %d is not supported.\n",
+			regwidth);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int flexfb_probe_common(struct spi_device *sdev,
 			       struct platform_device *pdev)
 {
@@ -413,20 +432,9 @@ static int flexfb_probe_common(struct spi_device *sdev,
 		par->init_sequence = initp;
 	par->fbtftops.init_display = fbtft_init_display;
 
-	/* registerwrite functions */
-	switch (regwidth) {
-	case 8:
-		par->fbtftops.write_register = fbtft_write_reg8_bus8;
-		break;
-	case 16:
-		par->fbtftops.write_register = fbtft_write_reg16_bus8;
-		break;
-	default:
-		dev_err(dev,
-			"argument 'regwidth': %d is not supported.\n",
-			regwidth);
-		return -EINVAL;
-	}
+	ret = flexfb_set_regwrite_func(dev, par);
+	if (ret)
+		goto out_release;
 
 	/* bus functions */
 	if (sdev) {
-- 
2.1.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux