public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Alexandru Hossu <hossu.alexandru@gmail.com>
To: andy@kernel.org, gregkh@linuxfoundation.org
Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	Alexandru Hossu <hossu.alexandru@gmail.com>
Subject: [PATCH] staging: fbtft: fbtft-bus: replace function-defining macro with concrete functions
Date: Fri, 24 Apr 2026 11:28:18 +0200	[thread overview]
Message-ID: <20260424092818.3322248-1-hossu.alexandru@gmail.com> (raw)

The define_fbtft_write_reg macro defines full function bodies including
a goto statement and a trailing semicolon on EXPORT_SYMBOL(), which
violates kernel coding style (checkpatch reports 2 ERRORs, 2 WARNINGs,
and 5 CHECKs).

Replace it with three concrete C functions that are semantically
identical to the macro expansions:
  - fbtft_write_reg8_bus8   (u8 buffer, u8 data)
  - fbtft_write_reg16_bus8  (__be16 buffer, u16 data, cpu_to_be16)
  - fbtft_write_reg16_bus16 (u16 buffer, u16 data)

The function declarations in fbtft.h are already present and unchanged.

Signed-off-by: Alexandru Hossu <hossu.alexandru@gmail.com>
---
 drivers/staging/fbtft/fbtft-bus.c | 191 +++++++++++++++++++++---------
 1 file changed, 137 insertions(+), 54 deletions(-)

diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c
index 30e436ff1..acd035203 100644
--- a/drivers/staging/fbtft/fbtft-bus.c
+++ b/drivers/staging/fbtft/fbtft-bus.c
@@ -11,60 +11,143 @@
  *
  *****************************************************************************/
 
