input: edt-ft5x06: fixed a macro coding style issue
Subsystems (2)
PATCH 1/1 input: edt-ft5x06: fixed a macro coding style issue
Fixed a coding style error, macros with complex values should be enclosed in parentheses.
--- drivers/input/touchscreen/edt-ft5x06.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/input/touchscreen/edt-ft5x06.c +3 -2
@@ -849,10 +849,11 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client,return 0 ; } -#define EDT_ATTR_CHECKSET (name, reg) \ +#define EDT_ATTR_CHECKSET (name, reg) { \ if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \ pdata->name <= edt_ft5x06_attr_##name.limit_high) \ - edt_ft5x06_register_write(tsdata, reg, pdata->name) + edt_ft5x06_register_write(tsdata, reg, pdata->name); \ +}#define EDT_GET_PROP (name, reg) { \ u32 val; \
Signature · 1 line
1.7.0.4
Quoted 2 lines · Asaf Vertz
Fixed a coding style error, macros with complex values should be enclosed in parentheses.
[]
drivers/input/touchscreen/edt-ft5x06.c
Quoted 1 line
drivers/input/touchscreen/edt-ft5x06.c +0
-0
[]
drivers/input/touchscreen/edt-ft5x06.c static int edt_ft5x06_ts_identify(struct i2c_client *client, · line 856
Quoted 11 lines
drivers/input/touchscreen/edt-ft5x06.c +3
-2@@ -849,10 +849,11 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client,return 0 ; } -#define EDT_ATTR_CHECKSET (name, reg) \ +#define EDT_ATTR_CHECKSET (name, reg) { \ if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \ pdata->name <= edt_ft5x06_attr_##name.limit_high) \ - edt_ft5x06_register_write(tsdata, reg, pdata->name) + edt_ft5x06_register_write(tsdata, reg, pdata->name); \ +}
Any time you see a naked if (foo) bar in a macro
prefer to use a do while (0) like;
#define EDT_ATTR_CHECKSET(name, reg) \
do { \
if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \
pdata->name <= edt_ft5x06_attr_##name.limit_high) \
edt_ft5x06_register_write(tsdata, reg, pdata->name); \while (0)
Quoted 15 lines · Joe Perches
drivers/input/touchscreen/edt-ft5x06.c static int edt_ft5x06_ts_identify(struct i2c_client *client, · line 856
Quoted 10 lines · Asaf Vertz
Fixed a coding style error, macros with complex values should be enclosed in parentheses.
drivers/input/touchscreen/edt-ft5x06.c +3
-2-#define EDT_ATTR_CHECKSET (name, reg) \ +#define EDT_ATTR_CHECKSET (name, reg) { \ if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \ pdata->name <= edt_ft5x06_attr_##name.limit_high) \ - edt_ft5x06_register_write(tsdata, reg, pdata->name) + edt_ft5x06_register_write(tsdata, reg, pdata->name); \ +}Any time you see a naked if (foo) bar in a macro
prefer to use a do while (0) like;
Quoted 7 lines
#define
EDT_ATTR_CHECKSET(name, reg)\do { \ if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \ pdata->name <= edt_ft5x06_attr_##name.limit_high) \ edt_ft5x06_register_write(tsdata, reg, pdata->name); \while (0)
thanks for the input, I will update and resend it