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: 65943 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp9995wrd; Tue, 7 Mar 2023 15:02:56 -0800 (PST) X-Google-Smtp-Source: AK7set++Wadzjp7tgOjfvv+Opioc8RH+bb9s0JgeIU6NTz2tm5e6jZV4WJljT143w/aGSpTPffPo X-Received: by 2002:aa7:c242:0:b0:4ab:4c5e:b0ed with SMTP id y2-20020aa7c242000000b004ab4c5eb0edmr13405494edo.21.1678230175954; Tue, 07 Mar 2023 15:02:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678230175; cv=none; d=google.com; s=arc-20160816; b=POhyNSmd7rgUqDORr1Pz+rqNTkSsiqcOrLaZUxwZMAD/fcyj+9ttpoo2v8inzY2WP0 jwohx/vG5xQFE+gfTZJPn00y8ZmDaTFpHNYgjCVH9eLnUYp7uI/xSFdZEwjvhIR+432s ll6x9NYV5bWg8hrGm9BovRGZI45qUJ040hSUIHvXBl2utQasT9Zw8dEG44BfAAa6duoZ UEO1hzjL9KbgDiWlSQkW2kOv9lLM6kskfQO9NKi+Js0C2KAhxY+0SJugGShOFLVz4F2b dIa+nbaoW4VwMcesdE8X0rlISMkgfSVXds+iPW1Rs8RRbf4hL4v1BWfwSiKagmc27QOh X7ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QnMAL0mZLt1Ug+TVzDC7CHMVPSjIHLEIDgKl9uJKA10=; b=LUPh+7yg1hoxUbpqEtBCCJ68HjHzyNql616nWEUzY20H9ylwZB2fIVMklEsjQ4ZinT EVXohvQmC8l+Nhlo17zu/aGcchBtg+48JemdBmgoP9A240UIiAuk68kjD1VhFpQjrpOh Od8vphxuxbEej5NTfUW42Yzczy3QZYtDN0+DBEjiFtTAWKvX2uN26t3P4IY/1QiZggnJ uozdGS6Kjt9hI9ohxvP0OkRmklHZlvVXr3b16hl9JVp8oO2qr8KPA8BHAcM9xLbqlXsQ 1n4gMJqg13h/OUALI4OYL06SKUSe7Ne0TWw/KKHMAdzJwjQhA/ngH4qiuRl8TFdfn+kr oPJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o3-20020a170906768300b008c673be343dsi13789594ejm.612.2023.03.07.15.02.29; Tue, 07 Mar 2023 15:02:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231154AbjCGWrc (ORCPT + 99 others); Tue, 7 Mar 2023 17:47:32 -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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759751884944606697?= X-GMAIL-MSGID: =?utf-8?q?1759751884944606697?= 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 :