* [PATCH 15/15] Staging: comedi: fix macro coding style issue in adl_pci9111.c
@ 2010-03-10 14:02 Maurice Dawson
2010-03-10 16:49 ` Joe Perches
2010-04-08 19:33 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: Maurice Dawson @ 2010-03-10 14:02 UTC (permalink / raw)
To: gregkh, wfp5p, devel, linux-kernel
Patch to the adl_pci9111.c file that fixes, ERROR: Macros with multiple statements should be enclosed in a do - while block, found by the checkpatch.pl tool
Signed-off-by: Maurice Dawson <mauricedawson2699@googlemail.com>
---
drivers/staging/comedi/drivers/adl_pci9111.c | 44 +++++++++++++++++--------
1 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c
index 5e6f72f..5171176 100755
--- a/drivers/staging/comedi/drivers/adl_pci9111.c
+++ b/drivers/staging/comedi/drivers/adl_pci9111.c
@@ -207,12 +207,14 @@ Add external multiplexer support.
outb(0, PCI9111_IO_BASE+PCI9111_REGISTER_SOFTWARE_TRIGGER)
#define pci9111_fifo_reset() \
- outb(PCI9111_FFEN_SET_FIFO_ENABLE, \
- PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
- outb(PCI9111_FFEN_SET_FIFO_DISABLE, \
- PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
- outb(PCI9111_FFEN_SET_FIFO_ENABLE, \
- PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL)
+ do { \
+ outb(PCI9111_FFEN_SET_FIFO_ENABLE, \
+ PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
+ outb(PCI9111_FFEN_SET_FIFO_DISABLE, \
+ PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
+ outb(PCI9111_FFEN_SET_FIFO_ENABLE, \
+ PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
+ } while (0);
#define pci9111_is_fifo_full() \
((inb(PCI9111_IO_BASE+PCI9111_REGISTER_RANGE_STATUS_READBACK)& \
@@ -264,16 +266,28 @@ Add external multiplexer support.
outb(flags, PCI9111_IO_BASE+PCI9111_REGISTER_8254_CONTROL)
#define pci9111_8254_counter_0_set(data) \
- outb(data & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_0); \
- outb((data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_0)
+ do { \
+ outb(data & 0xFF, \
+ PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_0); \
+ outb((data >> 8) & 0xFF, \
+ PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_0); \
+ } while (0);
#define pci9111_8254_counter_1_set(data) \
- outb(data & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_1); \
- outb((data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_1)
+ do { \
+ outb(data & 0xFF, \
+ PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_1); \
+ outb((data >> 8) & 0xFF, \
+ PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_1); \
+ } while (0);
#define pci9111_8254_counter_2_set(data) \
- outb(data & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_2); \
- outb((data >> 8) & 0xFF, PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_2)
+ do { \
+ outb(data & 0xFF, \
+ PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_2); \
+ outb((data >> 8) & 0xFF, \
+ PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_2); \
+ } while (0);
/* Function prototypes */
@@ -564,8 +578,10 @@ static int pci9111_ai_cancel(struct comedi_device *dev,
/* Test analog input command */
#define pci9111_check_trigger_src(src, flags) \
- tmp = src; \
- src &= flags; if (!src || tmp != src) error++
+ do { \
+ tmp = src; \
+ src &= flags; if (!src || tmp != src) error++; \
+ } while (0);
static int
pci9111_ai_do_cmd_test(struct comedi_device *dev,
--
1.6.3.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 15/15] Staging: comedi: fix macro coding style issue in adl_pci9111.c
2010-03-10 14:02 [PATCH 15/15] Staging: comedi: fix macro coding style issue in adl_pci9111.c Maurice Dawson
@ 2010-03-10 16:49 ` Joe Perches
2010-04-08 19:33 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Joe Perches @ 2010-03-10 16:49 UTC (permalink / raw)
To: Maurice Dawson; +Cc: gregkh, wfp5p, devel, linux-kernel
On Wed, 2010-03-10 at 14:02 +0000, Maurice Dawson wrote:
> fixes, ERROR: Macros with multiple statements
> should be enclosed in a do - while block,
> found by the checkpatch.pl tool
Hello Maurice.
do {} while (0) macros should not use a trailing semicolon.
This allows the macro to be used in single statement if/else.
for example:
#define foo(a, b, c) \
do { \
x = (a); \
y = (b); \
z = (c); \
} while (0)
use:
if (test)
foo(1, 2, 3);
else
foo(4, 5, 6);
> #define pci9111_fifo_reset() \
> - outb(PCI9111_FFEN_SET_FIFO_ENABLE, \
> - PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
> - outb(PCI9111_FFEN_SET_FIFO_DISABLE, \
> - PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
> - outb(PCI9111_FFEN_SET_FIFO_ENABLE, \
> - PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL)
> + do { \
> + outb(PCI9111_FFEN_SET_FIFO_ENABLE, \
> + PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
> + outb(PCI9111_FFEN_SET_FIFO_DISABLE, \
> + PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
> + outb(PCI9111_FFEN_SET_FIFO_ENABLE, \
> + PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \
> + } while (0);
etc.
Also, there's a lot of uppercase and variable reuse in this macro
that makes it a bit difficult to parse and verify.
A couple more defines or a static inline could help.
Perhaps something like:
static inline void pci9111_fifo_reset(void)
{
unsigned long addr = PCI9111_IO_BASE + PCI9111_REGISTER_INTERRUPT_CONTROL;
outb(PCI9111_FFEN_SET_FIFO_ENABLE, addr);
outb(PCI9111_FFEN_SET_FIFO_DISABLE, addr);
outb(PCI9111_FFEN_SET_FIFO_ENABLE, addr);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 15/15] Staging: comedi: fix macro coding style issue in adl_pci9111.c
2010-03-10 14:02 [PATCH 15/15] Staging: comedi: fix macro coding style issue in adl_pci9111.c Maurice Dawson
2010-03-10 16:49 ` Joe Perches
@ 2010-04-08 19:33 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2010-04-08 19:33 UTC (permalink / raw)
To: Maurice Dawson; +Cc: gregkh, wfp5p, devel, linux-kernel
On Wed, Mar 10, 2010 at 02:02:15PM +0000, Maurice Dawson wrote:
> Patch to the adl_pci9111.c file that fixes, ERROR: Macros with multiple statements should be enclosed in a do - while block, found by the checkpatch.pl tool
Doesn't apply :(
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-04-08 20:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-10 14:02 [PATCH 15/15] Staging: comedi: fix macro coding style issue in adl_pci9111.c Maurice Dawson
2010-03-10 16:49 ` Joe Perches
2010-04-08 19:33 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox