[PCMCIA] Check return status of register calls in i82365
diff mbox series

Message ID 20040521115529.GA1408@gondor.apana.org.au
State New, archived
Headers show
Series
  • [PCMCIA] Check return status of register calls in i82365
Related show

Commit Message

Herbert Xu May 21, 2004, 11:55 a.m. UTC
Hi:

i82365 calls driver_register and platform_device_register without
checking their return values.  This patch fixes that.

Cheers,

Comments

Andrew Morton May 21, 2004, 11:41 p.m. UTC | #1
Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> i82365 calls driver_register and platform_device_register without
> checking their return values.  This patch fixes that.

It does more than that - you've also changed it to run platform_device_register()
prior to isa_probe().  How come?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Herbert Xu May 21, 2004, 11:46 p.m. UTC | #2
On Fri, May 21, 2004 at 04:41:11PM -0700, Andrew Morton wrote:
> Herbert Xu <herbert@gondor.apana.org.au> wrote:
> >
> > i82365 calls driver_register and platform_device_register without
> > checking their return values.  This patch fixes that.
> 
> It does more than that - you've also changed it to run platform_device_register()
> prior to isa_probe().  How come?

1. The platform device being registered is a place-holder that does not
   rely on the probing at all.
2. If it was done after the probe then should the registration fail, we'll
   have to roll back all the changes done by isa_probe().

Cheers,

Patch
diff mbox series

diff -Nru a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
--- a/drivers/pcmcia/i82365.c	Fri May 21 21:53:42 2004
+++ b/drivers/pcmcia/i82365.c	Fri May 21 21:53:42 2004
@@ -1372,8 +1372,15 @@ 
 {
     int i, ret;
 
-    if (driver_register(&i82365_driver))
-	return -1;
+    ret = driver_register(&i82365_driver);
+    if (ret)
+	return ret;
+
+    ret = platform_device_register(&i82365_device);
+    if (ret) {
+	driver_unregister(&i82365_driver);
+	return ret;
+    }
 
     printk(KERN_INFO "Intel ISA PCIC probe: ");
     sockets = 0;
@@ -1382,11 +1389,10 @@ 
 
     if (sockets == 0) {
 	printk("not found.\n");
+	platform_device_unregister(&i82365_device);
 	driver_unregister(&i82365_driver);
 	return -ENODEV;
     }
-
-    platform_device_register(&i82365_device);
 
     /* Set up interrupt handler(s) */
     if (grab_irq != 0)