diff options
| author | Joe Perches <joe@perches.com> | 2010-03-10 18:20:48 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-12 18:52:29 -0500 |
| commit | d7b2b2ecd88d06ae212d069a4e187ab690b1636f (patch) | |
| tree | afcabe5b53d0ade068e9dc2464ce7d3387dbc11a /drivers/block | |
| parent | 045f98363080ddbbcef6b8b8306ec58a818406a0 (diff) | |
drivers/block/floppy.c: hoist assigns from if()s, neatening
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>
Cc: Stephen Hemminger <shemminger@vyatta.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block')
| -rw-r--r-- | 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 88a741c75110..7d1cd21a0ebc 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
| @@ -1175,9 +1175,9 @@ static int wait_til_ready(void) | |||
| 1175 | /* sends a command byte to the fdc */ | 1175 | /* sends a command byte to the fdc */ |
| 1176 | static int output_byte(char byte) | 1176 | static int output_byte(char byte) |
| 1177 | { | 1177 | { |
| 1178 | int status; | 1178 | int status = wait_til_ready(); |
| 1179 | 1179 | ||
| 1180 | if ((status = wait_til_ready()) < 0) | 1180 | if (status < 0) |
| 1181 | return -1; | 1181 | return -1; |
| 1182 | if ((status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY) { | 1182 | if ((status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY) { |
| 1183 | fd_outb(byte, FD_DATA); | 1183 | fd_outb(byte, FD_DATA); |
| @@ -1207,7 +1207,8 @@ static int result(void) | |||
| 1207 | int status = 0; | 1207 | int status = 0; |
| 1208 | 1208 | ||
| 1209 | for (i = 0; i < MAX_REPLIES; i++) { | 1209 | for (i = 0; i < MAX_REPLIES; i++) { |
| 1210 | if ((status = wait_til_ready()) < 0) | 1210 | status = wait_til_ready(); |
| 1211 | if (status < 0) | ||
| 1211 | break; | 1212 | break; |
| 1212 | status &= STATUS_DIR | STATUS_READY | STATUS_BUSY | STATUS_DMA; | 1213 | status &= STATUS_DIR | STATUS_READY | STATUS_BUSY | STATUS_DMA; |
| 1213 | if ((status & ~STATUS_BUSY) == STATUS_READY) { | 1214 | if ((status & ~STATUS_BUSY) == STATUS_READY) { |
| @@ -1236,9 +1237,9 @@ static int result(void) | |||
| 1236 | /* does the fdc need more output? */ | 1237 | /* does the fdc need more output? */ |
| 1237 | static int need_more_output(void) | 1238 | static int need_more_output(void) |
| 1238 | { | 1239 | { |
| 1239 | int status; | 1240 | int status = wait_til_ready(); |
| 1240 | 1241 | ||
| 1241 | if ((status = wait_til_ready()) < 0) | 1242 | if (status < 0) |
| 1242 | return -1; | 1243 | return -1; |
| 1243 | if ((status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY) | 1244 | if ((status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY) |
| 1244 | return MORE_OUTPUT; | 1245 | return MORE_OUTPUT; |
| @@ -1414,8 +1415,8 @@ static int fdc_dtr(void) | |||
| 1414 | * Pause 5 msec to avoid trouble. (Needs to be 2 jiffies) | 1415 | * Pause 5 msec to avoid trouble. (Needs to be 2 jiffies) |
| 1415 | */ | 1416 | */ |
| 1416 | FDCS->dtr = raw_cmd->rate & 3; | 1417 | FDCS->dtr = raw_cmd->rate & 3; |
| 1417 | return (fd_wait_for_completion(jiffies + 2UL * HZ / 100, | 1418 | return fd_wait_for_completion(jiffies + 2UL * HZ / 100, |
| 1418 | (timeout_fn) floppy_ready)); | 1419 | (timeout_fn)floppy_ready); |
| 1419 | } /* fdc_dtr */ | 1420 | } /* fdc_dtr */ |
| 1420 | 1421 | ||
| 1421 | static void tell_sector(void) | 1422 | static void tell_sector(void) |
| @@ -1951,8 +1952,8 @@ static int start_motor(void (*function)(void)) | |||
| 1951 | set_dor(fdc, mask, data); | 1952 | set_dor(fdc, mask, data); |
| 1952 | 1953 | ||
| 1953 | /* wait_for_completion also schedules reset if needed. */ | 1954 | /* wait_for_completion also schedules reset if needed. */ |
| 1954 | return (fd_wait_for_completion(DRS->select_date + DP->select_delay, | 1955 | return fd_wait_for_completion(DRS->select_date + DP->select_delay, |
| 1955 | (timeout_fn) function)); | 1956 | (timeout_fn)function); |
| 1956 | } | 1957 | } |
| 1957 | 1958 | ||
| 1958 | static void floppy_ready(void) | 1959 | static void floppy_ready(void) |
| @@ -2729,8 +2730,10 @@ static int make_raw_rw_request(void) | |||
| 2729 | } | 2730 | } |
| 2730 | } else if (in_sector_offset || blk_rq_sectors(current_req) < ssize) { | 2731 | } else if (in_sector_offset || blk_rq_sectors(current_req) < ssize) { |
| 2731 | if (CT(COMMAND) == FD_WRITE) { | 2732 | if (CT(COMMAND) == FD_WRITE) { |
| 2732 | if (fsector_t + blk_rq_sectors(current_req) > ssize && | 2733 | unsigned int sectors; |
| 2733 | fsector_t + blk_rq_sectors(current_req) < ssize + ssize) | 2734 | |
| 2735 | sectors = fsector_t + blk_rq_sectors(current_req); | ||
| 2736 | if (sectors > ssize && sectors < ssize + ssize) | ||
| 2734 | max_size = ssize + ssize; | 2737 | max_size = ssize + ssize; |
| 2735 | else | 2738 | else |
| 2736 | max_size = ssize; | 2739 | max_size = ssize; |
| @@ -2751,9 +2754,8 @@ static int make_raw_rw_request(void) | |||
| 2751 | * on a 64 bit machine! | 2754 | * on a 64 bit machine! |
| 2752 | */ | 2755 | */ |
| 2753 | max_size = buffer_chain_size(); | 2756 | max_size = buffer_chain_size(); |
| 2754 | dma_limit = | 2757 | dma_limit = (MAX_DMA_ADDRESS - |
| 2755 | (MAX_DMA_ADDRESS - | 2758 | ((unsigned long)current_req->buffer)) >> 9; |
| 2756 | ((unsigned long)current_req->buffer)) >> 9; | ||
| 2757 | if ((unsigned long)max_size > dma_limit) | 2759 | if ((unsigned long)max_size > dma_limit) |
| 2758 | max_size = dma_limit; | 2760 | max_size = dma_limit; |
| 2759 | /* 64 kb boundaries */ | 2761 | /* 64 kb boundaries */ |
| @@ -2771,16 +2773,16 @@ static int make_raw_rw_request(void) | |||
| 2771 | */ | 2773 | */ |
| 2772 | if (!direct || | 2774 | if (!direct || |
| 2773 | (indirect * 2 > direct * 3 && | 2775 | (indirect * 2 > direct * 3 && |
| 2774 | *errors < DP->max_errors.read_track && ((!probing | 2776 | *errors < DP->max_errors.read_track && |
| 2775 | || (DP->read_track & (1 << DRS->probed_format)))))) { | 2777 | ((!probing || |
| 2778 | (DP->read_track & (1 << DRS->probed_format)))))) { | ||
| 2776 | max_size = blk_rq_sectors(current_req); | 2779 | max_size = blk_rq_sectors(current_req); |
| 2777 | } else { | 2780 | } else { |
| 2778 | raw_cmd->kernel_data = current_req->buffer; | 2781 | raw_cmd->kernel_data = current_req->buffer; |
| 2779 | raw_cmd->length = current_count_sectors << 9; | 2782 | raw_cmd->length = current_count_sectors << 9; |
| 2780 | if (raw_cmd->length == 0) { | 2783 | if (raw_cmd->length == 0) { |
| 2781 | DPRINT | 2784 | DPRINT("zero dma transfer attempted from make_raw_request\n"); |
| 2782 | ("zero dma transfer attempted from make_raw_request\n"); | 2785 | DPRINT("indirect=%d direct=%d fsector_t=%d\n", |
| 2783 | DPRINT("indirect=%d direct=%d fsector_t=%d", | ||
| 2784 | indirect, direct, fsector_t); | 2786 | indirect, direct, fsector_t); |
| 2785 | return 0; | 2787 | return 0; |
| 2786 | } | 2788 | } |
| @@ -2977,7 +2979,7 @@ static void process_fd_request(void) | |||
| 2977 | schedule_bh(redo_fd_request); | 2979 | schedule_bh(redo_fd_request); |
| 2978 | } | 2980 | } |
| 2979 | 2981 | ||
| 2980 | static void do_fd_request(struct request_queue * q) | 2982 | static void do_fd_request(struct request_queue *q) |
| 2981 | { | 2983 | { |
| 2982 | if (max_buffer_sectors == 0) { | 2984 | if (max_buffer_sectors == 0) { |
| 2983 | pr_info("VFS: do_fd_request called on non-open device\n"); | 2985 | pr_info("VFS: do_fd_request called on non-open device\n"); |
| @@ -3937,7 +3939,8 @@ static char __init get_fdc_version(void) | |||
| 3937 | output_byte(FD_DUMPREGS); /* 82072 and better know DUMPREGS */ | 3939 | output_byte(FD_DUMPREGS); /* 82072 and better know DUMPREGS */ |
| 3938 | if (FDCS->reset) | 3940 | if (FDCS->reset) |
| 3939 | return FDC_NONE; | 3941 | return FDC_NONE; |
| 3940 | if ((r = result()) <= 0x00) | 3942 | r = result(); |
| 3943 | if (r <= 0x00) | ||
| 3941 | return FDC_NONE; /* No FDC present ??? */ | 3944 | return FDC_NONE; /* No FDC present ??? */ |
| 3942 | if ((r == 1) && (reply_buffer[0] == 0x80)) { | 3945 | if ((r == 1) && (reply_buffer[0] == 0x80)) { |
| 3943 | pr_info("FDC %d is an 8272A\n", fdc); | 3946 | pr_info("FDC %d is an 8272A\n", fdc); |
| @@ -3966,7 +3969,7 @@ static char __init get_fdc_version(void) | |||
| 3966 | r = result(); | 3969 | r = result(); |
| 3967 | if ((r == 1) && (reply_buffer[0] == 0x80)) { | 3970 | if ((r == 1) && (reply_buffer[0] == 0x80)) { |
| 3968 | pr_info("FDC %d is a pre-1991 82077\n", fdc); | 3971 | pr_info("FDC %d is a pre-1991 82077\n", fdc); |
| 3969 | return FDC_82077_ORIG; /* Pre-1991 82077, doesn't know | 3972 | return FDC_82077_ORIG; /* Pre-1991 82077, doesn't know |
| 3970 | * LOCK/UNLOCK */ | 3973 | * LOCK/UNLOCK */ |
| 3971 | } | 3974 | } |
| 3972 | if ((r != 1) || (reply_buffer[0] != 0x00)) { | 3975 | if ((r != 1) || (reply_buffer[0] != 0x00)) { |
| @@ -4357,7 +4360,8 @@ static int __init floppy_init(void) | |||
| 4357 | if (err) | 4360 | if (err) |
| 4358 | goto out_flush_work; | 4361 | goto out_flush_work; |
| 4359 | 4362 | ||
| 4360 | err = device_create_file(&floppy_device[drive].dev,&dev_attr_cmos); | 4363 | err = device_create_file(&floppy_device[drive].dev, |
| 4364 | &dev_attr_cmos); | ||
| 4361 | if (err) | 4365 | if (err) |
| 4362 | goto out_unreg_platform_dev; | 4366 | goto out_unreg_platform_dev; |
| 4363 | 4367 | ||
| @@ -4578,7 +4582,8 @@ static void __init parse_floppy_cfg_string(char *cfg) | |||
| 4578 | char *ptr; | 4582 | char *ptr; |
| 4579 | 4583 | ||
| 4580 | while (*cfg) { | 4584 | while (*cfg) { |
| 4581 | for (ptr = cfg; *cfg && *cfg != ' ' && *cfg != '\t'; cfg++) ; | 4585 | for (ptr = cfg; *cfg && *cfg != ' ' && *cfg != '\t'; cfg++) |
| 4586 | ; | ||
| 4582 | if (*cfg) { | 4587 | if (*cfg) { |
| 4583 | *cfg = '\0'; | 4588 | *cfg = '\0'; |
| 4584 | cfg++; | 4589 | cfg++; |
