* [PATCH] input: edt-ft5x06: fixed a macro coding style issue
@ 2014-12-09 6:34 Asaf Vertz
2014-12-09 6:44 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Asaf Vertz @ 2014-12-09 6:34 UTC (permalink / raw)
To: dmitry.torokhov
Cc: LW, B38611, maksqwe1, jg1.han, linux, fabf, asaf.vertz,
linux-input, linux-kernel
Fixed a coding style error, macros with complex values should be
enclosed in parentheses.
Signed-off-by: Asaf Vertz <asaf.vertz@tandemg.com>
---
drivers/input/touchscreen/edt-ft5x06.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index ee3434f..6db9253 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -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; \
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] input: edt-ft5x06: fixed a macro coding style issue
2014-12-09 6:34 [PATCH] input: edt-ft5x06: fixed a macro coding style issue Asaf Vertz
@ 2014-12-09 6:44 ` Joe Perches
2014-12-09 7:51 ` Asaf Vertz
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2014-12-09 6:44 UTC (permalink / raw)
To: Asaf Vertz
Cc: dmitry.torokhov, LW, B38611, maksqwe1, jg1.han, linux, fabf,
linux-input, linux-kernel
On Tue, 2014-12-09 at 08:34 +0200, Asaf Vertz wrote:
> Fixed a coding style error, macros with complex values should be
> enclosed in parentheses.
[]
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
[]
> @@ -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)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] input: edt-ft5x06: fixed a macro coding style issue
2014-12-09 6:44 ` Joe Perches
@ 2014-12-09 7:51 ` Asaf Vertz
0 siblings, 0 replies; 3+ messages in thread
From: Asaf Vertz @ 2014-12-09 7:51 UTC (permalink / raw)
To: Joe Perches
Cc: dmitry.torokhov, LW, B38611, maksqwe1, jg1.han, linux, fabf,
linux-input, linux-kernel
On 12/09/2014 08:44 AM, Joe Perches wrote:
> On Tue, 2014-12-09 at 08:34 +0200, Asaf Vertz wrote:
>> Fixed a coding style error, macros with complex values should be
>> enclosed in parentheses.
>>
>> -#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)
>
thanks for the input, I will update and resend it
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-12-09 7:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-09 6:34 [PATCH] input: edt-ft5x06: fixed a macro coding style issue Asaf Vertz
2014-12-09 6:44 ` Joe Perches
2014-12-09 7:51 ` Asaf Vertz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.