mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-08-10 01:06:59 +02:00
usb: ether: Fix error handling in usb_ether_init
The code checks the return value from uclass_first_device as well as that the device exists but it passes on the return value which may be zero if there are no gadget devices. Just check that a device was returned and return -ENODEV otherwise. Also remove the dev variable which is not really used for anything. Signed-off-by: Michal Suchanek <msuchanek@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
28a22cd9a4
commit
2cb43ef1c2
@ -2636,18 +2636,17 @@ static const struct eth_ops usb_eth_ops = {
|
|||||||
|
|
||||||
int usb_ether_init(void)
|
int usb_ether_init(void)
|
||||||
{
|
{
|
||||||
struct udevice *dev;
|
|
||||||
struct udevice *usb_dev;
|
struct udevice *usb_dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = uclass_first_device(UCLASS_USB_GADGET_GENERIC, &usb_dev);
|
uclass_first_device(UCLASS_USB_GADGET_GENERIC, &usb_dev);
|
||||||
if (!usb_dev || ret) {
|
if (!usb_dev) {
|
||||||
pr_err("No USB device found\n");
|
pr_err("No USB device found\n");
|
||||||
return ret;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = device_bind_driver(usb_dev, "usb_ether", "usb_ether", &dev);
|
ret = device_bind_driver(usb_dev, "usb_ether", "usb_ether", NULL);
|
||||||
if (!dev || ret) {
|
if (ret) {
|
||||||
pr_err("usb - not able to bind usb_ether device\n");
|
pr_err("usb - not able to bind usb_ether device\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user