]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
floppy: split the base port from the register in I/O accesses
authorWilly Tarreau <w@1wt.eu>
Tue, 31 Mar 2020 09:40:32 +0000 (11:40 +0200)
committerDenis Efremov <efremov@linux.com>
Tue, 12 May 2020 16:34:52 +0000 (19:34 +0300)
Currently we have architecture-specific fd_inb() and fd_outb() functions
or macros, taking just a port which is in fact made of a base address and
a register. The base address is FDC-specific and derived from the local or
global "fdc" variable through the FD_IOPORT macro used in the base address
calculation.

This change splits this by explicitly passing the FDC's base address and
the register separately to fd_outb() and fd_inb(). It affects the
following archs:
  - x86, alpha, mips, powerpc, parisc, arm, m68k:
    simple remap of port -> base+reg

  - sparc32: use of reg only, since the base address was already masked
    out and the FDC controller is known from a static struct.

  - sparc64: like x86 for PCI, like sparc32 for 82077

Some archs use inline functions and others macros. This was not
unified in order to minimize the number of changes to review. For the
same reason checkpatch still spews a few warnings about things that
were already there before.

The parisc still uses hard-coded register values and could be cleaned up
by taking the register definitions.

The sparc per-controller inb/outb functions could further be refined
to explicitly take an FDC register instead of a port in argument but it
was not needed yet and may be cleaned later.

Link: https://lore.kernel.org/r/20200331094054.24441-2-w@1wt.eu
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Ian Molton <spyro@f2s.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Helge Deller <deller@gmx.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: x86@kernel.org
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Denis Efremov <efremov@linux.com>
arch/alpha/include/asm/floppy.h
arch/arm/include/asm/floppy.h
arch/m68k/include/asm/floppy.h
arch/mips/include/asm/mach-generic/floppy.h
arch/mips/include/asm/mach-jazz/floppy.h
arch/parisc/include/asm/floppy.h
arch/powerpc/include/asm/floppy.h
arch/sparc/include/asm/floppy_32.h
arch/sparc/include/asm/floppy_64.h
arch/x86/include/asm/floppy.h
drivers/block/floppy.c

index 942924756cf2150750421ef7ad872cf52228e83b..8dfdb3aa1d964611b6daead306e8de6b57e37db6 100644 (file)
@@ -11,8 +11,8 @@
 #define __ASM_ALPHA_FLOPPY_H
 
 
-#define fd_inb(port)                   inb_p(port)
-#define fd_outb(value,port)            outb_p(value,port)
+#define fd_inb(base, reg)              inb_p((base) + (reg))
+#define fd_outb(value, base, reg)      outb_p(value, (base) + (reg))
 
 #define fd_enable_dma()         enable_dma(FLOPPY_DMA)
 #define fd_disable_dma()        disable_dma(FLOPPY_DMA)
index 79fa327238e8dd16b4fbac8df4af0da0073569df..e1cb04ed50081e8abca140134ab1f173038ca56c 100644 (file)
@@ -9,20 +9,20 @@
 #ifndef __ASM_ARM_FLOPPY_H
 #define __ASM_ARM_FLOPPY_H
 
-#define fd_outb(val,port)                                              \
+#define fd_outb(val, base, reg)                                                \
        do {                                                            \
                int new_val = (val);                                    \
-               if (((port) & 7) == FD_DOR) {                           \
+               if ((reg) == FD_DOR) {                                  \
                        if (new_val & 0xf0)                             \
                                new_val = (new_val & 0x0c) |            \
                                          floppy_selects[new_val & 3];  \
                        else                                            \
                                new_val &= 0x0c;                        \
                }                                                       \
-               outb(new_val, (port));                                  \
+               outb(new_val, (base) + (reg));                          \
        } while(0)
 
-#define fd_inb(port)           inb((port))
+#define fd_inb(base, reg)      inb((base) + (reg))
 #define fd_request_irq()       request_irq(IRQ_FLOPPYDISK,floppy_interrupt,\
                                            0,"floppy",NULL)
 #define fd_free_irq()          free_irq(IRQ_FLOPPYDISK,NULL)
