diff mbox series

Remove redundant check for usb_generic_driver_probe()

Message ID 20240126120313.1362573-1-ingyujang25@unist.ac.kr (mailing list archive)
State New
Headers show
Series Remove redundant check for usb_generic_driver_probe() | expand

Commit Message

Ingyu Jang Jan. 26, 2024, 12:03 p.m. UTC
usb_generic_driver_probe() only returns 0.
Inside this function, there are only errors that are marked as not fatal.
However, drivers/usb/core/driver.c:269 checks
if usb_generic_driver_probe() returns error.
No need to change usb_generic_driver_probe() to return error,
only remove redundant error check.

Signed-off-by: Ingyu Jang <ingyujang25@unist.ac.kr>
---
 drivers/usb/core/driver.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Alan Stern Jan. 26, 2024, 2:29 p.m. UTC | #1
On Fri, Jan 26, 2024 at 09:03:13PM +0900, Ingyu Jang wrote:
> usb_generic_driver_probe() only returns 0.
> Inside this function, there are only errors that are marked as not fatal.
> However, drivers/usb/core/driver.c:269 checks
> if usb_generic_driver_probe() returns error.
> No need to change usb_generic_driver_probe() to return error,
> only remove redundant error check.
> 
> Signed-off-by: Ingyu Jang <ingyujang25@unist.ac.kr>
> ---
>  drivers/usb/core/driver.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> index e01b1913d02b..b6274580b7ca 100644
> --- a/drivers/usb/core/driver.c
> +++ b/drivers/usb/core/driver.c
> @@ -266,8 +266,6 @@ static int usb_probe_device(struct device *dev)
>  
>  	if (udriver->generic_subclass)
>  		error = usb_generic_driver_probe(udev);
> -	if (error)
> -		return error;
>  
>  	/* Probe the USB device with the driver in hand, but only
>  	 * defer to a generic driver in case the current USB

Don't do this unless you add comments both here _and_ in 
usb_generic_driver_probe() explaining that the routine never returns 
anything but 0.  Otherwise, some day in the future someone will change 
the probe routine to make it return an error code, and won't realize 
that code here needs to be changed too.

Better yet, don't make this change at all.  It's a trivial matter and 
it's not on a hot path.

Alan Stern
diff mbox series

Patch

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index e01b1913d02b..b6274580b7ca 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -266,8 +266,6 @@  static int usb_probe_device(struct device *dev)
 
 	if (udriver->generic_subclass)
 		error = usb_generic_driver_probe(udev);
-	if (error)
-		return error;
 
 	/* Probe the USB device with the driver in hand, but only
 	 * defer to a generic driver in case the current USB