Revert "staging: fbtft: remove goto from define_fbtft_write_reg macro and clarify empty modifier fbtft-bus.c"
Subsystems (3)
PATCH 1/1 Revert "staging: fbtft: remove goto from define_fbtft_write_reg macro and clarify empty modifier fbtft-bus.c"
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.
--- drivers/staging/fbtft/fbtft-bus.c | 41 ++++++++++++++++--------------- 1 file changed, 21 insertions(+), 20 deletions(-)
drivers/staging/fbtft/fbtft-bus.c +21 -20
@@ -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, ...) {
Signature · 1 line
2.43.0
PATCH 1/1 staging: fbtft: fix macro flow control warning and empty macro argument in fbtft-bus.c
Fix checkpatch warning by adding identity modifier for define_fbtft_write_reg(). No functional change.
--- drivers/staging/fbtft/fbtft-bus.c | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/staging/fbtft/fbtft-bus.c +18 -18
@@ -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, ...) {
Signature · 1 line
2.43.0
Quoted 6 lines · On Tue, Feb 03, 2026 at 10:17:27AM +0530, KrishnaAgarwal1308 wrote:
Replace the goto-based error handling in the
define_fbtft_write_regmacro with an early return while ensuringva_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.
Quoted 6 lines
No functional change intended.
This reverts commit
6eec69e273e124dca8549fc52b0958b2953085ee. As per maintainer's feedback.Signed-off-by Krishna Agarwal <[email protected]>---
There is no need to revert the commit because we weren't going to apply it.
Also checkpatch is going to complain about return statements the same way it complains about gotos. Actually, I'm surprised checkpatch complains about gotos. Does it differentiate between local gotos? I can't be bothered to check. #LazyWeb
regards,
dan carpenter