Commit 96dad77a authored by Willy Tarreau's avatar Willy Tarreau Committed by Denis Efremov

floppy: cleanup: make result() not rely on current_fdc anymore

Now the fdc is passed in argument so that the function does not
use current_fdc anymore.

It's worth noting that there's still a single reply_buffer[] which
will store the result for the current fdc. It may or may not make
sense to implement one buffer per fdc in the future.

Link: https://lore.kernel.org/r/20200331094054.24441-15-w@1wt.euSigned-off-by: default avatarWilly Tarreau <w@1wt.eu>
Signed-off-by: default avatarDenis Efremov <efremov@linux.com>
parent f8a8e0f7
...@@ -1153,13 +1153,13 @@ static int output_byte(int fdc, char byte) ...@@ -1153,13 +1153,13 @@ static int output_byte(int fdc, char byte)
} }
/* gets the response from the fdc */ /* gets the response from the fdc */
static int result(void) static int result(int fdc)
{ {
int i; int i;
int status = 0; int status = 0;
for (i = 0; i < MAX_REPLIES; i++) { for (i = 0; i < MAX_REPLIES; i++) {
status = wait_til_ready(current_fdc); status = wait_til_ready(fdc);
if (status < 0) if (status < 0)
break; break;
status &= STATUS_DIR | STATUS_READY | STATUS_BUSY | STATUS_DMA; status &= STATUS_DIR | STATUS_READY | STATUS_BUSY | STATUS_DMA;
...@@ -1169,16 +1169,16 @@ static int result(void) ...@@ -1169,16 +1169,16 @@ static int result(void)
return i; return i;
} }
if (status == (STATUS_DIR | STATUS_READY | STATUS_BUSY)) if (status == (STATUS_DIR | STATUS_READY | STATUS_BUSY))
reply_buffer[i] = fdc_inb(current_fdc, FD_DATA); reply_buffer[i] = fdc_inb(fdc, FD_DATA);
else else
break; break;
} }
if (initialized) { if (initialized) {
DPRINT("get result error. Fdc=%d Last status=%x Read bytes=%d\n", DPRINT("get result error. Fdc=%d Last status=%x Read bytes=%d\n",
current_fdc, status, i); fdc, status, i);
show_floppy(current_fdc); show_floppy(fdc);
} }
fdc_state[current_fdc].reset = 1; fdc_state[fdc].reset = 1;
return -1; return -1;
} }
...@@ -1194,7 +1194,7 @@ static int need_more_output(void) ...@@ -1194,7 +1194,7 @@ static int need_more_output(void)
if (is_ready_state(status)) if (is_ready_state(status))
return MORE_OUTPUT; return MORE_OUTPUT;
return result(); return result(current_fdc);
} }
/* Set perpendicular mode as required, based on data rate, if supported. /* Set perpendicular mode as required, based on data rate, if supported.
...@@ -1524,7 +1524,7 @@ static void setup_rw_floppy(void) ...@@ -1524,7 +1524,7 @@ static void setup_rw_floppy(void)
} }
if (!(flags & FD_RAW_INTR)) { if (!(flags & FD_RAW_INTR)) {
inr = result(); inr = result(current_fdc);
cont->interrupt(); cont->interrupt();
} else if (flags & FD_RAW_NEED_DISK) } else if (flags & FD_RAW_NEED_DISK)
fd_watchdog(); fd_watchdog();
...@@ -1568,7 +1568,7 @@ static void check_wp(void) ...@@ -1568,7 +1568,7 @@ static void check_wp(void)
/* check write protection */ /* check write protection */
output_byte(current_fdc, FD_GETSTATUS); output_byte(current_fdc, FD_GETSTATUS);
output_byte(current_fdc, UNIT(current_drive)); output_byte(current_fdc, UNIT(current_drive));
if (result() != 1) { if (result(current_fdc) != 1) {
fdc_state[current_fdc].reset = 1; fdc_state[current_fdc].reset = 1;
return; return;
} }
...@@ -1742,14 +1742,14 @@ irqreturn_t floppy_interrupt(int irq, void *dev_id) ...@@ -1742,14 +1742,14 @@ irqreturn_t floppy_interrupt(int irq, void *dev_id)
do_print = !handler && print_unex && initialized; do_print = !handler && print_unex && initialized;
inr = result(); inr = result(current_fdc);
if (do_print) if (do_print)
print_result("unexpected interrupt", inr); print_result("unexpected interrupt", inr);
if (inr == 0) { if (inr == 0) {
int max_sensei = 4; int max_sensei = 4;
do { do {
output_byte(current_fdc, FD_SENSEI); output_byte(current_fdc, FD_SENSEI);
inr = result(); inr = result(current_fdc);
if (do_print) if (do_print)
print_result("sensei", inr); print_result("sensei", inr);
max_sensei--; max_sensei--;
...@@ -1782,7 +1782,7 @@ static void recalibrate_floppy(void) ...@@ -1782,7 +1782,7 @@ static void recalibrate_floppy(void)
static void reset_interrupt(void) static void reset_interrupt(void)
{ {
debugt(__func__, ""); debugt(__func__, "");
result(); /* get the status ready for set_fdc */ result(current_fdc); /* get the status ready for set_fdc */
if (fdc_state[current_fdc].reset) { if (fdc_state[current_fdc].reset) {
pr_info("reset set in interrupt, calling %ps\n", cont->error); pr_info("reset set in interrupt, calling %ps\n", cont->error);
cont->error(); /* a reset just after a reset. BAD! */ cont->error(); /* a reset just after a reset. BAD! */
...@@ -4305,7 +4305,7 @@ static char __init get_fdc_version(void) ...@@ -4305,7 +4305,7 @@ static char __init get_fdc_version(void)
output_byte(current_fdc, FD_DUMPREGS); /* 82072 and better know DUMPREGS */ output_byte(current_fdc, FD_DUMPREGS); /* 82072 and better know DUMPREGS */
if (fdc_state[current_fdc].reset) if (fdc_state[current_fdc].reset)
return FDC_NONE; return FDC_NONE;
r = result(); r = result(current_fdc);
if (r <= 0x00) if (r <= 0x00)
return FDC_NONE; /* No FDC present ??? */ return FDC_NONE; /* No FDC present ??? */
if ((r == 1) && (reply_buffer[0] == 0x80)) { if ((r == 1) && (reply_buffer[0] == 0x80)) {
...@@ -4332,7 +4332,7 @@ static char __init get_fdc_version(void) ...@@ -4332,7 +4332,7 @@ static char __init get_fdc_version(void)
} }
output_byte(current_fdc, FD_UNLOCK); output_byte(current_fdc, FD_UNLOCK);
r = result(); r = result(current_fdc);
if ((r == 1) && (reply_buffer[0] == 0x80)) { if ((r == 1) && (reply_buffer[0] == 0x80)) {
pr_info("FDC %d is a pre-1991 82077\n", current_fdc); pr_info("FDC %d is a pre-1991 82077\n", current_fdc);
return FDC_82077_ORIG; /* Pre-1991 82077, doesn't know return FDC_82077_ORIG; /* Pre-1991 82077, doesn't know
...@@ -4344,7 +4344,7 @@ static char __init get_fdc_version(void) ...@@ -4344,7 +4344,7 @@ static char __init get_fdc_version(void)
return FDC_UNKNOWN; return FDC_UNKNOWN;
} }
output_byte(current_fdc, FD_PARTID); output_byte(current_fdc, FD_PARTID);
r = result(); r = result(current_fdc);
if (r != 1) { if (r != 1) {
pr_info("FDC %d init: PARTID: unexpected return of %d bytes.\n", pr_info("FDC %d init: PARTID: unexpected return of %d bytes.\n",
current_fdc, r); current_fdc, r);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment