From patchwork Sun Sep 25 08:28:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Michal_Such=C3=A1nek?= X-Patchwork-Id: 1682006 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=mNLpWliQ; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Sf+kSE9g; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MZzby431zz1ypX for ; Sun, 25 Sep 2022 18:30:38 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DCB4F84A93; Sun, 25 Sep 2022 10:29:12 +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="mNLpWliQ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Sf+kSE9g"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A1AE5849AB; Sun, 25 Sep 2022 10:28:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) (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 E4E08849E9 for ; Sun, 25 Sep 2022 10:28:35 +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-out1.suse.de (Postfix) with ESMTP id B513C21FE8; Sun, 25 Sep 2022 08:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1664094515; 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=1YUWMs5IjXHCUB+cDdGY773MmKHYhifyiV6UC7QGuQA=; b=mNLpWliQ3UnOGxmMhpHUJFEc55Pz2Lm/+2iHcOMeIzfyQpvswlUXFOeYx6zKKr8HhRfuu9 UT6e7ZvVAKi0IUysGL+9TVF3iWHQ2R2jLOhJcmsYNLJ5R1DxuPWdPXIDqoBRwq+o9+jRIG MqANLSKf6QzQu/JjkQ8j/HwieOFipUI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1664094515; 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=1YUWMs5IjXHCUB+cDdGY773MmKHYhifyiV6UC7QGuQA=; b=Sf+kSE9gIvq+X9qY7xr6Rw/oZTcF65/X64E7uMONnPi2FVYjxc2E2B1q4N6uewqghY75cj j8rljGU+BD+lz+Cg== Received: from naga.suse.cz (unknown [10.100.224.114]) by relay2.suse.de (Postfix) with ESMTP id 966D02C186; Sun, 25 Sep 2022 08:28:35 +0000 (UTC) From: Michal Suchanek To: u-boot@lists.denx.de Cc: Michal Suchanek , Lukasz Majewski , Marek Vasut Subject: [PATCH v4 09/21] usb: ether: Fix error handling in usb_ether_init Date: Sun, 25 Sep 2022 10:28:02 +0200 Message-Id: <03f3ea7aab287e15179a8c857db713e9cb7ee27a.1664093812.git.msuchanek@suse.de> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 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 abb5332f13..ad394c80fc 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; }