Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1541810ybf; Sun, 1 Mar 2020 11:57:25 -0800 (PST) X-Google-Smtp-Source: APXvYqyHfDFODVjfGHHZYW0QYpXxLf0f+ATLmDIEM4zd8TfyjRaqRlIdyGdfTtH7VHaWNIQeb+kU X-Received: by 2002:a05:6830:19:: with SMTP id c25mr4744716otp.349.1583092645372; Sun, 01 Mar 2020 11:57:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583092645; cv=none; d=google.com; s=arc-20160816; b=zsDOWIQ2JmrKwzZiq3e0Rj8RavkfXz84hs5wu7wi62k2J6yAwI7RYh8qVbnYkxOXmy eDpuM29AlQDsn265r6tIce3OtL7Afwg8jVhq78l78leK8EJmNDQJBUUA7oyEUSwmZ2aw 2N1jQ5TOAZ7KCNDhF55+/erv+RBXexuFcpbmGIkCcbqlIFk+HIpmzQiGRrtORl3fiYlo tPtrWZ+JoG3WNy93lulvutIO42s/LANE6Ct4h5cOe1p8t2XXLRqK5ehvAWhJU6v35xtb B7Tp5enahmvVIJPU5kAjKqC1hvV9BZuqtm93IkeIM8x57VEueEiq4fXLe9B/xUhoiuUF 4WMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=a8qWDPmdX2Rdb+p2ejC6MbGDhSKS5p5NnA4y5mnlWVM=; b=KZ/rvbg4gZcRqHnBvdyF5X+jQpMbWbDzEj18muME6LrlF7Gux+R6mMiVNAm/r5qLiB Qj0ZAqpEa8KoZecyaB01XC0dTjOZ+YD1U1R598w4JETXrD1aHJbn4P6/m1j92qh3nQhk dso5pgQ0Z2Oe997OAAgw5WX4/0l8Lt9qypyG3R7gjKGdeRGwDTKeBDIiY0RQQZqVVU93 XZfk32NmPhlmREPh8jgulNyCa/2m4ZkswkmzdEhlsTZeP09Q+2lnqs5bHz+7+cEdFknl W7MUVYlt5VD6hvSgiIoBgDeaF7nmNj5tPeZNtAPoPOwdhv9w2WbjVZYl283YpcYMnDwN V1ug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n15si5318130otr.262.2020.03.01.11.57.13; Sun, 01 Mar 2020 11:57:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726894AbgCAT5B (ORCPT + 99 others); Sun, 1 Mar 2020 14:57:01 -0500 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:32079 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726843AbgCAT5B (ORCPT ); Sun, 1 Mar 2020 14:57:01 -0500 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 021Ju5bo011205; Sun, 1 Mar 2020 20:56:05 +0100 From: Willy Tarreau To: Denis Efremov Cc: Jens Axboe , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Willy Tarreau , Ian Molton , Russell King , Linus Torvalds Subject: [PATCH v2 5/6] floppy: separate the FDC's base address from its registers Date: Sun, 1 Mar 2020 20:55:54 +0100 Message-Id: <20200301195555.11154-6-w@1wt.eu> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20200301195555.11154-1-w@1wt.eu> References: <20200301195555.11154-1-w@1wt.eu> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org FDC registers FD_STATUS, FD_DATA, FD_DOR, FD_DIR and FD_DCR used to be defined relative to FD_IOPORT, which is the FDC's base address, itself a macro depending on the "fdc" local or global variable. This patch changes this so that the register macros above now only reference the address offset, and that the FDC's address is explicitly passed in each call to fd_inb() and fd_outb(), thus removing the macro. With this change there is no more implicit usage of the local/global "fdc" variable. One place in the ARM code used to check if the port was equal to FD_DOR, this was changed to testing the register by applying a mask to the port, as was already done in the sparc code. There are still occurrences of fd_inb() and fd_outb() in the PARISC code and these ones remain unaffected since they already used to work with a base address and a register offset. The sparc, m68k and parisc code could now be slightly cleaned up to benefit from the macro definitions above instead of the equivalent hard-coded values. Cc: Ian Molton Cc: Russell King Cc: Linus Torvalds Signed-off-by: Willy Tarreau --- arch/arm/include/asm/floppy.h | 2 +- drivers/block/floppy.c | 9 ++++----- include/uapi/linux/fdreg.h | 18 +++++------------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/arch/arm/include/asm/floppy.h b/arch/arm/include/asm/floppy.h index 34ebd86..79fa327 100644 --- a/arch/arm/include/asm/floppy.h +++ b/arch/arm/include/asm/floppy.h @@ -12,7 +12,7 @@ #define fd_outb(val,port) \ do { \ int new_val = (val); \ - if ((port) == (u32)FD_DOR) { \ + if (((port) & 7) == FD_DOR) { \ if (new_val & 0xf0) \ new_val = (new_val & 0x0c) | \ floppy_selects[new_val & 3]; \ diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 250a451..4e43a7e 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -171,7 +171,6 @@ static int print_unex = 1; #include #include #include -#define FDPATCHES #include #include #include @@ -594,14 +593,14 @@ 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) +static inline unsigned char fdc_inb(int fdc, int reg) { - return fd_inb(addr); + return fd_inb(fdc_state[fdc].address + reg); } -static inline void fdc_outb(unsigned char value, int fdc, unsigned long addr) +static inline void fdc_outb(unsigned char value, int fdc, int reg) { - fd_outb(value, addr); + fd_outb(value, fdc_state[fdc].address + reg); } static inline bool drive_no_geom(int drive) diff --git a/include/uapi/linux/fdreg.h b/include/uapi/linux/fdreg.h index 5e2981d..1318881 100644 --- a/include/uapi/linux/fdreg.h +++ b/include/uapi/linux/fdreg.h @@ -7,26 +7,18 @@ * Handbook", Sanches and Canton. */ -#ifdef FDPATCHES -#define FD_IOPORT fdc_state[fdc].address -#else -/* It would be a lot saner just to force fdc_state[fdc].address to always - be set ! FIXME */ -#define FD_IOPORT 0x3f0 -#endif - /* Fd controller regs. S&C, about page 340 */ -#define FD_STATUS (4 + FD_IOPORT ) -#define FD_DATA (5 + FD_IOPORT ) +#define FD_STATUS 4 +#define FD_DATA 5 /* Digital Output Register */ -#define FD_DOR (2 + FD_IOPORT ) +#define FD_DOR 2 /* Digital Input Register (read) */ -#define FD_DIR (7 + FD_IOPORT ) +#define FD_DIR 7 /* Diskette Control Register (write)*/ -#define FD_DCR (7 + FD_IOPORT ) +#define FD_DCR 7 /* Bits of main status register */ #define STATUS_BUSYMASK 0x0F /* drive busy mask */ -- 2.9.0