mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Maurice Dawson <mauricedawson2699@googlemail.com>
Cc: gregkh@suse.de, wfp5p@virginia.edu, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 15/15] Staging: comedi: fix macro coding style issue in adl_pci9111.c
Date: Wed, 10 Mar 2010 08:49:28 -0800	[thread overview]
Message-ID: <1268239768.1545.292.camel@Joe-Laptop.home> (raw)
In-Reply-To: <1268229735-5387-1-git-send-email-mauricedawson2699@googlemail.com>

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);
}



  reply	other threads:[~2010-03-10 16:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-10 14:02 Maurice Dawson
2010-03-10 16:49 ` Joe Perches [this message]
2010-04-08 19:33 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1268239768.1545.292.camel@Joe-Laptop.home \
    --to=joe@perches.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mauricedawson2699@googlemail.com \
    --cc=wfp5p@virginia.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®