Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4626719ybv; Wed, 26 Feb 2020 00:10:09 -0800 (PST) X-Google-Smtp-Source: APXvYqyzzi06WsT7E7BVGEPLPPQHHlskOBKCWhd9lslViEvZVSb32w8DQ7BXE7oOv/eAF49JfdvS X-Received: by 2002:a54:440e:: with SMTP id k14mr2017137oiw.160.1582704608939; Wed, 26 Feb 2020 00:10:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582704608; cv=none; d=google.com; s=arc-20160816; b=SkG9WtKyrdxewJmN4AQCqEUO5P4JxsFtyIlhQLBQV29QEgnqr0xdqGVrltv1MmmIeb /hYtg17ik7lTXGfegn3tjsS5Lik1XOOApRYFuDAIK9Xajf0yUE28SzEmPNoNKVLiQTLk elNuP2RyKRhkhOU1DIG0jK8hZNtcr2kDmhEqilPPdRrwkyopfIcceg4kSsNwfSFBzt/o tYZHLoi1fg6HidSnIknu6HAXt9wjJhlLprJLRuHmvR3AD2wG9uzFnyIoE7Dfw2bd5K+Y c2+nHIw7XR72NZvaOcqTK5uJewh4UHr6cRLLsjnHrjnH2ErIBW0/udU+3mJ1s+Kzy9mG v3ew== 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=j6Vlf7eF2H0XByek998CTipmgrMwx9JTgtM1ZBKxUbo=; b=Bz/OWeAxWvJK6WiOX2ka0EvI26SoBqxPFR1vdHZIQeh5s2SJiAS0OI2WRrs4YFwSct LSaI6qlgLOZUThmKjVg3Q5ySe1lZ+KMuXVzdEFInP4396mYb1BBLkAyPKXlukpMhCLDp 3oXC05HpyeLEh/20McvXq1VVMJIrJH1IpuT6x1jvQvivCmDOD18tJFRSD3VBT3XNMy8P 93WedLimqfO1x26/+4KRvC+3ny7OgK9PiR4SXGlVzABWNNetqpEf3cx5GdZxb+CfJwx5 TCeA+EdKonOZeFBESvspYesVxTQcI1PmlPCYcfkGGa3mqeMpqHqDqFJPRYlLuvGDKiJ6 JZzQ== 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 b141si802045oii.79.2020.02.26.00.09.56; Wed, 26 Feb 2020 00:10:08 -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 S1727527AbgBZII2 (ORCPT + 99 others); Wed, 26 Feb 2020 03:08:28 -0500 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:31574 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727327AbgBZII2 (ORCPT ); Wed, 26 Feb 2020 03:08:28 -0500 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 01Q87i3b001962; Wed, 26 Feb 2020 09:07:44 +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 14/16] floppy: introduce new functions fdc_inb() and fdc_outb() Date: Wed, 26 Feb 2020 09:07:30 +0100 Message-Id: <20200226080732.1913-4-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 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