mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marcin Slusarz <marcin.slusarz@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: Stephen Hemminger <shemminger@vyatta.com>,
	David Miller <davem@davemloft.net>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drivers/block/floppy.c: stylistic cleanups
Date: Tue, 1 Dec 2009 18:36:35 +0100	[thread overview]
Message-ID: <20091201173635.GB2688@joi.lan> (raw)
In-Reply-To: <1259640820.13592.37.camel@Joe-Laptop.home>

On Mon, Nov 30, 2009 at 08:13:40PM -0800, Joe Perches wrote:
> On Mon, 2009-11-30 at 09:28 -0800, Stephen Hemminger wrote:
> > Rather than playing with the dangling operator format which seems to be a coding
> > style that only David cares about. Why not go through and fix the really ugly old
> > drivers that need it. For a good horror experience, go look at the floppy driver.
> 
> Just for you Stephen, here's a cleaned up version.
> Now to see if it gets applied, which I rather doubt.
> 
> Changes:
> 
> Removed macro definitions and uses of
> 	IN, OUT, LAST_OUT, CLEARSTRUCT, and CHECK_RESET
> Used C99 initializers
> Removed assigns from if statements
> Converted printks without KERN_ levels to pr_info and pr_cont
> Removed unnecessary braces
> Used print_hex_dump
> Moved leading logical tests to end of previous line
> Surrounded still ugly CALL and ECALL macro with do {} while (0)
> 
> Checkpatch complaints before:
> total: 393 errors, 132 warnings, 4647 lines checked
> 
> after:
> total: 1 errors, 11 warnings, 5352 lines checked
> 
> Compile tested only, x86 allyesconfig
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> 
>  drivers/block/floppy.c | 1853 +++++++++++++++++++++++++++++++++---------------
>  1 files changed, 1279 insertions(+), 574 deletions(-)
> 
>
...
> @@ -515,11 +1035,12 @@ static DECLARE_WAIT_QUEUE_HEAD(fdc_wait);
>  static DECLARE_WAIT_QUEUE_HEAD(command_done);
>  
>  #define NO_SIGNAL (!interruptible || !signal_pending(current))
> -#define CALL(x) if ((x) == -EINTR) return -EINTR
> -#define ECALL(x) if ((ret = (x))) return ret;
> -#define _WAIT(x,i) CALL(ret=wait_til_done((x),i))
> -#define WAIT(x) _WAIT((x),interruptible)
> -#define IWAIT(x) _WAIT((x),1)
> +
> +#define CALL(x)		do { if ((x) == -EINTR) return -EINTR; } while (0)
> +#define ECALL(x)	do { if ((ret = (x))) return ret; } while (0)
> +#define _WAIT(x, i)	CALL(ret = wait_til_done((x), i))
> +#define WAIT(x)		_WAIT((x), interruptible)
> +#define IWAIT(x)	_WAIT((x), 1)

why not remove these macros too? (probably in a seperate patch)
macros which hide "return" are very annoying...

...
> @@ -909,10 +1431,12 @@ static int _lock_fdc(int drive, int interruptible, int line)
>  	return 0;
>  }
>  
> -#define lock_fdc(drive,interruptible) _lock_fdc(drive,interruptible, __LINE__)
> +#define lock_fdc(drive, interruptible)			\
> +	_lock_fdc(drive, interruptible, __LINE__)
>  
> -#define LOCK_FDC(drive,interruptible) \
> -if (lock_fdc(drive,interruptible)) return -EINTR;
> +#define LOCK_FDC(drive, interruptible)	    \
> +	if (lock_fdc(drive, interruptible)) \
> +		return -EINTR;

another annoying macro
  
>  /* unlocks the driver */
>  static inline void unlock_fdc(void)
...
> @@ -1809,7 +2339,10 @@ static void recalibrate_floppy(void)
>  	debugt("recalibrate floppy:");
>  	do_floppy = recal_interrupt;
>  	output_byte(FD_RECALIBRATE);
> -	LAST_OUT(UNIT(current_drive));
> +	if (UNIT(current_drive) < 0) {
> +		reset_fdc();
> +		return;
> +	}
>  }

unneeded return

>  
>  /*
...
> @@ -3479,143 +4010,163 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
>  	/* convert compatibility eject ioctls into floppy eject ioctl.
>  	 * We do this in order to provide a means to eject floppy disks before
>  	 * installing the new fdutils package */
> -	if (cmd == CDROMEJECT ||	/* CD-ROM eject */
> -	    cmd == 0x6470 /* SunOS floppy eject */ ) {
> +	if (cmd == CDROMEJECT || cmd == 0x6470) {

please add descriptive constant

>  		DPRINT("obsolete eject ioctl\n");
>  		DPRINT("please use floppycontrol --eject\n");
>  		cmd = FDEJECT;
>  	}


  parent reply	other threads:[~2009-12-01 17:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1259001504.16503.79.camel@Joe-Laptop.home>
     [not found] ` <20091123.104130.117837098.davem@davemloft.net>
     [not found]   ` <1259528449.29779.194.camel@Joe-Laptop.home>
     [not found]     ` <20091129.165557.84377714.davem@davemloft.net>
     [not found]       ` <20091130092837.4998f961@nehalam>
2009-12-01  4:13         ` Joe Perches
2009-12-01 16:45           ` Stephen Hemminger
2009-12-01 19:09             ` Bartlomiej Zolnierkiewicz
2009-12-01 17:36           ` Marcin Slusarz [this message]
2009-12-01 17:46             ` Joe Perches
2009-12-01 18:39           ` Bartlomiej Zolnierkiewicz
     [not found]       ` <1259863101.22783.63.camel@Joe-Laptop.home>
     [not found]         ` <4B190A29.5080905@myri.com>
     [not found]           ` <1259947271.22783.120.camel@Joe-Laptop.home>
2009-12-05 12:43             ` [PATCH net-next-2.6] drivers/net: Move && and || to end of previous line William Allen Simpson
2009-12-05 17:50               ` Joe Perches
2009-12-05 22:05                 ` Jarek Poplawski
2009-12-06  3:36                 ` William Allen Simpson
2009-12-05 22:21               ` David Miller
2009-12-06  3:00                 ` William Allen Simpson
2009-12-06 17:01                   ` Jonathan Corbet

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=20091201173635.GB2688@joi.lan \
    --to=marcin.slusarz@gmail.com \
    --cc=davem@davemloft.net \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /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®