Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4625976ybv; Wed, 26 Feb 2020 00:09:22 -0800 (PST) X-Google-Smtp-Source: APXvYqzzB/Krmusd7dMOrx/MMZvKqJpBk23iAQTPkvPn7knX65EfGyszisGjJcOgbjf5q/MKd1Im X-Received: by 2002:a9d:774e:: with SMTP id t14mr1937090otl.358.1582704562526; Wed, 26 Feb 2020 00:09:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582704562; cv=none; d=google.com; s=arc-20160816; b=HXT/PKN9MU4J/xzEmD1SXxs/+m2lAs09O1uLwjjulD/xa6KPPctLLySsyS5hYDIP1+ t40fKqmFR+z1cLWmeoCt7plWR6FZ0jKXB5CIRz8IQeYmcLCso92D6QuT/C+dPGogIPnf boS8t8EYxCOfqjRkUvEug7PU6kuYyB2PPdpfpcWTCiCa6X0izT60UOnI14JUt7qHhX1D UNMlUfD+s9ddk8wM0dqzRq2BRX+dMIOmMp7DH4ELCxtpcI+3VCYA52aiwIojxFdTPigL xCstRYq3L6zyIFBOBMcZcVqv7fmJn4QBTKFm9OMZ6Lk2PVsUtFN5iqFViabPb3ykD8E0 R8qA== 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=LxXSULCMFezZtRJNun20ienw5mgcej/MeNFvkXAQxhY=; b=QGGrXuy5gFpRXRS4Je9mpF3TeR0Tmi9/aucMasC/j5KkcYXwNppgJi6cYWmAGxKM1+ hEirQGNFPuIpz7xeobN2gkTn0cziFJV/uWAmFo8V8iGDaFXBjxHgyfS6qfqYh7t3ty2J Pfr1KPPBIX+SGKsYKu1OWEVuM86TMsp35LJZIFhnbV/MYP3sqAo8x3g8Dh8P4uVBc/om jDjUcNrJdPhDPK66cCFMTQElH5lsbY2Ro5u1OoSdspsYsB2GPO7+Dq9VhKHW2KuHIql6 1gxugNavztOkZaS5kbTbjOTbNEVOvjRyc9m2llqp0qjhT5e+H/Du5WQmMxPJu/373Amq qaEQ== 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 d2si853172ote.9.2020.02.26.00.09.09; Wed, 26 Feb 2020 00:09:22 -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 S1727560AbgBZIIg (ORCPT + 99 others); Wed, 26 Feb 2020 03:08:36 -0500 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:31578 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727327AbgBZIIg (ORCPT ); Wed, 26 Feb 2020 03:08:36 -0500 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 01Q87jWY001963; Wed, 26 Feb 2020 09:07:45 +0100 From: Willy Tarreau To: Denis Efremov , Linus Torvalds Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Willy Tarreau Subject: [PATCH 15/16] floppy: separate the FDC's base address from its registers Date: Wed, 26 Feb 2020 09:07:31 +0100 Message-Id: <20200226080732.1913-5-w@1wt.eu> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20200226080732.1913-1-w@1wt.eu> References: <20200224212352.8640-1-w@1wt.eu> <20200226080732.1913-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. 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 c665136..4e3fb71 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