Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

floppy: use symbolic register names in the sparc64 port

Now by splitting the base address from the register index we can
use the symbolic register names instead of the hard-coded numeric
values.

Link: https://lore.kernel.org/r/20200331094054.24441-8-w@1wt.eu
Cc: "David S. Miller" <davem@davemloft.net>
[willy: fix printk warnings s/%lx/%x/g in sun_82077_fd_{inb,outb}()]
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Denis Efremov <efremov@linux.com>

authored by

Willy Tarreau and committed by
Denis Efremov
6cb7e696 6d362018

+32 -27
+32 -27
arch/sparc/include/asm/floppy_64.h
··· 47 47 static struct platform_device *floppy_op = NULL; 48 48 49 49 struct sun_floppy_ops { 50 - unsigned char (*fd_inb) (unsigned long port); 51 - void (*fd_outb) (unsigned char value, unsigned long port); 50 + unsigned char (*fd_inb) (unsigned long port, unsigned int reg); 51 + void (*fd_outb) (unsigned char value, unsigned long base, 52 + unsigned int reg); 52 53 void (*fd_enable_dma) (void); 53 54 void (*fd_disable_dma) (void); 54 55 void (*fd_set_dma_mode) (int); ··· 63 62 64 63 static struct sun_floppy_ops sun_fdops; 65 64 66 - #define fd_inb(base, reg) sun_fdops.fd_inb((base) + (reg)) 67 - #define fd_outb(value, base, reg) sun_fdops.fd_outb(value, (base) + (reg)) 65 + #define fd_inb(base, reg) sun_fdops.fd_inb(base, reg) 66 + #define fd_outb(value, base, reg) sun_fdops.fd_outb(value, base, reg) 68 67 #define fd_enable_dma() sun_fdops.fd_enable_dma() 69 68 #define fd_disable_dma() sun_fdops.fd_disable_dma() 70 69 #define fd_request_dma() (0) /* nothing... */ ··· 98 97 /* No 64k boundary crossing problems on the Sparc. */ 99 98 #define CROSS_64KB(a,s) (0) 100 99 101 - static unsigned char sun_82077_fd_inb(unsigned long port) 100 + static unsigned char sun_82077_fd_inb(unsigned long base, unsigned int reg) 102 101 { 103 102 udelay(5); 104 - switch(port & 7) { 103 + switch (reg) { 105 104 default: 106 - printk("floppy: Asked to read unknown port %lx\n", port); 105 + printk("floppy: Asked to read unknown port %x\n", reg); 107 106 panic("floppy: Port bolixed."); 108 - case 4: /* FD_STATUS */ 107 + case FD_STATUS: 109 108 return sbus_readb(&sun_fdc->status_82077) & ~STATUS_DMA; 110 - case 5: /* FD_DATA */ 109 + case FD_DATA: 111 110 return sbus_readb(&sun_fdc->data_82077); 112 - case 7: /* FD_DIR */ 111 + case FD_DIR: 113 112 /* XXX: Is DCL on 0x80 in sun4m? */ 114 113 return sbus_readb(&sun_fdc->dir_82077); 115 114 } 116 115 panic("sun_82072_fd_inb: How did I get here?"); 117 116 } 118 117 119 - static void sun_82077_fd_outb(unsigned char value, unsigned long port) 118 + static void sun_82077_fd_outb(unsigned char value, unsigned long base, 119 + unsigned int reg) 120 120 { 121 121 udelay(5); 122 - switch(port & 7) { 122 + switch (reg) { 123 123 default: 124 - printk("floppy: Asked to write to unknown port %lx\n", port); 124 + printk("floppy: Asked to write to unknown port %x\n", reg); 125 125 panic("floppy: Port bolixed."); 126 - case 2: /* FD_DOR */ 126 + case FD_DOR: 127 127 /* Happily, the 82077 has a real DOR register. */ 128 128 sbus_writeb(value, &sun_fdc->dor_82077); 129 129 break; 130 - case 5: /* FD_DATA */ 130 + case FD_DATA: 131 131 sbus_writeb(value, &sun_fdc->data_82077); 132 132 break; 133 - case 7: /* FD_DCR */ 133 + case FD_DCR: 134 134 sbus_writeb(value, &sun_fdc->dcr_82077); 135 135 break; 136 - case 4: /* FD_STATUS */ 136 + case FD_DSR: 137 137 sbus_writeb(value, &sun_fdc->status_82077); 138 138 break; 139 139 } ··· 300 298 301 299 irqreturn_t floppy_interrupt(int irq, void *dev_id); 302 300 303 - static unsigned char sun_pci_fd_inb(unsigned long port) 301 + static unsigned char sun_pci_fd_inb(unsigned long base, unsigned int reg) 304 302 { 305 303 udelay(5); 306 - return inb(port); 304 + return inb(base + reg); 307 305 } 308 306 309 - static void sun_pci_fd_outb(unsigned char val, unsigned long port) 307 + static void sun_pci_fd_outb(unsigned char val, unsigned long base, 308 + unsigned int reg) 310 309 { 311 310 udelay(5); 312 - outb(val, port); 311 + outb(val, base + reg); 313 312 } 314 313 315 - static void sun_pci_fd_broken_outb(unsigned char val, unsigned long port) 314 + static void sun_pci_fd_broken_outb(unsigned char val, unsigned long base, 315 + unsigned int reg) 316 316 { 317 317 udelay(5); 318 318 /* ··· 324 320 * this does not hurt correct hardware like the AXmp. 325 321 * (Eddie, Sep 12 1998). 326 322 */ 327 - if (port == ((unsigned long)sun_fdc) + 2) { 323 + if (reg == FD_DOR) { 328 324 if (((val & 0x03) == sun_pci_broken_drive) && (val & 0x20)) { 329 325 val |= 0x10; 330 326 } 331 327 } 332 - outb(val, port); 328 + outb(val, base + reg); 333 329 } 334 330 335 331 #ifdef PCI_FDC_SWAP_DRIVES 336 - static void sun_pci_fd_lde_broken_outb(unsigned char val, unsigned long port) 332 + static void sun_pci_fd_lde_broken_outb(unsigned char val, unsigned long base, 333 + unsigned int reg) 337 334 { 338 335 udelay(5); 339 336 /* ··· 344 339 * this does not hurt correct hardware like the AXmp. 345 340 * (Eddie, Sep 12 1998). 346 341 */ 347 - if (port == ((unsigned long)sun_fdc) + 2) { 342 + if (reg == FD_DOR) { 348 343 if (((val & 0x03) == sun_pci_broken_drive) && (val & 0x10)) { 349 344 val &= ~(0x03); 350 345 val |= 0x21; 351 346 } 352 347 } 353 - outb(val, port); 348 + outb(val, base + reg); 354 349 } 355 350 #endif /* PCI_FDC_SWAP_DRIVES */ 356 351