macintosh/via-macii: Remove BUG_ON assertions
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> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
parent
b52dce8738
commit
5f93d7081a
|
@ -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 command_byte; /* the most recent command byte transmitted */
|
||||||
static int autopoll_devs; /* bits set are device addresses to be polled */
|
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 */
|
/* Check for MacII style ADB */
|
||||||
static int macii_probe(void)
|
static int macii_probe(void)
|
||||||
{
|
{
|
||||||
|
@ -213,8 +196,6 @@ static void macii_queue_poll(void)
|
||||||
else
|
else
|
||||||
next_device = ffs(autopoll_devs) - 1;
|
next_device = ffs(autopoll_devs) - 1;
|
||||||
|
|
||||||
BUG_ON(request_is_queued(&req));
|
|
||||||
|
|
||||||
adb_request(&req, NULL, ADBREQ_NOSEND, 1,
|
adb_request(&req, NULL, ADBREQ_NOSEND, 1,
|
||||||
ADB_READREG(next_device, 0));
|
ADB_READREG(next_device, 0));
|
||||||
|
|
||||||
|
@ -237,18 +218,13 @@ static int macii_send_request(struct adb_request *req, int sync)
|
||||||
int err;
|
int err;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
BUG_ON(request_is_queued(req));
|
|
||||||
|
|
||||||
local_irq_save(flags);
|
local_irq_save(flags);
|
||||||
err = macii_write(req);
|
err = macii_write(req);
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
|
|
||||||
if (!err && sync) {
|
if (!err && sync)
|
||||||
while (!req->complete) {
|
while (!req->complete)
|
||||||
macii_poll();
|
macii_poll();
|
||||||
}
|
|
||||||
BUG_ON(request_is_queued(req));
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -327,9 +303,6 @@ static int macii_reset_bus(void)
|
||||||
{
|
{
|
||||||
static struct adb_request req;
|
static struct adb_request req;
|
||||||
|
|
||||||
if (request_is_queued(&req))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Command = 0, Address = ignored */
|
/* Command = 0, Address = ignored */
|
||||||
adb_request(&req, NULL, ADBREQ_NOSEND, 1, ADB_BUSRESET);
|
adb_request(&req, NULL, ADBREQ_NOSEND, 1, ADB_BUSRESET);
|
||||||
macii_send_request(&req, 1);
|
macii_send_request(&req, 1);
|
||||||
|
@ -347,10 +320,6 @@ static void macii_start(void)
|
||||||
|
|
||||||
req = current_req;
|
req = current_req;
|
||||||
|
|
||||||
BUG_ON(req == NULL);
|
|
||||||
|
|
||||||
BUG_ON(macii_state != idle);
|
|
||||||
|
|
||||||
/* Now send it. Be careful though, that first byte of the request
|
/* Now send it. Be careful though, that first byte of the request
|
||||||
* is actually ADB_PACKET; the real data begins at index 1!
|
* is actually ADB_PACKET; the real data begins at index 1!
|
||||||
* And req->nbytes is the number of bytes of real data plus one.
|
* 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)
|
static irqreturn_t macii_interrupt(int irq, void *arg)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
static int entered;
|
|
||||||
struct adb_request *req;
|
struct adb_request *req;
|
||||||
|
|
||||||
if (!arg) {
|
if (!arg) {
|
||||||
|
@ -399,8 +367,6 @@ static irqreturn_t macii_interrupt(int irq, void *arg)
|
||||||
return IRQ_NONE;
|
return IRQ_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BUG_ON(entered++);
|
|
||||||
|
|
||||||
last_status = status;
|
last_status = status;
|
||||||
status = via[B] & (ST_MASK|CTLR_IRQ);
|
status = via[B] & (ST_MASK|CTLR_IRQ);
|
||||||
|
|
||||||
|
@ -409,7 +375,7 @@ static irqreturn_t macii_interrupt(int irq, void *arg)
|
||||||
if (reading_reply) {
|
if (reading_reply) {
|
||||||
reply_ptr = current_req->reply;
|
reply_ptr = current_req->reply;
|
||||||
} else {
|
} else {
|
||||||
BUG_ON(current_req != NULL);
|
WARN_ON(current_req);
|
||||||
reply_ptr = reply_buf;
|
reply_ptr = reply_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,8 +440,8 @@ static irqreturn_t macii_interrupt(int irq, void *arg)
|
||||||
|
|
||||||
case reading:
|
case reading:
|
||||||
x = via[SR];
|
x = via[SR];
|
||||||
BUG_ON((status & ST_MASK) == ST_CMD ||
|
WARN_ON((status & ST_MASK) == ST_CMD ||
|
||||||
(status & ST_MASK) == ST_IDLE);
|
(status & ST_MASK) == ST_IDLE);
|
||||||
|
|
||||||
/* Bus timeout with SRQ sequence:
|
/* Bus timeout with SRQ sequence:
|
||||||
* data is "XX FF" while CTLR_IRQ is "L L"
|
* 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) {
|
if (macii_state == reading &&
|
||||||
BUG_ON(reply_len > 15);
|
reply_len < ARRAY_SIZE(reply_buf)) {
|
||||||
reply_ptr++;
|
reply_ptr++;
|
||||||
*reply_ptr = x;
|
*reply_ptr = x;
|
||||||
reply_len++;
|
reply_len++;
|
||||||
|
@ -546,6 +512,5 @@ static irqreturn_t macii_interrupt(int irq, void *arg)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
entered--;
|
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user