From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6BE1FC433FE for ; Wed, 12 Oct 2022 19:59:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F039484F19; Wed, 12 Oct 2022 21:58:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="Y3424M0+"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="00lL/xz5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DFA1384EB0; Wed, 12 Oct 2022 21:58:40 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1E16B84F09 for ; Wed, 12 Oct 2022 21:58:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=msuchanek@suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E0E6B1FE4B; Wed, 12 Oct 2022 19:58:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1665604708; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ljkpp2mqwwzLWkN6QZz1CdRANeJ2yFsM20IKy3OZCUA=; b=Y3424M0+6WnAe1JEEm61JICEUG3T0i12o/uuxOKCTENEytK3ujHNP4gpyxFt/5d8x1bad5 A+uyu8EYCtvDSWwdNVZkUbWPt4Fn28hIfeneIzr+pS7YDxMdSDJ3u0CRu3udVlnYVREhCX 8oaq4EHZoBr2haBBGVSgSPK+YsSxOZ4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1665604708; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ljkpp2mqwwzLWkN6QZz1CdRANeJ2yFsM20IKy3OZCUA=; b=00lL/xz5BPQ/JJ7sWFpP1uKQKbGEH3LIJQX3NxO5RUsrcPBvuOyz1o9lyF6ASbmKFGcZKJ CxE9Plc6j/m224Ag== Received: from naga.suse.cz (unknown [10.100.224.114]) by relay2.suse.de (Postfix) with ESMTP id BBB312C149; Wed, 12 Oct 2022 19:58:28 +0000 (UTC) From: Michal Suchanek To: u-boot@lists.denx.de Cc: Michal Suchanek , Lukasz Majewski , Marek Vasut , Simon Glass Subject: [PATCH v6 05/20] usb: ether: Fix error handling in usb_ether_init Date: Wed, 12 Oct 2022 21:57:54 +0200 Message-Id: <69ad698a2db409376903f379e0c52bba1142af65.1665604425.git.msuchanek@suse.de> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 Reviewed-by: Simon Glass --- drivers/usb/gadget/ether.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 6ce389de9f..43aec7ffa7 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -2636,18 +2636,17 @@ static const struct eth_ops usb_eth_ops = { int usb_ether_init(void) { - struct udevice *dev; struct udevice *usb_dev; int ret; - ret = uclass_first_device(UCLASS_USB_GADGET_GENERIC, &usb_dev); - if (!usb_dev || ret) { + uclass_first_device(UCLASS_USB_GADGET_GENERIC, &usb_dev); + if (!usb_dev) { pr_err("No USB device found\n"); - return ret; + return -ENODEV; } - ret = device_bind_driver(usb_dev, "usb_ether", "usb_ether", &dev); - if (!dev || ret) { + ret = device_bind_driver(usb_dev, "usb_ether", "usb_ether", NULL); + if (ret) { pr_err("usb - not able to bind usb_ether device\n"); return ret; } -- 2.37.3