Skip to content

floppy: make use of the local/global fdc explicit

Willy Tarreau linux-block lkml 2 versions – Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 3 repliesApplied
  2. v16 of 16 patches 5 repliesSuperseded

Changes in v2 from the cover letter

- CC arch maintainers in ARM patches
- fixed issues after Denis' review:
- extra braces in floppy.h in declaration of floppy_selects[]
- missing parenthesis in fd_outb() macro to silence a warning
- used the swap() macro in driveswap()

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/6floppy: remove dead code for drives scanning on ARMarch/arm/include/asm/floppy.h+0 -510 replies
2/6floppy: remove incomplete support for second FDC from ARM codearch/arm/include/asm/floppy.h+3 -90 replies
3/6floppy: prepare ARM code to simplify base address separationarch/arm/include/asm/floppy.h+11 -160 replies
4/6floppy: introduce new functions fdc_inb() and fdc_outb()drivers/block/floppy.c+26 -160 replies
5/6floppy: separate the FDC's base address from its registersarch/arm/include/asm/floppy.h drivers/block/floppy.c include/uapi/linux/fdreg.h+10 -190 replies
6/6floppy: rename the global "fdc" variable to "current_fdc"drivers/block/floppy.c+137 -1300 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/6] floppy: make use of the local/global fdc explicit

This is an update to the first minimal cleanup of the floppy driver in order to make use of the FDC number explicit so as to avoid bugs like the one fixed by 2e90ca68 ("floppy: check FDC index for errors before assigning it").

The purpose of this patchset is to rename the "fdc" global variable to "current_fdc" as Linus suggested and adjust the macros which rely on it depending on their context.

The most problematic part at this step are the FD_* macros derived from FD_IOPORT, itself referencing the fdc to get its base address. These are exclusively used by fd_outb() and fd_inb(). However on ARM FD_DOR is also used to compare the register based on the port, hence a small change in the ARM specific code to only check the register without relying on this hidden memory access.

In order to avoid touching the fd_outb() and fd_inb() macros/functions on all supported architectures, a new set of fdc_outb()/fdc_inb() functions was added to the driver to call the former after adding the register to the FDC's base address.

There are still opportunities for more cleanup, though it's uncertain they're welcome in this old driver :
- the base address and register can be passed separately to fd_outb()

    and fd_inb() in order to simplify register retrieval in some archs;

- a dozen of functions in the driver implicitly depend on current_fdc while passing it as an argument makes the driver a bit more readable but that represents less than half of the code and doesn't address all the readability concerns;

- a test was done to limit support to a single FDC, but after these cleanups it doesn't provide any significant benefit in terms of code readability.

These patches are to be applied on top of Denis' floppy-next branch.

v2:
- CC arch maintainers in ARM patches
- fixed issues after Denis' review:
- extra braces in floppy.h in declaration of floppy_selects[]
- missing parenthesis in fd_outb() macro to silence a warning
- used the swap() macro in driveswap()

Willy Tarreau (6):
floppy: remove dead code for drives scanning on ARM
floppy: remove incomplete support for second FDC from ARM code
floppy: prepare ARM code to simplify base address separation
floppy: introduce new functions fdc_inb() and fdc_outb()
floppy: separate the FDC's base address from its registers
floppy: rename the global "fdc" variable to "current_fdc"

 arch/arm/include/asm/floppy.h |  88 ++-----------
 drivers/block/floppy.c        | 284 ++++++++++++++++++++++--------------------
 include/uapi/linux/fdreg.h    |  18 +--
 3 files changed, 168 insertions(+), 222 deletions(-)
Signature · 1 line
2.9.0