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 C3DABC433FE for ; Wed, 12 Oct 2022 19:59:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1CF6C84F14; Wed, 12 Oct 2022 21:59:07 +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="zc62obL9"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="gbEYN3hj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 89A9B84EA7; Wed, 12 Oct 2022 21:58:43 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (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 5D3ED84F0B 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-out1.suse.de (Postfix) with ESMTP id 2685521F7D; Wed, 12 Oct 2022 19:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1665604709; 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=gPZvOCS8C5BntBg8/17VPUFPgR8UmdbFhT4WgzjK34A=; b=zc62obL9e41Mc0xJzzJgevCDVl534mU1xlagZJXDZFRbn70ofVgFH5IJ6d4OqkktM5sC9S T/LT28paF+Bbk25sL/48aVMyVI7LNtA0jJkYYglKk4TwoaRdr90rPgylKTPYda7S0q7phC hPNNsBkU7vwgliTYuH2AoEwGz5dR5xw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1665604709; 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=gPZvOCS8C5BntBg8/17VPUFPgR8UmdbFhT4WgzjK34A=; b=gbEYN3hjtw8V0kJiYWZGKcjulwwjLZp4b1RQQOTSyYEPns+8mAp/uxSbG0y7BgH0OolCld 3+NbXf2RCuWrg4Bw== Received: from naga.suse.cz (unknown [10.100.224.114]) by relay2.suse.de (Postfix) with ESMTP id EB0372C14B; Wed, 12 Oct 2022 19:58:28 +0000 (UTC) From: Michal Suchanek To: u-boot@lists.denx.de Cc: Michal Suchanek , Simon Glass , Jason Liu , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Heinrich Schuchardt , Loic Poulain Subject: [PATCH v6 06/20] stdio: Fix class iteration in stdio_add_devices() Date: Wed, 12 Oct 2022 21:57:55 +0200 Message-Id: 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 There is a complaint in the code that iterates keyboards that we don't have the _check variant of class iterator but we in fact do, use it. In the code that iterates video devices there is an attempt to print errors but the simple iterator does not return a device when there is an error. Use the _check variant of the iterator as well. Also format error messages consistently. Signed-off-by: Michal Suchanek Reviewed-by: Simon Glass --- v6: - drop errno_str - fix dev vs vdev in video error print --- common/stdio.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/common/stdio.c b/common/stdio.c index 13083842cb..e316a355fa 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -314,7 +314,6 @@ int stdio_init_tables(void) int stdio_add_devices(void) { struct udevice *dev; - struct uclass *uc; int ret; if (IS_ENABLED(CONFIG_DM_KEYBOARD)) { @@ -324,24 +323,18 @@ int stdio_add_devices(void) * have a list of input devices to start up in the stdin * environment variable. That work probably makes more sense * when stdio itself is converted to driver model. - * - * TODO(sjg@chromium.org): Convert changing - * uclass_first_device() etc. to return the device even on - * error. Then we could use that here. */ - ret = uclass_get(UCLASS_KEYBOARD, &uc); - if (ret) - return ret; /* * Don't report errors to the caller - assume that they are * non-fatal */ - uclass_foreach_dev(dev, uc) { - ret = device_probe(dev); + for (ret = uclass_first_device_check(UCLASS_KEYBOARD, &dev); + dev; + ret = uclass_next_device_check(&dev)) { if (ret) - printf("Failed to probe keyboard '%s'\n", - dev->name); + printf("%s: Failed to probe keyboard '%s' (ret=%d)\n", + __func__, dev->name, ret); } } #if CONFIG_IS_ENABLED(SYS_I2C_LEGACY) @@ -361,13 +354,14 @@ int stdio_add_devices(void) int ret; if (!IS_ENABLED(CONFIG_SYS_CONSOLE_IS_IN_ENV)) { - for (ret = uclass_first_device(UCLASS_VIDEO, &vdev); - vdev; - ret = uclass_next_device(&vdev)) - ; - if (ret) - printf("%s: Video device failed (ret=%d)\n", - __func__, ret); + for (ret = uclass_first_device_check(UCLASS_VIDEO, + &vdev); + vdev; + ret = uclass_next_device_check(&vdev)) { + if (ret) + printf("%s: Failed to probe video device '%s' (ret=%d)\n", + __func__, vdev->name, ret); + } } if (IS_ENABLED(CONFIG_SPLASH_SCREEN) && IS_ENABLED(CONFIG_CMD_BMP)) -- 2.37.3