Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1799279ybt; Sat, 27 Jun 2020 21:32:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ0rWecK8jfVdv+3GZmskBDVXJ+s94Bc62TPdCntsqqSZSSITpfuG/ZWLPQ0ksxt1pamZF X-Received: by 2002:a17:907:4003:: with SMTP id nj3mr7384922ejb.278.1593318734717; Sat, 27 Jun 2020 21:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593318734; cv=none; d=google.com; s=arc-20160816; b=dkQJO5kvDexKMSQL+joe0XKUSExy+pmQeTwr9V5U4xhoc2ZHP1hrdLRcS5kp2al+Mm SewbkCl6mVxAexdTMws9pjAcq0OHplPuaLx1M9g1B49YXJRCq3Bbja2DSZ1nbPjGeA8R hI7uZ/YKj8QVaI2JCk4vbuAccvTpDPhVFqTP+EyUy+F45ylvZ/VFdOVuIiT8EIvSW0B9 04QJPjf3jjsWyNQRS3qByWnOFSRRvU2mJyfp82OQC+JMub0A3cmtGAvAB88V/rS1jWnt I6KYnsJ0SxBmBuHnHU7pOKeas49FEIU/g+XfrsiKcBzGEEgaqd5bEwzmibSqFg62O9DZ wn1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:from:references:in-reply-to :message-id:cc:to; bh=k5o75oTSuE1k0LAkI20nSwfggydpZtaeG3oarU+FtG8=; b=h7sWQuWJx0ewlgaxCdai+ypF40ydEVZRMNl/GRjkSHF2ty7BwXJH9hVGGZRrmKAFS3 0eJwRJ4I0c88x4IHx5XLeLRuN4YzgwVeJfEH0pPcd3visBTEW2GuI4xCvwUOP0F3AXeK omQHq6cVbn3lRJFJ5ReYgAJTS6caGP+z138viv8Wn24i8MTt8DDR99x3ol/QDUWsekr/ uOjztW/wHTsWWCmRqgqgtyv7jErHtY0S2L0B/gNMlqGs3+H+V8MH8EvrN16m3AUJFQjC 9ZmxTrIY+KTaTPQzseMXrYp8dk8Hs8WAJQcwU9InlTMvZ1IEA3aThWgygs6DOBo+mGtD nehA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s23si279313eji.327.2020.06.27.21.31.51; Sat, 27 Jun 2020 21:32:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726066AbgF1Ebq (ORCPT + 99 others); Sun, 28 Jun 2020 00:31:46 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:34264 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725999AbgF1Ebq (ORCPT ); Sun, 28 Jun 2020 00:31:46 -0400 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 4625629708; Sun, 28 Jun 2020 00:31:44 -0400 (EDT) To: Benjamin Herrenschmidt Cc: Joshua Thompson , Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Laurent Vivier , Mark Cave-Ayland , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Message-Id: <0253194363af4426f9788796811a6a29fb87c713.1593318192.git.fthain@telegraphics.com.au> In-Reply-To: References: From: Finn Thain Subject: [PATCH 4/9] macintosh/via-macii: Remove read_done state Date: Sun, 28 Jun 2020 14:23:12 +1000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The driver state machine may enter the 'read_done' state when leaving the 'idle' or 'reading' state. This transition is pointless, as is the extra interrupt it requires. The interrupt is produced by the transceiver (even when it has no data to send) because an extra EVEN/ODD toggle was signalled by the driver. Drop the extra state to simplify the code. Fixes: 1da177e4c3f41 ("Linux-2.6.12-rc2") # v5.0+ Tested-by: Stan Johnson Signed-off-by: Finn Thain --- drivers/macintosh/via-macii.c | 70 ++++++++++++++--------------------- 1 file changed, 28 insertions(+), 42 deletions(-) diff --git a/drivers/macintosh/via-macii.c b/drivers/macintosh/via-macii.c index 6a5cd7de05baf..d29c87943ca46 100644 --- a/drivers/macintosh/via-macii.c +++ b/drivers/macintosh/via-macii.c @@ -110,7 +110,6 @@ static enum macii_state { idle, sending, reading, - read_done, } macii_state; static struct adb_request *current_req; /* first request struct in the queue */ @@ -411,8 +410,8 @@ static irqreturn_t macii_interrupt(int irq, void *arg) reply_len = 1; } else { /* bus timeout */ - macii_state = read_done; reply_len = 0; + break; } /* set ADB state = even for first data byte */ @@ -471,20 +470,6 @@ static irqreturn_t macii_interrupt(int irq, void *arg) current_req = req->next; if (req->done) (*req->done)(req); - - if (!current_req) - macii_queue_poll(); - - if (current_req && macii_state == idle) - macii_start(); - - if (macii_state == idle) { - /* reset to shift in */ - via[ACR] &= ~SR_OUT; - x = via[SR]; - /* set ADB state idle - might get SRQ */ - via[B] = (via[B] & ~ST_MASK) | ST_IDLE; - } break; } } else { @@ -511,12 +496,28 @@ static irqreturn_t macii_interrupt(int irq, void *arg) } else if (status == ST_ODD && reply_len == 2) { srq_asserted = true; } else { - macii_state = read_done; + macii_state = idle; + + if (bus_timeout) + reply_len = 0; + + if (reading_reply) { + struct adb_request *req = current_req; + + req->reply_len = reply_len; + + req->complete = 1; + current_req = req->next; + if (req->done) + (*req->done)(req); + } else if (reply_len && autopoll_devs) { + adb_input(reply_buf, reply_len, 0); + } + break; } } - if (macii_state == reading && - reply_len < ARRAY_SIZE(reply_buf)) { + if (reply_len < ARRAY_SIZE(reply_buf)) { reply_ptr++; *reply_ptr = x; reply_len++; @@ -526,37 +527,22 @@ static irqreturn_t macii_interrupt(int irq, void *arg) via[B] ^= ST_MASK; break; - case read_done: - x = via[SR]; - - if (bus_timeout) - reply_len = 0; - - if (reading_reply) { - reading_reply = 0; - req = current_req; - req->reply_len = reply_len; - req->complete = 1; - current_req = req->next; - if (req->done) - (*req->done)(req); - } else if (reply_len && autopoll_devs) - adb_input(reply_buf, reply_len, 0); - - macii_state = idle; + default: + break; + } + if (macii_state == idle) { if (!current_req) macii_queue_poll(); if (current_req) macii_start(); - if (macii_state == idle) + if (macii_state == idle) { + via[ACR] &= ~SR_OUT; + x = via[SR]; via[B] = (via[B] & ~ST_MASK) | ST_IDLE; - break; - - default: - break; + } } local_irq_restore(flags); -- 2.26.2