All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: Denis Efremov <efremov@linux.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Willy Tarreau <w@1wt.eu>
Subject: [PATCH 14/16] floppy: introduce new functions fdc_inb() and fdc_outb()
Date: Wed, 26 Feb 2020 09:07:30 +0100	[thread overview]
Message-ID: <20200226080732.1913-4-w@1wt.eu> (raw)
In-Reply-To: <20200226080732.1913-1-w@1wt.eu>

These two functions replace fd_inb() and fd_outb() in that they take
the FDC in argument. This will ease the separation of the base address
and the port everywhere the code is used.
---
 drivers/block/floppy.c | 42 ++++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index d521899..250a451 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -594,6 +594,16 @@ 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)
+{
+	return fd_inb(addr);
+}
+
+static inline void fdc_outb(unsigned char value, int fdc, unsigned long addr)
+{
+	fd_outb(value, addr);
+}
+
 static inline bool drive_no_geom(int drive)
 {
 	return !current_type[drive] && !ITYPE(drive_state[drive].fd_device);
@@ -743,14 +753,14 @@ static int disk_change(int drive)
 		  "checking disk change line for drive %d\n", drive);
 	debug_dcl(drive_params[drive].flags, "jiffies=%lu\n", jiffies);
 	debug_dcl(drive_params[drive].flags, "disk change line=%x\n",
-		  fd_inb(FD_DIR) & 0x80);
+		  fdc_inb(fdc, FD_DIR) & 0x80);
 	debug_dcl(drive_params[drive].flags, "flags=%lx\n",
 		  drive_state[drive].flags);
 
 	if (drive_params[drive].flags & FD_BROKEN_DCL)
 		return test_bit(FD_DISK_CHANGED_BIT,
 				&drive_state[drive].flags);
-	if ((fd_inb(FD_DIR) ^ drive_params[drive].flags) & 0x80) {
+	if ((fdc_inb(fdc, FD_DIR) ^ drive_params[drive].flags) & 0x80) {
 		set_bit(FD_VERIFY_BIT, &drive_state[drive].flags);
 					/* verify write protection */
 
@@ -807,7 +817,7 @@ static int set_dor(int fdc, char mask, char data)
 			disk_change(drive);
 		}
 		fdc_state[fdc].dor = newdor;
-		fd_outb(newdor, FD_DOR);
+		fdc_outb(newdor, fdc, FD_DOR);
 
 		unit = newdor & 0x3;
 		if (!is_selected(olddor, unit) && is_selected(newdor, unit)) {
@@ -822,8 +832,8 @@ static void twaddle(void)
 {
 	if (drive_params[current_drive].select_delay)
 		return;
-	fd_outb(fdc_state[fdc].dor & ~(0x10 << UNIT(current_drive)), FD_DOR);
-	fd_outb(fdc_state[fdc].dor, FD_DOR);
+	fdc_outb(fdc_state[fdc].dor & ~(0x10 << UNIT(current_drive)), fdc, FD_DOR);
+	fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR);
 	drive_state[current_drive].select_date = jiffies;
 }
 
@@ -864,7 +874,7 @@ static void set_fdc(int drive)
 #endif
 	if (fdc_state[fdc].rawcmd == 2)
 		reset_fdc_info(1);
-	if (fd_inb(FD_STATUS) != STATUS_READY)
+	if (fdc_inb(fdc, FD_STATUS) != STATUS_READY)
 		fdc_state[fdc].reset = 1;
 }
 
@@ -1103,7 +1113,7 @@ static int wait_til_ready(void)
 	if (fdc_state[fdc].reset)
 		return -1;
 	for (counter = 0; counter < 10000; counter++) {
-		status = fd_inb(FD_STATUS);
+		status = fdc_inb(fdc, FD_STATUS);
 		if (status & STATUS_READY)
 			return status;
 	}
@@ -1124,7 +1134,7 @@ static int output_byte(char byte)
 		return -1;
 
 	if (is_ready_state(status)) {
-		fd_outb(byte, FD_DATA);
+		fdc_outb(byte, fdc, FD_DATA);
 		output_log[output_log_pos].data = byte;
 		output_log[output_log_pos].status = status;
 		output_log[output_log_pos].jiffies = jiffies;
@@ -1157,7 +1167,7 @@ static int result(void)
 			return i;
 		}
 		if (status == (STATUS_DIR | STATUS_READY | STATUS_BUSY))
-			reply_buffer[i] = fd_inb(FD_DATA);
+			reply_buffer[i] = fdc_inb(fdc, FD_DATA);
 		else
 			break;
 	}
@@ -1352,7 +1362,7 @@ static int fdc_dtr(void)
 		return 0;
 
 	/* Set dtr */
-	fd_outb(raw_cmd->rate & 3, FD_DCR);
+	fdc_outb(raw_cmd->rate & 3, fdc, FD_DCR);
 
 	/* TODO: some FDC/drive combinations (C&T 82C711 with TEAC 1.2MB)
 	 * need a stabilization period of several milliseconds to be
@@ -1796,11 +1806,11 @@ static void reset_fdc(void)
 	release_dma_lock(flags);
 
 	if (fdc_state[fdc].version >= FDC_82072A)
-		fd_outb(0x80 | (fdc_state[fdc].dtr & 3), FD_STATUS);
+		fdc_outb(0x80 | (fdc_state[fdc].dtr & 3), fdc, FD_STATUS);
 	else {
-		fd_outb(fdc_state[fdc].dor & ~0x04, FD_DOR);
+		fdc_outb(fdc_state[fdc].dor & ~0x04, fdc, FD_DOR);
 		udelay(FD_RESET_DELAY);
-		fd_outb(fdc_state[fdc].dor, FD_DOR);
+		fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR);
 	}
 }
 
@@ -1827,7 +1837,7 @@ static void show_floppy(void)
 	print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
 		       reply_buffer, resultsize, true);
 
-	pr_info("status=%x\n", fd_inb(FD_STATUS));
+	pr_info("status=%x\n", fdc_inb(fdc, FD_STATUS));
 	pr_info("fdc_busy=%lu\n", fdc_busy);
 	if (do_floppy)
 		pr_info("do_floppy=%ps\n", do_floppy);
@@ -4875,7 +4885,7 @@ static int floppy_grab_irq_and_dma(void)
 	for (fdc = 0; fdc < N_FDC; fdc++) {
 		if (fdc_state[fdc].address != -1) {
 			reset_fdc_info(1);
-			fd_outb(fdc_state[fdc].dor, FD_DOR);
+			fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR);
 		}
 	}
 	fdc = 0;
@@ -4883,7 +4893,7 @@ static int floppy_grab_irq_and_dma(void)
 
 	for (fdc = 0; fdc < N_FDC; fdc++)
 		if (fdc_state[fdc].address != -1)
-			fd_outb(fdc_state[fdc].dor, FD_DOR);
+			fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR);
 	/*
 	 * The driver will try and free resources and relies on us
 	 * to know if they were allocated or not.
-- 
2.9.0


  parent reply	other threads:[~2020-02-26  8:08 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   ` Willy Tarreau [this message]
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
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=20200226080732.1913-4-w@1wt.eu \
    --to=w@1wt.eu \
    --cc=axboe@kernel.dk \
    --cc=efremov@linux.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.