From patchwork Tue Mar 7 22:46:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 65937 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp8129wrd; Tue, 7 Mar 2023 14:59:53 -0800 (PST) X-Google-Smtp-Source: AK7set+L6hnISpNN8xa8yPB3LGRgzg7v3BcaxWD1+9i4Jpz5rew8rcB8G1pPMCRYILq6QeJQ7J8l X-Received: by 2002:a17:907:64c:b0:8ab:a378:5f96 with SMTP id wq12-20020a170907064c00b008aba3785f96mr19896924ejb.3.1678229993024; Tue, 07 Mar 2023 14:59:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678229993; cv=none; d=google.com; s=arc-20160816; b=BuDYJnWm7EyzxxJTPLtOuFaQovdwevK0m9Ae2PLTATOdG0BJ8X2eo5A2bAxsWFld/o YJgV3lrS0lFEtTg8n4d56QNnYlAyFhkFBGomTwX1+BLy3FobwJc8UVAbDonOFVlwyxnm bW+qfljru398GZK1LZH0LgOa7485CJCCFsAdidxYOkyePUDxjRNNV7NB1c1BmTgMqhOr oVNfZuNhv8Cjl54c+hdQ26O5mqSuT4CG0l62Kg/JnQ8Ny7/lsqQTJh0oqWiw4617tLv7 ehuRstjBWLRWf+al+kChxvk1hkQlIBxpzb9l7DiT9ZY/pZchRkn/E7ffTzyNwyYtmpim oGIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=SayNx3/nsgZFHGspnLny6R92wMJ1DN01COrXjujtJAk=; b=BlQM+lNwlV/D7UYKr5JmFx3ElL7GO2inRu2ae+cds4pdTmE1lQClJiVTDCk+Hd2qaZ HCamWngefZCAPxL+JkQtwghjy0rbXds2X1+qOxqiBCKybhQj+Y8dHRGiATjqSWcaz3Y3 sqrQcOzQ29EmSx+ISwnV1Gsax3jogPQMxh2gsJIbuOWG5R/MmDCxtvjxmI82qJPBQL0o 2s90H/kvl0oLYutxRIoWVRGAQMKewU177MWMR6ajWCqK7kcmkPE7GRJHUQ/q5Eq1f5Co fpj1b0bBrVFIJAoHpCyWEFUDzFYPqF8wKPsN6c2LLWC5gPtMeJE/KS8A3xplelOajG8G wf7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id di8-20020a170906730800b008b17569b4d9si5612980ejc.361.2023.03.07.14.59.29; Tue, 07 Mar 2023 14:59:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231782AbjCGWrp (ORCPT + 99 others); Tue, 7 Mar 2023 17:47:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbjCGWrI (ORCPT ); Tue, 7 Mar 2023 17:47:08 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 68CEF93C8; Tue, 7 Mar 2023 14:47:01 -0800 (PST) Received: from gsql.ggedos.sk (off-20.infotel.telecom.sk [212.5.213.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by hosting.gsystem.sk (Postfix) with ESMTPSA id 2240E7A0708; Tue, 7 Mar 2023 23:46:49 +0100 (CET) From: Ondrej Zary To: Damien Le Moal , Sudip Mukherjee Cc: Christoph Hellwig , Sergey Shtylyov , Jens Axboe , Tim Waugh , linux-block@vger.kernel.org, linux-parport@lists.infradead.org, linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/32] pata_parport-bpck6: use parport access functions instead of port I/O Date: Tue, 7 Mar 2023 23:46:07 +0100 Message-Id: <20230307224627.28011-13-linux@zary.sk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230307224627.28011-1-linux@zary.sk> References: <20230307224627.28011-1-linux@zary.sk> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759751693413277957?= X-GMAIL-MSGID: =?utf-8?q?1759751693413277957?= Use parport access functions instead of inb/outb/inw/outw/inl/outl. Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 1 - drivers/ata/pata_parport/ppc6lnx.c | 212 +++++++++-------------------- 2 files changed, 68 insertions(+), 145 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index dc0f71cc305e..39ac6e1a0aee 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include "pata_parport.h" #include "ppc6lnx.c" diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 09480a7fcaee..89c40d6ab036 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -17,7 +17,6 @@ #define port_int 16 -#define port_dir 0x20 #define ECR_EPP 0x80 #define ECR_BI 0x20 @@ -106,65 +105,60 @@ static int ppc6_select(struct pi_adapter *pi) { u8 i, j, k; - i = inb(pi->port + 1); + pi->saved_r0 = parport_read_data(pi->pardev->port); - if (i & 1) - outb(i, pi->port + 1); - - pi->saved_r0 = inb(pi->port); - - pi->saved_r2 = inb(pi->port + 2) & 0x5F; // readback ctrl + pi->saved_r2 = parport_read_control(pi->pardev->port) & 0x5F; // readback ctrl CUR_CTRL = pi->saved_r2; CUR_CTRL |= PARPORT_CONTROL_SELECT; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); if (pi->saved_r0 == 'b') - outb('x', pi->port); + parport_write_data(pi->pardev->port, 'x'); - outb('b', pi->port); - outb('p', pi->port); - outb(pi->unit, pi->port); - outb(~pi->unit, pi->port); + parport_write_data(pi->pardev->port, 'b'); + parport_write_data(pi->pardev->port, 'p'); + parport_write_data(pi->pardev->port, pi->unit); + parport_write_data(pi->pardev->port, ~pi->unit); CUR_CTRL &= ~PARPORT_CONTROL_SELECT; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); CUR_CTRL = (CUR_CTRL & port_int) | PARPORT_CONTROL_INIT; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); i = mode_map[pi->mode] & 0x0C; if (i == 0) i = (mode_map[pi->mode] & 2) | 1; - outb(i, pi->port); + parport_write_data(pi->pardev->port, i); CUR_CTRL |= PARPORT_CONTROL_SELECT; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); // DELAY CUR_CTRL |= PARPORT_CONTROL_AUTOFD; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); j = ((i & 0x08) << 4) | ((i & 0x07) << 3); - k = inb(pi->port + 1) & 0xB8; + k = parport_read_status(pi->pardev->port) & 0xB8; if (j == k) { CUR_CTRL &= ~PARPORT_CONTROL_AUTOFD; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); - k = (inb(pi->port + 1) & 0xB8) ^ 0xB8; + k = (parport_read_status(pi->pardev->port) & 0xB8) ^ 0xB8; if (j == k) { @@ -173,15 +167,15 @@ static int ppc6_select(struct pi_adapter *pi) else // PPC/ECP CUR_CTRL &= ~PARPORT_CONTROL_SELECT; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); return(1); } } - outb(pi->saved_r2, pi->port + 2); + parport_write_control(pi->pardev->port, pi->saved_r2); - outb(pi->saved_r0, pi->port); + parport_write_data(pi->pardev->port, pi->saved_r0); return(0); // FAIL } @@ -195,13 +189,13 @@ static void ppc6_deselect(struct pi_adapter *pi) else // PPC/ECP CUR_CTRL |= PARPORT_CONTROL_SELECT; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); - outb(pi->saved_r0, pi->port); + parport_write_data(pi->pardev->port, pi->saved_r0); - outb((pi->saved_r2 | PARPORT_CONTROL_SELECT), pi->port + 2); + parport_write_control(pi->pardev->port, (pi->saved_r2 | PARPORT_CONTROL_SELECT)); - outb(pi->saved_r2, pi->port + 2); + parport_write_control(pi->pardev->port, pi->saved_r2); } //*************************************************************************** @@ -215,11 +209,11 @@ static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) case PPCMODE_BI_SW : case PPCMODE_BI_FW : { - outb(cmd, pi->port); + parport_write_data(pi->pardev->port, cmd); CUR_CTRL ^= PARPORT_CONTROL_AUTOFD; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); break; } @@ -228,7 +222,7 @@ static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) case PPCMODE_EPP_WORD : case PPCMODE_EPP_DWORD : { - outb(cmd, pi->port + 3); + pi->pardev->port->ops->epp_write_addr(pi->pardev->port, &cmd, 1, 0); break; } @@ -246,11 +240,11 @@ static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) case PPCMODE_BI_SW : case PPCMODE_BI_FW : { - outb(data, pi->port); + parport_write_data(pi->pardev->port, data); CUR_CTRL ^= PARPORT_CONTROL_INIT; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); break; } @@ -259,7 +253,7 @@ static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) case PPCMODE_EPP_WORD : case PPCMODE_EPP_DWORD : { - outb(data, pi->port + 4); + pi->pardev->port->ops->epp_write_data(pi->pardev->port, &data, 1, 0); break; } @@ -279,21 +273,21 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) { CUR_CTRL = (CUR_CTRL & ~PARPORT_CONTROL_STROBE) ^ PARPORT_CONTROL_INIT; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); // DELAY - data = inb(pi->port + 1); + data = parport_read_status(pi->pardev->port); data = ((data & 0x80) >> 1) | ((data & 0x38) >> 3); CUR_CTRL |= PARPORT_CONTROL_STROBE; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); // DELAY - data |= inb(pi->port + 1) & 0xB8; + data |= parport_read_status(pi->pardev->port) & 0xB8; break; } @@ -301,23 +295,19 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) case PPCMODE_BI_SW : case PPCMODE_BI_FW : { - CUR_CTRL |= port_dir; - - outb(CUR_CTRL, pi->port + 2); + parport_data_reverse(pi->pardev->port); CUR_CTRL = (CUR_CTRL | PARPORT_CONTROL_STROBE) ^ PARPORT_CONTROL_INIT; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); - data = inb(pi->port); + data = parport_read_data(pi->pardev->port); CUR_CTRL &= ~PARPORT_CONTROL_STROBE; - outb(CUR_CTRL, pi->port + 2); - - CUR_CTRL &= ~port_dir; + parport_write_control(pi->pardev->port, CUR_CTRL); - outb(CUR_CTRL, pi->port + 2); + parport_data_forward(pi->pardev->port); break; } @@ -326,11 +316,7 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) case PPCMODE_EPP_WORD : case PPCMODE_EPP_DWORD : { - outb((CUR_CTRL | port_dir), pi->port + 2); - - data = inb(pi->port + 4); - - outb(CUR_CTRL, pi->port + 2); + pi->pardev->port->ops->epp_read_data(pi->pardev->port, &data, 1, 0); break; } @@ -373,21 +359,21 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) CUR_CTRL = (CUR_CTRL & ~PARPORT_CONTROL_STROBE) ^ PARPORT_CONTROL_INIT; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); // DELAY - d = inb(pi->port + 1); + d = parport_read_status(pi->pardev->port); d = ((d & 0x80) >> 1) | ((d & 0x38) >> 3); CUR_CTRL |= PARPORT_CONTROL_STROBE; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); // DELAY - d |= inb(pi->port + 1) & 0xB8; + d |= parport_read_status(pi->pardev->port) & 0xB8; *data++ = d; count--; @@ -399,9 +385,7 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) case PPCMODE_BI_SW : case PPCMODE_BI_FW : { - CUR_CTRL |= port_dir; - - outb(CUR_CTRL, pi->port + 2); + parport_data_reverse(pi->pardev->port); CUR_CTRL |= PARPORT_CONTROL_STROBE; @@ -409,84 +393,47 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) { CUR_CTRL ^= PARPORT_CONTROL_INIT; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); - *data++ = inb(pi->port); + *data++ = parport_read_data(pi->pardev->port); count--; } CUR_CTRL &= ~PARPORT_CONTROL_STROBE; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); - CUR_CTRL &= ~port_dir; - - outb(CUR_CTRL, pi->port + 2); + parport_data_forward(pi->pardev->port); break; } case PPCMODE_EPP_BYTE : { - outb((CUR_CTRL | port_dir), pi->port + 2); - // DELAY - while(count) - { - *data++ = inb(pi->port + 4); - count--; - } - - outb(CUR_CTRL, pi->port + 2); + pi->pardev->port->ops->epp_read_data(pi->pardev->port, + data, count, PARPORT_EPP_FAST_8); break; } case PPCMODE_EPP_WORD : { - outb((CUR_CTRL | port_dir), pi->port + 2); - // DELAY - while(count > 1) - { - *((u16 *)data) = inw(pi->port + 4); - data += 2; - count -= 2; - } - - while(count) - { - *data++ = inb(pi->port + 4); - count--; - } - - outb(CUR_CTRL, pi->port + 2); + pi->pardev->port->ops->epp_read_data(pi->pardev->port, + data, count, PARPORT_EPP_FAST_16); break; } case PPCMODE_EPP_DWORD : { - outb((CUR_CTRL | port_dir), pi->port + 2); - // DELAY - while(count > 3) - { - *((u32 *)data) = inl(pi->port + 4); - data += 4; - count -= 4; - } - - while(count) - { - *data++ = inb(pi->port + 4); - count--; - } - - outb(CUR_CTRL, pi->port + 2); + pi->pardev->port->ops->epp_read_data(pi->pardev->port, + data, count, PARPORT_EPP_FAST_32); break; } @@ -503,7 +450,7 @@ static void ppc6_wait_for_fifo(struct pi_adapter *pi) if (PPC_FLAGS & fifo_wait) { for(i=0; i<20; i++) - inb(pi->port + 1); + parport_read_status(pi->pardev->port); } } @@ -518,11 +465,11 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) { while(count--) { - outb(*data++, pi->port); + parport_write_data(pi->pardev->port, *data++); CUR_CTRL ^= PARPORT_CONTROL_INIT; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); } break; @@ -537,11 +484,11 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) CUR_CTRL |= PARPORT_CONTROL_STROBE; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); last = *data; - outb(last, pi->port); + parport_write_data(pi->pardev->port, last); while(count) { @@ -552,11 +499,11 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) { CUR_CTRL ^= PARPORT_CONTROL_INIT; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); } else { - outb(this, pi->port); + parport_write_data(pi->pardev->port, this); last = this; } @@ -564,7 +511,7 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) CUR_CTRL &= ~PARPORT_CONTROL_STROBE; - outb(CUR_CTRL, pi->port + 2); + parport_write_control(pi->pardev->port, CUR_CTRL); ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_FASTWR); @@ -573,11 +520,8 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) case PPCMODE_EPP_BYTE : { - while(count) - { - outb(*data++, pi->port + 4); - count--; - } + pi->pardev->port->ops->epp_write_data(pi->pardev->port, + data, count, PARPORT_EPP_FAST_8); ppc6_wait_for_fifo(pi); @@ -586,18 +530,8 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) case PPCMODE_EPP_WORD : { - while(count > 1) - { - outw(*((u16 *)data), pi->port + 4); - data += 2; - count -= 2; - } - - while(count) - { - outb(*data++, pi->port + 4); - count--; - } + pi->pardev->port->ops->epp_write_data(pi->pardev->port, + data, count, PARPORT_EPP_FAST_16); ppc6_wait_for_fifo(pi); @@ -606,18 +540,8 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) case PPCMODE_EPP_DWORD : { - while(count > 3) - { - outl(*((u32 *)data), pi->port + 4); - data += 4; - count -= 4; - } - - while(count) - { - outb(*data++, pi->port + 4); - count--; - } + pi->pardev->port->ops->epp_write_data(pi->pardev->port, + data, count, PARPORT_EPP_FAST_32); ppc6_wait_for_fifo(pi);