From: Finn Thain <fthain@telegraphics.com.au>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: <linuxppc-dev@lists.ozlabs.org>,
<linux-m68k@lists.linux-m68k.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 4/7] macintosh/via-macii: Remove BUG_ON assertions
Date: Tue, 11 Sep 2018 20:18:44 -0400 (EDT) [thread overview]
Message-ID: <40e706689c8fb6e2adfed4a4d2794f5f8ff384d1.1536709753.git.fthain@telegraphics.com.au> (raw)
In-Reply-To: <cover.1536709753.git.fthain@telegraphics.com.au>
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 <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
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
next prev parent reply other threads:[~2018-09-12 0:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-12 0:18 [PATCH 0/7] Miscellaneous Macintosh fixes and clean up Finn Thain
2018-09-12 0:18 ` [PATCH 6/7] macintosh/via-macii, macintosh/adb-iop: Modernize printk calls Finn Thain
2018-09-12 0:18 ` [PATCH 5/7] macintosh/via-macii: Simplify locking Finn Thain
2018-09-12 0:18 ` [PATCH 3/7] macintosh/via-macii: Synchronous bus reset Finn Thain
2018-09-12 0:18 ` [PATCH 2/7] macintosh/adb: Rework printk output again Finn Thain
2018-09-12 0:18 ` [PATCH 7/7] macintosh/via-macii, macintosh/adb-iop: Clean up whitespace Finn Thain
2018-09-12 0:18 ` Finn Thain [this message]
2018-09-12 0:18 ` [PATCH 1/7] macintosh: Use common code to access RTC Finn Thain
2018-10-04 13:05 ` Geert Uytterhoeven
2018-10-15 4:00 ` [1/7] " Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40e706689c8fb6e2adfed4a4d2794f5f8ff384d1.1536709753.git.fthain@telegraphics.com.au \
--to=fthain@telegraphics.com.au \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®