[PATCH 11/14] net: plip: return proper error values from attach

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



now that we are monitoring the return value from attach, make the
required changes to return proper value from its attach function.
also return the proper error code in module_init.

Signed-off-by: Sudip Mukherjee <sudip@xxxxxxxxxxxxxxx>
---
 drivers/net/plip/plip.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/plip/plip.c b/drivers/net/plip/plip.c
index 040b897..6706bc3 100644
--- a/drivers/net/plip/plip.c
+++ b/drivers/net/plip/plip.c
@@ -1243,7 +1243,7 @@ plip_searchfor(int list[], int a)
 
 /* plip_attach() is called (by the parport code) when a port is
  * available to use. */
-static void plip_attach (struct parport *port)
+static int plip_attach(struct parport *port)
 {
 	static int unit;
 	struct net_device *dev;
@@ -1254,13 +1254,13 @@ static void plip_attach (struct parport *port)
 	    plip_searchfor(parport, port->number)) {
 		if (unit == PLIP_MAX) {
 			printk(KERN_ERR "plip: too many devices\n");
-			return;
+			return -EINVAL;
 		}
 
 		sprintf(name, "plip%d", unit);
 		dev = alloc_etherdev(sizeof(struct net_local));
 		if (!dev)
-			return;
+			return -ENOMEM;
 
 		strcpy(dev->name, name);
 
@@ -1300,12 +1300,13 @@ static void plip_attach (struct parport *port)
 					 dev->name, dev->base_addr);
 		dev_plip[unit++] = dev;
 	}
-	return;
+	return 0;
 
 err_parport_unregister:
 	parport_unregister_device(nl->pardev);
 err_free_dev:
 	free_netdev(dev);
+	return -ENODEV;
 }
 
 /* plip_detach() is called (by the parport code) when a port is
@@ -1379,6 +1380,8 @@ __setup("plip=", plip_setup);
 
 static int __init plip_init (void)
 {
+	int err;
+
 	if (parport[0] == -2)
 		return 0;
 
@@ -1387,9 +1390,10 @@ static int __init plip_init (void)
 		timid = 0;
 	}
 
-	if (parport_register_driver (&plip_driver)) {
+	err = parport_register_driver(&plip_driver);
+	if (err) {
 		printk (KERN_WARNING "plip: couldn't register driver\n");
-		return 1;
+		return err;
 	}
 
 	return 0;
-- 
1.8.1.2

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux