linux-mips
[Top] [All Lists]

[PATCH] dz.c: Don't panic() when request_irq() fails

To: Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] dz.c: Don't panic() when request_irq() fails
From: "Maciej W. Rozycki" <macro@linux-mips.org>
Date: Fri, 19 Oct 2007 21:24:16 +0100 (BST)
Cc: linux-mips@linux-mips.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
 Well, panic() is a little bit undue if request_irq() fails; there is 
probably no need to justify it any further.  Handle the case gracefully, 
by unregistering the driver.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
 Tested with checkpatch.pl and at the run-time -- MIPS/Linux on a
DECstation 5000/200.

 Please apply,

  Maciej

patch-mips-2.6.18-20060920-dz-init-0
diff -up --recursive --new-file 
linux-mips-2.6.18-20060920.macro/drivers/serial/dz.c 
linux-mips-2.6.18-20060920/drivers/serial/dz.c
--- linux-mips-2.6.18-20060920.macro/drivers/serial/dz.c        2006-11-23 
05:17:01.000000000 +0000
+++ linux-mips-2.6.18-20060920/drivers/serial/dz.c      2007-01-14 
00:39:20.000000000 +0000
@@ -795,18 +795,28 @@ static int __init dz_init(void)
        dz_reset(&dz_ports[0]);
 #endif
 
-       if (request_irq(dz_ports[0].port.irq, dz_interrupt,
-                       IRQF_DISABLED, "DZ", &dz_ports[0]))
-               panic("Unable to register DZ interrupt");
-
        ret = uart_register_driver(&dz_reg);
        if (ret != 0)
-               return ret;
+               goto out;
+
+       ret = request_irq(dz_ports[0].port.irq, dz_interrupt, IRQF_DISABLED,
+                         "DZ", &dz_ports[0]);
+       if (ret != 0) {
+               printk(KERN_ERR "dz: Cannot get IRQ %d!\n",
+                      dz_ports[0].port.irq);
+               goto out_unregister;
+       }
 
        for (i = 0; i < DZ_NB_PORT; i++)
                uart_add_one_port(&dz_reg, &dz_ports[i].port);
 
        return ret;
+
+out_unregister:
+       uart_unregister_driver(&dz_reg);
+
+out:
+       return ret;
 }
 
 module_init(dz_init);

<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH] dz.c: Don't panic() when request_irq() fails, Maciej W. Rozycki <=