From patchwork Tue Mar 7 22:45:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164886 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08B94C74A44 for ; Tue, 7 Mar 2023 22:47:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230037AbjCGWrC (ORCPT ); Tue, 7 Mar 2023 17:47:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229746AbjCGWrA (ORCPT ); Tue, 7 Mar 2023 17:47:00 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3EB4993C8; Tue, 7 Mar 2023 14:46:49 -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 E06927A02E3; Tue, 7 Mar 2023 23:46:47 +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 01/32] pata_parport-bpck6: remove useless defines Date: Tue, 7 Mar 2023 23:45:56 +0100 Message-Id: <20230307224627.28011-2-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Almost all the ATAPI_ defines are unused. Remove them and use ATA_REG_DATA instead of ATAPI_DATA. Signed-off-by: Ondrej Zary Reviewed-by: Sergey Shtylyov --- drivers/ata/pata_parport/bpck6.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 964bc688e280..842e8116b649 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -23,23 +23,6 @@ #define PPCSTRUCT(pi) ((Interface *)(pi->private)) -/****************************************************************/ -/* - ATAPI CDROM DRIVE REGISTERS -*/ -#define ATAPI_DATA 0 /* data port */ -#define ATAPI_ERROR 1 /* error register (read) */ -#define ATAPI_FEATURES 1 /* feature register (write) */ -#define ATAPI_INT_REASON 2 /* interrupt reason register */ -#define ATAPI_COUNT_LOW 4 /* byte count register (low) */ -#define ATAPI_COUNT_HIGH 5 /* byte count register (high) */ -#define ATAPI_DRIVE_SEL 6 /* drive select register */ -#define ATAPI_STATUS 7 /* status port (read) */ -#define ATAPI_COMMAND 7 /* command port (write) */ -#define ATAPI_ALT_STATUS 0x0e /* alternate status reg (read) */ -#define ATAPI_DEVICE_CONTROL 0x0e /* device control (write) */ -/****************************************************************/ - static int bpck6_read_regr(struct pi_adapter *pi, int cont, int reg) { unsigned int out; @@ -64,12 +47,12 @@ static void bpck6_write_regr(struct pi_adapter *pi, int cont, int reg, int val) static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) { - ppc6_wr_port16_blk(PPCSTRUCT(pi),ATAPI_DATA,buf,(u32)len>>1); + ppc6_wr_port16_blk(PPCSTRUCT(pi), ATA_REG_DATA, buf, (u32)len>>1); } static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) { - ppc6_rd_port16_blk(PPCSTRUCT(pi),ATAPI_DATA,buf,(u32)len>>1); + ppc6_rd_port16_blk(PPCSTRUCT(pi), ATA_REG_DATA, buf, (u32)len>>1); } static void bpck6_connect(struct pi_adapter *pi) From patchwork Tue Mar 7 22:45:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164887 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F6F5C6FD1E for ; Tue, 7 Mar 2023 22:47:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbjCGWrC (ORCPT ); Tue, 7 Mar 2023 17:47:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229691AbjCGWrA (ORCPT ); Tue, 7 Mar 2023 17:47:00 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3E0E059D9; Tue, 7 Mar 2023 14:46:49 -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 053947A0533; Tue, 7 Mar 2023 23:46:48 +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 02/32] pata_parport-bpck6: remove useless range check from read/write_regr Date: Tue, 7 Mar 2023 23:45:57 +0100 Message-Id: <20230307224627.28011-3-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org bpck6_read_regr() and bpck6_write_regr() check values of cont and reg but there's no point in doing that. They can only be called with a fixed set of values. Remove the checks. Signed-off-by: Ondrej Zary Reviewed-by: Sergey Shtylyov --- drivers/ata/pata_parport/bpck6.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 842e8116b649..4d6edb9c1245 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -25,24 +25,12 @@ static int bpck6_read_regr(struct pi_adapter *pi, int cont, int reg) { - unsigned int out; - - /* check for bad settings */ - if (reg<0 || reg>7 || cont<0 || cont>2) - { - return(-1); - } - out=ppc6_rd_port(PPCSTRUCT(pi),cont?reg|8:reg); - return(out); + return ppc6_rd_port(PPCSTRUCT(pi), cont?reg|8:reg); } static void bpck6_write_regr(struct pi_adapter *pi, int cont, int reg, int val) { - /* check for bad settings */ - if (reg>=0 && reg<=7 && cont>=0 && cont<=1) - { - ppc6_wr_port(PPCSTRUCT(pi),cont?reg|8:reg,(u8)val); - } + ppc6_wr_port(PPCSTRUCT(pi), cont?reg|8:reg, val); } static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) From patchwork Tue Mar 7 22:45:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCF57C742A7 for ; Tue, 7 Mar 2023 22:47:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229789AbjCGWrD (ORCPT ); Tue, 7 Mar 2023 17:47:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbjCGWrB (ORCPT ); Tue, 7 Mar 2023 17:47:01 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3DFF240D2; Tue, 7 Mar 2023 14:46:49 -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 2A4F67A0568; Tue, 7 Mar 2023 23:46:48 +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 03/32] pata_parport-bpck6: don't cast pi->pardev to struct pardevice * Date: Tue, 7 Mar 2023 23:45:58 +0100 Message-Id: <20230307224627.28011-4-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org pi->pardev is struct pardevice *, no need to cast it to the same type. Also clean up the return mess. Signed-off-by: Ondrej Zary Reviewed-by: Sergey Shtylyov --- drivers/ata/pata_parport/bpck6.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 4d6edb9c1245..fa1f7d4fe3cb 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -74,30 +74,18 @@ static void bpck6_disconnect(struct pi_adapter *pi) static int bpck6_test_port(struct pi_adapter *pi) /* check for 8-bit port */ { dev_dbg(&pi->dev, "PARPORT indicates modes=%x for lp=0x%lx\n", - ((struct pardevice *)(pi->pardev))->port->modes, - ((struct pardevice *)(pi->pardev))->port->base); + pi->pardev->port->modes, pi->pardev->port->base); /*copy over duplicate stuff.. initialize state info*/ PPCSTRUCT(pi)->ppc_id=pi->unit; PPCSTRUCT(pi)->lpt_addr=pi->port; - /* look at the parport device to see if what modes we can use */ - if(((struct pardevice *)(pi->pardev))->port->modes & - (PARPORT_MODE_EPP) - ) - { - return 5; /* Can do EPP*/ - } - else if(((struct pardevice *)(pi->pardev))->port->modes & - (PARPORT_MODE_TRISTATE) - ) - { + /* look at the parport device to see what modes we can use */ + if (pi->pardev->port->modes & PARPORT_MODE_EPP) + return 5; /* Can do EPP */ + if (pi->pardev->port->modes & PARPORT_MODE_TRISTATE) return 2; - } - else /*Just flat SPP*/ - { - return 1; - } + return 1; /* Just flat SPP */ } static int bpck6_probe_unit(struct pi_adapter *pi) From patchwork Tue Mar 7 22:45:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164889 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30E31C76188 for ; Tue, 7 Mar 2023 22:47:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229971AbjCGWrG (ORCPT ); Tue, 7 Mar 2023 17:47:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbjCGWrB (ORCPT ); Tue, 7 Mar 2023 17:47:01 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3E2A57288; Tue, 7 Mar 2023 14:46:49 -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 3CBE07A05AB; Tue, 7 Mar 2023 23:46:48 +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 04/32] pata_parport-bpck6: pass around struct pi_adapter * Date: Tue, 7 Mar 2023 23:45:59 +0100 Message-Id: <20230307224627.28011-5-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Remove Interface typedef, pass around struct pi_adapter * down to all functions instead. Remove PPCSTRUCT define. Signed-off-by: Ondrej Zary Reviewed-by: Sergey Shtylyov Reviewed-by: Sergey Shtylyov --- drivers/ata/pata_parport/bpck6.c | 43 ++++----- drivers/ata/pata_parport/ppc6lnx.c | 139 +++++++++++++++-------------- 2 files changed, 96 insertions(+), 86 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index fa1f7d4fe3cb..bc128a2c444e 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -18,67 +18,67 @@ #include #include #include -#include "ppc6lnx.c" #include "pata_parport.h" - -#define PPCSTRUCT(pi) ((Interface *)(pi->private)) +#include "ppc6lnx.c" static int bpck6_read_regr(struct pi_adapter *pi, int cont, int reg) { - return ppc6_rd_port(PPCSTRUCT(pi), cont?reg|8:reg); + return ppc6_rd_port(pi, cont?reg|8:reg); } static void bpck6_write_regr(struct pi_adapter *pi, int cont, int reg, int val) { - ppc6_wr_port(PPCSTRUCT(pi), cont?reg|8:reg, val); + ppc6_wr_port(pi, cont?reg|8:reg, val); } static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) { - ppc6_wr_port16_blk(PPCSTRUCT(pi), ATA_REG_DATA, buf, (u32)len>>1); + ppc6_wr_port16_blk(pi, ATA_REG_DATA, buf, (u32)len>>1); } static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) { - ppc6_rd_port16_blk(PPCSTRUCT(pi), ATA_REG_DATA, buf, (u32)len>>1); + ppc6_rd_port16_blk(pi, ATA_REG_DATA, buf, (u32)len>>1); } static void bpck6_connect(struct pi_adapter *pi) { + struct ppc_storage *ppc = (void *)(pi->private); dev_dbg(&pi->dev, "connect\n"); if(pi->mode >=2) { - PPCSTRUCT(pi)->mode=4+pi->mode-2; + ppc->mode = 4+pi->mode-2; } else if(pi->mode==1) { - PPCSTRUCT(pi)->mode=3; + ppc->mode = 3; } else { - PPCSTRUCT(pi)->mode=1; + ppc->mode = 1; } - ppc6_open(PPCSTRUCT(pi)); - ppc6_wr_extout(PPCSTRUCT(pi),0x3); + ppc6_open(pi); + ppc6_wr_extout(pi, 0x3); } static void bpck6_disconnect(struct pi_adapter *pi) { dev_dbg(&pi->dev, "disconnect\n"); - ppc6_wr_extout(PPCSTRUCT(pi),0x0); - ppc6_close(PPCSTRUCT(pi)); + ppc6_wr_extout(pi, 0x0); + ppc6_close(pi); } static int bpck6_test_port(struct pi_adapter *pi) /* check for 8-bit port */ { + struct ppc_storage *ppc = (void *)(pi->private); dev_dbg(&pi->dev, "PARPORT indicates modes=%x for lp=0x%lx\n", pi->pardev->port->modes, pi->pardev->port->base); /*copy over duplicate stuff.. initialize state info*/ - PPCSTRUCT(pi)->ppc_id=pi->unit; - PPCSTRUCT(pi)->lpt_addr=pi->port; + ppc->ppc_id = pi->unit; + ppc->lpt_addr = pi->port; /* look at the parport device to see what modes we can use */ if (pi->pardev->port->modes & PARPORT_MODE_EPP) @@ -90,23 +90,24 @@ static int bpck6_test_port(struct pi_adapter *pi) /* check for 8-bit port */ static int bpck6_probe_unit(struct pi_adapter *pi) { + struct ppc_storage *ppc = (void *)(pi->private); int out; dev_dbg(&pi->dev, "PROBE UNIT %x on port:%x\n", pi->unit, pi->port); /*SET PPC UNIT NUMBER*/ - PPCSTRUCT(pi)->ppc_id=pi->unit; + ppc->ppc_id = pi->unit; /*LOWER DOWN TO UNIDIRECTIONAL*/ - PPCSTRUCT(pi)->mode=1; + ppc->mode = 1; - out=ppc6_open(PPCSTRUCT(pi)); + out = ppc6_open(pi); dev_dbg(&pi->dev, "ppc_open returned %2x\n", out); if(out) { - ppc6_close(PPCSTRUCT(pi)); + ppc6_close(pi); dev_dbg(&pi->dev, "leaving probe\n"); return(1); } @@ -128,7 +129,7 @@ static void bpck6_log_adapter(struct pi_adapter *pi) static int bpck6_init_proto(struct pi_adapter *pi) { - Interface *p = kzalloc(sizeof(Interface), GFP_KERNEL); + struct ppc_storage *p = kzalloc(sizeof(struct ppc_storage), GFP_KERNEL); if (p) { pi->private = (unsigned long)p; diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 5e5521d3b1dd..f12bb019fc61 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -64,7 +64,7 @@ //*************************************************************************** -typedef struct ppc_storage { +struct ppc_storage { u16 lpt_addr; // LPT base address u8 ppc_id; u8 mode; // operating mode @@ -79,7 +79,7 @@ typedef struct ppc_storage { u8 org_data; // original LPT data port contents u8 org_ctrl; // original LPT control port contents u8 cur_ctrl; // current control port contents -} Interface; +}; //*************************************************************************** @@ -101,26 +101,27 @@ typedef struct ppc_storage { //*************************************************************************** -static int ppc6_select(Interface *ppc); -static void ppc6_deselect(Interface *ppc); -static void ppc6_send_cmd(Interface *ppc, u8 cmd); -static void ppc6_wr_data_byte(Interface *ppc, u8 data); -static u8 ppc6_rd_data_byte(Interface *ppc); -static u8 ppc6_rd_port(Interface *ppc, u8 port); -static void ppc6_wr_port(Interface *ppc, u8 port, u8 data); -static void ppc6_rd_data_blk(Interface *ppc, u8 *data, long count); -static void ppc6_wait_for_fifo(Interface *ppc); -static void ppc6_wr_data_blk(Interface *ppc, u8 *data, long count); -static void ppc6_rd_port16_blk(Interface *ppc, u8 port, u8 *data, long length); -static void ppc6_wr_port16_blk(Interface *ppc, u8 port, u8 *data, long length); -static void ppc6_wr_extout(Interface *ppc, u8 regdata); -static int ppc6_open(Interface *ppc); -static void ppc6_close(Interface *ppc); +static int ppc6_select(struct pi_adapter *pi); +static void ppc6_deselect(struct pi_adapter *pi); +static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd); +static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data); +static u8 ppc6_rd_data_byte(struct pi_adapter *pi); +static u8 ppc6_rd_port(struct pi_adapter *pi, u8 port); +static void ppc6_wr_port(struct pi_adapter *pi, u8 port, u8 data); +static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count); +static void ppc6_wait_for_fifo(struct pi_adapter *pi); +static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count); +static void ppc6_rd_port16_blk(struct pi_adapter *pi, u8 port, u8 *data, long length); +static void ppc6_wr_port16_blk(struct pi_adapter *pi, u8 port, u8 *data, long length); +static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata); +static int ppc6_open(struct pi_adapter *pi); +static void ppc6_close(struct pi_adapter *pi); //*************************************************************************** -static int ppc6_select(Interface *ppc) +static int ppc6_select(struct pi_adapter *pi) { + struct ppc_storage *ppc = (void *)(pi->private); u8 i, j, k; i = inb(ppc->lpt_addr + 1); @@ -205,8 +206,9 @@ static int ppc6_select(Interface *ppc) //*************************************************************************** -static void ppc6_deselect(Interface *ppc) +static void ppc6_deselect(struct pi_adapter *pi) { + struct ppc_storage *ppc = (void *)(pi->private); if (ppc->mode & 4) // EPP ppc->cur_ctrl |= port_init; else // PPC/ECP @@ -223,8 +225,9 @@ static void ppc6_deselect(Interface *ppc) //*************************************************************************** -static void ppc6_send_cmd(Interface *ppc, u8 cmd) +static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) { + struct ppc_storage *ppc = (void *)(pi->private); switch(ppc->mode) { case PPCMODE_UNI_SW : @@ -254,8 +257,9 @@ static void ppc6_send_cmd(Interface *ppc, u8 cmd) //*************************************************************************** -static void ppc6_wr_data_byte(Interface *ppc, u8 data) +static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) { + struct ppc_storage *ppc = (void *)(pi->private); switch(ppc->mode) { case PPCMODE_UNI_SW : @@ -285,8 +289,9 @@ static void ppc6_wr_data_byte(Interface *ppc, u8 data) //*************************************************************************** -static u8 ppc6_rd_data_byte(Interface *ppc) +static u8 ppc6_rd_data_byte(struct pi_adapter *pi) { + struct ppc_storage *ppc = (void *)(pi->private); u8 data = 0; switch(ppc->mode) @@ -358,26 +363,27 @@ static u8 ppc6_rd_data_byte(Interface *ppc) //*************************************************************************** -static u8 ppc6_rd_port(Interface *ppc, u8 port) +static u8 ppc6_rd_port(struct pi_adapter *pi, u8 port) { - ppc6_send_cmd(ppc,(u8)(port | ACCESS_PORT | ACCESS_READ)); + ppc6_send_cmd(pi, port | ACCESS_PORT | ACCESS_READ); - return(ppc6_rd_data_byte(ppc)); + return ppc6_rd_data_byte(pi); } //*************************************************************************** -static void ppc6_wr_port(Interface *ppc, u8 port, u8 data) +static void ppc6_wr_port(struct pi_adapter *pi, u8 port, u8 data) { - ppc6_send_cmd(ppc,(u8)(port | ACCESS_PORT | ACCESS_WRITE)); + ppc6_send_cmd(pi, port | ACCESS_PORT | ACCESS_WRITE); - ppc6_wr_data_byte(ppc, data); + ppc6_wr_data_byte(pi, data); } //*************************************************************************** -static void ppc6_rd_data_blk(Interface *ppc, u8 *data, long count) +static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) { + struct ppc_storage *ppc = (void *)(pi->private); switch(ppc->mode) { case PPCMODE_UNI_SW : @@ -512,8 +518,9 @@ static void ppc6_rd_data_blk(Interface *ppc, u8 *data, long count) //*************************************************************************** -static void ppc6_wait_for_fifo(Interface *ppc) +static void ppc6_wait_for_fifo(struct pi_adapter *pi) { + struct ppc_storage *ppc = (void *)(pi->private); int i; if (ppc->ppc_flags & fifo_wait) @@ -525,8 +532,9 @@ static void ppc6_wait_for_fifo(Interface *ppc) //*************************************************************************** -static void ppc6_wr_data_blk(Interface *ppc, u8 *data, long count) +static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) { + struct ppc_storage *ppc = (void *)(pi->private); switch(ppc->mode) { case PPCMODE_UNI_SW : @@ -549,7 +557,7 @@ static void ppc6_wr_data_blk(Interface *ppc, u8 *data, long count) { u8 this, last; - ppc6_send_cmd(ppc,(CMD_PREFIX_SET | PREFIX_FASTWR)); + ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_FASTWR); ppc->cur_ctrl |= port_stb; @@ -582,7 +590,7 @@ static void ppc6_wr_data_blk(Interface *ppc, u8 *data, long count) outb(ppc->cur_ctrl, ppc->lpt_addr + 2); - ppc6_send_cmd(ppc,(CMD_PREFIX_RESET | PREFIX_FASTWR)); + ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_FASTWR); break; } @@ -595,7 +603,7 @@ static void ppc6_wr_data_blk(Interface *ppc, u8 *data, long count) count--; } - ppc6_wait_for_fifo(ppc); + ppc6_wait_for_fifo(pi); break; } @@ -615,7 +623,7 @@ static void ppc6_wr_data_blk(Interface *ppc, u8 *data, long count) count--; } - ppc6_wait_for_fifo(ppc); + ppc6_wait_for_fifo(pi); break; } @@ -635,7 +643,7 @@ static void ppc6_wr_data_blk(Interface *ppc, u8 *data, long count) count--; } - ppc6_wait_for_fifo(ppc); + ppc6_wait_for_fifo(pi); break; } @@ -644,72 +652,73 @@ static void ppc6_wr_data_blk(Interface *ppc, u8 *data, long count) //*************************************************************************** -static void ppc6_rd_port16_blk(Interface *ppc, u8 port, u8 *data, long length) +static void ppc6_rd_port16_blk(struct pi_adapter *pi, u8 port, u8 *data, long length) { length = length << 1; - ppc6_send_cmd(ppc, (REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE)); - ppc6_wr_data_byte(ppc,(u8)length); - ppc6_wr_data_byte(ppc,(u8)(length >> 8)); - ppc6_wr_data_byte(ppc,0); + ppc6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); + ppc6_wr_data_byte(pi, (u8)length); + ppc6_wr_data_byte(pi, (u8)(length >> 8)); + ppc6_wr_data_byte(pi, 0); - ppc6_send_cmd(ppc, (CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK)); + ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); - ppc6_send_cmd(ppc, (u8)(port | ACCESS_PORT | ACCESS_READ)); + ppc6_send_cmd(pi, port | ACCESS_PORT | ACCESS_READ); - ppc6_rd_data_blk(ppc, data, length); + ppc6_rd_data_blk(pi, data, length); - ppc6_send_cmd(ppc, (CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK)); + ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); } //*************************************************************************** -static void ppc6_wr_port16_blk(Interface *ppc, u8 port, u8 *data, long length) +static void ppc6_wr_port16_blk(struct pi_adapter *pi, u8 port, u8 *data, long length) { length = length << 1; - ppc6_send_cmd(ppc, (REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE)); - ppc6_wr_data_byte(ppc,(u8)length); - ppc6_wr_data_byte(ppc,(u8)(length >> 8)); - ppc6_wr_data_byte(ppc,0); + ppc6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); + ppc6_wr_data_byte(pi, (u8)length); + ppc6_wr_data_byte(pi, (u8)(length >> 8)); + ppc6_wr_data_byte(pi, 0); - ppc6_send_cmd(ppc, (CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK)); + ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); - ppc6_send_cmd(ppc, (u8)(port | ACCESS_PORT | ACCESS_WRITE)); + ppc6_send_cmd(pi, port | ACCESS_PORT | ACCESS_WRITE); - ppc6_wr_data_blk(ppc, data, length); + ppc6_wr_data_blk(pi, data, length); - ppc6_send_cmd(ppc, (CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK)); + ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); } //*************************************************************************** -static void ppc6_wr_extout(Interface *ppc, u8 regdata) +static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata) { - ppc6_send_cmd(ppc,(REG_VERSION | ACCESS_REG | ACCESS_WRITE)); + ppc6_send_cmd(pi, REG_VERSION | ACCESS_REG | ACCESS_WRITE); - ppc6_wr_data_byte(ppc, (u8)((regdata & 0x03) << 6)); + ppc6_wr_data_byte(pi, (u8)((regdata & 0x03) << 6)); } //*************************************************************************** -static int ppc6_open(Interface *ppc) +static int ppc6_open(struct pi_adapter *pi) { + struct ppc_storage *ppc = (void *)(pi->private); int ret; - ret = ppc6_select(ppc); + ret = ppc6_select(pi); if (ret == 0) return(ret); ppc->ppc_flags &= ~fifo_wait; - ppc6_send_cmd(ppc, (ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE)); - ppc6_wr_data_byte(ppc, RAMSIZE_128K); + ppc6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE); + ppc6_wr_data_byte(pi, RAMSIZE_128K); - ppc6_send_cmd(ppc, (ACCESS_REG | ACCESS_READ | REG_VERSION)); + ppc6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); - if ((ppc6_rd_data_byte(ppc) & 0x3F) == 0x0C) + if ((ppc6_rd_data_byte(pi) & 0x3F) == 0x0C) ppc->ppc_flags |= fifo_wait; return(ret); @@ -717,9 +726,9 @@ static int ppc6_open(Interface *ppc) //*************************************************************************** -static void ppc6_close(Interface *ppc) +static void ppc6_close(struct pi_adapter *pi) { - ppc6_deselect(ppc); + ppc6_deselect(pi); } //*************************************************************************** From patchwork Tue Mar 7 22:46:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B27EDC76188 for ; Tue, 7 Mar 2023 22:47:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229975AbjCGWrT (ORCPT ); Tue, 7 Mar 2023 17:47:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbjCGWrH (ORCPT ); Tue, 7 Mar 2023 17:47:07 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4D9E84EE4; Tue, 7 Mar 2023 14:47:00 -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 5F2977A05BD; Tue, 7 Mar 2023 23:46:48 +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 05/32] pata_parport-bpck6: remove lpt_addr from struct ppc_storage Date: Tue, 7 Mar 2023 23:46:00 +0100 Message-Id: <20230307224627.28011-6-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org lpt_addr duplicates pi->port. Remove it. Signed-off-by: Ondrej Zary Reviewed-by: Sergey Shtylyov --- drivers/ata/pata_parport/bpck6.c | 1 - drivers/ata/pata_parport/ppc6lnx.c | 153 ++++++++++++++--------------- 2 files changed, 76 insertions(+), 78 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index bc128a2c444e..50d313fc529e 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -78,7 +78,6 @@ static int bpck6_test_port(struct pi_adapter *pi) /* check for 8-bit port */ /*copy over duplicate stuff.. initialize state info*/ ppc->ppc_id = pi->unit; - ppc->lpt_addr = pi->port; /* look at the parport device to see what modes we can use */ if (pi->pardev->port->modes & PARPORT_MODE_EPP) diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index f12bb019fc61..c00e561cc833 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -65,7 +65,6 @@ //*************************************************************************** struct ppc_storage { - u16 lpt_addr; // LPT base address u8 ppc_id; u8 mode; // operating mode // 0 = PPC Uni SW @@ -124,65 +123,65 @@ static int ppc6_select(struct pi_adapter *pi) struct ppc_storage *ppc = (void *)(pi->private); u8 i, j, k; - i = inb(ppc->lpt_addr + 1); + i = inb(pi->port + 1); if (i & 1) - outb(i, ppc->lpt_addr + 1); + outb(i, pi->port + 1); - ppc->org_data = inb(ppc->lpt_addr); + ppc->org_data = inb(pi->port); - ppc->org_ctrl = inb(ppc->lpt_addr + 2) & 0x5F; // readback ctrl + ppc->org_ctrl = inb(pi->port + 2) & 0x5F; // readback ctrl ppc->cur_ctrl = ppc->org_ctrl; ppc->cur_ctrl |= port_sel; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); if (ppc->org_data == 'b') - outb('x', ppc->lpt_addr); + outb('x', pi->port); - outb('b', ppc->lpt_addr); - outb('p', ppc->lpt_addr); - outb(ppc->ppc_id, ppc->lpt_addr); - outb(~ppc->ppc_id,ppc->lpt_addr); + outb('b', pi->port); + outb('p', pi->port); + outb(ppc->ppc_id, pi->port); + outb(~ppc->ppc_id, pi->port); ppc->cur_ctrl &= ~port_sel; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); ppc->cur_ctrl = (ppc->cur_ctrl & port_int) | port_init; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); i = ppc->mode & 0x0C; if (i == 0) i = (ppc->mode & 2) | 1; - outb(i, ppc->lpt_addr); + outb(i, pi->port); ppc->cur_ctrl |= port_sel; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); // DELAY ppc->cur_ctrl |= port_afd; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); j = ((i & 0x08) << 4) | ((i & 0x07) << 3); - k = inb(ppc->lpt_addr + 1) & 0xB8; + k = inb(pi->port + 1) & 0xB8; if (j == k) { ppc->cur_ctrl &= ~port_afd; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); - k = (inb(ppc->lpt_addr + 1) & 0xB8) ^ 0xB8; + k = (inb(pi->port + 1) & 0xB8) ^ 0xB8; if (j == k) { @@ -191,15 +190,15 @@ static int ppc6_select(struct pi_adapter *pi) else // PPC/ECP ppc->cur_ctrl &= ~port_sel; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); return(1); } } - outb(ppc->org_ctrl, ppc->lpt_addr + 2); + outb(ppc->org_ctrl, pi->port + 2); - outb(ppc->org_data, ppc->lpt_addr); + outb(ppc->org_data, pi->port); return(0); // FAIL } @@ -214,13 +213,13 @@ static void ppc6_deselect(struct pi_adapter *pi) else // PPC/ECP ppc->cur_ctrl |= port_sel; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); - outb(ppc->org_data, ppc->lpt_addr); + outb(ppc->org_data, pi->port); - outb((ppc->org_ctrl | port_sel), ppc->lpt_addr + 2); + outb((ppc->org_ctrl | port_sel), pi->port + 2); - outb(ppc->org_ctrl, ppc->lpt_addr + 2); + outb(ppc->org_ctrl, pi->port + 2); } //*************************************************************************** @@ -235,11 +234,11 @@ static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) case PPCMODE_BI_SW : case PPCMODE_BI_FW : { - outb(cmd, ppc->lpt_addr); + outb(cmd, pi->port); ppc->cur_ctrl ^= cmd_stb; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); break; } @@ -248,7 +247,7 @@ static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) case PPCMODE_EPP_WORD : case PPCMODE_EPP_DWORD : { - outb(cmd, ppc->lpt_addr + 3); + outb(cmd, pi->port + 3); break; } @@ -267,11 +266,11 @@ static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) case PPCMODE_BI_SW : case PPCMODE_BI_FW : { - outb(data, ppc->lpt_addr); + outb(data, pi->port); ppc->cur_ctrl ^= data_stb; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); break; } @@ -280,7 +279,7 @@ static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) case PPCMODE_EPP_WORD : case PPCMODE_EPP_DWORD : { - outb(data, ppc->lpt_addr + 4); + outb(data, pi->port + 4); break; } @@ -301,21 +300,21 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) { ppc->cur_ctrl = (ppc->cur_ctrl & ~port_stb) ^ data_stb; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); // DELAY - data = inb(ppc->lpt_addr + 1); + data = inb(pi->port + 1); data = ((data & 0x80) >> 1) | ((data & 0x38) >> 3); ppc->cur_ctrl |= port_stb; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); // DELAY - data |= inb(ppc->lpt_addr + 1) & 0xB8; + data |= inb(pi->port + 1) & 0xB8; break; } @@ -325,21 +324,21 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) { ppc->cur_ctrl |= port_dir; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); ppc->cur_ctrl = (ppc->cur_ctrl | port_stb) ^ data_stb; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); - data = inb(ppc->lpt_addr); + data = inb(pi->port); ppc->cur_ctrl &= ~port_stb; - outb(ppc->cur_ctrl,ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); ppc->cur_ctrl &= ~port_dir; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); break; } @@ -348,11 +347,11 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) case PPCMODE_EPP_WORD : case PPCMODE_EPP_DWORD : { - outb((ppc->cur_ctrl | port_dir),ppc->lpt_addr + 2); + outb((ppc->cur_ctrl | port_dir), pi->port + 2); - data = inb(ppc->lpt_addr + 4); + data = inb(pi->port + 4); - outb(ppc->cur_ctrl,ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); break; } @@ -395,21 +394,21 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) ppc->cur_ctrl = (ppc->cur_ctrl & ~port_stb) ^ data_stb; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); // DELAY - d = inb(ppc->lpt_addr + 1); + d = inb(pi->port + 1); d = ((d & 0x80) >> 1) | ((d & 0x38) >> 3); ppc->cur_ctrl |= port_stb; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); // DELAY - d |= inb(ppc->lpt_addr + 1) & 0xB8; + d |= inb(pi->port + 1) & 0xB8; *data++ = d; count--; @@ -423,7 +422,7 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) { ppc->cur_ctrl |= port_dir; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); ppc->cur_ctrl |= port_stb; @@ -431,84 +430,84 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) { ppc->cur_ctrl ^= data_stb; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); - *data++ = inb(ppc->lpt_addr); + *data++ = inb(pi->port); count--; } ppc->cur_ctrl &= ~port_stb; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); ppc->cur_ctrl &= ~port_dir; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); break; } case PPCMODE_EPP_BYTE : { - outb((ppc->cur_ctrl | port_dir), ppc->lpt_addr + 2); + outb((ppc->cur_ctrl | port_dir), pi->port + 2); // DELAY while(count) { - *data++ = inb(ppc->lpt_addr + 4); + *data++ = inb(pi->port + 4); count--; } - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); break; } case PPCMODE_EPP_WORD : { - outb((ppc->cur_ctrl | port_dir), ppc->lpt_addr + 2); + outb((ppc->cur_ctrl | port_dir), pi->port + 2); // DELAY while(count > 1) { - *((u16 *)data) = inw(ppc->lpt_addr + 4); + *((u16 *)data) = inw(pi->port + 4); data += 2; count -= 2; } while(count) { - *data++ = inb(ppc->lpt_addr + 4); + *data++ = inb(pi->port + 4); count--; } - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); break; } case PPCMODE_EPP_DWORD : { - outb((ppc->cur_ctrl | port_dir),ppc->lpt_addr + 2); + outb((ppc->cur_ctrl | port_dir), pi->port + 2); // DELAY while(count > 3) { - *((u32 *)data) = inl(ppc->lpt_addr + 4); + *((u32 *)data) = inl(pi->port + 4); data += 4; count -= 4; } while(count) { - *data++ = inb(ppc->lpt_addr + 4); + *data++ = inb(pi->port + 4); count--; } - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); break; } @@ -526,7 +525,7 @@ static void ppc6_wait_for_fifo(struct pi_adapter *pi) if (ppc->ppc_flags & fifo_wait) { for(i=0; i<20; i++) - inb(ppc->lpt_addr + 1); + inb(pi->port + 1); } } @@ -542,11 +541,11 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) { while(count--) { - outb(*data++, ppc->lpt_addr); + outb(*data++, pi->port); ppc->cur_ctrl ^= data_stb; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); } break; @@ -561,11 +560,11 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) ppc->cur_ctrl |= port_stb; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); last = *data; - outb(last, ppc->lpt_addr); + outb(last, pi->port); while(count) { @@ -576,11 +575,11 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) { ppc->cur_ctrl ^= data_stb; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); } else { - outb(this, ppc->lpt_addr); + outb(this, pi->port); last = this; } @@ -588,7 +587,7 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) ppc->cur_ctrl &= ~port_stb; - outb(ppc->cur_ctrl, ppc->lpt_addr + 2); + outb(ppc->cur_ctrl, pi->port + 2); ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_FASTWR); @@ -599,7 +598,7 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) { while(count) { - outb(*data++,ppc->lpt_addr + 4); + outb(*data++, pi->port + 4); count--; } @@ -612,14 +611,14 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) { while(count > 1) { - outw(*((u16 *)data),ppc->lpt_addr + 4); + outw(*((u16 *)data), pi->port + 4); data += 2; count -= 2; } while(count) { - outb(*data++,ppc->lpt_addr + 4); + outb(*data++, pi->port + 4); count--; } @@ -632,14 +631,14 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) { while(count > 3) { - outl(*((u32 *)data),ppc->lpt_addr + 4); + outl(*((u32 *)data), pi->port + 4); data += 4; count -= 4; } while(count) { - outb(*data++,ppc->lpt_addr + 4); + outb(*data++, pi->port + 4); count--; } From patchwork Tue Mar 7 22:46:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164890 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC28AC742A7 for ; Tue, 7 Mar 2023 22:47:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230362AbjCGWrK (ORCPT ); Tue, 7 Mar 2023 17:47:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbjCGWrE (ORCPT ); Tue, 7 Mar 2023 17:47:04 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CC646E067; Tue, 7 Mar 2023 14:47:00 -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 7921D7A05D5; Tue, 7 Mar 2023 23:46:48 +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 06/32] pata_parport-bpck6: remove ppc_id from struct ppc_storage Date: Tue, 7 Mar 2023 23:46:01 +0100 Message-Id: <20230307224627.28011-7-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org ppc_id duplicates pi->unit. Remove it. Signed-off-by: Ondrej Zary Reviewed-by: Sergey Shtylyov --- drivers/ata/pata_parport/bpck6.c | 7 ------- drivers/ata/pata_parport/ppc6lnx.c | 5 ++--- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 50d313fc529e..176bf456c698 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -72,13 +72,9 @@ static void bpck6_disconnect(struct pi_adapter *pi) static int bpck6_test_port(struct pi_adapter *pi) /* check for 8-bit port */ { - struct ppc_storage *ppc = (void *)(pi->private); dev_dbg(&pi->dev, "PARPORT indicates modes=%x for lp=0x%lx\n", pi->pardev->port->modes, pi->pardev->port->base); - /*copy over duplicate stuff.. initialize state info*/ - ppc->ppc_id = pi->unit; - /* look at the parport device to see what modes we can use */ if (pi->pardev->port->modes & PARPORT_MODE_EPP) return 5; /* Can do EPP */ @@ -94,9 +90,6 @@ static int bpck6_probe_unit(struct pi_adapter *pi) dev_dbg(&pi->dev, "PROBE UNIT %x on port:%x\n", pi->unit, pi->port); - /*SET PPC UNIT NUMBER*/ - ppc->ppc_id = pi->unit; - /*LOWER DOWN TO UNIDIRECTIONAL*/ ppc->mode = 1; diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index c00e561cc833..dd9f3040f9a7 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -65,7 +65,6 @@ //*************************************************************************** struct ppc_storage { - u8 ppc_id; u8 mode; // operating mode // 0 = PPC Uni SW // 1 = PPC Uni FW @@ -143,8 +142,8 @@ static int ppc6_select(struct pi_adapter *pi) outb('b', pi->port); outb('p', pi->port); - outb(ppc->ppc_id, pi->port); - outb(~ppc->ppc_id, pi->port); + outb(pi->unit, pi->port); + outb(~pi->unit, pi->port); ppc->cur_ctrl &= ~port_sel; From patchwork Tue Mar 7 22:46:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD5D7C678D5 for ; Tue, 7 Mar 2023 22:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbjCGWrO (ORCPT ); Tue, 7 Mar 2023 17:47:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230333AbjCGWrH (ORCPT ); Tue, 7 Mar 2023 17:47:07 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4DD5229E15; 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 957DF7A05DC; Tue, 7 Mar 2023 23:46:48 +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 07/32] pata_parport-bpck6: remove org_* from struct ppc_storage Date: Tue, 7 Mar 2023 23:46:02 +0100 Message-Id: <20230307224627.28011-8-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org org_data duplicates saved_r0 and org_ctrl duplicates saved_r2 in pi->unit. Remove them. Signed-off-by: Ondrej Zary Reviewed-by: Sergey Shtylyov --- drivers/ata/pata_parport/ppc6lnx.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index dd9f3040f9a7..7ea8e8a31aeb 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -74,8 +74,6 @@ struct ppc_storage { // 5 = EPP Word // 6 = EPP Dword u8 ppc_flags; - u8 org_data; // original LPT data port contents - u8 org_ctrl; // original LPT control port contents u8 cur_ctrl; // current control port contents }; @@ -127,17 +125,17 @@ static int ppc6_select(struct pi_adapter *pi) if (i & 1) outb(i, pi->port + 1); - ppc->org_data = inb(pi->port); + pi->saved_r0 = inb(pi->port); - ppc->org_ctrl = inb(pi->port + 2) & 0x5F; // readback ctrl + pi->saved_r2 = inb(pi->port + 2) & 0x5F; // readback ctrl - ppc->cur_ctrl = ppc->org_ctrl; + ppc->cur_ctrl = pi->saved_r2; ppc->cur_ctrl |= port_sel; outb(ppc->cur_ctrl, pi->port + 2); - if (ppc->org_data == 'b') + if (pi->saved_r0 == 'b') outb('x', pi->port); outb('b', pi->port); @@ -195,9 +193,9 @@ static int ppc6_select(struct pi_adapter *pi) } } - outb(ppc->org_ctrl, pi->port + 2); + outb(pi->saved_r2, pi->port + 2); - outb(ppc->org_data, pi->port); + outb(pi->saved_r0, pi->port); return(0); // FAIL } @@ -214,11 +212,11 @@ static void ppc6_deselect(struct pi_adapter *pi) outb(ppc->cur_ctrl, pi->port + 2); - outb(ppc->org_data, pi->port); + outb(pi->saved_r0, pi->port); - outb((ppc->org_ctrl | port_sel), pi->port + 2); + outb((pi->saved_r2 | port_sel), pi->port + 2); - outb(ppc->org_ctrl, pi->port + 2); + outb(pi->saved_r2, pi->port + 2); } //*************************************************************************** From patchwork Tue Mar 7 22:46:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164891 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95B70C74A4B for ; Tue, 7 Mar 2023 22:47:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230150AbjCGWrL (ORCPT ); Tue, 7 Mar 2023 17:47:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229904AbjCGWrF (ORCPT ); Tue, 7 Mar 2023 17:47:05 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4DB1459D9; 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 ADFE17A06EC; Tue, 7 Mar 2023 23:46:48 +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 08/32] pata_parport-bpck6: remove mode from struct ppc_storage Date: Tue, 7 Mar 2023 23:46:03 +0100 Message-Id: <20230307224627.28011-9-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org introduce mode_map[] that maps bpck6 modes to ppc6 modes and use it to replace mode in ppc_storage Signed-off-by: Ondrej Zary Reviewed-by: Sergey Shtylyov --- drivers/ata/pata_parport/bpck6.c | 22 +++++----------------- drivers/ata/pata_parport/ppc6lnx.c | 27 +++++++++++---------------- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 176bf456c698..fe97d1dee51c 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -43,22 +43,8 @@ static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) static void bpck6_connect(struct pi_adapter *pi) { - struct ppc_storage *ppc = (void *)(pi->private); dev_dbg(&pi->dev, "connect\n"); - if(pi->mode >=2) - { - ppc->mode = 4+pi->mode-2; - } - else if(pi->mode==1) - { - ppc->mode = 3; - } - else - { - ppc->mode = 1; - } - ppc6_open(pi); ppc6_wr_extout(pi, 0x3); } @@ -85,13 +71,13 @@ static int bpck6_test_port(struct pi_adapter *pi) /* check for 8-bit port */ static int bpck6_probe_unit(struct pi_adapter *pi) { - struct ppc_storage *ppc = (void *)(pi->private); - int out; + int out, saved_mode; dev_dbg(&pi->dev, "PROBE UNIT %x on port:%x\n", pi->unit, pi->port); + saved_mode = pi->mode; /*LOWER DOWN TO UNIDIRECTIONAL*/ - ppc->mode = 1; + pi->mode = 0; out = ppc6_open(pi); @@ -101,11 +87,13 @@ static int bpck6_probe_unit(struct pi_adapter *pi) { ppc6_close(pi); dev_dbg(&pi->dev, "leaving probe\n"); + pi->mode = saved_mode; return(1); } else { dev_dbg(&pi->dev, "Failed open\n"); + pi->mode = saved_mode; return(0); } } diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 7ea8e8a31aeb..75f9748d8de5 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -65,14 +65,6 @@ //*************************************************************************** struct ppc_storage { - u8 mode; // operating mode - // 0 = PPC Uni SW - // 1 = PPC Uni FW - // 2 = PPC Bi SW - // 3 = PPC Bi FW - // 4 = EPP Byte - // 5 = EPP Word - // 6 = EPP Dword u8 ppc_flags; u8 cur_ctrl; // current control port contents }; @@ -115,6 +107,9 @@ static void ppc6_close(struct pi_adapter *pi); //*************************************************************************** +int mode_map[] = { PPCMODE_UNI_FW, PPCMODE_BI_FW, PPCMODE_EPP_BYTE, + PPCMODE_EPP_WORD, PPCMODE_EPP_DWORD }; + static int ppc6_select(struct pi_adapter *pi) { struct ppc_storage *ppc = (void *)(pi->private); @@ -151,10 +146,10 @@ static int ppc6_select(struct pi_adapter *pi) outb(ppc->cur_ctrl, pi->port + 2); - i = ppc->mode & 0x0C; + i = mode_map[pi->mode] & 0x0C; if (i == 0) - i = (ppc->mode & 2) | 1; + i = (mode_map[pi->mode] & 2) | 1; outb(i, pi->port); @@ -205,7 +200,7 @@ static int ppc6_select(struct pi_adapter *pi) static void ppc6_deselect(struct pi_adapter *pi) { struct ppc_storage *ppc = (void *)(pi->private); - if (ppc->mode & 4) // EPP + if (mode_map[pi->mode] & 4) // EPP ppc->cur_ctrl |= port_init; else // PPC/ECP ppc->cur_ctrl |= port_sel; @@ -224,7 +219,7 @@ static void ppc6_deselect(struct pi_adapter *pi) static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) { struct ppc_storage *ppc = (void *)(pi->private); - switch(ppc->mode) + switch (mode_map[pi->mode]) { case PPCMODE_UNI_SW : case PPCMODE_UNI_FW : @@ -256,7 +251,7 @@ static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) { struct ppc_storage *ppc = (void *)(pi->private); - switch(ppc->mode) + switch (mode_map[pi->mode]) { case PPCMODE_UNI_SW : case PPCMODE_UNI_FW : @@ -290,7 +285,7 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) struct ppc_storage *ppc = (void *)(pi->private); u8 data = 0; - switch(ppc->mode) + switch (mode_map[pi->mode]) { case PPCMODE_UNI_SW : case PPCMODE_UNI_FW : @@ -380,7 +375,7 @@ static void ppc6_wr_port(struct pi_adapter *pi, u8 port, u8 data) static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) { struct ppc_storage *ppc = (void *)(pi->private); - switch(ppc->mode) + switch (mode_map[pi->mode]) { case PPCMODE_UNI_SW : case PPCMODE_UNI_FW : @@ -531,7 +526,7 @@ static void ppc6_wait_for_fifo(struct pi_adapter *pi) static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) { struct ppc_storage *ppc = (void *)(pi->private); - switch(ppc->mode) + switch (mode_map[pi->mode]) { case PPCMODE_UNI_SW : case PPCMODE_BI_SW : From patchwork Tue Mar 7 22:46:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B5BDC74A44 for ; Tue, 7 Mar 2023 22:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229691AbjCGWrX (ORCPT ); Tue, 7 Mar 2023 17:47:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbjCGWrL (ORCPT ); Tue, 7 Mar 2023 17:47:11 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C3E47136DA; 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 CC22D7A06F6; Tue, 7 Mar 2023 23:46:48 +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 09/32] pata_parport-bpck6: remove struct ppc_storage Date: Tue, 7 Mar 2023 23:46:04 +0100 Message-Id: <20230307224627.28011-10-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Store the remaining two variables (cur_ctrl and ppc_flags) in struct ppc_storage directly in pi->private and remove struct ppc_storage. Signed-off-by: Ondrej Zary Reviewed-by: Sergey Shtylyov --- drivers/ata/pata_parport/bpck6.c | 21 ---- drivers/ata/pata_parport/ppc6lnx.c | 149 +++++++++++++---------------- 2 files changed, 69 insertions(+), 101 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index fe97d1dee51c..dc0f71cc305e 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -107,24 +106,6 @@ static void bpck6_log_adapter(struct pi_adapter *pi) pi->unit, pi->port, pi->mode, mode_string[pi->mode], pi->delay); } -static int bpck6_init_proto(struct pi_adapter *pi) -{ - struct ppc_storage *p = kzalloc(sizeof(struct ppc_storage), GFP_KERNEL); - - if (p) { - pi->private = (unsigned long)p; - return 0; - } - - dev_err(&pi->dev, "ERROR COULDN'T ALLOCATE MEMORY\n"); - return -1; -} - -static void bpck6_release_proto(struct pi_adapter *pi) -{ - kfree((void *)(pi->private)); -} - static struct pi_protocol bpck6 = { .owner = THIS_MODULE, .name = "bpck6", @@ -140,8 +121,6 @@ static struct pi_protocol bpck6 = { .test_port = bpck6_test_port, .probe_unit = bpck6_probe_unit, .log_adapter = bpck6_log_adapter, - .init_proto = bpck6_init_proto, - .release_proto = bpck6_release_proto, }; MODULE_LICENSE("GPL"); diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 75f9748d8de5..ee8cee6bae7c 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -64,10 +64,8 @@ //*************************************************************************** -struct ppc_storage { - u8 ppc_flags; - u8 cur_ctrl; // current control port contents -}; +#define CUR_CTRL (((u8 *)&pi->private)[0]) +#define PPC_FLAGS (((u8 *)&pi->private)[1]) //*************************************************************************** @@ -112,7 +110,6 @@ int mode_map[] = { PPCMODE_UNI_FW, PPCMODE_BI_FW, PPCMODE_EPP_BYTE, static int ppc6_select(struct pi_adapter *pi) { - struct ppc_storage *ppc = (void *)(pi->private); u8 i, j, k; i = inb(pi->port + 1); @@ -124,11 +121,11 @@ static int ppc6_select(struct pi_adapter *pi) pi->saved_r2 = inb(pi->port + 2) & 0x5F; // readback ctrl - ppc->cur_ctrl = pi->saved_r2; + CUR_CTRL = pi->saved_r2; - ppc->cur_ctrl |= port_sel; + CUR_CTRL |= port_sel; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); if (pi->saved_r0 == 'b') outb('x', pi->port); @@ -138,13 +135,13 @@ static int ppc6_select(struct pi_adapter *pi) outb(pi->unit, pi->port); outb(~pi->unit, pi->port); - ppc->cur_ctrl &= ~port_sel; + CUR_CTRL &= ~port_sel; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); - ppc->cur_ctrl = (ppc->cur_ctrl & port_int) | port_init; + CUR_CTRL = (CUR_CTRL & port_int) | port_init; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); i = mode_map[pi->mode] & 0x0C; @@ -153,15 +150,15 @@ static int ppc6_select(struct pi_adapter *pi) outb(i, pi->port); - ppc->cur_ctrl |= port_sel; + CUR_CTRL |= port_sel; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); // DELAY - ppc->cur_ctrl |= port_afd; + CUR_CTRL |= port_afd; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); j = ((i & 0x08) << 4) | ((i & 0x07) << 3); @@ -169,20 +166,20 @@ static int ppc6_select(struct pi_adapter *pi) if (j == k) { - ppc->cur_ctrl &= ~port_afd; + CUR_CTRL &= ~port_afd; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); k = (inb(pi->port + 1) & 0xB8) ^ 0xB8; if (j == k) { if (i & 4) // EPP - ppc->cur_ctrl &= ~(port_sel | port_init); + CUR_CTRL &= ~(port_sel | port_init); else // PPC/ECP - ppc->cur_ctrl &= ~port_sel; + CUR_CTRL &= ~port_sel; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); return(1); } @@ -199,13 +196,12 @@ static int ppc6_select(struct pi_adapter *pi) static void ppc6_deselect(struct pi_adapter *pi) { - struct ppc_storage *ppc = (void *)(pi->private); if (mode_map[pi->mode] & 4) // EPP - ppc->cur_ctrl |= port_init; + CUR_CTRL |= port_init; else // PPC/ECP - ppc->cur_ctrl |= port_sel; + CUR_CTRL |= port_sel; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); outb(pi->saved_r0, pi->port); @@ -218,7 +214,6 @@ static void ppc6_deselect(struct pi_adapter *pi) static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) { - struct ppc_storage *ppc = (void *)(pi->private); switch (mode_map[pi->mode]) { case PPCMODE_UNI_SW : @@ -228,9 +223,9 @@ static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) { outb(cmd, pi->port); - ppc->cur_ctrl ^= cmd_stb; + CUR_CTRL ^= cmd_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); break; } @@ -250,7 +245,6 @@ static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) { - struct ppc_storage *ppc = (void *)(pi->private); switch (mode_map[pi->mode]) { case PPCMODE_UNI_SW : @@ -260,9 +254,9 @@ static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) { outb(data, pi->port); - ppc->cur_ctrl ^= data_stb; + CUR_CTRL ^= data_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); break; } @@ -282,7 +276,6 @@ static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) static u8 ppc6_rd_data_byte(struct pi_adapter *pi) { - struct ppc_storage *ppc = (void *)(pi->private); u8 data = 0; switch (mode_map[pi->mode]) @@ -290,9 +283,9 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) case PPCMODE_UNI_SW : case PPCMODE_UNI_FW : { - ppc->cur_ctrl = (ppc->cur_ctrl & ~port_stb) ^ data_stb; + CUR_CTRL = (CUR_CTRL & ~port_stb) ^ data_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); // DELAY @@ -300,9 +293,9 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) data = ((data & 0x80) >> 1) | ((data & 0x38) >> 3); - ppc->cur_ctrl |= port_stb; + CUR_CTRL |= port_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); // DELAY @@ -314,23 +307,23 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) case PPCMODE_BI_SW : case PPCMODE_BI_FW : { - ppc->cur_ctrl |= port_dir; + CUR_CTRL |= port_dir; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); - ppc->cur_ctrl = (ppc->cur_ctrl | port_stb) ^ data_stb; + CUR_CTRL = (CUR_CTRL | port_stb) ^ data_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); data = inb(pi->port); - ppc->cur_ctrl &= ~port_stb; + CUR_CTRL &= ~port_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); - ppc->cur_ctrl &= ~port_dir; + CUR_CTRL &= ~port_dir; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); break; } @@ -339,11 +332,11 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) case PPCMODE_EPP_WORD : case PPCMODE_EPP_DWORD : { - outb((ppc->cur_ctrl | port_dir), pi->port + 2); + outb((CUR_CTRL | port_dir), pi->port + 2); data = inb(pi->port + 4); - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); break; } @@ -374,7 +367,6 @@ static void ppc6_wr_port(struct pi_adapter *pi, u8 port, u8 data) static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) { - struct ppc_storage *ppc = (void *)(pi->private); switch (mode_map[pi->mode]) { case PPCMODE_UNI_SW : @@ -384,9 +376,9 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) { u8 d; - ppc->cur_ctrl = (ppc->cur_ctrl & ~port_stb) ^ data_stb; + CUR_CTRL = (CUR_CTRL & ~port_stb) ^ data_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); // DELAY @@ -394,9 +386,9 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) d = ((d & 0x80) >> 1) | ((d & 0x38) >> 3); - ppc->cur_ctrl |= port_stb; + CUR_CTRL |= port_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); // DELAY @@ -412,36 +404,36 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) case PPCMODE_BI_SW : case PPCMODE_BI_FW : { - ppc->cur_ctrl |= port_dir; + CUR_CTRL |= port_dir; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); - ppc->cur_ctrl |= port_stb; + CUR_CTRL |= port_stb; while(count) { - ppc->cur_ctrl ^= data_stb; + CUR_CTRL ^= data_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); *data++ = inb(pi->port); count--; } - ppc->cur_ctrl &= ~port_stb; + CUR_CTRL &= ~port_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); - ppc->cur_ctrl &= ~port_dir; + CUR_CTRL &= ~port_dir; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); break; } case PPCMODE_EPP_BYTE : { - outb((ppc->cur_ctrl | port_dir), pi->port + 2); + outb((CUR_CTRL | port_dir), pi->port + 2); // DELAY @@ -451,14 +443,14 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) count--; } - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); break; } case PPCMODE_EPP_WORD : { - outb((ppc->cur_ctrl | port_dir), pi->port + 2); + outb((CUR_CTRL | port_dir), pi->port + 2); // DELAY @@ -475,14 +467,14 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) count--; } - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); break; } case PPCMODE_EPP_DWORD : { - outb((ppc->cur_ctrl | port_dir), pi->port + 2); + outb((CUR_CTRL | port_dir), pi->port + 2); // DELAY @@ -499,7 +491,7 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) count--; } - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); break; } @@ -511,10 +503,9 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) static void ppc6_wait_for_fifo(struct pi_adapter *pi) { - struct ppc_storage *ppc = (void *)(pi->private); int i; - if (ppc->ppc_flags & fifo_wait) + if (PPC_FLAGS & fifo_wait) { for(i=0; i<20; i++) inb(pi->port + 1); @@ -525,7 +516,6 @@ static void ppc6_wait_for_fifo(struct pi_adapter *pi) static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) { - struct ppc_storage *ppc = (void *)(pi->private); switch (mode_map[pi->mode]) { case PPCMODE_UNI_SW : @@ -535,9 +525,9 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) { outb(*data++, pi->port); - ppc->cur_ctrl ^= data_stb; + CUR_CTRL ^= data_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); } break; @@ -550,9 +540,9 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_FASTWR); - ppc->cur_ctrl |= port_stb; + CUR_CTRL |= port_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); last = *data; @@ -565,9 +555,9 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) if (this == last) { - ppc->cur_ctrl ^= data_stb; + CUR_CTRL ^= data_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); } else { @@ -577,9 +567,9 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) } } - ppc->cur_ctrl &= ~port_stb; + CUR_CTRL &= ~port_stb; - outb(ppc->cur_ctrl, pi->port + 2); + outb(CUR_CTRL, pi->port + 2); ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_FASTWR); @@ -694,7 +684,6 @@ static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata) static int ppc6_open(struct pi_adapter *pi) { - struct ppc_storage *ppc = (void *)(pi->private); int ret; ret = ppc6_select(pi); @@ -702,7 +691,7 @@ static int ppc6_open(struct pi_adapter *pi) if (ret == 0) return(ret); - ppc->ppc_flags &= ~fifo_wait; + PPC_FLAGS &= ~fifo_wait; ppc6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE); ppc6_wr_data_byte(pi, RAMSIZE_128K); @@ -710,7 +699,7 @@ static int ppc6_open(struct pi_adapter *pi) ppc6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); if ((ppc6_rd_data_byte(pi) & 0x3F) == 0x0C) - ppc->ppc_flags |= fifo_wait; + PPC_FLAGS |= fifo_wait; return(ret); } From patchwork Tue Mar 7 22:46:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09384C742A7 for ; Tue, 7 Mar 2023 22:47:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231252AbjCGWrP (ORCPT ); Tue, 7 Mar 2023 17:47:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbjCGWrH (ORCPT ); Tue, 7 Mar 2023 17:47:07 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4BC0A40D2; 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 E14E37A06F8; Tue, 7 Mar 2023 23:46:48 +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 10/32] pata_parport-bpck6: remove parallel port bit defines Date: Tue, 7 Mar 2023 23:46:05 +0100 Message-Id: <20230307224627.28011-11-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Remove port_stb, port_afd, cmd_stb, port_init, data_stb and port_sel defines and use standard PARPORT_CONTROL_* instead. Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/ppc6lnx.c | 59 ++++++++++++++---------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index ee8cee6bae7c..09480a7fcaee 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -16,12 +16,6 @@ //*************************************************************************** -#define port_stb 1 -#define port_afd 2 -#define cmd_stb port_afd -#define port_init 4 -#define data_stb port_init -#define port_sel 8 #define port_int 16 #define port_dir 0x20 @@ -123,7 +117,7 @@ static int ppc6_select(struct pi_adapter *pi) CUR_CTRL = pi->saved_r2; - CUR_CTRL |= port_sel; + CUR_CTRL |= PARPORT_CONTROL_SELECT; outb(CUR_CTRL, pi->port + 2); @@ -135,11 +129,11 @@ static int ppc6_select(struct pi_adapter *pi) outb(pi->unit, pi->port); outb(~pi->unit, pi->port); - CUR_CTRL &= ~port_sel; + CUR_CTRL &= ~PARPORT_CONTROL_SELECT; outb(CUR_CTRL, pi->port + 2); - CUR_CTRL = (CUR_CTRL & port_int) | port_init; + CUR_CTRL = (CUR_CTRL & port_int) | PARPORT_CONTROL_INIT; outb(CUR_CTRL, pi->port + 2); @@ -150,13 +144,13 @@ static int ppc6_select(struct pi_adapter *pi) outb(i, pi->port); - CUR_CTRL |= port_sel; + CUR_CTRL |= PARPORT_CONTROL_SELECT; outb(CUR_CTRL, pi->port + 2); // DELAY - CUR_CTRL |= port_afd; + CUR_CTRL |= PARPORT_CONTROL_AUTOFD; outb(CUR_CTRL, pi->port + 2); @@ -166,7 +160,7 @@ static int ppc6_select(struct pi_adapter *pi) if (j == k) { - CUR_CTRL &= ~port_afd; + CUR_CTRL &= ~PARPORT_CONTROL_AUTOFD; outb(CUR_CTRL, pi->port + 2); @@ -175,9 +169,9 @@ static int ppc6_select(struct pi_adapter *pi) if (j == k) { if (i & 4) // EPP - CUR_CTRL &= ~(port_sel | port_init); + CUR_CTRL &= ~(PARPORT_CONTROL_SELECT | PARPORT_CONTROL_INIT); else // PPC/ECP - CUR_CTRL &= ~port_sel; + CUR_CTRL &= ~PARPORT_CONTROL_SELECT; outb(CUR_CTRL, pi->port + 2); @@ -197,15 +191,15 @@ static int ppc6_select(struct pi_adapter *pi) static void ppc6_deselect(struct pi_adapter *pi) { if (mode_map[pi->mode] & 4) // EPP - CUR_CTRL |= port_init; + CUR_CTRL |= PARPORT_CONTROL_INIT; else // PPC/ECP - CUR_CTRL |= port_sel; + CUR_CTRL |= PARPORT_CONTROL_SELECT; outb(CUR_CTRL, pi->port + 2); outb(pi->saved_r0, pi->port); - outb((pi->saved_r2 | port_sel), pi->port + 2); + outb((pi->saved_r2 | PARPORT_CONTROL_SELECT), pi->port + 2); outb(pi->saved_r2, pi->port + 2); } @@ -223,7 +217,7 @@ static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) { outb(cmd, pi->port); - CUR_CTRL ^= cmd_stb; + CUR_CTRL ^= PARPORT_CONTROL_AUTOFD; outb(CUR_CTRL, pi->port + 2); @@ -254,7 +248,7 @@ static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) { outb(data, pi->port); - CUR_CTRL ^= data_stb; + CUR_CTRL ^= PARPORT_CONTROL_INIT; outb(CUR_CTRL, pi->port + 2); @@ -283,7 +277,7 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) case PPCMODE_UNI_SW : case PPCMODE_UNI_FW : { - CUR_CTRL = (CUR_CTRL & ~port_stb) ^ data_stb; + CUR_CTRL = (CUR_CTRL & ~PARPORT_CONTROL_STROBE) ^ PARPORT_CONTROL_INIT; outb(CUR_CTRL, pi->port + 2); @@ -293,7 +287,7 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) data = ((data & 0x80) >> 1) | ((data & 0x38) >> 3); - CUR_CTRL |= port_stb; + CUR_CTRL |= PARPORT_CONTROL_STROBE; outb(CUR_CTRL, pi->port + 2); @@ -311,13 +305,13 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) outb(CUR_CTRL, pi->port + 2); - CUR_CTRL = (CUR_CTRL | port_stb) ^ data_stb; + CUR_CTRL = (CUR_CTRL | PARPORT_CONTROL_STROBE) ^ PARPORT_CONTROL_INIT; outb(CUR_CTRL, pi->port + 2); data = inb(pi->port); - CUR_CTRL &= ~port_stb; + CUR_CTRL &= ~PARPORT_CONTROL_STROBE; outb(CUR_CTRL, pi->port + 2); @@ -376,7 +370,8 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) { u8 d; - CUR_CTRL = (CUR_CTRL & ~port_stb) ^ data_stb; + CUR_CTRL = (CUR_CTRL & ~PARPORT_CONTROL_STROBE) + ^ PARPORT_CONTROL_INIT; outb(CUR_CTRL, pi->port + 2); @@ -386,7 +381,7 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) d = ((d & 0x80) >> 1) | ((d & 0x38) >> 3); - CUR_CTRL |= port_stb; + CUR_CTRL |= PARPORT_CONTROL_STROBE; outb(CUR_CTRL, pi->port + 2); @@ -408,11 +403,11 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) outb(CUR_CTRL, pi->port + 2); - CUR_CTRL |= port_stb; + CUR_CTRL |= PARPORT_CONTROL_STROBE; while(count) { - CUR_CTRL ^= data_stb; + CUR_CTRL ^= PARPORT_CONTROL_INIT; outb(CUR_CTRL, pi->port + 2); @@ -420,7 +415,7 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) count--; } - CUR_CTRL &= ~port_stb; + CUR_CTRL &= ~PARPORT_CONTROL_STROBE; outb(CUR_CTRL, pi->port + 2); @@ -525,7 +520,7 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) { outb(*data++, pi->port); - CUR_CTRL ^= data_stb; + CUR_CTRL ^= PARPORT_CONTROL_INIT; outb(CUR_CTRL, pi->port + 2); } @@ -540,7 +535,7 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_FASTWR); - CUR_CTRL |= port_stb; + CUR_CTRL |= PARPORT_CONTROL_STROBE; outb(CUR_CTRL, pi->port + 2); @@ -555,7 +550,7 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) if (this == last) { - CUR_CTRL ^= data_stb; + CUR_CTRL ^= PARPORT_CONTROL_INIT; outb(CUR_CTRL, pi->port + 2); } @@ -567,7 +562,7 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) } } - CUR_CTRL &= ~port_stb; + CUR_CTRL &= ~PARPORT_CONTROL_STROBE; outb(CUR_CTRL, pi->port + 2); From patchwork Tue Mar 7 22:46:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164892 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 972CCC6FD1E for ; Tue, 7 Mar 2023 22:47:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231250AbjCGWrO (ORCPT ); Tue, 7 Mar 2023 17:47:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230232AbjCGWrH (ORCPT ); Tue, 7 Mar 2023 17:47:07 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6842A7288; 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 09CF57A06FE; 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 11/32] parport_pc: add 16-bit and 8-bit fast EPP transfer flags Date: Tue, 7 Mar 2023 23:46:06 +0100 Message-Id: <20230307224627.28011-12-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org PARPORT_EPP_FAST flag currently uses 32-bit I/O port access for data read/write (insl/outsl). Add PARPORT_EPP_FAST_16 and PARPORT_EPP_FAST_8 that use insw/outsw and insb/outsb (and PARPORT_EPP_FAST_32 as alias for PARPORT_EPP_FAST). Signed-off-by: Ondrej Zary --- drivers/parport/parport_pc.c | 20 ++++++++++++++++---- include/uapi/linux/parport.h | 3 +++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c index 5784dc20fb38..eda4e4e6d4e8 100644 --- a/drivers/parport/parport_pc.c +++ b/drivers/parport/parport_pc.c @@ -298,9 +298,15 @@ static size_t parport_pc_epp_read_data(struct parport *port, void *buf, } return got; } - if ((flags & PARPORT_EPP_FAST) && (length > 1)) { - if (!(((long)buf | length) & 0x03)) + if ((length > 1) && ((flags & PARPORT_EPP_FAST_32) + || flags & PARPORT_EPP_FAST_16 + || flags & PARPORT_EPP_FAST_8)) { + if ((flags & PARPORT_EPP_FAST_32) + && !(((long)buf | length) & 0x03)) insl(EPPDATA(port), buf, (length >> 2)); + else if ((flags & PARPORT_EPP_FAST_16) + && !(((long)buf | length) & 0x01)) + insw(EPPDATA(port), buf, length >> 1); else insb(EPPDATA(port), buf, length); if (inb(STATUS(port)) & 0x01) { @@ -327,9 +333,15 @@ static size_t parport_pc_epp_write_data(struct parport *port, const void *buf, { size_t written = 0; - if ((flags & PARPORT_EPP_FAST) && (length > 1)) { - if (!(((long)buf | length) & 0x03)) + if ((length > 1) && ((flags & PARPORT_EPP_FAST_32) + || flags & PARPORT_EPP_FAST_16 + || flags & PARPORT_EPP_FAST_8)) { + if ((flags & PARPORT_EPP_FAST_32) + && !(((long)buf | length) & 0x03)) outsl(EPPDATA(port), buf, (length >> 2)); + else if ((flags & PARPORT_EPP_FAST_16) + && !(((long)buf | length) & 0x01)) + outsw(EPPDATA(port), buf, length >> 1); else outsb(EPPDATA(port), buf, length); if (inb(STATUS(port)) & 0x01) { diff --git a/include/uapi/linux/parport.h b/include/uapi/linux/parport.h index f41388f88dc3..fe93e41fc205 100644 --- a/include/uapi/linux/parport.h +++ b/include/uapi/linux/parport.h @@ -90,6 +90,9 @@ typedef enum { /* Flags for block transfer operations. */ #define PARPORT_EPP_FAST (1<<0) /* Unreliable counts. */ #define PARPORT_W91284PIC (1<<1) /* have a Warp9 w91284pic in the device */ +#define PARPORT_EPP_FAST_32 PARPORT_EPP_FAST /* 32-bit EPP transfers */ +#define PARPORT_EPP_FAST_16 (1<<2) /* 16-bit EPP transfers */ +#define PARPORT_EPP_FAST_8 (1<<3) /* 8-bit EPP transfers */ /* The rest is for the kernel only */ #endif /* _UAPI_PARPORT_H_ */ 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: 13164894 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02B07C6FA99 for ; Tue, 7 Mar 2023 22:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbjCGWrR (ORCPT ); Tue, 7 Mar 2023 17:47:17 -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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org 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); From patchwork Tue Mar 7 22:46:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164896 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73984C6FD1E for ; Tue, 7 Mar 2023 22:47:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231407AbjCGWrS (ORCPT ); Tue, 7 Mar 2023 17:47:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230355AbjCGWrH (ORCPT ); Tue, 7 Mar 2023 17:47:07 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D0DA315C91; Tue, 7 Mar 2023 14:47:02 -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 409EE7A0709; 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 13/32] pata_parport-bpck6: use parport_frob_control and remove CUR_CTRL Date: Tue, 7 Mar 2023 23:46:08 +0100 Message-Id: <20230307224627.28011-14-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Use parport_frob_control instead of manually maintaining control register state. Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/ppc6lnx.c | 120 +++++++++-------------------- 1 file changed, 36 insertions(+), 84 deletions(-) diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 89c40d6ab036..fdc11875bf1b 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -15,14 +15,6 @@ //*************************************************************************** - -#define port_int 16 - -#define ECR_EPP 0x80 -#define ECR_BI 0x20 - -//*************************************************************************** - // 60772 Commands #define ACCESS_REG 0x00 @@ -57,7 +49,6 @@ //*************************************************************************** -#define CUR_CTRL (((u8 *)&pi->private)[0]) #define PPC_FLAGS (((u8 *)&pi->private)[1]) //*************************************************************************** @@ -109,11 +100,7 @@ static int ppc6_select(struct pi_adapter *pi) pi->saved_r2 = parport_read_control(pi->pardev->port) & 0x5F; // readback ctrl - CUR_CTRL = pi->saved_r2; - - CUR_CTRL |= PARPORT_CONTROL_SELECT; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, PARPORT_CONTROL_SELECT); if (pi->saved_r0 == 'b') parport_write_data(pi->pardev->port, 'x'); @@ -123,13 +110,9 @@ static int ppc6_select(struct pi_adapter *pi) parport_write_data(pi->pardev->port, pi->unit); parport_write_data(pi->pardev->port, ~pi->unit); - CUR_CTRL &= ~PARPORT_CONTROL_SELECT; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, 0); - CUR_CTRL = (CUR_CTRL & port_int) | PARPORT_CONTROL_INIT; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_write_control(pi->pardev->port, PARPORT_CONTROL_INIT); i = mode_map[pi->mode] & 0x0C; @@ -138,15 +121,11 @@ static int ppc6_select(struct pi_adapter *pi) parport_write_data(pi->pardev->port, i); - CUR_CTRL |= PARPORT_CONTROL_SELECT; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, PARPORT_CONTROL_SELECT); // DELAY - CUR_CTRL |= PARPORT_CONTROL_AUTOFD; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_AUTOFD, PARPORT_CONTROL_AUTOFD); j = ((i & 0x08) << 4) | ((i & 0x07) << 3); @@ -154,20 +133,18 @@ static int ppc6_select(struct pi_adapter *pi) if (j == k) { - CUR_CTRL &= ~PARPORT_CONTROL_AUTOFD; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_AUTOFD, 0); k = (parport_read_status(pi->pardev->port) & 0xB8) ^ 0xB8; if (j == k) { if (i & 4) // EPP - CUR_CTRL &= ~(PARPORT_CONTROL_SELECT | PARPORT_CONTROL_INIT); + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_SELECT | PARPORT_CONTROL_INIT, 0); else // PPC/ECP - CUR_CTRL &= ~PARPORT_CONTROL_SELECT; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_SELECT, 0); return(1); } @@ -185,11 +162,11 @@ static int ppc6_select(struct pi_adapter *pi) static void ppc6_deselect(struct pi_adapter *pi) { if (mode_map[pi->mode] & 4) // EPP - CUR_CTRL |= PARPORT_CONTROL_INIT; + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_INIT, PARPORT_CONTROL_INIT); else // PPC/ECP - CUR_CTRL |= PARPORT_CONTROL_SELECT; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_SELECT, PARPORT_CONTROL_SELECT); parport_write_data(pi->pardev->port, pi->saved_r0); @@ -210,10 +187,7 @@ static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) case PPCMODE_BI_FW : { parport_write_data(pi->pardev->port, cmd); - - CUR_CTRL ^= PARPORT_CONTROL_AUTOFD; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, 0, PARPORT_CONTROL_AUTOFD); break; } @@ -241,10 +215,7 @@ static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) case PPCMODE_BI_FW : { parport_write_data(pi->pardev->port, data); - - CUR_CTRL ^= PARPORT_CONTROL_INIT; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, 0, PARPORT_CONTROL_INIT); break; } @@ -271,9 +242,8 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) case PPCMODE_UNI_SW : case PPCMODE_UNI_FW : { - CUR_CTRL = (CUR_CTRL & ~PARPORT_CONTROL_STROBE) ^ PARPORT_CONTROL_INIT; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_STROBE, PARPORT_CONTROL_INIT); // DELAY @@ -281,9 +251,8 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) data = ((data & 0x80) >> 1) | ((data & 0x38) >> 3); - CUR_CTRL |= PARPORT_CONTROL_STROBE; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_STROBE, PARPORT_CONTROL_STROBE); // DELAY @@ -297,15 +266,12 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) { parport_data_reverse(pi->pardev->port); - CUR_CTRL = (CUR_CTRL | PARPORT_CONTROL_STROBE) ^ PARPORT_CONTROL_INIT; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_STROBE | PARPORT_CONTROL_INIT); data = parport_read_data(pi->pardev->port); - CUR_CTRL &= ~PARPORT_CONTROL_STROBE; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, 0); parport_data_forward(pi->pardev->port); @@ -356,10 +322,8 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) { u8 d; - CUR_CTRL = (CUR_CTRL & ~PARPORT_CONTROL_STROBE) - ^ PARPORT_CONTROL_INIT; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_STROBE, PARPORT_CONTROL_INIT); // DELAY @@ -367,9 +331,8 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) d = ((d & 0x80) >> 1) | ((d & 0x38) >> 3); - CUR_CTRL |= PARPORT_CONTROL_STROBE; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_STROBE, PARPORT_CONTROL_STROBE); // DELAY @@ -387,21 +350,16 @@ static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) { parport_data_reverse(pi->pardev->port); - CUR_CTRL |= PARPORT_CONTROL_STROBE; - while(count) { - CUR_CTRL ^= PARPORT_CONTROL_INIT; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_STROBE | PARPORT_CONTROL_INIT); *data++ = parport_read_data(pi->pardev->port); count--; } - CUR_CTRL &= ~PARPORT_CONTROL_STROBE; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, 0); parport_data_forward(pi->pardev->port); @@ -467,9 +425,7 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) { parport_write_data(pi->pardev->port, *data++); - CUR_CTRL ^= PARPORT_CONTROL_INIT; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, 0, PARPORT_CONTROL_INIT); } break; @@ -482,9 +438,8 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_FASTWR); - CUR_CTRL |= PARPORT_CONTROL_STROBE; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_STROBE, PARPORT_CONTROL_STROBE); last = *data; @@ -497,9 +452,8 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) if (this == last) { - CUR_CTRL ^= PARPORT_CONTROL_INIT; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, + 0, PARPORT_CONTROL_INIT); } else { @@ -509,9 +463,7 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) } } - CUR_CTRL &= ~PARPORT_CONTROL_STROBE; - - parport_write_control(pi->pardev->port, CUR_CTRL); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, 0); ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_FASTWR); From patchwork Tue Mar 7 22:46:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C11DC678D5 for ; Tue, 7 Mar 2023 22:47:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231499AbjCGWrS (ORCPT ); Tue, 7 Mar 2023 17:47:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbjCGWrK (ORCPT ); Tue, 7 Mar 2023 17:47:10 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EEEED43928; Tue, 7 Mar 2023 14:47:02 -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 503E87A071B; 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 14/32] pata_parport-bpck6: remove PPC_FLAGS Date: Tue, 7 Mar 2023 23:46:09 +0100 Message-Id: <20230307224627.28011-15-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org pi->private is now not used for any other purpose, so store wait_fifo flag directly there and remove PPC_FLAGS define. Signed-off-by: Ondrej Zary Reviewed-by: Sergey Shtylyov --- drivers/ata/pata_parport/ppc6lnx.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index fdc11875bf1b..9a166f396112 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -49,10 +49,6 @@ //*************************************************************************** -#define PPC_FLAGS (((u8 *)&pi->private)[1]) - -//*************************************************************************** - // ppc_flags #define fifo_wait 0x10 @@ -405,7 +401,7 @@ static void ppc6_wait_for_fifo(struct pi_adapter *pi) { int i; - if (PPC_FLAGS & fifo_wait) + if (pi->private & fifo_wait) { for(i=0; i<20; i++) parport_read_status(pi->pardev->port); @@ -562,7 +558,7 @@ static int ppc6_open(struct pi_adapter *pi) if (ret == 0) return(ret); - PPC_FLAGS &= ~fifo_wait; + pi->private = 0; ppc6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE); ppc6_wr_data_byte(pi, RAMSIZE_128K); @@ -570,7 +566,7 @@ static int ppc6_open(struct pi_adapter *pi) ppc6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); if ((ppc6_rd_data_byte(pi) & 0x3F) == 0x0C) - PPC_FLAGS |= fifo_wait; + pi->private |= fifo_wait; return(ret); } From patchwork Tue Mar 7 22:46:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EF05C6FA99 for ; Tue, 7 Mar 2023 22:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231620AbjCGWrV (ORCPT ); Tue, 7 Mar 2023 17:47:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbjCGWrK (ORCPT ); Tue, 7 Mar 2023 17:47:10 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E823A4FAA7; Tue, 7 Mar 2023 14:47:04 -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 65F1C7A071E; 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 15/32] pata_parport-bpck6: remove ppc6_close Date: Tue, 7 Mar 2023 23:46:10 +0100 Message-Id: <20230307224627.28011-16-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org ppc6_close does not do anything except calling ppc6_deselect. Remove ppc6_close and call ppc6_deselect directly. Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 4 ++-- drivers/ata/pata_parport/ppc6lnx.c | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 39ac6e1a0aee..b8135a6eed16 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -51,7 +51,7 @@ static void bpck6_disconnect(struct pi_adapter *pi) { dev_dbg(&pi->dev, "disconnect\n"); ppc6_wr_extout(pi, 0x0); - ppc6_close(pi); + ppc6_deselect(pi); } static int bpck6_test_port(struct pi_adapter *pi) /* check for 8-bit port */ @@ -83,7 +83,7 @@ static int bpck6_probe_unit(struct pi_adapter *pi) if(out) { - ppc6_close(pi); + ppc6_deselect(pi); dev_dbg(&pi->dev, "leaving probe\n"); pi->mode = saved_mode; return(1); diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 9a166f396112..5b7796083e7e 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -81,7 +81,6 @@ static void ppc6_rd_port16_blk(struct pi_adapter *pi, u8 port, u8 *data, long le static void ppc6_wr_port16_blk(struct pi_adapter *pi, u8 port, u8 *data, long length); static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata); static int ppc6_open(struct pi_adapter *pi); -static void ppc6_close(struct pi_adapter *pi); //*************************************************************************** @@ -573,10 +572,3 @@ static int ppc6_open(struct pi_adapter *pi) //*************************************************************************** -static void ppc6_close(struct pi_adapter *pi) -{ - ppc6_deselect(pi); -} - -//*************************************************************************** - From patchwork Tue Mar 7 22:46:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164898 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0879CC74A4B for ; Tue, 7 Mar 2023 22:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230420AbjCGWrU (ORCPT ); Tue, 7 Mar 2023 17:47:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230044AbjCGWrK (ORCPT ); Tue, 7 Mar 2023 17:47:10 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8CA5A838AD; Tue, 7 Mar 2023 14:47:04 -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 834BD7A0728; 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 16/32] pata_parport-bpck6: merge ppc6_rd_port into bpck6_read_regr Date: Tue, 7 Mar 2023 23:46:11 +0100 Message-Id: <20230307224627.28011-17-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org ppc6_rd_port is only called by bpck6_read_regr. Merge ppc6_rd_port into bpck6_read_regr. Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 5 ++++- drivers/ata/pata_parport/ppc6lnx.c | 10 ---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index b8135a6eed16..2918fc9e9def 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -21,7 +21,10 @@ static int bpck6_read_regr(struct pi_adapter *pi, int cont, int reg) { - return ppc6_rd_port(pi, cont?reg|8:reg); + u8 port = cont ? reg | 8 : reg; + + ppc6_send_cmd(pi, port | ACCESS_PORT | ACCESS_READ); + return ppc6_rd_data_byte(pi); } static void bpck6_write_regr(struct pi_adapter *pi, int cont, int reg, int val) diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 5b7796083e7e..23dce177b722 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -72,7 +72,6 @@ static void ppc6_deselect(struct pi_adapter *pi); static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd); static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data); static u8 ppc6_rd_data_byte(struct pi_adapter *pi); -static u8 ppc6_rd_port(struct pi_adapter *pi, u8 port); static void ppc6_wr_port(struct pi_adapter *pi, u8 port, u8 data); static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count); static void ppc6_wait_for_fifo(struct pi_adapter *pi); @@ -288,15 +287,6 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) //*************************************************************************** -static u8 ppc6_rd_port(struct pi_adapter *pi, u8 port) -{ - ppc6_send_cmd(pi, port | ACCESS_PORT | ACCESS_READ); - - return ppc6_rd_data_byte(pi); -} - -//*************************************************************************** - static void ppc6_wr_port(struct pi_adapter *pi, u8 port, u8 data) { ppc6_send_cmd(pi, port | ACCESS_PORT | ACCESS_WRITE); From patchwork Tue Mar 7 22:46:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164902 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CD21C74A44 for ; Tue, 7 Mar 2023 22:47:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231223AbjCGWr0 (ORCPT ); Tue, 7 Mar 2023 17:47:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230177AbjCGWrM (ORCPT ); Tue, 7 Mar 2023 17:47:12 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 813FD166D6; Tue, 7 Mar 2023 14:47:05 -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 ABC9A7A0731; 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 17/32] pata_parport-bpck6: merge ppc6_wr_port into bpck6_write_regr Date: Tue, 7 Mar 2023 23:46:12 +0100 Message-Id: <20230307224627.28011-18-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org ppc6_wr_port is only called by bpck6_write_regr. Merge ppc6_wr_port into bpck6_write_regr. Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 5 ++++- drivers/ata/pata_parport/ppc6lnx.c | 10 ---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 2918fc9e9def..8e0094e3b02b 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -29,7 +29,10 @@ static int bpck6_read_regr(struct pi_adapter *pi, int cont, int reg) static void bpck6_write_regr(struct pi_adapter *pi, int cont, int reg, int val) { - ppc6_wr_port(pi, cont?reg|8:reg, val); + u8 port = cont ? reg | 8 : reg; + + ppc6_send_cmd(pi, port | ACCESS_PORT | ACCESS_WRITE); + ppc6_wr_data_byte(pi, val); } static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 23dce177b722..35427742e4d3 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -72,7 +72,6 @@ static void ppc6_deselect(struct pi_adapter *pi); static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd); static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data); static u8 ppc6_rd_data_byte(struct pi_adapter *pi); -static void ppc6_wr_port(struct pi_adapter *pi, u8 port, u8 data); static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count); static void ppc6_wait_for_fifo(struct pi_adapter *pi); static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count); @@ -287,15 +286,6 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) //*************************************************************************** -static void ppc6_wr_port(struct pi_adapter *pi, u8 port, u8 data) -{ - ppc6_send_cmd(pi, port | ACCESS_PORT | ACCESS_WRITE); - - ppc6_wr_data_byte(pi, data); -} - -//*************************************************************************** - static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) { switch (mode_map[pi->mode]) From patchwork Tue Mar 7 22:46:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 953EBC6FD1E for ; Tue, 7 Mar 2023 22:47:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229904AbjCGWrd (ORCPT ); Tue, 7 Mar 2023 17:47:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231232AbjCGWrN (ORCPT ); Tue, 7 Mar 2023 17:47:13 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 827CA1EBC3; Tue, 7 Mar 2023 14:47:06 -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 D24B77A073E; 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 18/32] pata_parport-bpck6: merge ppc6_rd_port16_blk into bpck6_read_block Date: Tue, 7 Mar 2023 23:46:13 +0100 Message-Id: <20230307224627.28011-19-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org ppc6_rd_port16_blk is only called by bpck6_read_block. Merge ppc6_rd_port16_blk into bpck6_read_block. Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 10 +++++++++- drivers/ata/pata_parport/ppc6lnx.c | 21 --------------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 8e0094e3b02b..aaf6737891a5 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -42,7 +42,15 @@ static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) { - ppc6_rd_port16_blk(pi, ATA_REG_DATA, buf, (u32)len>>1); + ppc6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); + ppc6_wr_data_byte(pi, (u8)len); + ppc6_wr_data_byte(pi, (u8)(len >> 8)); + ppc6_wr_data_byte(pi, 0); + + ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); + ppc6_send_cmd(pi, ATA_REG_DATA | ACCESS_PORT | ACCESS_READ); + ppc6_rd_data_blk(pi, buf, len); + ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); } static void bpck6_connect(struct pi_adapter *pi) diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 35427742e4d3..ac336ce1695b 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -75,7 +75,6 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi); static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count); static void ppc6_wait_for_fifo(struct pi_adapter *pi); static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count); -static void ppc6_rd_port16_blk(struct pi_adapter *pi, u8 port, u8 *data, long length); static void ppc6_wr_port16_blk(struct pi_adapter *pi, u8 port, u8 *data, long length); static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata); static int ppc6_open(struct pi_adapter *pi); @@ -479,26 +478,6 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) //*************************************************************************** -static void ppc6_rd_port16_blk(struct pi_adapter *pi, u8 port, u8 *data, long length) -{ - length = length << 1; - - ppc6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); - ppc6_wr_data_byte(pi, (u8)length); - ppc6_wr_data_byte(pi, (u8)(length >> 8)); - ppc6_wr_data_byte(pi, 0); - - ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); - - ppc6_send_cmd(pi, port | ACCESS_PORT | ACCESS_READ); - - ppc6_rd_data_blk(pi, data, length); - - ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); -} - -//*************************************************************************** - static void ppc6_wr_port16_blk(struct pi_adapter *pi, u8 port, u8 *data, long length) { length = length << 1; From patchwork Tue Mar 7 22:46:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FC21C6FA99 for ; Tue, 7 Mar 2023 22:48:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231575AbjCGWsG (ORCPT ); Tue, 7 Mar 2023 17:48:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231546AbjCGWrV (ORCPT ); Tue, 7 Mar 2023 17:47:21 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E73FC9DE1A; Tue, 7 Mar 2023 14:47:07 -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 E109A7A0741; 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 19/32] pata_parport-bpck6: merge ppc6_wr_port16_blk into bpck6_write_block Date: Tue, 7 Mar 2023 23:46:14 +0100 Message-Id: <20230307224627.28011-20-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org ppc6_wr_port16_blk is only called by bpck6_write_block. Merge ppc6_wr_port16_blk into bpck6_write_block. Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 10 +++++++++- drivers/ata/pata_parport/ppc6lnx.c | 21 --------------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index aaf6737891a5..1c04fcaba74a 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -37,7 +37,15 @@ static void bpck6_write_regr(struct pi_adapter *pi, int cont, int reg, int val) static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) { - ppc6_wr_port16_blk(pi, ATA_REG_DATA, buf, (u32)len>>1); + ppc6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); + ppc6_wr_data_byte(pi, (u8)len); + ppc6_wr_data_byte(pi, (u8)(len >> 8)); + ppc6_wr_data_byte(pi, 0); + + ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); + ppc6_send_cmd(pi, ATA_REG_DATA | ACCESS_PORT | ACCESS_WRITE); + ppc6_wr_data_blk(pi, buf, len); + ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); } static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index ac336ce1695b..d275de3f1ead 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -75,7 +75,6 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi); static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count); static void ppc6_wait_for_fifo(struct pi_adapter *pi); static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count); -static void ppc6_wr_port16_blk(struct pi_adapter *pi, u8 port, u8 *data, long length); static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata); static int ppc6_open(struct pi_adapter *pi); @@ -478,26 +477,6 @@ static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) //*************************************************************************** -static void ppc6_wr_port16_blk(struct pi_adapter *pi, u8 port, u8 *data, long length) -{ - length = length << 1; - - ppc6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); - ppc6_wr_data_byte(pi, (u8)length); - ppc6_wr_data_byte(pi, (u8)(length >> 8)); - ppc6_wr_data_byte(pi, 0); - - ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); - - ppc6_send_cmd(pi, port | ACCESS_PORT | ACCESS_WRITE); - - ppc6_wr_data_blk(pi, data, length); - - ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); -} - -//*************************************************************************** - static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata) { ppc6_send_cmd(pi, REG_VERSION | ACCESS_REG | ACCESS_WRITE); From patchwork Tue Mar 7 22:46:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164904 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58F02C742A7 for ; Tue, 7 Mar 2023 22:48:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231820AbjCGWsH (ORCPT ); Tue, 7 Mar 2023 17:48:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231555AbjCGWrV (ORCPT ); Tue, 7 Mar 2023 17:47:21 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8426B9CBE4; Tue, 7 Mar 2023 14:47:07 -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 F351D7A0742; 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 20/32] pata_parport-bpck6: merge ppc6_rd_data_blk into bpck6_read_block Date: Tue, 7 Mar 2023 23:46:15 +0100 Message-Id: <20230307224627.28011-21-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org ppc6_rd_data_blk is only called by bpck6_read_block. Merge ppc6_rd_data_blk into bpck6_read_block. Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 49 +++++++++++++++- drivers/ata/pata_parport/ppc6lnx.c | 91 ------------------------------ 2 files changed, 48 insertions(+), 92 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 1c04fcaba74a..d379603424ff 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -57,7 +57,54 @@ static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); ppc6_send_cmd(pi, ATA_REG_DATA | ACCESS_PORT | ACCESS_READ); - ppc6_rd_data_blk(pi, buf, len); + + switch (mode_map[pi->mode]) { + case PPCMODE_UNI_SW: + case PPCMODE_UNI_FW: + while (len) { + u8 d; + + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_INIT); /* DATA STROBE */ + d = parport_read_status(pi->pardev->port); + d = ((d & 0x80) >> 1) | ((d & 0x38) >> 3); + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_STROBE); + d |= parport_read_status(pi->pardev->port) & 0xB8; + *buf++ = d; + len--; + } + break; + case PPCMODE_BI_SW: + case PPCMODE_BI_FW: + parport_data_reverse(pi->pardev->port); + while (len) { + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_STROBE | PARPORT_CONTROL_INIT); + *buf++ = parport_read_data(pi->pardev->port); + len--; + } + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + 0); + parport_data_forward(pi->pardev->port); + break; + case PPCMODE_EPP_BYTE: + pi->pardev->port->ops->epp_read_data(pi->pardev->port, buf, len, + PARPORT_EPP_FAST_8); + break; + case PPCMODE_EPP_WORD: + pi->pardev->port->ops->epp_read_data(pi->pardev->port, buf, len, + PARPORT_EPP_FAST_16); + break; + case PPCMODE_EPP_DWORD: + pi->pardev->port->ops->epp_read_data(pi->pardev->port, buf, len, + PARPORT_EPP_FAST_32); + break; + } + ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); } diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index d275de3f1ead..679261e19ac5 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -72,7 +72,6 @@ static void ppc6_deselect(struct pi_adapter *pi); static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd); static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data); static u8 ppc6_rd_data_byte(struct pi_adapter *pi); -static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count); static void ppc6_wait_for_fifo(struct pi_adapter *pi); static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count); static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata); @@ -284,96 +283,6 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) //*************************************************************************** -static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count) -{ - switch (mode_map[pi->mode]) - { - case PPCMODE_UNI_SW : - case PPCMODE_UNI_FW : - { - while(count) - { - u8 d; - - parport_frob_control(pi->pardev->port, - PARPORT_CONTROL_STROBE, PARPORT_CONTROL_INIT); - - // DELAY - - d = parport_read_status(pi->pardev->port); - - d = ((d & 0x80) >> 1) | ((d & 0x38) >> 3); - - parport_frob_control(pi->pardev->port, - PARPORT_CONTROL_STROBE, PARPORT_CONTROL_STROBE); - - // DELAY - - d |= parport_read_status(pi->pardev->port) & 0xB8; - - *data++ = d; - count--; - } - - break; - } - - case PPCMODE_BI_SW : - case PPCMODE_BI_FW : - { - parport_data_reverse(pi->pardev->port); - - while(count) - { - parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, - PARPORT_CONTROL_STROBE | PARPORT_CONTROL_INIT); - - *data++ = parport_read_data(pi->pardev->port); - count--; - } - - parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, 0); - - parport_data_forward(pi->pardev->port); - - break; - } - - case PPCMODE_EPP_BYTE : - { - // DELAY - - pi->pardev->port->ops->epp_read_data(pi->pardev->port, - data, count, PARPORT_EPP_FAST_8); - - break; - } - - case PPCMODE_EPP_WORD : - { - // DELAY - - pi->pardev->port->ops->epp_read_data(pi->pardev->port, - data, count, PARPORT_EPP_FAST_16); - - break; - } - - case PPCMODE_EPP_DWORD : - { - // DELAY - - pi->pardev->port->ops->epp_read_data(pi->pardev->port, - data, count, PARPORT_EPP_FAST_32); - - break; - } - } - -} - -//*************************************************************************** - static void ppc6_wait_for_fifo(struct pi_adapter *pi) { int i; From patchwork Tue Mar 7 22:46:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89011C6FA99 for ; Tue, 7 Mar 2023 22:48:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231372AbjCGWsb (ORCPT ); Tue, 7 Mar 2023 17:48:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbjCGWr0 (ORCPT ); Tue, 7 Mar 2023 17:47:26 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D914C59D9; Tue, 7 Mar 2023 14:47:07 -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 143267A0749; Tue, 7 Mar 2023 23:46:50 +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 21/32] pata_parport-bpck6: merge ppc6_wr_data_blk into bpck6_write_block Date: Tue, 7 Mar 2023 23:46:16 +0100 Message-Id: <20230307224627.28011-22-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org ppc6_wr_data_blk is only called by bpck6_write_block. Merge ppc6_wr_data_blk into bpck6_write_block. Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 58 ++++++++++++++++++- drivers/ata/pata_parport/ppc6lnx.c | 91 ------------------------------ 2 files changed, 57 insertions(+), 92 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index d379603424ff..27c1fa3bb336 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -37,6 +37,8 @@ static void bpck6_write_regr(struct pi_adapter *pi, int cont, int reg, int val) static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) { + u8 this, last; + ppc6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); ppc6_wr_data_byte(pi, (u8)len); ppc6_wr_data_byte(pi, (u8)(len >> 8)); @@ -44,7 +46,61 @@ static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); ppc6_send_cmd(pi, ATA_REG_DATA | ACCESS_PORT | ACCESS_WRITE); - ppc6_wr_data_blk(pi, buf, len); + + switch (mode_map[pi->mode]) { + case PPCMODE_UNI_SW: + case PPCMODE_BI_SW: + while (len--) { + parport_write_data(pi->pardev->port, *buf++); + parport_frob_control(pi->pardev->port, 0, + PARPORT_CONTROL_INIT); + } + break; + case PPCMODE_UNI_FW: + case PPCMODE_BI_FW: + ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_FASTWR); + + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_STROBE); + + last = *buf; + + parport_write_data(pi->pardev->port, last); + + while (len) { + this = *buf++; + len--; + + if (this == last) { + parport_frob_control(pi->pardev->port, 0, + PARPORT_CONTROL_INIT); + } else { + parport_write_data(pi->pardev->port, this); + last = this; + } + } + + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + 0); + ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_FASTWR); + break; + case PPCMODE_EPP_BYTE: + pi->pardev->port->ops->epp_write_data(pi->pardev->port, buf, + len, PARPORT_EPP_FAST_8); + ppc6_wait_for_fifo(pi); + break; + case PPCMODE_EPP_WORD: + pi->pardev->port->ops->epp_write_data(pi->pardev->port, buf, + len, PARPORT_EPP_FAST_16); + ppc6_wait_for_fifo(pi); + break; + case PPCMODE_EPP_DWORD: + pi->pardev->port->ops->epp_write_data(pi->pardev->port, buf, + len, PARPORT_EPP_FAST_32); + ppc6_wait_for_fifo(pi); + break; + } + ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); } diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 679261e19ac5..3ba920251c1c 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -73,7 +73,6 @@ static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd); static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data); static u8 ppc6_rd_data_byte(struct pi_adapter *pi); static void ppc6_wait_for_fifo(struct pi_adapter *pi); -static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count); static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata); static int ppc6_open(struct pi_adapter *pi); @@ -296,96 +295,6 @@ static void ppc6_wait_for_fifo(struct pi_adapter *pi) //*************************************************************************** -static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count) -{ - switch (mode_map[pi->mode]) - { - case PPCMODE_UNI_SW : - case PPCMODE_BI_SW : - { - while(count--) - { - parport_write_data(pi->pardev->port, *data++); - - parport_frob_control(pi->pardev->port, 0, PARPORT_CONTROL_INIT); - } - - break; - } - - case PPCMODE_UNI_FW : - case PPCMODE_BI_FW : - { - u8 this, last; - - ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_FASTWR); - - parport_frob_control(pi->pardev->port, - PARPORT_CONTROL_STROBE, PARPORT_CONTROL_STROBE); - - last = *data; - - parport_write_data(pi->pardev->port, last); - - while(count) - { - this = *data++; - count--; - - if (this == last) - { - parport_frob_control(pi->pardev->port, - 0, PARPORT_CONTROL_INIT); - } - else - { - parport_write_data(pi->pardev->port, this); - - last = this; - } - } - - parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, 0); - - ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_FASTWR); - - break; - } - - case PPCMODE_EPP_BYTE : - { - pi->pardev->port->ops->epp_write_data(pi->pardev->port, - data, count, PARPORT_EPP_FAST_8); - - ppc6_wait_for_fifo(pi); - - break; - } - - case PPCMODE_EPP_WORD : - { - pi->pardev->port->ops->epp_write_data(pi->pardev->port, - data, count, PARPORT_EPP_FAST_16); - - ppc6_wait_for_fifo(pi); - - break; - } - - case PPCMODE_EPP_DWORD : - { - pi->pardev->port->ops->epp_write_data(pi->pardev->port, - data, count, PARPORT_EPP_FAST_32); - - ppc6_wait_for_fifo(pi); - - break; - } - } -} - -//*************************************************************************** - static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata) { ppc6_send_cmd(pi, REG_VERSION | ACCESS_REG | ACCESS_WRITE); From patchwork Tue Mar 7 22:46:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164920 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B577C6FD1E for ; Tue, 7 Mar 2023 22:49:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231143AbjCGWtN (ORCPT ); Tue, 7 Mar 2023 17:49:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231348AbjCGWru (ORCPT ); Tue, 7 Mar 2023 17:47:50 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8E2165371E; Tue, 7 Mar 2023 14:47:08 -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 2FB3A7A074C; Tue, 7 Mar 2023 23:46:50 +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 22/32] pata_parport-bpck6: move ppc6_wait_for_fifo to bpck6.c and rename Date: Tue, 7 Mar 2023 23:46:17 +0100 Message-Id: <20230307224627.28011-23-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Move ppc6_wait_for_fifo to bpck6.c and rename it to bpck6_wait_for_fifo Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 16 +++++++++++++--- drivers/ata/pata_parport/ppc6lnx.c | 14 -------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 27c1fa3bb336..1f976ee04ef2 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -35,6 +35,16 @@ static void bpck6_write_regr(struct pi_adapter *pi, int cont, int reg, int val) ppc6_wr_data_byte(pi, val); } +static void bpck6_wait_for_fifo(struct pi_adapter *pi) +{ + int i; + + if (pi->private & fifo_wait) { + for (i = 0; i < 20; i++) + parport_read_status(pi->pardev->port); + } +} + static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) { u8 this, last; @@ -87,17 +97,17 @@ static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) case PPCMODE_EPP_BYTE: pi->pardev->port->ops->epp_write_data(pi->pardev->port, buf, len, PARPORT_EPP_FAST_8); - ppc6_wait_for_fifo(pi); + bpck6_wait_for_fifo(pi); break; case PPCMODE_EPP_WORD: pi->pardev->port->ops->epp_write_data(pi->pardev->port, buf, len, PARPORT_EPP_FAST_16); - ppc6_wait_for_fifo(pi); + bpck6_wait_for_fifo(pi); break; case PPCMODE_EPP_DWORD: pi->pardev->port->ops->epp_write_data(pi->pardev->port, buf, len, PARPORT_EPP_FAST_32); - ppc6_wait_for_fifo(pi); + bpck6_wait_for_fifo(pi); break; } diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 3ba920251c1c..cd4fa31a5ff8 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -72,7 +72,6 @@ static void ppc6_deselect(struct pi_adapter *pi); static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd); static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data); static u8 ppc6_rd_data_byte(struct pi_adapter *pi); -static void ppc6_wait_for_fifo(struct pi_adapter *pi); static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata); static int ppc6_open(struct pi_adapter *pi); @@ -282,19 +281,6 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) //*************************************************************************** -static void ppc6_wait_for_fifo(struct pi_adapter *pi) -{ - int i; - - if (pi->private & fifo_wait) - { - for(i=0; i<20; i++) - parport_read_status(pi->pardev->port); - } -} - -//*************************************************************************** - static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata) { ppc6_send_cmd(pi, REG_VERSION | ACCESS_REG | ACCESS_WRITE); From patchwork Tue Mar 7 22:46:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 573D5C74A4B for ; Tue, 7 Mar 2023 22:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbjCGWtH (ORCPT ); Tue, 7 Mar 2023 17:49:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231598AbjCGWrd (ORCPT ); Tue, 7 Mar 2023 17:47:33 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E6393867D3; Tue, 7 Mar 2023 14:47:08 -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 425DB7A0750; Tue, 7 Mar 2023 23:46:50 +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 23/32] pata_parport-bpck6: move ppc6_wr_extout to bpck6.c and rename Date: Tue, 7 Mar 2023 23:46:18 +0100 Message-Id: <20230307224627.28011-24-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Move ppc6_wr_extout to bpck6.c and rename it to bpck6_wr_extout Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 10 ++++++++-- drivers/ata/pata_parport/ppc6lnx.c | 10 ---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 1f976ee04ef2..968c9f3297e3 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -174,18 +174,24 @@ static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); } +static void bpck6_wr_extout(struct pi_adapter *pi, u8 regdata) +{ + ppc6_send_cmd(pi, REG_VERSION | ACCESS_REG | ACCESS_WRITE); + ppc6_wr_data_byte(pi, (u8)((regdata & 0x03) << 6)); +} + static void bpck6_connect(struct pi_adapter *pi) { dev_dbg(&pi->dev, "connect\n"); ppc6_open(pi); - ppc6_wr_extout(pi, 0x3); + bpck6_wr_extout(pi, 0x3); } static void bpck6_disconnect(struct pi_adapter *pi) { dev_dbg(&pi->dev, "disconnect\n"); - ppc6_wr_extout(pi, 0x0); + bpck6_wr_extout(pi, 0x0); ppc6_deselect(pi); } diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index cd4fa31a5ff8..931bf67fabb9 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -72,7 +72,6 @@ static void ppc6_deselect(struct pi_adapter *pi); static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd); static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data); static u8 ppc6_rd_data_byte(struct pi_adapter *pi); -static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata); static int ppc6_open(struct pi_adapter *pi); //*************************************************************************** @@ -281,15 +280,6 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) //*************************************************************************** -static void ppc6_wr_extout(struct pi_adapter *pi, u8 regdata) -{ - ppc6_send_cmd(pi, REG_VERSION | ACCESS_REG | ACCESS_WRITE); - - ppc6_wr_data_byte(pi, (u8)((regdata & 0x03) << 6)); -} - -//*************************************************************************** - static int ppc6_open(struct pi_adapter *pi) { int ret; From patchwork Tue Mar 7 22:46:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164918 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A4FFC74A44 for ; Tue, 7 Mar 2023 22:49:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231888AbjCGWtK (ORCPT ); Tue, 7 Mar 2023 17:49:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230332AbjCGWrf (ORCPT ); Tue, 7 Mar 2023 17:47:35 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E68AA9BA45; Tue, 7 Mar 2023 14:47:08 -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 5AE3D7A0755; Tue, 7 Mar 2023 23:46:50 +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 24/32] pata_parport-bpck6: move ppc6_open to bpck6.c and rename Date: Tue, 7 Mar 2023 23:46:19 +0100 Message-Id: <20230307224627.28011-25-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Move ppc6_open to bpck6.c and rename it to bpck6_open Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 23 +++++++++++++++++++++-- drivers/ata/pata_parport/ppc6lnx.c | 28 ---------------------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 968c9f3297e3..02f16dedfd29 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -174,6 +174,25 @@ static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); } +static int bpck6_open(struct pi_adapter *pi) +{ + int ret = ppc6_select(pi); + + if (ret == 0) + return ret; + + pi->private = 0; + + ppc6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE); + ppc6_wr_data_byte(pi, RAMSIZE_128K); + + ppc6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); + if ((ppc6_rd_data_byte(pi) & 0x3F) == 0x0C) + pi->private |= fifo_wait; + + return ret; +} + static void bpck6_wr_extout(struct pi_adapter *pi, u8 regdata) { ppc6_send_cmd(pi, REG_VERSION | ACCESS_REG | ACCESS_WRITE); @@ -184,7 +203,7 @@ static void bpck6_connect(struct pi_adapter *pi) { dev_dbg(&pi->dev, "connect\n"); - ppc6_open(pi); + bpck6_open(pi); bpck6_wr_extout(pi, 0x3); } @@ -218,7 +237,7 @@ static int bpck6_probe_unit(struct pi_adapter *pi) /*LOWER DOWN TO UNIDIRECTIONAL*/ pi->mode = 0; - out = ppc6_open(pi); + out = bpck6_open(pi); dev_dbg(&pi->dev, "ppc_open returned %2x\n", out); diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 931bf67fabb9..a902ede5ecc5 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -72,7 +72,6 @@ static void ppc6_deselect(struct pi_adapter *pi); static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd); static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data); static u8 ppc6_rd_data_byte(struct pi_adapter *pi); -static int ppc6_open(struct pi_adapter *pi); //*************************************************************************** @@ -277,30 +276,3 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) return(data); } - -//*************************************************************************** - -static int ppc6_open(struct pi_adapter *pi) -{ - int ret; - - ret = ppc6_select(pi); - - if (ret == 0) - return(ret); - - pi->private = 0; - - ppc6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE); - ppc6_wr_data_byte(pi, RAMSIZE_128K); - - ppc6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); - - if ((ppc6_rd_data_byte(pi) & 0x3F) == 0x0C) - pi->private |= fifo_wait; - - return(ret); -} - -//*************************************************************************** - From patchwork Tue Mar 7 22:46:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164906 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C695DC74A4B for ; Tue, 7 Mar 2023 22:48:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230128AbjCGWsI (ORCPT ); Tue, 7 Mar 2023 17:48:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231600AbjCGWrV (ORCPT ); Tue, 7 Mar 2023 17:47:21 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8B33D2ED57; Tue, 7 Mar 2023 14:47:08 -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 734E07A0756; Tue, 7 Mar 2023 23:46:50 +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 25/32] pata_parport-bpck6: merge ppc6_select into bpck6_open Date: Tue, 7 Mar 2023 23:46:20 +0100 Message-Id: <20230307224627.28011-26-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org ppc6_select is only called by bpck6_open. Merge ppc6_select into bpck6_open. Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 68 ++++++++++++++++++++++++------ drivers/ata/pata_parport/ppc6lnx.c | 66 ----------------------------- 2 files changed, 55 insertions(+), 79 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 02f16dedfd29..9b05e1c827cd 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -176,21 +176,63 @@ static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) static int bpck6_open(struct pi_adapter *pi) { - int ret = ppc6_select(pi); - - if (ret == 0) - return ret; - - pi->private = 0; - - ppc6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE); - ppc6_wr_data_byte(pi, RAMSIZE_128K); + u8 i, j, k; + + pi->saved_r0 = parport_read_data(pi->pardev->port); + pi->saved_r2 = parport_read_control(pi->pardev->port) & 0x5F; + + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, + PARPORT_CONTROL_SELECT); + if (pi->saved_r0 == 'b') + parport_write_data(pi->pardev->port, 'x'); + 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); + + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, 0); + parport_write_control(pi->pardev->port, PARPORT_CONTROL_INIT); + + i = mode_map[pi->mode] & 0x0C; + if (i == 0) + i = (mode_map[pi->mode] & 2) | 1; + parport_write_data(pi->pardev->port, i); + + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, + PARPORT_CONTROL_SELECT); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_AUTOFD, + PARPORT_CONTROL_AUTOFD); + + j = ((i & 0x08) << 4) | ((i & 0x07) << 3); + k = parport_read_status(pi->pardev->port) & 0xB8; + if (j == k) { + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_AUTOFD, 0); + k = (parport_read_status(pi->pardev->port) & 0xB8) ^ 0xB8; + if (j == k) { + if (i & 4) // EPP + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_SELECT | PARPORT_CONTROL_INIT, 0); + else // PPC/ECP + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_SELECT, 0); + + pi->private = 0; + + ppc6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE); + ppc6_wr_data_byte(pi, RAMSIZE_128K); + + ppc6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); + if ((ppc6_rd_data_byte(pi) & 0x3F) == 0x0C) + pi->private |= fifo_wait; + + return 1; + } + } - ppc6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); - if ((ppc6_rd_data_byte(pi) & 0x3F) == 0x0C) - pi->private |= fifo_wait; + parport_write_control(pi->pardev->port, pi->saved_r2); + parport_write_data(pi->pardev->port, pi->saved_r0); - return ret; + return 0; // FAIL } static void bpck6_wr_extout(struct pi_adapter *pi, u8 regdata) diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index a902ede5ecc5..16d0497dfeaa 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -67,7 +67,6 @@ //*************************************************************************** -static int ppc6_select(struct pi_adapter *pi); static void ppc6_deselect(struct pi_adapter *pi); static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd); static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data); @@ -78,71 +77,6 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi); int mode_map[] = { PPCMODE_UNI_FW, PPCMODE_BI_FW, PPCMODE_EPP_BYTE, PPCMODE_EPP_WORD, PPCMODE_EPP_DWORD }; -static int ppc6_select(struct pi_adapter *pi) -{ - u8 i, j, k; - - pi->saved_r0 = parport_read_data(pi->pardev->port); - - pi->saved_r2 = parport_read_control(pi->pardev->port) & 0x5F; // readback ctrl - - parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, PARPORT_CONTROL_SELECT); - - if (pi->saved_r0 == 'b') - parport_write_data(pi->pardev->port, 'x'); - - 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); - - parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, 0); - - parport_write_control(pi->pardev->port, PARPORT_CONTROL_INIT); - - i = mode_map[pi->mode] & 0x0C; - - if (i == 0) - i = (mode_map[pi->mode] & 2) | 1; - - parport_write_data(pi->pardev->port, i); - - parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, PARPORT_CONTROL_SELECT); - - // DELAY - - parport_frob_control(pi->pardev->port, PARPORT_CONTROL_AUTOFD, PARPORT_CONTROL_AUTOFD); - - j = ((i & 0x08) << 4) | ((i & 0x07) << 3); - - k = parport_read_status(pi->pardev->port) & 0xB8; - - if (j == k) - { - parport_frob_control(pi->pardev->port, PARPORT_CONTROL_AUTOFD, 0); - - k = (parport_read_status(pi->pardev->port) & 0xB8) ^ 0xB8; - - if (j == k) - { - if (i & 4) // EPP - parport_frob_control(pi->pardev->port, - PARPORT_CONTROL_SELECT | PARPORT_CONTROL_INIT, 0); - else // PPC/ECP - parport_frob_control(pi->pardev->port, - PARPORT_CONTROL_SELECT, 0); - - return(1); - } - } - - parport_write_control(pi->pardev->port, pi->saved_r2); - - parport_write_data(pi->pardev->port, pi->saved_r0); - - return(0); // FAIL -} - //*************************************************************************** static void ppc6_deselect(struct pi_adapter *pi) From patchwork Tue Mar 7 22:46:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164912 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FAEBC76188 for ; Tue, 7 Mar 2023 22:48:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231592AbjCGWse (ORCPT ); Tue, 7 Mar 2023 17:48:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230029AbjCGWrd (ORCPT ); Tue, 7 Mar 2023 17:47:33 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E629516332; Tue, 7 Mar 2023 14:47:08 -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 815EB7A075A; Tue, 7 Mar 2023 23:46:50 +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 26/32] pata_parport-bpck6: move ppc6_deselect to bpck6.c and rename Date: Tue, 7 Mar 2023 23:46:21 +0100 Message-Id: <20230307224627.28011-27-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Move ppc6_deselect to bpck6.c and rename it to bpck6_deselect Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 19 +++++++++++++++++-- drivers/ata/pata_parport/ppc6lnx.c | 19 ------------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 9b05e1c827cd..46a91b04aed3 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -235,6 +235,21 @@ static int bpck6_open(struct pi_adapter *pi) return 0; // FAIL } +static void bpck6_deselect(struct pi_adapter *pi) +{ + if (mode_map[pi->mode] & 4) // EPP + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_INIT, + PARPORT_CONTROL_INIT); + else // PPC/ECP + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, + PARPORT_CONTROL_SELECT); + + parport_write_data(pi->pardev->port, pi->saved_r0); + parport_write_control(pi->pardev->port, + pi->saved_r2 | PARPORT_CONTROL_SELECT); + parport_write_control(pi->pardev->port, pi->saved_r2); +} + static void bpck6_wr_extout(struct pi_adapter *pi, u8 regdata) { ppc6_send_cmd(pi, REG_VERSION | ACCESS_REG | ACCESS_WRITE); @@ -253,7 +268,7 @@ static void bpck6_disconnect(struct pi_adapter *pi) { dev_dbg(&pi->dev, "disconnect\n"); bpck6_wr_extout(pi, 0x0); - ppc6_deselect(pi); + bpck6_deselect(pi); } static int bpck6_test_port(struct pi_adapter *pi) /* check for 8-bit port */ @@ -285,7 +300,7 @@ static int bpck6_probe_unit(struct pi_adapter *pi) if(out) { - ppc6_deselect(pi); + bpck6_deselect(pi); dev_dbg(&pi->dev, "leaving probe\n"); pi->mode = saved_mode; return(1); diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 16d0497dfeaa..6c34bbbdf6db 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -67,7 +67,6 @@ //*************************************************************************** -static void ppc6_deselect(struct pi_adapter *pi); static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd); static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data); static u8 ppc6_rd_data_byte(struct pi_adapter *pi); @@ -79,24 +78,6 @@ int mode_map[] = { PPCMODE_UNI_FW, PPCMODE_BI_FW, PPCMODE_EPP_BYTE, //*************************************************************************** -static void ppc6_deselect(struct pi_adapter *pi) -{ - if (mode_map[pi->mode] & 4) // EPP - parport_frob_control(pi->pardev->port, - PARPORT_CONTROL_INIT, PARPORT_CONTROL_INIT); - else // PPC/ECP - parport_frob_control(pi->pardev->port, - PARPORT_CONTROL_SELECT, PARPORT_CONTROL_SELECT); - - parport_write_data(pi->pardev->port, pi->saved_r0); - - parport_write_control(pi->pardev->port, (pi->saved_r2 | PARPORT_CONTROL_SELECT)); - - parport_write_control(pi->pardev->port, pi->saved_r2); -} - -//*************************************************************************** - static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) { switch (mode_map[pi->mode]) From patchwork Tue Mar 7 22:46:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BDACC742A7 for ; Tue, 7 Mar 2023 22:49:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231918AbjCGWtP (ORCPT ); Tue, 7 Mar 2023 17:49:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230268AbjCGWru (ORCPT ); Tue, 7 Mar 2023 17:47:50 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4F26893125; Tue, 7 Mar 2023 14:47:08 -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 977937A076F; Tue, 7 Mar 2023 23:46:50 +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 27/32] pata_parport-bpck6: move ppc6_send_cmd to bpck6.c and rename Date: Tue, 7 Mar 2023 23:46:22 +0100 Message-Id: <20230307224627.28011-28-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Move ppc6_send_cmd to bpck6.c and rename it to bpck6_send_cmd Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 48 ++++++++++++++++++++---------- drivers/ata/pata_parport/ppc6lnx.c | 29 ------------------ 2 files changed, 33 insertions(+), 44 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 46a91b04aed3..32dc9e61e80c 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -19,11 +19,29 @@ #include "pata_parport.h" #include "ppc6lnx.c" +static void bpck6_send_cmd(struct pi_adapter *pi, u8 cmd) +{ + switch (mode_map[pi->mode]) { + case PPCMODE_UNI_SW: + case PPCMODE_UNI_FW: + case PPCMODE_BI_SW: + case PPCMODE_BI_FW: + parport_write_data(pi->pardev->port, cmd); + parport_frob_control(pi->pardev->port, 0, PARPORT_CONTROL_AUTOFD); + break; + case PPCMODE_EPP_BYTE: + case PPCMODE_EPP_WORD: + case PPCMODE_EPP_DWORD: + pi->pardev->port->ops->epp_write_addr(pi->pardev->port, &cmd, 1, 0); + break; + } +} + static int bpck6_read_regr(struct pi_adapter *pi, int cont, int reg) { u8 port = cont ? reg | 8 : reg; - ppc6_send_cmd(pi, port | ACCESS_PORT | ACCESS_READ); + bpck6_send_cmd(pi, port | ACCESS_PORT | ACCESS_READ); return ppc6_rd_data_byte(pi); } @@ -31,7 +49,7 @@ static void bpck6_write_regr(struct pi_adapter *pi, int cont, int reg, int val) { u8 port = cont ? reg | 8 : reg; - ppc6_send_cmd(pi, port | ACCESS_PORT | ACCESS_WRITE); + bpck6_send_cmd(pi, port | ACCESS_PORT | ACCESS_WRITE); ppc6_wr_data_byte(pi, val); } @@ -49,13 +67,13 @@ static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) { u8 this, last; - ppc6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); + bpck6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); ppc6_wr_data_byte(pi, (u8)len); ppc6_wr_data_byte(pi, (u8)(len >> 8)); ppc6_wr_data_byte(pi, 0); - ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); - ppc6_send_cmd(pi, ATA_REG_DATA | ACCESS_PORT | ACCESS_WRITE); + bpck6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); + bpck6_send_cmd(pi, ATA_REG_DATA | ACCESS_PORT | ACCESS_WRITE); switch (mode_map[pi->mode]) { case PPCMODE_UNI_SW: @@ -68,7 +86,7 @@ static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) break; case PPCMODE_UNI_FW: case PPCMODE_BI_FW: - ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_FASTWR); + bpck6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_FASTWR); parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, PARPORT_CONTROL_STROBE); @@ -92,7 +110,7 @@ static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, 0); - ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_FASTWR); + bpck6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_FASTWR); break; case PPCMODE_EPP_BYTE: pi->pardev->port->ops->epp_write_data(pi->pardev->port, buf, @@ -111,18 +129,18 @@ static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) break; } - ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); + bpck6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); } static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) { - ppc6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); + bpck6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); ppc6_wr_data_byte(pi, (u8)len); ppc6_wr_data_byte(pi, (u8)(len >> 8)); ppc6_wr_data_byte(pi, 0); - ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); - ppc6_send_cmd(pi, ATA_REG_DATA | ACCESS_PORT | ACCESS_READ); + bpck6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); + bpck6_send_cmd(pi, ATA_REG_DATA | ACCESS_PORT | ACCESS_READ); switch (mode_map[pi->mode]) { case PPCMODE_UNI_SW: @@ -171,7 +189,7 @@ static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) break; } - ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); + bpck6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK); } static int bpck6_open(struct pi_adapter *pi) @@ -218,10 +236,10 @@ static int bpck6_open(struct pi_adapter *pi) pi->private = 0; - ppc6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE); + bpck6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE); ppc6_wr_data_byte(pi, RAMSIZE_128K); - ppc6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); + bpck6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); if ((ppc6_rd_data_byte(pi) & 0x3F) == 0x0C) pi->private |= fifo_wait; @@ -252,7 +270,7 @@ static void bpck6_deselect(struct pi_adapter *pi) static void bpck6_wr_extout(struct pi_adapter *pi, u8 regdata) { - ppc6_send_cmd(pi, REG_VERSION | ACCESS_REG | ACCESS_WRITE); + bpck6_send_cmd(pi, REG_VERSION | ACCESS_REG | ACCESS_WRITE); ppc6_wr_data_byte(pi, (u8)((regdata & 0x03) << 6)); } diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 6c34bbbdf6db..d3c3968fbfc8 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -67,7 +67,6 @@ //*************************************************************************** -static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd); static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data); static u8 ppc6_rd_data_byte(struct pi_adapter *pi); @@ -78,34 +77,6 @@ int mode_map[] = { PPCMODE_UNI_FW, PPCMODE_BI_FW, PPCMODE_EPP_BYTE, //*************************************************************************** -static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) -{ - switch (mode_map[pi->mode]) - { - case PPCMODE_UNI_SW : - case PPCMODE_UNI_FW : - case PPCMODE_BI_SW : - case PPCMODE_BI_FW : - { - parport_write_data(pi->pardev->port, cmd); - parport_frob_control(pi->pardev->port, 0, PARPORT_CONTROL_AUTOFD); - - break; - } - - case PPCMODE_EPP_BYTE : - case PPCMODE_EPP_WORD : - case PPCMODE_EPP_DWORD : - { - pi->pardev->port->ops->epp_write_addr(pi->pardev->port, &cmd, 1, 0); - - break; - } - } -} - -//*************************************************************************** - static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) { switch (mode_map[pi->mode]) From patchwork Tue Mar 7 22:46:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F81EC6FD1E for ; Tue, 7 Mar 2023 22:49:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231282AbjCGWtL (ORCPT ); Tue, 7 Mar 2023 17:49:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231776AbjCGWrp (ORCPT ); Tue, 7 Mar 2023 17:47:45 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C0F957D0C; Tue, 7 Mar 2023 14:47:08 -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 B21D77A0771; Tue, 7 Mar 2023 23:46:50 +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 28/32] pata_parport-bpck6: move ppc6_rd_data_byte to bpck6.c and rename Date: Tue, 7 Mar 2023 23:46:23 +0100 Message-Id: <20230307224627.28011-29-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Move ppc6_rd_data_byte to bpck6.c and rename it to bpck6_rd_data_byte Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 38 ++++++++++++++++++- drivers/ata/pata_parport/ppc6lnx.c | 61 ------------------------------ 2 files changed, 36 insertions(+), 63 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 32dc9e61e80c..064696b6d68f 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -37,12 +37,46 @@ static void bpck6_send_cmd(struct pi_adapter *pi, u8 cmd) } } +static u8 bpck6_rd_data_byte(struct pi_adapter *pi) +{ + u8 data = 0; + + switch (mode_map[pi->mode]) { + case PPCMODE_UNI_SW: + case PPCMODE_UNI_FW: + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_INIT); + data = parport_read_status(pi->pardev->port); + data = ((data & 0x80) >> 1) | ((data & 0x38) >> 3); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_STROBE); + data |= parport_read_status(pi->pardev->port) & 0xB8; + break; + case PPCMODE_BI_SW: + case PPCMODE_BI_FW: + parport_data_reverse(pi->pardev->port); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, + PARPORT_CONTROL_STROBE | PARPORT_CONTROL_INIT); + data = parport_read_data(pi->pardev->port); + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, 0); + parport_data_forward(pi->pardev->port); + break; + case PPCMODE_EPP_BYTE: + case PPCMODE_EPP_WORD: + case PPCMODE_EPP_DWORD: + pi->pardev->port->ops->epp_read_data(pi->pardev->port, &data, 1, 0); + break; + } + + return data; +} + static int bpck6_read_regr(struct pi_adapter *pi, int cont, int reg) { u8 port = cont ? reg | 8 : reg; bpck6_send_cmd(pi, port | ACCESS_PORT | ACCESS_READ); - return ppc6_rd_data_byte(pi); + return bpck6_rd_data_byte(pi); } static void bpck6_write_regr(struct pi_adapter *pi, int cont, int reg, int val) @@ -240,7 +274,7 @@ static int bpck6_open(struct pi_adapter *pi) ppc6_wr_data_byte(pi, RAMSIZE_128K); bpck6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); - if ((ppc6_rd_data_byte(pi) & 0x3F) == 0x0C) + if ((bpck6_rd_data_byte(pi) & 0x3F) == 0x0C) pi->private |= fifo_wait; return 1; diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index d3c3968fbfc8..838af60a0d4d 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -68,7 +68,6 @@ //*************************************************************************** static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data); -static u8 ppc6_rd_data_byte(struct pi_adapter *pi); //*************************************************************************** @@ -102,63 +101,3 @@ static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) } } } - -//*************************************************************************** - -static u8 ppc6_rd_data_byte(struct pi_adapter *pi) -{ - u8 data = 0; - - switch (mode_map[pi->mode]) - { - case PPCMODE_UNI_SW : - case PPCMODE_UNI_FW : - { - parport_frob_control(pi->pardev->port, - PARPORT_CONTROL_STROBE, PARPORT_CONTROL_INIT); - - // DELAY - - data = parport_read_status(pi->pardev->port); - - data = ((data & 0x80) >> 1) | ((data & 0x38) >> 3); - - parport_frob_control(pi->pardev->port, - PARPORT_CONTROL_STROBE, PARPORT_CONTROL_STROBE); - - // DELAY - - data |= parport_read_status(pi->pardev->port) & 0xB8; - - break; - } - - case PPCMODE_BI_SW : - case PPCMODE_BI_FW : - { - parport_data_reverse(pi->pardev->port); - - parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, - PARPORT_CONTROL_STROBE | PARPORT_CONTROL_INIT); - - data = parport_read_data(pi->pardev->port); - - parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, 0); - - parport_data_forward(pi->pardev->port); - - break; - } - - case PPCMODE_EPP_BYTE : - case PPCMODE_EPP_WORD : - case PPCMODE_EPP_DWORD : - { - pi->pardev->port->ops->epp_read_data(pi->pardev->port, &data, 1, 0); - - break; - } - } - - return(data); -} From patchwork Tue Mar 7 22:46:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23542C742A7 for ; Tue, 7 Mar 2023 22:49:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229997AbjCGWs6 (ORCPT ); Tue, 7 Mar 2023 17:48:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231775AbjCGWrp (ORCPT ); Tue, 7 Mar 2023 17:47:45 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6E3DC99C2D; Tue, 7 Mar 2023 14:47:09 -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 CAA287A0776; Tue, 7 Mar 2023 23:46:50 +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 29/32] pata_parport-bpck6: move ppc6_wr_data_byte to bpck6.c and rename Date: Tue, 7 Mar 2023 23:46:24 +0100 Message-Id: <20230307224627.28011-30-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Move ppc6_wr_data_byte to bpck6.c and rename it to bpck6_wr_data_byte Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 36 ++++++++++++++++++++++-------- drivers/ata/pata_parport/ppc6lnx.c | 32 -------------------------- 2 files changed, 27 insertions(+), 41 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 064696b6d68f..f6d0916577b3 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -71,6 +71,24 @@ static u8 bpck6_rd_data_byte(struct pi_adapter *pi) return data; } +static void bpck6_wr_data_byte(struct pi_adapter *pi, u8 data) +{ + switch (mode_map[pi->mode]) { + case PPCMODE_UNI_SW: + case PPCMODE_UNI_FW: + case PPCMODE_BI_SW: + case PPCMODE_BI_FW: + parport_write_data(pi->pardev->port, data); + parport_frob_control(pi->pardev->port, 0, PARPORT_CONTROL_INIT); + break; + case PPCMODE_EPP_BYTE: + case PPCMODE_EPP_WORD: + case PPCMODE_EPP_DWORD: + pi->pardev->port->ops->epp_write_data(pi->pardev->port, &data, 1, 0); + break; + } +} + static int bpck6_read_regr(struct pi_adapter *pi, int cont, int reg) { u8 port = cont ? reg | 8 : reg; @@ -84,7 +102,7 @@ static void bpck6_write_regr(struct pi_adapter *pi, int cont, int reg, int val) u8 port = cont ? reg | 8 : reg; bpck6_send_cmd(pi, port | ACCESS_PORT | ACCESS_WRITE); - ppc6_wr_data_byte(pi, val); + bpck6_wr_data_byte(pi, val); } static void bpck6_wait_for_fifo(struct pi_adapter *pi) @@ -102,9 +120,9 @@ static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) u8 this, last; bpck6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); - ppc6_wr_data_byte(pi, (u8)len); - ppc6_wr_data_byte(pi, (u8)(len >> 8)); - ppc6_wr_data_byte(pi, 0); + bpck6_wr_data_byte(pi, (u8)len); + bpck6_wr_data_byte(pi, (u8)(len >> 8)); + bpck6_wr_data_byte(pi, 0); bpck6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); bpck6_send_cmd(pi, ATA_REG_DATA | ACCESS_PORT | ACCESS_WRITE); @@ -169,9 +187,9 @@ static void bpck6_write_block(struct pi_adapter *pi, char *buf, int len) static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) { bpck6_send_cmd(pi, REG_BLKSIZE | ACCESS_REG | ACCESS_WRITE); - ppc6_wr_data_byte(pi, (u8)len); - ppc6_wr_data_byte(pi, (u8)(len >> 8)); - ppc6_wr_data_byte(pi, 0); + bpck6_wr_data_byte(pi, (u8)len); + bpck6_wr_data_byte(pi, (u8)(len >> 8)); + bpck6_wr_data_byte(pi, 0); bpck6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK); bpck6_send_cmd(pi, ATA_REG_DATA | ACCESS_PORT | ACCESS_READ); @@ -271,7 +289,7 @@ static int bpck6_open(struct pi_adapter *pi) pi->private = 0; bpck6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE); - ppc6_wr_data_byte(pi, RAMSIZE_128K); + bpck6_wr_data_byte(pi, RAMSIZE_128K); bpck6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); if ((bpck6_rd_data_byte(pi) & 0x3F) == 0x0C) @@ -305,7 +323,7 @@ static void bpck6_deselect(struct pi_adapter *pi) static void bpck6_wr_extout(struct pi_adapter *pi, u8 regdata) { bpck6_send_cmd(pi, REG_VERSION | ACCESS_REG | ACCESS_WRITE); - ppc6_wr_data_byte(pi, (u8)((regdata & 0x03) << 6)); + bpck6_wr_data_byte(pi, (u8)((regdata & 0x03) << 6)); } static void bpck6_connect(struct pi_adapter *pi) diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 838af60a0d4d..9a763cbda130 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -67,37 +67,5 @@ //*************************************************************************** -static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data); - -//*************************************************************************** - int mode_map[] = { PPCMODE_UNI_FW, PPCMODE_BI_FW, PPCMODE_EPP_BYTE, PPCMODE_EPP_WORD, PPCMODE_EPP_DWORD }; - -//*************************************************************************** - -static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data) -{ - switch (mode_map[pi->mode]) - { - case PPCMODE_UNI_SW : - case PPCMODE_UNI_FW : - case PPCMODE_BI_SW : - case PPCMODE_BI_FW : - { - parport_write_data(pi->pardev->port, data); - parport_frob_control(pi->pardev->port, 0, PARPORT_CONTROL_INIT); - - break; - } - - case PPCMODE_EPP_BYTE : - case PPCMODE_EPP_WORD : - case PPCMODE_EPP_DWORD : - { - pi->pardev->port->ops->epp_write_data(pi->pardev->port, &data, 1, 0); - - break; - } - } -} From patchwork Tue Mar 7 22:46:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164916 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D86C3C6FD1E for ; Tue, 7 Mar 2023 22:49:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231878AbjCGWtD (ORCPT ); Tue, 7 Mar 2023 17:49:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231289AbjCGWrp (ORCPT ); Tue, 7 Mar 2023 17:47:45 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4E7188C502; Tue, 7 Mar 2023 14:47:09 -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 E31577A0779; Tue, 7 Mar 2023 23:46:50 +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 30/32] pata_parport-bpck6: move defines and mode_map to bpck6.c Date: Tue, 7 Mar 2023 23:46:25 +0100 Message-Id: <20230307224627.28011-31-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Move all register definitions and mode_map to bpck6.c Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 44 ++++++++++++++++++++++++ drivers/ata/pata_parport/ppc6lnx.c | 54 ------------------------------ 2 files changed, 44 insertions(+), 54 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index f6d0916577b3..0ed6a97ab04f 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -19,6 +19,50 @@ #include "pata_parport.h" #include "ppc6lnx.c" +/* 60772 Commands */ +#define ACCESS_REG 0x00 +#define ACCESS_PORT 0x40 + +#define ACCESS_READ 0x00 +#define ACCESS_WRITE 0x20 + +/* 60772 Command Prefix */ +#define CMD_PREFIX_SET 0xe0 // Special command that modifies next command's operation +#define CMD_PREFIX_RESET 0xc0 // Resets current cmd modifier reg bits + #define PREFIX_IO16 0x01 // perform 16-bit wide I/O + #define PREFIX_FASTWR 0x04 // enable PPC mode fast-write + #define PREFIX_BLK 0x08 // enable block transfer mode + +/* 60772 Registers */ +#define REG_STATUS 0x00 // status register + #define STATUS_IRQA 0x01 // Peripheral IRQA line + #define STATUS_EEPROM_DO 0x40 // Serial EEPROM data bit +#define REG_VERSION 0x01 // PPC version register (read) +#define REG_HWCFG 0x02 // Hardware Config register +#define REG_RAMSIZE 0x03 // Size of RAM Buffer + #define RAMSIZE_128K 0x02 +#define REG_EEPROM 0x06 // EEPROM control register + #define EEPROM_SK 0x01 // eeprom SK bit + #define EEPROM_DI 0x02 // eeprom DI bit + #define EEPROM_CS 0x04 // eeprom CS bit + #define EEPROM_EN 0x08 // eeprom output enable +#define REG_BLKSIZE 0x08 // Block transfer len (24 bit) + +/* flags */ +#define fifo_wait 0x10 + +/* DONT CHANGE THESE LEST YOU BREAK EVERYTHING - BIT FIELD DEPENDENCIES */ +#define PPCMODE_UNI_SW 0 +#define PPCMODE_UNI_FW 1 +#define PPCMODE_BI_SW 2 +#define PPCMODE_BI_FW 3 +#define PPCMODE_EPP_BYTE 4 +#define PPCMODE_EPP_WORD 5 +#define PPCMODE_EPP_DWORD 6 + +int mode_map[] = { PPCMODE_UNI_FW, PPCMODE_BI_FW, PPCMODE_EPP_BYTE, + PPCMODE_EPP_WORD, PPCMODE_EPP_DWORD }; + static void bpck6_send_cmd(struct pi_adapter *pi, u8 cmd) { switch (mode_map[pi->mode]) { diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c index 9a763cbda130..e72b1842adda 100644 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ b/drivers/ata/pata_parport/ppc6lnx.c @@ -15,57 +15,3 @@ //*************************************************************************** -// 60772 Commands - -#define ACCESS_REG 0x00 -#define ACCESS_PORT 0x40 - -#define ACCESS_READ 0x00 -#define ACCESS_WRITE 0x20 - -// 60772 Command Prefix - -#define CMD_PREFIX_SET 0xe0 // Special command that modifies the next command's operation -#define CMD_PREFIX_RESET 0xc0 // Resets current cmd modifier reg bits - #define PREFIX_IO16 0x01 // perform 16-bit wide I/O - #define PREFIX_FASTWR 0x04 // enable PPC mode fast-write - #define PREFIX_BLK 0x08 // enable block transfer mode - -// 60772 Registers - -#define REG_STATUS 0x00 // status register - #define STATUS_IRQA 0x01 // Peripheral IRQA line - #define STATUS_EEPROM_DO 0x40 // Serial EEPROM data bit -#define REG_VERSION 0x01 // PPC version register (read) -#define REG_HWCFG 0x02 // Hardware Config register -#define REG_RAMSIZE 0x03 // Size of RAM Buffer - #define RAMSIZE_128K 0x02 -#define REG_EEPROM 0x06 // EEPROM control register - #define EEPROM_SK 0x01 // eeprom SK bit - #define EEPROM_DI 0x02 // eeprom DI bit - #define EEPROM_CS 0x04 // eeprom CS bit - #define EEPROM_EN 0x08 // eeprom output enable -#define REG_BLKSIZE 0x08 // Block transfer len (24 bit) - -//*************************************************************************** - -// ppc_flags - -#define fifo_wait 0x10 - -//*************************************************************************** - -// DONT CHANGE THESE LEST YOU BREAK EVERYTHING - BIT FIELD DEPENDENCIES - -#define PPCMODE_UNI_SW 0 -#define PPCMODE_UNI_FW 1 -#define PPCMODE_BI_SW 2 -#define PPCMODE_BI_FW 3 -#define PPCMODE_EPP_BYTE 4 -#define PPCMODE_EPP_WORD 5 -#define PPCMODE_EPP_DWORD 6 - -//*************************************************************************** - -int mode_map[] = { PPCMODE_UNI_FW, PPCMODE_BI_FW, PPCMODE_EPP_BYTE, - PPCMODE_EPP_WORD, PPCMODE_EPP_DWORD }; From patchwork Tue Mar 7 22:46:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164914 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A077C6FA99 for ; Tue, 7 Mar 2023 22:49:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231679AbjCGWs7 (ORCPT ); Tue, 7 Mar 2023 17:48:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231779AbjCGWrp (ORCPT ); Tue, 7 Mar 2023 17:47:45 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0EEF7A0B29; Tue, 7 Mar 2023 14:47:08 -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 074197A077A; Tue, 7 Mar 2023 23:46:51 +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 31/32] pata_parport-bpck6: delete ppc6lnx.c Date: Tue, 7 Mar 2023 23:46:26 +0100 Message-Id: <20230307224627.28011-32-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Remove now empty ppc6lnx.c. Signed-off-by: Ondrej Zary Reviewed-by: Sergey Shtylyov --- drivers/ata/pata_parport/bpck6.c | 1 - drivers/ata/pata_parport/ppc6lnx.c | 17 ----------------- 2 files changed, 18 deletions(-) delete mode 100644 drivers/ata/pata_parport/ppc6lnx.c diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 0ed6a97ab04f..53d0ad1d6e89 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -17,7 +17,6 @@ #include #include #include "pata_parport.h" -#include "ppc6lnx.c" /* 60772 Commands */ #define ACCESS_REG 0x00 diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c deleted file mode 100644 index e72b1842adda..000000000000 --- a/drivers/ata/pata_parport/ppc6lnx.c +++ /dev/null @@ -1,17 +0,0 @@ -/* - ppc6lnx.c (c) 2001 Micro Solutions Inc. - Released under the terms of the GNU General Public license - - ppc6lnx.c is a par of the protocol driver for the Micro Solutions - "BACKPACK" parallel port IDE adapter - (Works on Series 6 drives) - -*/ - -//*************************************************************************** - -// PPC 6 Code in C sanitized for LINUX -// Original x86 ASM by Ron, Converted to C by Clive - -//*************************************************************************** - From patchwork Tue Mar 7 22:46:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 13164915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B26CC74A4B for ; Tue, 7 Mar 2023 22:49:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231698AbjCGWtB (ORCPT ); Tue, 7 Mar 2023 17:49:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231785AbjCGWrp (ORCPT ); Tue, 7 Mar 2023 17:47:45 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0EE4B9FE78; Tue, 7 Mar 2023 14:47:08 -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 1D93D7A077D; Tue, 7 Mar 2023 23:46:51 +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 32/32] pata_parport-bpck6: reduce indents in bpck6_open Date: Tue, 7 Mar 2023 23:46:27 +0100 Message-Id: <20230307224627.28011-33-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Reverse error handling conditions to reduce code indents in bpck6_open. Signed-off-by: Ondrej Zary --- drivers/ata/pata_parport/bpck6.c | 48 +++++++++++++++++--------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c index 53d0ad1d6e89..295dbe5cdaa4 100644 --- a/drivers/ata/pata_parport/bpck6.c +++ b/drivers/ata/pata_parport/bpck6.c @@ -318,30 +318,32 @@ static int bpck6_open(struct pi_adapter *pi) j = ((i & 0x08) << 4) | ((i & 0x07) << 3); k = parport_read_status(pi->pardev->port) & 0xB8; - if (j == k) { - parport_frob_control(pi->pardev->port, PARPORT_CONTROL_AUTOFD, 0); - k = (parport_read_status(pi->pardev->port) & 0xB8) ^ 0xB8; - if (j == k) { - if (i & 4) // EPP - parport_frob_control(pi->pardev->port, - PARPORT_CONTROL_SELECT | PARPORT_CONTROL_INIT, 0); - else // PPC/ECP - parport_frob_control(pi->pardev->port, - PARPORT_CONTROL_SELECT, 0); - - pi->private = 0; - - bpck6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE); - bpck6_wr_data_byte(pi, RAMSIZE_128K); - - bpck6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); - if ((bpck6_rd_data_byte(pi) & 0x3F) == 0x0C) - pi->private |= fifo_wait; - - return 1; - } - } + if (j != k) + goto fail; + + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_AUTOFD, 0); + k = (parport_read_status(pi->pardev->port) & 0xB8) ^ 0xB8; + if (j != k) + goto fail; + + if (i & 4) // EPP + parport_frob_control(pi->pardev->port, + PARPORT_CONTROL_SELECT | PARPORT_CONTROL_INIT, 0); + else // PPC/ECP + parport_frob_control(pi->pardev->port, PARPORT_CONTROL_SELECT, 0); + + pi->private = 0; + + bpck6_send_cmd(pi, ACCESS_REG | ACCESS_WRITE | REG_RAMSIZE); + bpck6_wr_data_byte(pi, RAMSIZE_128K); + + bpck6_send_cmd(pi, ACCESS_REG | ACCESS_READ | REG_VERSION); + if ((bpck6_rd_data_byte(pi) & 0x3F) == 0x0C) + pi->private |= fifo_wait; + + return 1; +fail: parport_write_control(pi->pardev->port, pi->saved_r2); parport_write_data(pi->pardev->port, pi->saved_r0);