From patchwork Tue Sep 30 00:51:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 443 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193541; bh=3hUfdFjTeMvoFKaIfatcJKgsZl57S7yxxzYD5jSFv5I=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=BE/FEtxImfMO0e3IrwfIFe2exw6REniWTFekcTwhy5Kf5Uw3da7IsqnTGto/Tk1c5 LMQ+I6p4h8Se8j06qZqpeeLzt7AeBNTQZORDZiIc3DauvgOg8EoMi22koU0JtRfcRI dJ2xiY6r992SaEVh0RXIpjQ/HibkSVVhw7bXC4VEUmbgnjVBSfp9UvosZVE+sihph1 Lm3kY8GRbt2lkkRDBwxsJ5Y2ctxzaJ1SR+08lvehumC8hPIPewqnSH6t4kHl/BXSqK SRv1VuFpGoUylRluRjvH/T6p+IuaQiLqwHFUW5g7Kg80xxq2TqxCoy55vy0rJt/kdJ sO56kQuJS5yag== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3209F67E31 for ; Mon, 29 Sep 2025 18:52:21 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 4xXWyeF0KcNe for ; Mon, 29 Sep 2025 18:52:21 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193541; bh=3hUfdFjTeMvoFKaIfatcJKgsZl57S7yxxzYD5jSFv5I=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=BE/FEtxImfMO0e3IrwfIFe2exw6REniWTFekcTwhy5Kf5Uw3da7IsqnTGto/Tk1c5 LMQ+I6p4h8Se8j06qZqpeeLzt7AeBNTQZORDZiIc3DauvgOg8EoMi22koU0JtRfcRI dJ2xiY6r992SaEVh0RXIpjQ/HibkSVVhw7bXC4VEUmbgnjVBSfp9UvosZVE+sihph1 Lm3kY8GRbt2lkkRDBwxsJ5Y2ctxzaJ1SR+08lvehumC8hPIPewqnSH6t4kHl/BXSqK SRv1VuFpGoUylRluRjvH/T6p+IuaQiLqwHFUW5g7Kg80xxq2TqxCoy55vy0rJt/kdJ sO56kQuJS5yag== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2035B67E03 for ; Mon, 29 Sep 2025 18:52:21 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193538; bh=8n8ZPmZdBJxJvKR7sR8bMH7mB2i8kpC6J3tPH/DKpt8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DiMK5pIUXeZlmXbkrGxcu6JOwM6vvZZ3fmLDsS0cShSYOR0CXO2VhuGFbJkqDS4K9 ogyL+qqhiM9tExD+OJKaUru72np06UnoL/YZWC3SSKnFuwYe4HE41ZG2XGaxVeSOVv /6e0NjDlcNmEk4noBqtuLqvjXL29fEq7pZux05H4ALYJQq2bsYUaPJIl2Xg+H3Ljt9 gBk2dkoY9ZED8JUvMfp2Ih6Qw8jQ2vieQFAvfGW+5J1WYr2R3FBjUjTvsQTaeld3z+ 1lzvcteQotFGHWfsfnAPachEk0fb4ZnM7LZyYhPmTglZdnI3jLN9oM9SonDZtm2MiG anXC46Rhby3qQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D2EBB67E15; Mon, 29 Sep 2025 18:52:18 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id qYoy__TqMv69; Mon, 29 Sep 2025 18:52:18 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193535; bh=+zFH0FxvOIUcLqkv4lR/8h80mBVBdEbdq9ZjLShIkN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dox273xZoqg4CHQEmeVK0g0DUO/0sDYpFJVYDe6iEgqBXiEeGsCfvecaBdrFPcSei s2NfRpLsA+Ui1fVoz9BDyNzxDWblGLKMAFe4yj1srJZZ7K6fkJQPvFCFdqfLH4j/zs HZ/meFybUpbKX7j39UWiqQM4gUWFsOnX4wrp0CqFJ9T3sNJgRb0NxNj5fk6vKI4kRT MrPr+CW/Wg75zsOvHVSKz9z5cELKSDA6lpT6GbIZ0d7VfxXQDD9O26ozY81KA+5Y7u 214rjlFeahHoZjm3hb8KNZazVjqB1xe5bqFRi/iWG5mEeox/aB7EBZ/VtDhzPhxPhi 3o3+U4vY2nFbg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E632667E5B; Mon, 29 Sep 2025 18:52:14 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:24 -0600 Message-ID: <20250930005137.3650600-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QM4SDVH5GZYIX77XTNP7BMCUII6PKR4T X-Message-ID-Hash: QM4SDVH5GZYIX77XTNP7BMCUII6PKR4T X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/15] boot: Move preparing bootdev into a function List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The code at the end of iter_inc() is already somewhat tortuous. Before making it worse, move it into a function. Signed-off-by: Simon Glass --- boot/bootflow.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 6f5876548b2..a91d76c6baf 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -245,6 +245,32 @@ static void scan_next_in_uclass(struct udevice **devp) *devp = dev; } +/** + * prepare_bootdev() - Get ready to use a bootdev + * + * @iter: Bootflow iterator being used + * @dev: UCLASS_BOOTDEV device to use + * @method_flags: Method flag for the bootdev + * Return 0 if OK, -ve if the bootdev failed to probe + */ +static int prepare_bootdev(struct bootflow_iter *iter, struct udevice *dev, + int method_flags) +{ + int ret; + + /* + * Probe the bootdev. This does not probe any attached block device, + * since they are siblings + */ + ret = device_probe(dev); + log_debug("probe %s %d\n", dev->name, ret); + if (ret) + return log_msg_ret("probe", ret); + bootflow_iter_set_dev(iter, dev, method_flags); + + return 0; +} + /** * iter_incr() - Move to the next item (method, part, bootdev) * @@ -389,18 +415,10 @@ static int iter_incr(struct bootflow_iter *iter) } log_debug("ret=%d, dev=%p %s\n", ret, dev, dev ? dev->name : "none"); - if (ret) { + if (ret) bootflow_iter_set_dev(iter, NULL, 0); - } else { - /* - * Probe the bootdev. This does not probe any attached - * block device, since they are siblings - */ - ret = device_probe(dev); - log_debug("probe %s %d\n", dev->name, ret); - if (!log_msg_ret("probe", ret)) - bootflow_iter_set_dev(iter, dev, method_flags); - } + else + ret = prepare_bootdev(iter, dev, method_flags); } /* if there are no more bootdevs, give up */