Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5052749ybv; Wed, 26 Feb 2020 07:38:29 -0800 (PST) X-Google-Smtp-Source: APXvYqw+YnU2SbWnmS+xKZOJq6RKk48Ypwz43U2obLzt9G+IBButWMH6L6p9oH56JZNr4UjcgK+n X-Received: by 2002:a05:6830:114c:: with SMTP id x12mr3573254otq.324.1582731509036; Wed, 26 Feb 2020 07:38:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582731509; cv=none; d=google.com; s=arc-20160816; b=jgOPTSTyQHdoHIGyefAn3ESHoNgqr903quJIZ+dB59+wqZk932RMFWzZzgQAAOBBOf BgOcIMZfVabpnN0mJBm9vQ7XIRbMzAs1n0IpFz21FnDFgHM94ffpEUhL82bDzXVEj0NG izuwvtSBec9C78djmwMbx67D2ecuUwB6CsHVnyFVY3s45H9855DUubSZZIxtsz+H8f+R xLAlVKrTPfZ+ngE8Snn8V4JJspbgZe0XAApDqO2O+kuozmuqKahP5QNeWcypCyIMkbdA 10mCifNX4rwCuyl3g+6dZ4TgNWYbaPLKJ/OevkVO1xFArVOt48a+cbilH8Uy5z2OOJtb qrmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:reply-to; bh=tLYmvTo+IUiYZSw2mbf7ipuU9Qwuuvs8XHZ4xNHHFbA=; b=aV1dKTc6z7f1uQAG0wdmDb1RODtZfGMekTqWJ5AHqhD+Mfza37V+oUOS65M8QI3kfC Qr6OGqxETrDQhGD+SEfo28jOmgTkE9aQYg5qpFHPJGenX5dRKwcwMIcT8K9szVQFlvqb zYjyQvPuyY+heggEG/sCHNxfp6Y+OZp+rQB3/lHJNFwPK6iT4dx4IHm30g86BpPv7UkG W3W3YDG7cQUgu7TXw/RjeI0UkohW74LUijU7vOsMLwK+1hruLhwHl5NWqoRSdTN8d8rj a7tMyWsnj41QNp0rSknKAiHRFU+7qyVgQYbKnUB9HL2eg+mt+7hW9IfPLzKzvZeadfoS yoNA== 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 k125si1433570oib.212.2020.02.26.07.38.17; Wed, 26 Feb 2020 07:38:29 -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 S1728260AbgBZPg5 (ORCPT + 99 others); Wed, 26 Feb 2020 10:36:57 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42396 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728172AbgBZPg5 (ORCPT ); Wed, 26 Feb 2020 10:36:57 -0500 Received: by mail-wr1-f65.google.com with SMTP id p18so3572891wre.9; Wed, 26 Feb 2020 07:36:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=tLYmvTo+IUiYZSw2mbf7ipuU9Qwuuvs8XHZ4xNHHFbA=; b=lPBbrh1eufzYZCHFdm3Pi+txT+IMMtQMEeq+OoYo3+S6Zz/MkFGT/vl6qj8yDhK88o UifU83mxURCJ8cLmfgfY0bMbiiiGWfHqHif2w8OESaK8LOe7ce4GQfg21/LC5zVJNMIW IoGleLz3ajqD7vIZG/5WDta/lhnxVwg+p3VYlb27NEMIspiPMqsI9rNkwix72vCrwWC/ b9pA5DjeW7Y0Wh50jU9dRlO6iDJR6gHQKawPIQDM3ZLp8aWkN0AvJ+7HCauebYVvvehO vGpai9X9kUlTI8wbHZ8W2S0yz43u/bJmlPDhDDMkrsIFQQAGh05YUmZ/RC4Ptuc/gvc5 YOBw== X-Gm-Message-State: APjAAAWmf0bZfZW5/IXJBrCR1UWYBOrVm2YF9jv9UHmqgwmcD5PLSvf/ hdJe6fp7/oZdeZotKVZrXZlocFsP X-Received: by 2002:adf:ea85:: with SMTP id s5mr6015479wrm.75.1582731414675; Wed, 26 Feb 2020 07:36:54 -0800 (PST) Received: from [10.10.2.174] (winnie.ispras.ru. [83.149.199.91]) by smtp.gmail.com with ESMTPSA id z16sm3556272wrp.33.2020.02.26.07.36.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Feb 2020 07:36:54 -0800 (PST) Reply-To: efremov@linux.com Subject: Re: [PATCH 15/16] floppy: separate the FDC's base address from its registers To: Willy Tarreau , Linus Torvalds Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200224212352.8640-1-w@1wt.eu> <20200226080732.1913-1-w@1wt.eu> <20200226080732.1913-5-w@1wt.eu> From: Denis Efremov Message-ID: Date: Wed, 26 Feb 2020 18:36:52 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200226080732.1913-5-w@1wt.eu> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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. > > 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. Just to note for future ref: the mask (7) can be introduced as define during future clean up of these magic constants. > > 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 Again, just to note: FD_IOPORT (now removed), FDC1, FDC_BASE are pointing to the same port 0x3f0 in many cases. And at least in some cases used directly: $ fgrep --include='*floppy*' -nrie '0x3f0' . ./arch/mips/include/asm/mach-generic/floppy.h:113: return 0x3f0; ./arch/m68k/include/asm/floppy.h:124: return 0x3f0; ./drivers/block/floppy.c:234:static unsigned short virtual_dma_port = 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 */ > Denis