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: 65923 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp5199wrd; Tue, 7 Mar 2023 14:51:26 -0800 (PST) X-Google-Smtp-Source: AK7set/aAIUvZbwKaS9meqNK07T8vFwQ668u6Cb3rFaZvPQ2OkwruhqFSH/RpUjkXKO+xCF25Ir9 X-Received: by 2002:a05:6a20:3d0c:b0:cb:6e5d:6ce0 with SMTP id y12-20020a056a203d0c00b000cb6e5d6ce0mr18761911pzi.37.1678229485819; Tue, 07 Mar 2023 14:51:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678229485; cv=none; d=google.com; s=arc-20160816; b=AW2ndFMBev+NI8PXaNTSLyTvn2hf9s/7pg6h2t6zWqia/EG4hP0MPCSHHsjMVebbti 9HYphijMcg41yvhCDVo3J8DqTr3/xw1zaDvr16gTwbYm1mgIKskqLGgzPTPRCtwZtpd6 wNn+cs3rbFitSycvhzYPMHSkcTtyMzfLchg1SOJdanNk/bX1KXK7FGkKnWP54TCJe+eD V+giaj5lSRMhZTJko0xrNBy6oAlrMA4uh3iQYRn+CW+8fR9ne9c/JdEO9uoxrYGkVpFZ KuFMRCyurzjFU9CnwtOHfy4KuZkDgf9TH+mQIiQe+p1UBeTnr+mzRhadT/d8ZHJ1wZ0E sypA== 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=FjLw3tJWeMmwqBXrfiXe9xRjRfRTupvFBhxF2WmWBFg=; b=LmFnWbz6BBez9w98/4UEjy2fG8ozl1L0OxvvI5PdXCK2TV1RSZQfWrxqNgEPkhK2Ae +lxQvF52XX0r4c26sVdjbiHGWxoUSlBNPHB3eq6u/CcDmNvKnNGnPp2PPwfcFlKRKZl8 7IAGvBUm4c9R89NgzXH+ujsUFrP0EzMjmQRVLg9inspXCUH60Bpew4hU+bwfHpOeW42A e7kP2Dyd9Css686snfM4JklQGiSEJdveQArbTzqpTo8TFJ+IRZDQuSIZIBZW6ejJUTcG EdoJDwZpEetGJp45tj6VgYXBnW2VAVsYkFwO18z8LqysIziwoLOhQg2nOCa0C+JXzhf0 VeUg== 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 r20-20020aa79634000000b005a85dd25ce3si13309435pfg.132.2023.03.07.14.51.13; Tue, 07 Mar 2023 14:51:25 -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 S231842AbjCGWs2 (ORCPT + 99 others); Tue, 7 Mar 2023 17:48:28 -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 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?1759751161580536806?= X-GMAIL-MSGID: =?utf-8?q?1759751161580536806?= 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)