index c3b9ad6732fc68cc78a65db116372d7055318a6b..2a6ce29b92aac9ecfb75374180fccbc407f37561 100644 (file)
@@ -63,21 +63,21 @@ static __inline__ void release_dma_lock(unsigned long flags)
 }
 
 
-static __inline__ unsigned char fd_inb(int port)
+static __inline__ unsigned char fd_inb(int base, int reg)
 {
        if(MACH_IS_Q40)
-               return inb_p(port);
+               return inb_p(base + reg);
        else if(MACH_IS_SUN3X)
-               return sun3x_82072_fd_inb(port);
+               return sun3x_82072_fd_inb(base + reg);
        return 0;
 }
 
-static __inline__ void fd_outb(unsigned char value, int port)
+static __inline__ void fd_outb(unsigned char value, int base, int reg)
 {
        if(MACH_IS_Q40)
-               outb_p(value, port);
+               outb_p(value, base + reg);
        else if(MACH_IS_SUN3X)
-               sun3x_82072_fd_outb(value, port);
+               sun3x_82072_fd_outb(value, base + reg);
 }
 
 
index 9ec2f6a5200b6f7ce5bff8d2708b1e7849972d3a..e3f446d54827e9572f5f68849ed32679399a090a 100644 (file)
 /*
  * How to access the FDC's registers.
  */
-static inline unsigned char fd_inb(unsigned int port)
+static inline unsigned char fd_inb(unsigned int base, unsigned int reg)
 {
-       return inb_p(port);
+       return inb_p(base + reg);
 }
 
-static inline void fd_outb(unsigned char value, unsigned int port)
+static inline void fd_outb(unsigned char value, unsigned int base, unsigned int reg)
 {
-       outb_p(value, port);
+       outb_p(value, base + reg);
 }
 
 /*
index 4b86c88a03b7738ec4ad7370e8ada5d03b934dda..095000c290e557ca30be7992d03c24822f4bcb8c 100644 (file)
 #include <asm/jazzdma.h>
 #include <asm/pgtable.h>
 
-static inline unsigned char fd_inb(unsigned int port)
+static inline unsigned char fd_inb(unsigned int base, unsigned int reg)
 {
        unsigned char c;
 
-       c = *(volatile unsigned char *) port;
+       c = *(volatile unsigned char *) (base + reg);
        udelay(1);
 
        return c;
 }
 
-static inline void fd_outb(unsigned char value, unsigned int port)
+static inline void fd_outb(unsigned char value, unsigned int base, unsigned int reg)
 {
-       *(volatile unsigned char *) port = value;
+       *(volatile unsigned char *) (base + reg) = value;
 }
 
 /*
index 09b6f4c1687e4657b76b2f0faf774c898e404599..1aebc23b77443c920634becd6f4ff62f3951d4fa 100644 (file)
@@ -29,8 +29,8 @@
 #define CSW fd_routine[can_use_virtual_dma & 1]
 
 
-#define fd_inb(port)                   readb(port)
-#define fd_outb(value, port)           writeb(value, port)
+#define fd_inb(base, reg)              readb((base) + (reg))
+#define fd_outb(value, base, reg)      writeb(value, (base) + (reg))
 
 #define fd_request_dma()        CSW._request_dma(FLOPPY_DMA,"floppy")
 #define fd_free_dma()           CSW._free_dma(FLOPPY_DMA)
@@ -75,19 +75,19 @@ static void floppy_hardint(int irq, void *dev_id, struct pt_regs * regs)
                register char *lptr = virtual_dma_addr;
 
                for (lcount = virtual_dma_count; lcount; lcount--) {
-                       st = fd_inb(virtual_dma_port+4) & 0xa0 ;
+                       st = fd_inb(virtual_dma_port, 4) & 0xa0;
                        if (st != 0xa0) 
                                break;
                        if (virtual_dma_mode) {
-                               fd_outb(*lptr, virtual_dma_port+5);
+                               fd_outb(*lptr, virtual_dma_port5);
                        } else {
-                               *lptr = fd_inb(virtual_dma_port+5);
+                               *lptr = fd_inb(virtual_dma_port5);
                        }
                        lptr++;
                }
                virtual_dma_count = lcount;
                virtual_dma_addr = lptr;
-               st = fd_inb(virtual_dma_port+4);
+               st = fd_inb(virtual_dma_port4);
        }
 
 #ifdef TRACE_FLPY_INT
index 167c44b588487005e07f2bb5ae9e2db5290277ad..ed467eb0c4c8d7d0f13b6940ac80772264ce1948 100644 (file)
@@ -13,8 +13,8 @@
 
 #include <asm/machdep.h>
 
-#define fd_inb(port)           inb_p(port)
-#define fd_outb(value,port)    outb_p(value,port)
+#define fd_inb(base, reg)              inb_p((base) + (reg))
+#define fd_outb(value, base, reg)      outb_p(value, (base) + (reg))
 
 #define fd_enable_dma()         enable_dma(FLOPPY_DMA)
 #define fd_disable_dma()        fd_ops->_disable_dma(FLOPPY_DMA)
index b519acf4383d9a523070abd48c5422612d19c139..4d08df4f4deb4b06ed60b3588b003bb8c6040543 100644 (file)
@@ -59,8 +59,8 @@ struct sun_floppy_ops {
 
 static struct sun_floppy_ops sun_fdops;
 
-#define fd_inb(port)              sun_fdops.fd_inb(port)
-#define fd_outb(value,port)       sun_fdops.fd_outb(value,port)
+#define fd_inb(base, reg)         sun_fdops.fd_inb(reg)
+#define fd_outb(value, base, reg) sun_fdops.fd_outb(value, reg)
 #define fd_enable_dma()           sun_fd_enable_dma()
 #define fd_disable_dma()          sun_fd_disable_dma()
 #define fd_request_dma()          (0) /* nothing... */
