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: 65945 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp10085wrd; Tue, 7 Mar 2023 15:03:08 -0800 (PST) X-Google-Smtp-Source: AK7set8Miblp6i1KGtWC50J8Wjm4CSYkdjlaHm2muPCHZaFj0dY6iR876eeGgyT3vkRRjk8t7wtM X-Received: by 2002:a17:906:1846:b0:8b2:abcd:624 with SMTP id w6-20020a170906184600b008b2abcd0624mr16645166eje.0.1678230187927; Tue, 07 Mar 2023 15:03:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678230187; cv=none; d=google.com; s=arc-20160816; b=sKw5G9mtqammRKRGvbu/RZmOG1GxhF+tPsveWkPHusoKgsqrEtdbq+WbSvgtksNrJx xIu8j4v+0Jan3eEZF8NJlwXZTFJAmlcGNuWhw+UpkZy0bg8g7AJ2PVFLHe2d1fB34t0E ET/Vq0K4cdF3850hKWtf34Xx8rNZb7O6PME4nUfd43iEM5W/HFPIHTENLtN90sY2zCj4 15o22iRHmVuZ5TOlipsg811mfJud+B55KUpTp+iadsTBeuuBpiPC0Amdx6vSLLu1WTr+ qUBEUbZW/hRLmSyww9kA0cwLlKvcyOINIv9l9pd6PBdLybPMqwVecNDJtRCFJqucjJEf i9QQ== 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=bmnmdtfVFepOxoEo5OHMVl/RXseDjw6Xwe0hy4SP0lA=; b=qaeOrhUtKAewWGUjM8ZV1uR/gf04k9f7VTIZEUIZvepcOroS5X7XYgCgvJA/GL278P 7+5NCM7dxvMfuROWkK0Dsctv9UfBxWyO9DWeAvVgCbkcAS+e4bhMB7xMI9hHjGictwfS i8u/7hYqWLrUSQNAn8NKTgVFO54qB268WZpRD+mRcS1Xq8Kd3DXejvIiVAOWjz3FnKhf Ttxy4FhJdNvHIPE5L2wB4nAqw6TvKprcNch6BFu0Zpbmf456GC838JTxNGCWk4MqGB9L qg0mo8ERlFD/zYXSuXWneJghpaAS2RzjcV8tW2omwQOqes9wSWJ+IvbppXMX7bbonlaL dzhg== 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 f3-20020a05640214c300b004be3964ffdcsi13937689edx.517.2023.03.07.15.02.42; Tue, 07 Mar 2023 15:03:07 -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 S230298AbjCGWrv (ORCPT + 99 others); Tue, 7 Mar 2023 17:47:51 -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 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?1759751897185747279?= X-GMAIL-MSGID: =?utf-8?q?1759751897185747279?= 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);