-#define define_fbtft_write_reg(func, buffer_type, data_type, modifier)        \
-void func(struct fbtft_par *par, int len, ...)                                \
-{                                                                             \
-	va_list args;                                                         \
-	int i, ret;                                                           \
-	int offset = 0;                                                       \
-	buffer_type *buf = (buffer_type *)par->buf;                           \
-									      \
-	if (unlikely(par->debug & DEBUG_WRITE_REGISTER)) {                    \
-		va_start(args, len);                                          \
-		for (i = 0; i < len; i++) {                                   \
-			buf[i] = modifier((data_type)va_arg(args,             \
-							    unsigned int));   \
-		}                                                             \
-		va_end(args);                                                 \
-		fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par,                  \
-				  par->info->device, buffer_type, buf, len,   \
-				  "%s: ", __func__);                          \
-	}                                                                     \
-									      \
-	va_start(args, len);                                                  \
-									      \
-	if (par->startbyte) {                                                 \
-		*(u8 *)par->buf = par->startbyte;                             \
-		buf = (buffer_type *)(par->buf + 1);                          \
-		offset = 1;                                                   \
-	}                                                                     \
-									      \
-	*buf = modifier((data_type)va_arg(args, unsigned int));               \
-	ret = fbtft_write_buf_dc(par, par->buf, sizeof(data_type) + offset,   \
-				 0);                                          \
-	if (ret < 0)							      \
-		goto out;						      \
-	len--;                                                                \
-									      \
-	if (par->startbyte)                                                   \
-		*(u8 *)par->buf = par->startbyte | 0x2;                       \
-									      \
-	if (len) {                                                            \
-		i = len;                                                      \
-		while (i--)						      \
-			*buf++ = modifier((data_type)va_arg(args,             \
-							    unsigned int));   \
-		fbtft_write_buf_dc(par, par->buf,			      \
-				   len * (sizeof(data_type) + offset), 1);    \
-	}                                                                     \
-out:									      \
-	va_end(args);                                                         \
-}                                                                             \
-EXPORT_SYMBOL(func);
-
-define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, )
-define_fbtft_write_reg(fbtft_write_reg16_bus8, __be16, u16, cpu_to_be16)
-define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, )
+void fbtft_write_reg8_bus8(struct fbtft_par *par, int len, ...)
+{
+	va_list args;
+	int i, ret;
+	int offset = 0;
+	u8 *buf = (u8 *)par->buf;
+
+	if (unlikely(par->debug & DEBUG_WRITE_REGISTER)) {
+		va_start(args, len);
+		for (i = 0; i < len; i++)
+			buf[i] = (u8)va_arg(args, unsigned int);
+		va_end(args);
+		fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par,
+				  par->info->device, u8, buf, len,
+				  "%s: ", __func__);
+	}
+
+	va_start(args, len);
+
+	if (par->startbyte) {
+		*(u8 *)par->buf = par->startbyte;
+		buf = (u8 *)(par->buf + 1);
+		offset = 1;
+	}
+
+	*buf = (u8)va_arg(args, unsigned int);
+	ret = fbtft_write_buf_dc(par, par->buf, sizeof(u8) + offset, 0);
+	if (ret < 0)
+		goto out;
+	len--;
+
+	if (par->startbyte)
+		*(u8 *)par->buf = par->startbyte | 0x2;
+
+	if (len) {
+		i = len;
+		while (i--)
+			*buf++ = (u8)va_arg(args, unsigned int);
+		fbtft_write_buf_dc(par, par->buf,
+				   len * (sizeof(u8) + offset), 1);
+	}
+out:
+	va_end(args);
+}
+EXPORT_SYMBOL(fbtft_write_reg8_bus8);
+
+void fbtft_write_reg16_bus8(struct fbtft_par *par, int len, ...)
+{
+	va_list args;
+	int i, ret;
+	int offset = 0;
+	__be16 *buf = (__be16 *)par->buf;
+
+	if (unlikely(par->debug & DEBUG_WRITE_REGISTER)) {
+		va_start(args, len);
+		for (i = 0; i < len; i++)
+			buf[i] = cpu_to_be16((u16)va_arg(args, unsigned int));
+		va_end(args);
+		fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par,
+				  par->info->device, __be16, buf, len,
+				  "%s: ", __func__);
+	}
+
+	va_start(args, len);
+
+	if (par->startbyte) {
+		*(u8 *)par->buf = par->startbyte;
+		buf = (__be16 *)(par->buf + 1);
+		offset = 1;
+	}
+
+	*buf = cpu_to_be16((u16)va_arg(args, unsigned int));
+	ret = fbtft_write_buf_dc(par, par->buf, sizeof(u16) + offset, 0);
+	if (ret < 0)
+		goto out;
+	len--;
+
+	if (par->startbyte)
+		*(u8 *)par->buf = par->startbyte | 0x2;
+
+	if (len) {
+		i = len;
+		while (i--)
+			*buf++ = cpu_to_be16((u16)va_arg(args, unsigned int));
+		fbtft_write_buf_dc(par, par->buf,
+				   len * (sizeof(u16) + offset), 1);
+	}
+out:
+	va_end(args);
+}
+EXPORT_SYMBOL(fbtft_write_reg16_bus8);
+
+void fbtft_write_reg16_bus16(struct fbtft_par *par, int len, ...)
+{
+	va_list args;
+	int i, ret;
+	int offset = 0;
+	u16 *buf = (u16 *)par->buf;
+
+	if (unlikely(par->debug & DEBUG_WRITE_REGISTER)) {
+		va_start(args, len);
+		for (i = 0; i < len; i++)
+			buf[i] = (u16)va_arg(args, unsigned int);
+		va_end(args);
+		fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par,
+				  par->info->device, u16, buf, len,
+				  "%s: ", __func__);
+	}
+
+	va_start(args, len);
+
+	if (par->startbyte) {
+		*(u8 *)par->buf = par->startbyte;
+		buf = (u16 *)(par->buf + 1);
+		offset = 1;
+	}
+
+	*buf = (u16)va_arg(args, unsigned int);
+	ret = fbtft_write_buf_dc(par, par->buf, sizeof(u16) + offset, 0);
+	if (ret < 0)
+		goto out;
+	len--;
+
+	if (par->startbyte)
+		*(u8 *)par->buf = par->startbyte | 0x2;
+
+	if (len) {
+		i = len;
+		while (i--)
+			*buf++ = (u16)va_arg(args, unsigned int);
+		fbtft_write_buf_dc(par, par->buf,
+				   len * (sizeof(u16) + offset), 1);
+	}
+out:
+	va_end(args);
+}
+EXPORT_SYMBOL(fbtft_write_reg16_bus16);
 
 void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...)
 {
-- 
2.53.0


             reply	other threads:[~2026-04-24  9:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24  9:28 Alexandru Hossu [this message]
2026-04-24  9:38 ` [PATCH] staging: fbtft: fbtft-bus: replace function-defining macro with concrete functions Andy Shevchenko
2026-04-24  9:40   ` Alexandru Hossu
2026-04-24  9:47     ` Andy Shevchenko
2026-04-24  9:49     ` Greg KH

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=20260424092818.3322248-1-hossu.alexandru@gmail.com \
    --to=hossu.alexandru@gmail.com \
    --cc=andy@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /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