From 3c6051afa3d4e22273e7eed11186513a12554515 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 1 Mar 2020 20:55:50 +0100 Subject: floppy: remove dead code for drives scanning on ARM On ARM, function fd_scandrives pre-dates Git era, is #ifed 0 out, not used, and cannot even compile since it references an fdc variable that's not declared anywhere (supposed to be the global one that we're turning to current_fdc apparently). There was also an ifdefde out include of mach/floppy.h that does not exist anymore either. Let's get rid of them since they complicate the fixing of the driver. Link: https://lore.kernel.org/r/20200301195555.11154-2-w@1wt.eu Cc: Ian Molton Cc: Russell King Cc: Linus Torvalds Signed-off-by: Willy Tarreau Signed-off-by: Denis Efremov Signed-off-by: Jens Axboe --- arch/arm/include/asm/floppy.h | 51 ------------------------------------------- 1 file changed, 51 deletions(-) (limited to 'arch') diff --git a/arch/arm/include/asm/floppy.h b/arch/arm/include/asm/floppy.h index f4fe4d02cef2..465565274345 100644 --- a/arch/arm/include/asm/floppy.h +++ b/arch/arm/include/asm/floppy.h @@ -8,9 +8,6 @@ */ #ifndef __ASM_ARM_FLOPPY_H #define __ASM_ARM_FLOPPY_H -#if 0 -#include -#endif #define fd_outb(val,port) \ do { \ @@ -69,54 +66,6 @@ do { \ outb(new_dor, FD_DOR); \ } while (0) -/* - * Someday, we'll automatically detect which drives are present... - */ -static inline void fd_scandrives (void) -{ -#if 0 - int floppy, drive_count; - - fd_disable_irq(); - raw_cmd = &default_raw_cmd; - raw_cmd->flags = FD_RAW_SPIN | FD_RAW_NEED_SEEK; - raw_cmd->track = 0; - raw_cmd->rate = ?; - drive_count = 0; - for (floppy = 0; floppy < 4; floppy ++) { - current_drive = drive_count; - /* - * Turn on floppy motor - */ - if (start_motor(redo_fd_request)) - continue; - /* - * Set up FDC - */ - fdc_specify(); - /* - * Tell FDC to recalibrate - */ - output_byte(FD_RECALIBRATE); - LAST_OUT(UNIT(floppy)); - /* wait for command to complete */ - if (!successful) { - int i; - for (i = drive_count; i < 3; i--) - floppy_selects[fdc][i] = floppy_selects[fdc][i + 1]; - floppy_selects[fdc][3] = 0; - floppy -= 1; - } else - drive_count++; - } -#else - floppy_selects[0][0] = 0x10; - floppy_selects[0][1] = 0x21; - floppy_selects[0][2] = 0x23; - floppy_selects[0][3] = 0x33; -#endif -} - #define FDC1 (0x3f0) #define FLOPPY0_TYPE 4 -- cgit v1.2.3 From 336eae37338590ea259954546a44a5f524256b6e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 1 Mar 2020 20:55:51 +0100 Subject: floppy: remove incomplete support for second FDC from ARM code The ARM code was written with the apparent hope to one day support a second FDC except that the code was incomplete and only touches the first one, which is also reflected by N_FDC==1. However this made its fd_outb() macro artificially depend on the global or local "fdc" variable. Let's get rid of this and make it explicit it doesn't rely on this variable anymore. Link: https://lore.kernel.org/r/20200301195555.11154-3-w@1wt.eu Cc: Ian Molton Cc: Russell King Cc: Linus Torvalds Signed-off-by: Willy Tarreau Signed-off-by: Denis Efremov Signed-off-by: Jens Axboe --- arch/arm/include/asm/floppy.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'arch') diff --git a/arch/arm/include/asm/floppy.h b/arch/arm/include/asm/floppy.h index 465565274345..7e58979f02bf 100644 --- a/arch/arm/include/asm/floppy.h +++ b/arch/arm/include/asm/floppy.h @@ -50,17 +50,13 @@ static inline int fd_dma_setup(void *data, unsigned int length, * to a non-zero track, and then restoring it to track 0. If an error occurs, * then there is no floppy drive present. [to be put back in again] */ -static unsigned char floppy_selects[2][4] = -{ - { 0x10, 0x21, 0x23, 0x33 }, - { 0x10, 0x21, 0x23, 0x33 } -}; +static unsigned char floppy_selects[4] = { 0x10, 0x21, 0x23, 0x33 }; #define fd_setdor(dor) \ do { \ int new_dor = (dor); \ if (new_dor & 0xf0) \ - new_dor = (new_dor & 0x0c) | floppy_selects[fdc][new_dor & 3]; \ + new_dor = (new_dor & 0x0c) | floppy_selects[new_dor & 3]; \ else \ new_dor &= 0x0c; \ outb(new_dor, FD_DOR); \ @@ -84,9 +80,7 @@ do { \ */ static void driveswap(int *ints, int dummy, int dummy2) { - floppy_selects[0][0] ^= floppy_selects[0][1]; - floppy_selects[0][1] ^= floppy_selects[0][0]; - floppy_selects[0][0] ^= floppy_selects[0][1]; + swap(floppy_selects[0], floppy_selects[1]); } #define EXTRA_FLOPPY_PARAMS ,{ "driveswap", &driveswap, NULL, 0, 0 } -- cgit v1.2.3 From fc0c5c0c85a83207a16011d34916ec4c5db083a1 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 1 Mar 2020 20:55:52 +0100 Subject: floppy: prepare ARM code to simplify base address separation The fd_outb() macro on ARM relies on a special fd_setdor() macro when the register is FD_DOR and both will need to be changed to accept a separate base address. Let's just remerge them to simplify the change and make this code more easily reviewable. Link: https://lore.kernel.org/r/20200301195555.11154-4-w@1wt.eu Cc: Ian Molton Cc: Russell King Cc: Linus Torvalds Signed-off-by: Willy Tarreau Signed-off-by: Denis Efremov Signed-off-by: Jens Axboe --- arch/arm/include/asm/floppy.h | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'arch') diff --git a/arch/arm/include/asm/floppy.h b/arch/arm/include/asm/floppy.h index 7e58979f02bf..34ebd86bf58b 100644 --- a/arch/arm/include/asm/floppy.h +++ b/arch/arm/include/asm/floppy.h @@ -9,12 +9,17 @@ #ifndef __ASM_ARM_FLOPPY_H #define __ASM_ARM_FLOPPY_H -#define fd_outb(val,port) \ - do { \ - if ((port) == (u32)FD_DOR) \ - fd_setdor((val)); \ - else \ - outb((val),(port)); \ +#define fd_outb(val,port) \ + do { \ + int new_val = (val); \ + if ((port) == (u32)FD_DOR) { \ + if (new_val & 0xf0) \ + new_val = (new_val & 0x0c) | \ + floppy_selects[new_val & 3]; \ + else \ + new_val &= 0x0c; \ + } \ + outb(new_val, (port)); \ } while(0) #define fd_inb(port) inb((port)) @@ -52,16 +57,6 @@ static inline int fd_dma_setup(void *data, unsigned int length, */ static unsigned char floppy_selects[4] = { 0x10, 0x21, 0x23, 0x33 }; -#define fd_setdor(dor) \ -do { \ - int new_dor = (dor); \ - if (new_dor & 0xf0) \ - new_dor = (new_dor & 0x0c) | floppy_selects[new_dor & 3]; \ - else \ - new_dor &= 0x0c; \ - outb(new_dor, FD_DOR); \ -} while (0) - #define FDC1 (0x3f0) #define FLOPPY0_TYPE 4 -- cgit v1.2.3 From e2032464fe189c33005a6296fa67c47d2fea4d05 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 1 Mar 2020 20:55:54 +0100 Subject: floppy: separate the FDC's base address from its registers FDC registers FD_STATUS, FD_DATA, FD_DOR, FD_DIR and FD_DCR used to be defined relative to FD_IOPORT, which is the FDC's base address, itself a macro depending on the "fdc" local or global variable. This patch changes this so that the register macros above now only reference the address offset, and that the FDC's address is explicitly passed in each call to fd_inb() and fd_outb(), thus removing the macro. With this change there is no more implicit usage of the local/global "fdc" variable. One place in the ARM code used to check if the port was equal to FD_DOR, this was changed to testing the register by applying a mask to the port, as was already done in the sparc code. There are still occurrences of fd_inb() and fd_outb() in the PARISC code and these ones remain unaffected since they already used to work with a base address and a register offset. The sparc, m68k and parisc code could now be slightly cleaned up to benefit from the macro definitions above instead of the equivalent hard-coded values. Link: https://lore.kernel.org/r/20200301195555.11154-6-w@1wt.eu Cc: Ian Molton Cc: Russell King Cc: Linus Torvalds Signed-off-by: Willy Tarreau Signed-off-by: Denis Efremov Signed-off-by: Jens Axboe --- arch/arm/include/asm/floppy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/arm/include/asm/floppy.h b/arch/arm/include/asm/floppy.h index 34ebd86bf58b..79fa327238e8 100644 --- a/arch/arm/include/asm/floppy.h +++ b/arch/arm/include/asm/floppy.h @@ -12,7 +12,7 @@ #define fd_outb(val,port) \ do { \ int new_val = (val); \ - if ((port) == (u32)FD_DOR) { \ + if (((port) & 7) == FD_DOR) { \ if (new_val & 0xf0) \ new_val = (new_val & 0x0c) | \ floppy_selects[new_val & 3]; \ -- cgit v1.2.3