From: Fabio Falzoi <fabio.falzoi84@gmail.com>
To: thomas.petazzoni@free-electrons.com, noralf@tronnes.org
Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org,
Fabio Falzoi <fabio.falzoi84@gmail.com>
Subject: [PATCH 05/10] Staging: fbtft: Set bus specific ops using separate functions
Date: Tue, 30 Jun 2015 08:43:12 +0200 [thread overview]
Message-ID: <1435646597-7612-6-git-send-email-fabio.falzoi84@gmail.com> (raw)
In-Reply-To: <1435646597-7612-1-git-send-email-fabio.falzoi84@gmail.com>
Use two separate functions for spi and platform bus
(flexfb_set_spi_bus_func and flexfb_set_platform_bus_func,
respectively) to set the appropriate write operations.
This patch corrects the following checkpatch errors:
WARNING:LONG_LiINE at lines 446, 450, 466, 476, 489 and 495.
CHECK:PARENTHESIS_ALIGNMENT at line 459.
Signed-off-by: Fabio Falzoi <fabio.falzoi84@gmail.com>
---
drivers/staging/fbtft/flexfb.c | 154 +++++++++++++++++++++++++----------------
1 file changed, 94 insertions(+), 60 deletions(-)
diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c
index dae092a..1b833f9 100644
--- a/drivers/staging/fbtft/flexfb.c
+++ b/drivers/staging/fbtft/flexfb.c
@@ -382,6 +382,94 @@ static int flexfb_set_regwrite_func(const struct device *dev,
return 0;
}
+static int flexfb_emulate_spi_8(struct fbtft_par *par, struct spi_device *sdev)
+{
+ struct device *dev = &sdev->dev;
+ int ret;
+
+ dev_warn(dev, "9-bit SPI not available, emulating using 8-bit.\n");
+ sdev->bits_per_word = 8;
+ ret = sdev->master->setup(sdev);
+ if (ret)
+ return ret;
+
+ /* allocate buffer with room for dc bits */
+ par->extra = devm_kzalloc(par->info->device,
+ par->txbuf.len + (par->txbuf.len / 8) + 8,
+ GFP_KERNEL);
+ if (!par->extra)
+ return -ENOMEM;
+ par->fbtftops.write = fbtft_write_spi_emulate_9;
+
+ return 0;
+}
+
+static int flexfb_set_spi_bus_func(struct fbtft_par *par,
+ struct spi_device *sdev)
+{
+ struct device *dev = &sdev->dev;
+ int ret;
+
+ par->fbtftops.write = fbtft_write_spi;
+ switch (buswidth) {
+ case 8:
+ par->fbtftops.write_vmem = fbtft_write_vmem16_bus8;
+ if (!par->startbyte)
+ par->fbtftops.verify_gpios = flexfb_verify_gpios_dc;
+ break;
+ case 9:
+ if (regwidth == 16) {
+ dev_err(dev, "argument 'regwidth': %d is not supported with buswidth=%d and SPI.\n",
+ regwidth, buswidth);
+ return -EINVAL;
+ }
+ 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);
+ if (ret) {
+ ret = flexfb_emulate_spi_8(par, sdev);
+ if (ret)
+ return ret;
+ }
+ break;
+ default:
+ dev_err(dev, "argument 'buswidth': %d is not supported with SPI.\n",
+ buswidth);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int flexfb_set_platform_bus_func(struct fbtft_par *par,
+ struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+
+ par->fbtftops.verify_gpios = flexfb_verify_gpios_db;
+ switch (buswidth) {
+ case 8:
+ par->fbtftops.write = fbtft_write_gpio8_wr;
+ par->fbtftops.write_vmem = fbtft_write_vmem16_bus8;
+ break;
+ case 16:
+ par->fbtftops.write_register = fbtft_write_reg16_bus16;
+ if (latched)
+ par->fbtftops.write = fbtft_write_gpio16_wr_latched;
+ else
+ par->fbtftops.write = fbtft_write_gpio16_wr;
+ par->fbtftops.write_vmem = fbtft_write_vmem16_bus16;
+ break;
+ default:
+ dev_err(dev, "argument 'buswidth': %d is not supported with parallel.\n",
+ buswidth);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int flexfb_probe_common(struct spi_device *sdev,
struct platform_device *pdev)
{
@@ -436,66 +524,12 @@ static int flexfb_probe_common(struct spi_device *sdev,
if (ret)
goto out_release;
- /* bus functions */
- if (sdev) {
- par->fbtftops.write = fbtft_write_spi;
- switch (buswidth) {
- case 8:
- par->fbtftops.write_vmem = fbtft_write_vmem16_bus8;
- if (!par->startbyte)
- par->fbtftops.verify_gpios = flexfb_verify_gpios_dc;
- break;
- case 9:
- if (regwidth == 16) {
- dev_err(dev, "argument 'regwidth': %d is not supported with buswidth=%d and SPI.\n", regwidth, buswidth);
- return -EINVAL;
- }
- 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);
- 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);
- if (ret)
- goto out_release;
- /* allocate buffer with room for dc bits */
- par->extra = devm_kzalloc(par->info->device,
- par->txbuf.len + (par->txbuf.len / 8) + 8,
- GFP_KERNEL);
- if (!par->extra) {
- ret = -ENOMEM;
- goto out_release;
- }
- par->fbtftops.write = fbtft_write_spi_emulate_9;
- }
- break;
- default:
- dev_err(dev, "argument 'buswidth': %d is not supported with SPI.\n", buswidth);
- return -EINVAL;
- }
- } else {
- par->fbtftops.verify_gpios = flexfb_verify_gpios_db;
- switch (buswidth) {
- case 8:
- par->fbtftops.write = fbtft_write_gpio8_wr;
- par->fbtftops.write_vmem = fbtft_write_vmem16_bus8;
- break;
- case 16:
- par->fbtftops.write_register = fbtft_write_reg16_bus16;
- if (latched)
- par->fbtftops.write = fbtft_write_gpio16_wr_latched;
- else
- par->fbtftops.write = fbtft_write_gpio16_wr;
- par->fbtftops.write_vmem = fbtft_write_vmem16_bus16;
- break;
- default:
- dev_err(dev, "argument 'buswidth': %d is not supported with parallel.\n", buswidth);
- return -EINVAL;
- }
- }
+ if (sdev)
+ ret = flexfb_set_spi_bus_func(par, sdev);
+ else
+ ret = flexfb_set_platform_bus_func(par, pdev);
+ if (ret)
+ goto out_release;
/* set_addr_win function */
switch (setaddrwin) {
--
2.1.4
next prev parent reply other threads:[~2015-06-30 6:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-30 6:43 [PATCH 00/10] Staging: fbtft: flexfb.c file clean up Fabio Falzoi
2015-06-30 6:43 ` [PATCH 01/10] Staging: fbtft: Remove paragraph about writing to FSF Fabio Falzoi
2015-06-30 6:43 ` [PATCH 02/10] Staging: fbtft: Remove unnecessary multiple blank lines Fabio Falzoi
2015-06-30 6:43 ` [PATCH 03/10] Staging: fbtft: Use a struct to describe each LCD controller Fabio Falzoi
2015-07-15 2:12 ` Greg KH
2015-07-23 11:09 ` Noralf Trønnes
2015-08-02 14:57 ` [PATCH v2] " Fabio Falzoi
2015-08-02 17:54 ` Noralf Trønnes
2015-08-02 20:17 ` Fabio Falzoi
2015-08-02 20:30 ` [PATCH v3] " Fabio Falzoi
2015-06-30 6:43 ` [PATCH 04/10] Staging: fbtft: Use a helper function to set write_register op Fabio Falzoi
2015-07-15 2:13 ` Greg KH
2015-06-30 6:43 ` Fabio Falzoi [this message]
2015-07-15 2:13 ` [PATCH 05/10] Staging: fbtft: Set bus specific ops using separate functions Greg KH
2015-06-30 6:43 ` [PATCH 06/10] Staging: fbtft: Use a helper function to set set_addr_win op Fabio Falzoi
2015-07-15 2:14 ` Greg KH
2015-07-23 11:19 ` Noralf Trønnes
2015-06-30 6:43 ` [PATCH 07/10] Staging: fbtft: Remove useless newline Fabio Falzoi
2015-06-30 7:42 ` Dan Carpenter
2015-06-30 14:55 ` Joe Perches
2015-06-30 17:45 ` Dan Carpenter
2015-06-30 19:03 ` Joe Perches
2015-06-30 6:43 ` [PATCH 08/10] Staging: fbtft: Avoid duplicating code to check gpio.dc value Fabio Falzoi
2015-06-30 6:43 ` [PATCH 09/10] Staging: fbtft: Fix parenthesis alignment coding style issue Fabio Falzoi
2015-06-30 6:43 ` [PATCH 10/10] Staging: fbtft: Fix spacing " Fabio Falzoi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1435646597-7612-6-git-send-email-fabio.falzoi84@gmail.com \
--to=fabio.falzoi84@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=noralf@tronnes.org \
--cc=thomas.petazzoni@free-electrons.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®