* [PATCH] staging: fbtft: fix macro flow control warning and empty macro argument in fbtft-bus.c
@ 2026-02-02 16:28 KrishnaAgarwal1308
2026-02-02 20:01 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: KrishnaAgarwal1308 @ 2026-02-02 16:28 UTC (permalink / raw)
To: Andy Shevchenko, Greg Kroah-Hartman
Cc: dri-devel, linux-fbdev, linux-staging, linux-kernel,
KrishnaAgarwal1308
Fix checkpatch warning by adding identity modifier for define_fbtft_write_reg().
No functional change.
Signed-off-by: KrishnaAgarwal1308 <krishnaworkemail1308@gmail.com>
---
drivers/staging/fbtft/fbtft-bus.c | 36 +++++++++++++++----------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c
index 30e436ff19e4..0ab4f5c4f886 100644
--- a/drivers/staging/fbtft/fbtft-bus.c
+++ b/drivers/staging/fbtft/fbtft-bus.c
@@ -10,6 +10,7 @@
* void (*write_reg)(struct fbtft_par *par, int len, ...);
*
*****************************************************************************/
+#define fbtft_identity(x) (x)
#define define_fbtft_write_reg(func, buffer_type, data_type, modifier) \
void func(struct fbtft_par *par, int len, ...) \
@@ -42,29 +43,28 @@ void func(struct fbtft_par *par, int len, ...) \
*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: \
+ if (ret >= 0) { \
+ 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); \
+ } \
+ } \
va_end(args); \
} \
EXPORT_SYMBOL(func);
-define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, )
+define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, fbtft_identity)
define_fbtft_write_reg(fbtft_write_reg16_bus8, __be16, u16, cpu_to_be16)
-define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, )
+define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, fbtft_identity)
void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] staging: fbtft: fix macro flow control warning and empty macro argument in fbtft-bus.c
2026-02-02 16:28 [PATCH] staging: fbtft: fix macro flow control warning and empty macro argument in fbtft-bus.c KrishnaAgarwal1308
@ 2026-02-02 20:01 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2026-02-02 20:01 UTC (permalink / raw)
To: KrishnaAgarwal1308
Cc: Andy Shevchenko, Greg Kroah-Hartman, dri-devel, linux-fbdev,
linux-staging, linux-kernel
On Mon, Feb 02, 2026 at 09:58:26PM +0530, KrishnaAgarwal1308 wrote:
> Fix checkpatch warning by adding identity modifier for define_fbtft_write_reg().
> No functional change.
>
This commit does two things. It introduces fbtft_identity()
and it flips the if (ret < 0) condition around to avoid the goto
inside a macro. Only the first change is mentioned in the commit
message.
I have see the fbtft_identity() approach before and I don't like it.
https://lore.kernel.org/all/20250718191935.5918-2-abronzo@mac.com/
The name identity() doesn't mean anything. It's a real word and
it has a meaning but it doesn't have a meaning which is at all
related to this code.
I think I would be okay with this the macro were called nop_endian()
or cpu_to_cpu_endian() or something. Or another approach is to just
leave the code as-is. Or maybe we could add a comment?
Regarding the flipped condition, the new code is badly formatted and
uglier than the original. I would prefer to leave it as-is.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Revert "staging: fbtft: remove goto from define_fbtft_write_reg macro and clarify empty modifier fbtft-bus.c"
@ 2026-02-03 4:47 KrishnaAgarwal1308
2026-02-03 4:47 ` [PATCH] staging: fbtft: fix macro flow control warning and empty macro argument in fbtft-bus.c KrishnaAgarwal1308
0 siblings, 1 reply; 3+ messages in thread
From: KrishnaAgarwal1308 @ 2026-02-03 4:47 UTC (permalink / raw)
To: Andy Shevchenko, Greg Kroah-Hartman
Cc: dri-devel, linux-fbdev, linux-staging, linux-kernel,
KrishnaAgarwal1308
Replace the goto-based error handling in the define_fbtft_write_reg macro with an
early return while ensuring va_end() is called on all exit paths.
Also add a short comment explaining the empty modifier argument used
for native byte-order writes, instead of introducing an identity macro.
No functional change intended.
This reverts commit 6eec69e273e124dca8549fc52b0958b2953085ee. As per maintainer's feedback.
Signed-off-by: Krishna Agarwal <krishnaworkemail1308@gmail.com>
---
drivers/staging/fbtft/fbtft-bus.c | 41 ++++++++++++++++---------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c
index 0ab4f5c4f886..9b9df0edc158 100644
--- a/drivers/staging/fbtft/fbtft-bus.c
+++ b/drivers/staging/fbtft/fbtft-bus.c
@@ -10,7 +10,6 @@
* void (*write_reg)(struct fbtft_par *par, int len, ...);
*
*****************************************************************************/
-#define fbtft_identity(x) (x)
#define define_fbtft_write_reg(func, buffer_type, data_type, modifier) \
void func(struct fbtft_par *par, int len, ...) \
@@ -43,28 +42,30 @@ void func(struct fbtft_par *par, int len, ...) \
*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) { \
- 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); \
- } \
- } \
- va_end(args); \
+ if (ret < 0) { \
+ va_end(args); \
+ return; \
+ } \
+ 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); \
+ } \
+ va_end(args); \
} \
EXPORT_SYMBOL(func);
-
-define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, fbtft_identity)
+/* No modifier --> No byte-conversion is needed, data in native byte order */
+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, fbtft_identity)
+define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, )
void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH] staging: fbtft: fix macro flow control warning and empty macro argument in fbtft-bus.c
2026-02-03 4:47 [PATCH] Revert "staging: fbtft: remove goto from define_fbtft_write_reg macro and clarify empty modifier fbtft-bus.c" KrishnaAgarwal1308
@ 2026-02-03 4:47 ` KrishnaAgarwal1308
0 siblings, 0 replies; 3+ messages in thread
From: KrishnaAgarwal1308 @ 2026-02-03 4:47 UTC (permalink / raw)
To: Andy Shevchenko, Greg Kroah-Hartman
Cc: dri-devel, linux-fbdev, linux-staging, linux-kernel,
KrishnaAgarwal1308
Fix checkpatch warning by adding identity modifier for define_fbtft_write_reg().
No functional change.
Signed-off-by: KrishnaAgarwal1308 <krishnaworkemail1308@gmail.com>
---
drivers/staging/fbtft/fbtft-bus.c | 36 +++++++++++++++----------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c
index 30e436ff19e4..0ab4f5c4f886 100644
--- a/drivers/staging/fbtft/fbtft-bus.c
+++ b/drivers/staging/fbtft/fbtft-bus.c
@@ -10,6 +10,7 @@
* void (*write_reg)(struct fbtft_par *par, int len, ...);
*
*****************************************************************************/
+#define fbtft_identity(x) (x)
#define define_fbtft_write_reg(func, buffer_type, data_type, modifier) \
void func(struct fbtft_par *par, int len, ...) \
@@ -42,29 +43,28 @@ void func(struct fbtft_par *par, int len, ...) \
*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: \
+ if (ret >= 0) { \
+ 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); \
+ } \
+ } \
va_end(args); \
} \
EXPORT_SYMBOL(func);
-define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, )
+define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, fbtft_identity)
define_fbtft_write_reg(fbtft_write_reg16_bus8, __be16, u16, cpu_to_be16)
-define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, )
+define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, fbtft_identity)
void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-03 4:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-02 16:28 [PATCH] staging: fbtft: fix macro flow control warning and empty macro argument in fbtft-bus.c KrishnaAgarwal1308
2026-02-02 20:01 ` Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2026-02-03 4:47 [PATCH] Revert "staging: fbtft: remove goto from define_fbtft_write_reg macro and clarify empty modifier fbtft-bus.c" KrishnaAgarwal1308
2026-02-03 4:47 ` [PATCH] staging: fbtft: fix macro flow control warning and empty macro argument in fbtft-bus.c KrishnaAgarwal1308
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox