* [PATCH] Cleanup usbnet_probe() return value handling
@ 2007-07-02 15:40 Peter Korsgaard
2007-07-02 16:14 ` David Brownell
0 siblings, 1 reply; 5+ messages in thread
From: Peter Korsgaard @ 2007-07-02 15:40 UTC (permalink / raw)
To: netdev; +Cc: dbrownell
usbnet_probe() handles a positive return value from the driver bind()
function as success, but will later only setup the status handler if the
return value was zero, leading to confusion. Patch adjusts this to only
accept 0 as success in both checks.
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
drivers/net/usb/usbnet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6.22-rc7/drivers/net/usb/usbnet.c
===================================================================
--- linux-2.6.22-rc7.orig/drivers/net/usb/usbnet.c
+++ linux-2.6.22-rc7/drivers/net/usb/usbnet.c
@@ -1182,7 +1182,7 @@
// NOTE net->name still not usable ...
if (info->bind) {
status = info->bind (dev, udev);
- if (status < 0)
+ if (status != 0)
goto out1;
// heuristic: "usb%d" for links we know are two-host,
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Cleanup usbnet_probe() return value handling
2007-07-02 15:40 [PATCH] Cleanup usbnet_probe() return value handling Peter Korsgaard
@ 2007-07-02 16:14 ` David Brownell
2007-07-02 22:46 ` Peter Korsgaard
0 siblings, 1 reply; 5+ messages in thread
From: David Brownell @ 2007-07-02 16:14 UTC (permalink / raw)
To: Peter Korsgaard; +Cc: netdev, dbrownell
On Monday 02 July 2007, Peter Korsgaard wrote:
> usbnet_probe() handles a positive return value from the driver bind()
> function as success, but will later only setup the status handler if the
> return value was zero, leading to confusion. Patch adjusts this to only
> accept 0 as success in both checks.
I'd rather see the later test updated to match this one.
(Good catch!)
The return convention is "negative means error". There's
code in USB which has multiple nonnegative success codes.
In particular usb_control_msg(), which would very naturally
used as the body of a bind() method, returns negative or
the number of bytes transferred.
- Dave
> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
> ---
> drivers/net/usb/usbnet.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: linux-2.6.22-rc7/drivers/net/usb/usbnet.c
> ===================================================================
> --- linux-2.6.22-rc7.orig/drivers/net/usb/usbnet.c
> +++ linux-2.6.22-rc7/drivers/net/usb/usbnet.c
> @@ -1182,7 +1182,7 @@
> // NOTE net->name still not usable ...
> if (info->bind) {
> status = info->bind (dev, udev);
> - if (status < 0)
> + if (status != 0)
> goto out1;
>
> // heuristic: "usb%d" for links we know are two-host,
>
> --
> Bye, Peter Korsgaard
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Cleanup usbnet_probe() return value handling
2007-07-02 16:14 ` David Brownell
@ 2007-07-02 22:46 ` Peter Korsgaard
2007-07-04 4:34 ` David Brownell
2007-07-10 16:42 ` Jeff Garzik
0 siblings, 2 replies; 5+ messages in thread
From: Peter Korsgaard @ 2007-07-02 22:46 UTC (permalink / raw)
To: David Brownell; +Cc: netdev, dbrownell
>>>>> "David" == David Brownell <david-b@pacbell.net> writes:
Hi,
David> I'd rather see the later test updated to match this one.
David> (Good catch!)
David> The return convention is "negative means error". There's
David> code in USB which has multiple nonnegative success codes.
Ok, updated patch does that instead.
David> In particular usb_control_msg(), which would very naturally
David> used as the body of a bind() method, returns negative or
David> the number of bytes transferred.
Yeah, that was the original problem in my dm9601 driver.
usbnet_probe() handles a positive return value from the driver bind()
function as success, but will later only setup the status handler if the
return value was zero, leading to confusion. Patch adjusts this to accept
positive values as success in both checks.
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
drivers/net/usb/usbnet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6.22-rc7/drivers/net/usb/usbnet.c
===================================================================
--- linux-2.6.22-rc7.orig/drivers/net/usb/usbnet.c
+++ linux-2.6.22-rc7/drivers/net/usb/usbnet.c
@@ -1208,7 +1208,7 @@
status = 0;
}
- if (status == 0 && dev->status)
+ if (status >= 0 && dev->status)
status = init_status (dev, udev);
if (status < 0)
goto out3;
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Cleanup usbnet_probe() return value handling
2007-07-02 22:46 ` Peter Korsgaard
@ 2007-07-04 4:34 ` David Brownell
2007-07-10 16:42 ` Jeff Garzik
1 sibling, 0 replies; 5+ messages in thread
From: David Brownell @ 2007-07-04 4:34 UTC (permalink / raw)
To: Peter Korsgaard; +Cc: netdev
On Monday 02 July 2007, Peter Korsgaard wrote:
> usbnet_probe() handles a positive return value from the driver bind()
> function as success, but will later only setup the status handler if the
> return value was zero, leading to confusion. Patch adjusts this to accept
> positive values as success in both checks.
>
> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
... though I'd adjust comments to say "non-negative" rather
than "positive". Most folks won't say that zero is positive.
> ---
> drivers/net/usb/usbnet.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: linux-2.6.22-rc7/drivers/net/usb/usbnet.c
> ===================================================================
> --- linux-2.6.22-rc7.orig/drivers/net/usb/usbnet.c
> +++ linux-2.6.22-rc7/drivers/net/usb/usbnet.c
> @@ -1208,7 +1208,7 @@
> status = 0;
>
> }
> - if (status == 0 && dev->status)
> + if (status >= 0 && dev->status)
> status = init_status (dev, udev);
> if (status < 0)
> goto out3;
>
> --
> Bye, Peter Korsgaard
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Cleanup usbnet_probe() return value handling
2007-07-02 22:46 ` Peter Korsgaard
2007-07-04 4:34 ` David Brownell
@ 2007-07-10 16:42 ` Jeff Garzik
1 sibling, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2007-07-10 16:42 UTC (permalink / raw)
To: Peter Korsgaard; +Cc: David Brownell, netdev, dbrownell
Peter Korsgaard wrote:
>>>>>> "David" == David Brownell <david-b@pacbell.net> writes:
>
> Hi,
>
> David> I'd rather see the later test updated to match this one.
> David> (Good catch!)
>
> David> The return convention is "negative means error". There's
> David> code in USB which has multiple nonnegative success codes.
>
> Ok, updated patch does that instead.
>
> David> In particular usb_control_msg(), which would very naturally
> David> used as the body of a bind() method, returns negative or
> David> the number of bytes transferred.
>
> Yeah, that was the original problem in my dm9601 driver.
>
> usbnet_probe() handles a positive return value from the driver bind()
> function as success, but will later only setup the status handler if the
> return value was zero, leading to confusion. Patch adjusts this to accept
> positive values as success in both checks.
>
> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
> ---
> drivers/net/usb/usbnet.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
applied
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-07-10 16:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-02 15:40 [PATCH] Cleanup usbnet_probe() return value handling Peter Korsgaard
2007-07-02 16:14 ` David Brownell
2007-07-02 22:46 ` Peter Korsgaard
2007-07-04 4:34 ` David Brownell
2007-07-10 16:42 ` Jeff Garzik
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).