mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: linux-kernel@vger.kernel.org
Cc: Marcin Slusarz <marcin.slusarz@gmail.com>,
	Stephen Hemminger <shemminger@vyatta.com>,
	Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 06/24] drivers/block/floppy.c: Hoist assigns from if()s, neatening
Date: Thu, 21 Jan 2010 20:52:36 -0800	[thread overview]
Message-ID: <798ebc180693752df5c3dd2acc909d47992d5ea9.1264133863.git.joe@perches.com> (raw)
In-Reply-To: <cover.1264133863.git.joe@perches.com>

Move assigns above if()s
Remove unnecessary parentheses from returns
Use a temporary for a duplicated test

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/block/floppy.c |   53 ++++++++++++++++++++++++++---------------------
 1 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index f8c69fa..461c99a 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -1175,9 +1175,9 @@ static int wait_til_ready(void)
 /* sends a command byte to the fdc */
 static int output_byte(char byte)
 {
-	int status;
+	int status = wait_til_ready();
 
-	if ((status = wait_til_ready()) < 0)
+	if (status < 0)
 		return -1;
 	if ((status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY) {
 		fd_outb(byte, FD_DATA);
@@ -1207,7 +1207,8 @@ static int result(void)
 	int status = 0;
 
 	for (i = 0; i < MAX_REPLIES; i++) {
-		if ((status = wait_til_ready()) < 0)
+		status = wait_til_ready();
+		if (status < 0)
 			break;
 		status &= STATUS_DIR | STATUS_READY | STATUS_BUSY | STATUS_DMA;
 		if ((status & ~STATUS_BUSY) == STATUS_READY) {
@@ -1236,9 +1237,9 @@ static int result(void)
 /* does the fdc need more output? */
 static int need_more_output(void)
 {
-	int status;
+	int status = wait_til_ready();
 
-	if ((status = wait_til_ready()) < 0)
+	if (status < 0)
 		return -1;
 	if ((status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY)
 		return MORE_OUTPUT;
@@ -1414,8 +1415,8 @@ static int fdc_dtr(void)
 	 * Pause 5 msec to avoid trouble. (Needs to be 2 jiffies)
 	 */
 	FDCS->dtr = raw_cmd->rate & 3;
-	return (fd_wait_for_completion(jiffies + 2UL * HZ / 100,
-				       (timeout_fn) floppy_ready));
+	return fd_wait_for_completion(jiffies + 2UL * HZ / 100,
+				      (timeout_fn)floppy_ready);
 }				/* fdc_dtr */
 
 static void tell_sector(void)
@@ -1951,8 +1952,8 @@ static int start_motor(void (*function)(void))
 	set_dor(fdc, mask, data);
 
 	/* wait_for_completion also schedules reset if needed. */
-	return (fd_wait_for_completion(DRS->select_date + DP->select_delay,
-				       (timeout_fn) function));
+	return fd_wait_for_completion(DRS->select_date + DP->select_delay,
+				      (timeout_fn)function);
 }
 
 static void floppy_ready(void)
@@ -2729,8 +2730,10 @@ static int make_raw_rw_request(void)
 		}
 	} else if (in_sector_offset || blk_rq_sectors(current_req) < ssize) {
 		if (CT(COMMAND) == FD_WRITE) {
-			if (fsector_t + blk_rq_sectors(current_req) > ssize &&
-			    fsector_t + blk_rq_sectors(current_req) < ssize + ssize)
+			unsigned int sectors;
+
+			sectors = fsector_t + blk_rq_sectors(current_req);
+			if (sectors > ssize && sectors < ssize + ssize)
 				max_size = ssize + ssize;
 			else
 				max_size = ssize;
@@ -2751,9 +2754,8 @@ static int make_raw_rw_request(void)
 		 * on a 64 bit machine!
 		 */
 		max_size = buffer_chain_size();
-		dma_limit =
-		    (MAX_DMA_ADDRESS -
-		     ((unsigned long)current_req->buffer)) >> 9;
+		dma_limit = (MAX_DMA_ADDRESS -
+			     ((unsigned long)current_req->buffer)) >> 9;
 		if ((unsigned long)max_size > dma_limit)
 			max_size = dma_limit;
 		/* 64 kb boundaries */
@@ -2771,16 +2773,16 @@ static int make_raw_rw_request(void)
 		 */
 		if (!direct ||
 		    (indirect * 2 > direct * 3 &&
-		     *errors < DP->max_errors.read_track && ((!probing
-		       || (DP->read_track & (1 << DRS->probed_format)))))) {
+		     *errors < DP->max_errors.read_track &&
+		     ((!probing ||
+		       (DP->read_track & (1 << DRS->probed_format)))))) {
 			max_size = blk_rq_sectors(current_req);
 		} else {
 			raw_cmd->kernel_data = current_req->buffer;
 			raw_cmd->length = current_count_sectors << 9;
 			if (raw_cmd->length == 0) {
-				DPRINT
-				    ("zero dma transfer attempted from make_raw_request\n");
-				DPRINT("indirect=%d direct=%d fsector_t=%d",
+				DPRINT("zero dma transfer attempted from make_raw_request\n");
+				DPRINT("indirect=%d direct=%d fsector_t=%d\n",
 				       indirect, direct, fsector_t);
 				return 0;
 			}
@@ -2977,7 +2979,7 @@ static void process_fd_request(void)
 	schedule_bh(redo_fd_request);
 }
 
-static void do_fd_request(struct request_queue * q)
+static void do_fd_request(struct request_queue *q)
 {
 	if (max_buffer_sectors == 0) {
 		pr_info("VFS: do_fd_request called on non-open device\n");
@@ -3937,7 +3939,8 @@ static char __init get_fdc_version(void)
 	output_byte(FD_DUMPREGS);	/* 82072 and better know DUMPREGS */
 	if (FDCS->reset)
 		return FDC_NONE;
-	if ((r = result()) <= 0x00)
+	r = result();
+	if (r <= 0x00)
 		return FDC_NONE;	/* No FDC present ??? */
 	if ((r == 1) && (reply_buffer[0] == 0x80)) {
 		pr_info("FDC %d is an 8272A\n", fdc);
@@ -3966,7 +3969,7 @@ static char __init get_fdc_version(void)
 	r = result();
 	if ((r == 1) && (reply_buffer[0] == 0x80)) {
 		pr_info("FDC %d is a pre-1991 82077\n", fdc);
-		return FDC_82077_ORIG;	/* Pre-1991 82077, doesn't know 
+		return FDC_82077_ORIG;	/* Pre-1991 82077, doesn't know
 					 * LOCK/UNLOCK */
 	}
 	if ((r != 1) || (reply_buffer[0] != 0x00)) {
@@ -4357,7 +4360,8 @@ static int __init floppy_init(void)
 		if (err)
 			goto out_flush_work;
 
-		err = device_create_file(&floppy_device[drive].dev,&dev_attr_cmos);
+		err = device_create_file(&floppy_device[drive].dev,
+					 &dev_attr_cmos);
 		if (err)
 			goto out_unreg_platform_dev;
 
@@ -4578,7 +4582,8 @@ static void __init parse_floppy_cfg_string(char *cfg)
 	char *ptr;
 
 	while (*cfg) {
-		for (ptr = cfg; *cfg && *cfg != ' ' && *cfg != '\t'; cfg++) ;
+		for (ptr = cfg; *cfg && *cfg != ' ' && *cfg != '\t'; cfg++)
+			;
 		if (*cfg) {
 			*cfg = '\0';
 			cfg++;
-- 
1.6.6.rc0.57.gad7a


  parent reply	other threads:[~2010-01-22  4:57 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-22  4:52 [PATCH 00/24] drivers/block/floppy.c cleanups Joe Perches
2010-01-22  4:52 ` [PATCH 01/24] drivers/block/floppy.c: Convert some #include <asm/ to #include <linux/ Joe Perches
2010-01-22  4:52 ` [PATCH 02/24] drivers/block/floppy.c: #define space and column neatening Joe Perches
2010-01-22  4:52 ` [PATCH 03/24] drivers/block/floppy.c: Use pr_<level> Joe Perches
2010-01-22  4:52 ` [PATCH 04/24] drivers/block/floppy.c: Remove unnecessary braces Joe Perches
2010-01-22  4:52 ` [PATCH 05/24] drivers/block/floppy.c: Remove used once CHECK_READY macro Joe Perches
2010-01-22  4:52 ` Joe Perches [this message]
2010-01-22  4:52 ` [PATCH 07/24] drivers/block/floppy.c: Remove LAST_OUT macro Joe Perches
2010-01-22  4:52 ` [PATCH 08/24] drivers/block/floppy.c: Comment neatening and remove naked ; Joe Perches
2010-01-22  4:52 ` [PATCH 09/24] drivers/block/floppy.c: Remove CLEARSTRUCT macro, use memset Joe Perches
2010-01-22  4:52 ` [PATCH 10/24] drivers/block/floppy.c: Indent a comment Joe Perches
2010-01-22  4:52 ` [PATCH 11/24] drivers/block/floppy.c: Remove IN/OUT macros, indent switch/case Joe Perches
2010-01-22  4:52 ` [PATCH 12/24] drivers/block/floppy.c: Remove a few spaces from function casts Joe Perches
2010-01-22  4:52 ` [PATCH 13/24] drivers/block/floppy.c: Remove macro LOCK_FDC Joe Perches
2010-01-22  4:52 ` [PATCH 14/24] drivers/block/floppy.c: Add debug_dcl(...) macro Joe Perches
2010-01-22  4:52 ` [PATCH 15/24] drivers/block/floppy.c: Remove [U]CLEARF, [U]SETF, and [U]TESTF macros Joe Perches
2010-01-22  4:52 ` [PATCH 16/24] drivers/block/floppy.c: Remove most uses of CALL and ECALL macros Joe Perches
2010-01-22  4:52 ` [PATCH 17/24] drivers/block/floppy.c: remove [_]COPYIN [_]COPYOUT " Joe Perches
2010-01-22  4:52 ` [PATCH 18/24] drivers/block/floppy.c: remove macros CALL, WAIT and IWAIT Joe Perches
2010-01-22  4:52 ` [PATCH 19/24] drivers/block/floppy.c: convert int 1/0 to bool true/false Joe Perches
2010-01-22  4:52 ` [PATCH 20/24] drivers/block/floppy.c: Move leading && and || to preceding line Joe Perches
2010-01-22  4:52 ` [PATCH 21/24] drivers/block/floppy.c: remove #define DEVICE_NAME "floppy" Joe Perches
2010-01-22  4:52 ` [PATCH 22/24] drivers/block/floppy.c: Convert int initialising to bool initialized Joe Perches
2010-01-22  4:52 ` [PATCH 23/24] drivers/block/floppy.c: Add function is_ready_state Joe Perches
2010-01-22  4:52 ` [PATCH 24/24] drivers/block/floppy.c: Remove unnecessary return and braces Joe Perches
2010-01-22 10:47 ` [PATCH 00/24] drivers/block/floppy.c cleanups Andi Kleen
2010-01-22 11:46   ` Alan Cox
2010-01-22 17:04     ` Stephen Hemminger

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=798ebc180693752df5c3dd2acc909d47992d5ea9.1264133863.git.joe@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=bzolnier@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcin.slusarz@gmail.com \
    --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®