From: Joe Perches on
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);
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Greg KH on
On Wed, Mar 10, 2010 at 09:59:39PM +0000, Maurice Dawson wrote:
> Patch to remove trailing semi-colons from do - while loops in the adl_pci9111.c file

Doesn't apply :(
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Greg KH on
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 :(
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/