index 3729fc35ba83966aeae6c52b62d1f86266da0359..c0cf157e5b1580f431abbf608e93e74c7d094c06 100644 (file)
@@ -62,8 +62,8 @@ struct sun_floppy_ops {
 
 static struct sun_floppy_ops sun_fdops;
 
-#define fd_inb(port)              sun_fdops.fd_inb(port)
-#define fd_outb(value,port)       sun_fdops.fd_outb(value,port)
+#define fd_inb(base, reg)         sun_fdops.fd_inb((base) + (reg))
+#define fd_outb(value, base, reg) sun_fdops.fd_outb(value, (base) + (reg))
 #define fd_enable_dma()           sun_fdops.fd_enable_dma()
 #define fd_disable_dma()          sun_fdops.fd_disable_dma()
 #define fd_request_dma()          (0) /* nothing... */
index 7ec59edde154c344cb5bfce7ba586360a6d32d19..20088cb08f5efa5822e1e2cbeb250f48c98e04ef 100644 (file)
@@ -31,8 +31,8 @@
 #define CSW fd_routine[can_use_virtual_dma & 1]
 
 
-#define fd_inb(port)           inb_p(port)
-#define fd_outb(value, port)   outb_p(value, port)
+#define fd_inb(base, reg)              inb_p((base) + (reg))
+#define fd_outb(value, base, reg)      outb_p(value, (base) + (reg))
 
 #define fd_request_dma()       CSW._request_dma(FLOPPY_DMA, "floppy")
 #define fd_free_dma()          CSW._free_dma(FLOPPY_DMA)
index c3daa64cb52c66188e03f3555d5eb61ad45022ad..1cda39098b07f101c5a471e9fed6d7d9294774fe 100644 (file)
@@ -595,12 +595,12 @@ static unsigned char in_sector_offset;    /* offset within physical sector,
 
 static inline unsigned char fdc_inb(int fdc, int reg)
 {
-       return fd_inb(fdc_state[fdc].address + reg);
+       return fd_inb(fdc_state[fdc].address, reg);
 }
 
 static inline void fdc_outb(unsigned char value, int fdc, int reg)
 {
-       fd_outb(value, fdc_state[fdc].address + reg);
+       fd_outb(value, fdc_state[fdc].address, reg);
 }
 
 static inline bool drive_no_geom(int drive)