Commit 91bf5ec3 authored by Jens Axboe's avatar Jens Axboe
Browse files

Merge tag 'floppy-for-5.8' of https://github.com/evdenis/linux-floppy into for-5.8/drivers



Floppy patches for 5.8

Cleanups:
  - symbolic register names for x86,sparc64,sparc32,powerpc,parisc,m68k
  - split of local/global variables for drive,fdc
  - UBSAN warning suppress in setup_rw_floppy()

Changes were compile tested on arm, sparc64, powerpc, m68k. Many patches
introduce no binary changes by using defines instead of magic numbers.
The patches were also tested with syzkaller and simple write/read/format
tests on real hardware.

Signed-off-by: default avatarDenis Efremov <efremov@linux.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>

* tag 'floppy-for-5.8' of https://github.com/evdenis/linux-floppy: (31 commits)
  floppy: suppress UBSAN warning in setup_rw_floppy()
  floppy: add defines for sizes of cmd & reply buffers of floppy_raw_cmd
  floppy: add FD_AUTODETECT_SIZE define for struct floppy_drive_params
  floppy: use print_hex_dump() in setup_DMA()
  floppy: cleanup: make set_fdc() always set current_drive and current_fd
  floppy: cleanup: get rid of current_reqD in favor of current_drive
  floppy: make sure to reset all FDCs upon resume()
  floppy: cleanup: do not iterate on current_fdc in do_floppy_init()
  floppy: cleanup: add a few comments about expectations in certain functions
  floppy: cleanup: do not iterate on current_fdc in DMA grab/release functions
  floppy: cleanup: make get_fdc_version() not rely on current_fdc anymore
  floppy: cleanup: make next_valid_format() not rely on current_drive anymore
  floppy: cleanup: make check_wp() not rely on current_{fdc,drive} anymore
  floppy: cleanup: make fdc_specify() not rely on current_{fdc,drive} anymore
  floppy: cleanup: make fdc_configure() not rely on current_fdc anymore
  floppy: cleanup: make perpendicular_mode() not rely on current_fdc anymore
  floppy: cleanup: make need_more_output() not rely on current_fdc anymore
  floppy: cleanup: make result() not rely on current_fdc anymore
  floppy: cleanup: make output_byte() not rely on current_fdc anymore
  floppy: cleanup: make wait_til_ready() not rely on current_fdc anymore
  ...
parents 92decf11 0836275d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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)
+4 −4
Original line number Diff line number Diff line
@@ -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)
+14 −13
Original line number Diff line number Diff line
@@ -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);
}


@@ -211,26 +211,27 @@ asmlinkage irqreturn_t floppy_hardint(int irq, void *dev_id)
		st=1;
		for(lcount=virtual_dma_count, lptr=virtual_dma_addr;
		    lcount; lcount--, lptr++) {
			st=inb(virtual_dma_port+4) & 0xa0 ;
			if(st != 0xa0)
			st = inb(virtual_dma_port + FD_STATUS);
			st &= STATUS_DMA | STATUS_READY;
			if (st != (STATUS_DMA | STATUS_READY))
				break;
			if(virtual_dma_mode)
				outb_p(*lptr, virtual_dma_port+5);
				outb_p(*lptr, virtual_dma_port + FD_DATA);
			else
				*lptr = inb_p(virtual_dma_port+5);
				*lptr = inb_p(virtual_dma_port + FD_DATA);
		}

		virtual_dma_count = lcount;
		virtual_dma_addr = lptr;
		st = inb(virtual_dma_port+4);
		st = inb(virtual_dma_port + FD_STATUS);
	}

#ifdef TRACE_FLPY_INT
	calls++;
#endif
	if(st == 0x20)
	if (st == STATUS_DMA)
		return IRQ_HANDLED;
	if(!(st & 0x20)) {
	if (!(st & STATUS_DMA)) {
		virtual_dma_residue += virtual_dma_count;
		virtual_dma_count=0;
#ifdef TRACE_FLPY_INT
+4 −4
Original line number Diff line number Diff line
@@ -26,14 +26,14 @@
/*
 * 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);
}

/*
+4 −4
Original line number Diff line number Diff line
@@ -17,19 +17,19 @@
#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;
}

/*
Loading