netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* register_netdevice return val fix
@ 2003-10-19  2:00 Andrew Morton
  2003-10-19  7:07 ` David S. Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Morton @ 2003-10-19  2:00 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev



If the driver's init function returns an error code (most likely -ENODEV),
register_netdevice will stomp on it and will always return -EIO.

You end up always getting an "Input/Output error" from modprobe, which is
confusing.

Fix register_netdevice() to return the init function's error code, if it
looks sane.



 net/core/dev.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff -puN net/core/dev.c~register_netdevice-retval-fix net/core/dev.c
--- 25/net/core/dev.c~register_netdevice-retval-fix	2003-10-18 18:50:52.000000000 -0700
+++ 25-akpm/net/core/dev.c	2003-10-18 18:51:39.000000000 -0700
@@ -2652,9 +2652,14 @@ int register_netdevice(struct net_device
 	dev->iflink = -1;
 
 	/* Init, if this function is available */
-	ret = -EIO;
-	if (dev->init && dev->init(dev))
-		goto out_err;
+	if (dev->init) {
+		ret = dev->init(dev);
+		if (ret) {
+			if (ret > 0)
+				ret = -EIO;
+			goto out_err;
+		}
+	}
 
 	dev->ifindex = dev_new_index();
 	if (dev->iflink == -1)

_

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: register_netdevice return val fix
  2003-10-19  2:00 register_netdevice return val fix Andrew Morton
@ 2003-10-19  7:07 ` David S. Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2003-10-19  7:07 UTC (permalink / raw)
  To: Andrew Morton; +Cc: netdev

On Sat, 18 Oct 2003 19:00:14 -0700
Andrew Morton <akpm@osdl.org> wrote:

> If the driver's init function returns an error code (most likely -ENODEV),
> register_netdevice will stomp on it and will always return -EIO.
> 
> You end up always getting an "Input/Output error" from modprobe, which is
> confusing.
> 
> Fix register_netdevice() to return the init function's error code, if it
> looks sane.

Looks fine, applied.

Thanks Andrew.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-10-19  7:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-19  2:00 register_netdevice return val fix Andrew Morton
2003-10-19  7:07 ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).