Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4739201imm; Tue, 11 Sep 2018 17:20:02 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaRVzSqgJVcYRIJpW+TAejPv/zKMYEs1Ja4PeD4tgEa+j8hvVFjP9IXr1kRZU2OJiyX9p8u X-Received: by 2002:a65:6109:: with SMTP id z9-v6mr31178933pgu.243.1536711602036; Tue, 11 Sep 2018 17:20:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536711602; cv=none; d=google.com; s=arc-20160816; b=wlD2DT97LP7nxmT1RRb5xxRu0+vOz75b7Eqj7o6fmB8+RghkvXCYPdb/O5VRUYuAi/ zzW2AHVubBaO15BGWVNeaH2Mx567JozGalxpqqp9eDxoZyb+Ntrt8/fvvW05MWD+725n 2PfHX+XPMg+kByIC5DOaybeOuJpfzC9LUc5SHE7d3cDhdcGWtitnAdxMyLp/Zs+2Uipx 4Anj4WGlSA4GGTaTTkhAtgf8WrREf7Ms6yDyZIWlIattnOb8F+sWDyoprmVb8xrX8hWw PH3r7J6fWxSab4i+QcN+ouFUN/hEdbcSPwpKP2jzCxRyfhBlwm8OHiqgIMaXI2e+D03g hXhA== 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=4lfYIdjw5Jfk/7dKGmeFmE022b7Cf85GOOLb04rQngU=; b=phYUJ1O3dnus+qGdJZZG9baWNoOToc0GAqXTpgBzN4Y9YkYZWqruXOZSr3acqYUQLO cdsKEbORzXQuVV4ehD020Ij7lkIIIjbIzy2B4CHBjpZNrbqZ9HXtUz7A699hMu4NLuqn QGVpy6jT311pNBUCrtQI7S/zmuygzz4lhNqYnNS7hoUL7cJ/ceHtr329/rYthSi3mNDM 0yCbtmE/QYnRRkbVwStnmhhLXdR1JJw9JmzRdsalCl1XaorzeSKAI4IZMI6SvFJqK/Or m1H3HB+5idAZP4hS3HVcpYi+NDezUErbNam19dOwfr20Ct+nakIlHj2+Vab0hxNvXNhb aYcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s184-v6si21339011pgb.123.2018.09.11.17.19.47; Tue, 11 Sep 2018 17:20:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728007AbeILFUw (ORCPT + 99 others); Wed, 12 Sep 2018 01:20:52 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:51530 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727413AbeILFUa (ORCPT ); Wed, 12 Sep 2018 01:20:30 -0400 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 3C3672A7D2; Tue, 11 Sep 2018 20:18:44 -0400 (EDT) To: Benjamin Herrenschmidt Cc: , , Message-Id: <40e706689c8fb6e2adfed4a4d2794f5f8ff384d1.1536709753.git.fthain@telegraphics.com.au> In-Reply-To: References: From: Finn Thain Subject: [PATCH 4/7] macintosh/via-macii: Remove BUG_ON assertions Date: Tue, 11 Sep 2018 20:18:44 -0400 (EDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The BUG_ON assertions I added to the via-macii driver over a decade ago haven't fired AFAIK. Some can never fire (by inspection). One assertion checks for a NULL pointer, but that would merely substitute a BUG crash for an Oops crash. Remove the pointless BUG_ON assertions and replace the others with a WARN_ON and an array bounds check. Tested-by: Stan Johnson Signed-off-by: Finn Thain --- drivers/macintosh/via-macii.c | 49 +++++++------------------------------------ 1 file changed, 7 insertions(+), 42 deletions(-) diff --git a/drivers/macintosh/via-macii.c b/drivers/macintosh/via-macii.c index 36a4f49e79b5..7e0e32fa7eb2 100644 --- a/drivers/macintosh/via-macii.c +++ b/drivers/macintosh/via-macii.c @@ -120,23 +120,6 @@ static int srq_asserted; /* have to poll for the device that asserted it */ static int command_byte; /* the most recent command byte transmitted */ static int autopoll_devs; /* bits set are device addresses to be polled */ -/* Sanity check for request queue. Doesn't check for cycles. */ -static int request_is_queued(struct adb_request *req) { - struct adb_request *cur; - unsigned long flags; - local_irq_save(flags); - cur = current_req; - while (cur) { - if (cur == req) { - local_irq_restore(flags); - return 1; - } - cur = cur->next; - } - local_irq_restore(flags); - return 0; -} - /* Check for MacII style ADB */ static int macii_probe(void) { @@ -213,8 +196,6 @@ static void macii_queue_poll(void) else next_device = ffs(autopoll_devs) - 1; - BUG_ON(request_is_queued(&req)); - adb_request(&req, NULL, ADBREQ_NOSEND, 1, ADB_READREG(next_device, 0)); @@ -237,18 +218,13 @@ static int macii_send_request(struct adb_request *req, int sync) int err; unsigned long flags; - BUG_ON(request_is_queued(req)); - local_irq_save(flags); err = macii_write(req); local_irq_restore(flags); - if (!err && sync) { - while (!req->complete) { + if (!err && sync) + while (!req->complete) macii_poll(); - } - BUG_ON(request_is_queued(req)); - } return err; } @@ -327,9 +303,6 @@ static int macii_reset_bus(void) { static struct adb_request req; - if (request_is_queued(&req)) - return 0; - /* Command = 0, Address = ignored */ adb_request(&req, NULL, ADBREQ_NOSEND, 1, ADB_BUSRESET); macii_send_request(&req, 1); @@ -347,10 +320,6 @@ static void macii_start(void) req = current_req; - BUG_ON(req == NULL); - - BUG_ON(macii_state != idle); - /* Now send it. Be careful though, that first byte of the request * is actually ADB_PACKET; the real data begins at index 1! * And req->nbytes is the number of bytes of real data plus one. @@ -388,7 +357,6 @@ static void macii_start(void) static irqreturn_t macii_interrupt(int irq, void *arg) { int x; - static int entered; struct adb_request *req; if (!arg) { @@ -399,8 +367,6 @@ static irqreturn_t macii_interrupt(int irq, void *arg) return IRQ_NONE; } - BUG_ON(entered++); - last_status = status; status = via[B] & (ST_MASK|CTLR_IRQ); @@ -409,7 +375,7 @@ static irqreturn_t macii_interrupt(int irq, void *arg) if (reading_reply) { reply_ptr = current_req->reply; } else { - BUG_ON(current_req != NULL); + WARN_ON(current_req); reply_ptr = reply_buf; } @@ -474,8 +440,8 @@ static irqreturn_t macii_interrupt(int irq, void *arg) case reading: x = via[SR]; - BUG_ON((status & ST_MASK) == ST_CMD || - (status & ST_MASK) == ST_IDLE); + WARN_ON((status & ST_MASK) == ST_CMD || + (status & ST_MASK) == ST_IDLE); /* Bus timeout with SRQ sequence: * data is "XX FF" while CTLR_IRQ is "L L" @@ -502,8 +468,8 @@ static irqreturn_t macii_interrupt(int irq, void *arg) } } - if (macii_state == reading) { - BUG_ON(reply_len > 15); + if (macii_state == reading && + reply_len < ARRAY_SIZE(reply_buf)) { reply_ptr++; *reply_ptr = x; reply_len++; @@ -546,6 +512,5 @@ static irqreturn_t macii_interrupt(int irq, void *arg) break; } - entered--; return IRQ_HANDLED; } -- 2.16.4