Skip to content

Commit

Permalink
drivers/block/floppy.c: add function is_ready_state
Browse files Browse the repository at this point in the history
Used a couple of times, might simplify the code a bit.

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>
  • Loading branch information
JoePerches authored and torvalds committed Mar 12, 2010
1 parent 29f1c78 commit 57584c5
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions drivers/block/floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,12 @@ static inline int is_selected(int dor, int unit)
return ((dor & (0x10 << unit)) && (dor & 3) == unit);
}

static bool is_ready_state(int status)
{
int state = status & (STATUS_READY | STATUS_DIR | STATUS_DMA);
return state == STATUS_READY;
}

static int set_dor(int fdc, char mask, char data)
{
unsigned char unit;
Expand Down Expand Up @@ -823,8 +829,10 @@ static void twaddle(void)
DRS->select_date = jiffies;
}

/* reset all driver information about the current fdc. This is needed after
* a reset, and after a raw command. */
/*
* Reset all driver information about the current fdc.
* This is needed after a reset, and after a raw command.
*/
static void reset_fdc_info(int mode)
{
int drive;
Expand Down Expand Up @@ -1162,7 +1170,8 @@ static int output_byte(char byte)

if (status < 0)
return -1;
if ((status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY) {

if (is_ready_state(status)) {
fd_outb(byte, FD_DATA);
#ifdef FLOPPY_SANITY_CHECK
output_log[output_log_pos].data = byte;
Expand Down Expand Up @@ -1221,8 +1230,10 @@ static int need_more_output(void)

if (status < 0)
return -1;
if ((status & (STATUS_READY | STATUS_DIR | STATUS_DMA)) == STATUS_READY)

if (is_ready_state(status))
return MORE_OUTPUT;

return result();
}

Expand Down

0 comments on commit 57584c5

Please sign in to comment.