From: Denis Efremov <efremov@linux.com>
To: Willy Tarreau <w@1wt.eu>, Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 15/16] floppy: separate the FDC's base address from its registers
Date: Wed, 26 Feb 2020 18:36:52 +0300 [thread overview]
Message-ID: <ab69fbdc-7ccb-05ef-6c25-7fb6ed6fce59@linux.com> (raw)
In-Reply-To: <20200226080732.1913-5-w@1wt.eu>
> 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.
>
> 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.
Just to note for future ref: the mask (7) can be introduced as define
during future clean up of these magic constants.
>
> Signed-off-by: Willy Tarreau <w@1wt.eu>
> ---
> arch/arm/include/asm/floppy.h | 2 +-
> drivers/block/floppy.c | 9 ++++-----
> include/uapi/linux/fdreg.h | 18 +++++-------------
> 3 files changed, 10 insertions(+), 19 deletions(-)
>
> diff --git a/arch/arm/include/asm/floppy.h b/arch/arm/include/asm/floppy.h
> index c665136..4e3fb71 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]; \
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index 250a451..4e43a7e 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -171,7 +171,6 @@ static int print_unex = 1;
> #include <linux/kernel.h>
> #include <linux/timer.h>
> #include <linux/workqueue.h>
> -#define FDPATCHES
> #include <linux/fdreg.h>
> #include <linux/fd.h>
> #include <linux/hdreg.h>
> @@ -594,14 +593,14 @@ static unsigned char fsector_t; /* sector in track */
> static unsigned char in_sector_offset; /* offset within physical sector,
> * expressed in units of 512 bytes */
>
> -static inline unsigned char fdc_inb(int fdc, unsigned long addr)
> +static inline unsigned char fdc_inb(int fdc, int reg)
> {
> - return fd_inb(addr);
> + return fd_inb(fdc_state[fdc].address + reg);
> }
>
> -static inline void fdc_outb(unsigned char value, int fdc, unsigned long addr)
> +static inline void fdc_outb(unsigned char value, int fdc, int reg)
> {
> - fd_outb(value, addr);
> + fd_outb(value, fdc_state[fdc].address + reg);
> }
>
> static inline bool drive_no_geom(int drive)
> diff --git a/include/uapi/linux/fdreg.h b/include/uapi/linux/fdreg.h
> index 5e2981d..1318881 100644
> --- a/include/uapi/linux/fdreg.h
> +++ b/include/uapi/linux/fdreg.h
> @@ -7,26 +7,18 @@
> * Handbook", Sanches and Canton.
> */
>
> -#ifdef FDPATCHES
> -#define FD_IOPORT fdc_state[fdc].address
> -#else
> -/* It would be a lot saner just to force fdc_state[fdc].address to always
> - be set ! FIXME */
> -#define FD_IOPORT 0x3f0
Again, just to note: FD_IOPORT (now removed), FDC1, FDC_BASE are pointing to
the same port 0x3f0 in many cases.
And at least in some cases used directly:
$ fgrep --include='*floppy*' -nrie '0x3f0' .
./arch/mips/include/asm/mach-generic/floppy.h:113: return 0x3f0;
./arch/m68k/include/asm/floppy.h:124: return 0x3f0;
./drivers/block/floppy.c:234:static unsigned short virtual_dma_port = 0x3f0;
> -#endif
> -
> /* Fd controller regs. S&C, about page 340 */
> -#define FD_STATUS (4 + FD_IOPORT )
> -#define FD_DATA (5 + FD_IOPORT )
> +#define FD_STATUS 4
> +#define FD_DATA 5
>
> /* Digital Output Register */
> -#define FD_DOR (2 + FD_IOPORT )
> +#define FD_DOR 2
>
> /* Digital Input Register (read) */
> -#define FD_DIR (7 + FD_IOPORT )
> +#define FD_DIR 7
>
> /* Diskette Control Register (write)*/
> -#define FD_DCR (7 + FD_IOPORT )
> +#define FD_DCR 7
>
> /* Bits of main status register */
> #define STATUS_BUSYMASK 0x0F /* drive busy mask */
>
Denis
next prev parent reply other threads:[~2020-02-26 15:36 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 21:23 [PATCH 00/10] floppy driver cleanups (deobfuscation) Willy Tarreau
2020-02-24 21:23 ` [PATCH 01/10] floppy: cleanup: expand macro FDCS Willy Tarreau
2020-02-24 21:53 ` Linus Torvalds
2020-02-24 23:13 ` Denis Efremov
2020-02-25 3:45 ` Willy Tarreau
2020-02-25 7:14 ` Denis Efremov
2020-02-25 14:02 ` Willy Tarreau
2020-02-25 15:22 ` Denis Efremov
2020-02-25 15:39 ` Denis Efremov
2020-02-25 16:12 ` Willy Tarreau
2020-02-25 18:02 ` Willy Tarreau
2020-02-25 18:08 ` Willy Tarreau
2020-02-25 18:08 ` Linus Torvalds
2020-02-25 18:15 ` Willy Tarreau
2020-02-25 18:27 ` Linus Torvalds
2020-02-26 8:18 ` Willy Tarreau
2020-02-25 11:37 ` Denis Efremov
2020-02-24 21:23 ` [PATCH 02/10] floppy: cleanup: expand macro UFDCS Willy Tarreau
2020-02-24 21:23 ` [PATCH 03/10] floppy: cleanup: expand macro UDP Willy Tarreau
2020-02-24 21:23 ` [PATCH 04/10] floppy: cleanup: expand macro UDRS Willy Tarreau
2020-02-24 21:23 ` [PATCH 05/10] floppy: cleanup: expand macro UDRWE Willy Tarreau
2020-02-24 21:23 ` [PATCH 06/10] floppy: cleanup: expand macro DP Willy Tarreau
2020-02-24 21:23 ` [PATCH 07/10] floppy: cleanup: expand macro DRS Willy Tarreau
2020-02-24 21:23 ` [PATCH 08/10] floppy: cleanup: expand macro DRWE Willy Tarreau
2020-02-24 21:23 ` [PATCH 09/10] floppy: cleanup: expand the R/W / format command macros Willy Tarreau
2020-02-24 21:23 ` [PATCH 10/10] floppy: cleanup: expand the reply_buffer macros Willy Tarreau
2020-02-26 8:07 ` [PATCH 11/16] floppy: remove dead code for drives scanning on ARM Willy Tarreau
2020-02-26 8:07 ` [PATCH 12/16] floppy: remove incomplete support for second FDC from ARM code Willy Tarreau
2020-02-29 16:38 ` Denis Efremov
2020-02-26 8:07 ` [PATCH 13/16] floppy: prepare ARM code to simplify base address separation Willy Tarreau
2020-02-26 8:07 ` [PATCH 14/16] floppy: introduce new functions fdc_inb() and fdc_outb() Willy Tarreau
2020-02-26 8:07 ` [PATCH 15/16] floppy: separate the FDC's base address from its registers Willy Tarreau
2020-02-26 15:36 ` Denis Efremov [this message]
2020-02-26 15:46 ` Willy Tarreau
2020-02-26 8:07 ` [PATCH 16/16] floppy: rename the global "fdc" variable to "current_fdc" Willy Tarreau
2020-03-01 8:21 ` [PATCH 11/16] floppy: remove dead code for drives scanning on ARM Denis Efremov
2020-03-01 8:59 ` Willy Tarreau
2020-02-26 14:57 ` [PATCH 00/10] floppy driver cleanups (deobfuscation) Denis Efremov
2020-02-26 17:49 ` Linus Torvalds
2020-02-26 18:41 ` Willy Tarreau
2020-02-29 14:13 ` Willy Tarreau
2020-02-29 15:58 ` Linus Torvalds
2020-02-29 23:19 ` Ondrej Zary
2020-03-01 6:46 ` Willy Tarreau
2020-03-01 17:01 ` Ondrej Zary
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=ab69fbdc-7ccb-05ef-6c25-7fb6ed6fce59@linux.com \
--to=efremov@linux.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=w@1wt.eu \
/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;
as well as URLs for NNTP newsgroup(s).