From patchwork Tue Sep 30 23:25:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 459 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=1759274815; bh=dTCgnJhkWIG6EouwT4XIOiIr1Eez0In9tk/bjDqG4h0=; 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=X+2vtAv66nrUVX8AlLm5RZg8N135SlUTdmSXow+IYDzPQr6Lpw2fa+s3rR7Mky3Gg faMzGkSGUO5mH+oSNvTxkmpLZ6CM5P5xKITXlwaKeghSqnMGd3gpe16OfG92p3c5Vt cR/glKFXSXMn2hIb8VhApQouWbsEBegINOLCLdxAmRUviW8veopgVb+p1lGCakm0MJ IAGL7eeyubWfgHDoY3E1tI1QG7U83xFDXUbSV0OUZrOiD9a46Sf8fi4vvDyQ9Enilw 3CY1YO48HmXJyY9RFrzL/+IrM7cl3wf/W9hHytxXlpPAqh0mcDS60GJn7Cy2SYGXEa ntDSFZzm8Q3vg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9AC1B67E2D for ; Tue, 30 Sep 2025 17:26:55 -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 kLtVfxZZ-wzL for ; Tue, 30 Sep 2025 17:26:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274815; bh=dTCgnJhkWIG6EouwT4XIOiIr1Eez0In9tk/bjDqG4h0=; 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=X+2vtAv66nrUVX8AlLm5RZg8N135SlUTdmSXow+IYDzPQr6Lpw2fa+s3rR7Mky3Gg faMzGkSGUO5mH+oSNvTxkmpLZ6CM5P5xKITXlwaKeghSqnMGd3gpe16OfG92p3c5Vt cR/glKFXSXMn2hIb8VhApQouWbsEBegINOLCLdxAmRUviW8veopgVb+p1lGCakm0MJ IAGL7eeyubWfgHDoY3E1tI1QG7U83xFDXUbSV0OUZrOiD9a46Sf8fi4vvDyQ9Enilw 3CY1YO48HmXJyY9RFrzL/+IrM7cl3wf/W9hHytxXlpPAqh0mcDS60GJn7Cy2SYGXEa ntDSFZzm8Q3vg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8A45067E2F for ; Tue, 30 Sep 2025 17:26:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274813; bh=jeVRNwV38Uj1MUQIzegV7ELmDxuPFe2Lgujc1HYB6p4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bq84ow//J+3D/JAiM7VwqQyp8fJRLPmiE6Kf03yzkUqI8Ri+ZbK7dFBZOxAaYtbNe em1L46mX3HaVrcKjIalgbwRCozcMWzoJ3RZFjjQz4wcfw0w/7rA3gU1b8NVDujyZE+ NyDGudmpjusXbCmrdFze86N5Uc8+tegorRWY0DXnBa5IoeCXkv9ZZj12d+4mO7FajB COzxTA+QBWPSs3tgaPW39GS9aX8LoSrh+w4PI4F8P2aK60OnMlg/JsPk2y99TgmylY GdwpraPNLOuihDhtewTv2PZTNbVK/HLsN+Mz882HsEYv3sdRFBdfza2vE/U2YJLz9+ QV4a3yVI/NkvQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AC74E67E2D; Tue, 30 Sep 2025 17:26:53 -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 Mz2LsE5fmLJ5; Tue, 30 Sep 2025 17:26:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274809; bh=hj+BYrembs9KTSJ+GxjlF8IUUgTVfSY4fI5It9lbyBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KqkO57UDiJGYeRYOGQkhAsW493Yx6hTK/wFiDQyEiCNTYoLQkMKVE4GS4J6abMUc5 JMaWa7uryQ24e5V4W8I8wGXKZtFrI3n6u42V1o73fONj67wtiLJli8rLHF4ylM5a6L p/pFRMR0izUTqHu+eI964VThdgDO+5Ww85yJxFDdYWBrom2wSNCGVyPSF6AYM6YEsj mMXtPf7RLEIjNSV3luoBbmiCXerufqXsY134WSFmgTcs2N6v7bqWZgf0olIeiUtt8n yUBSpoC8oqdbnjX5P52SDLo9kmQ8ch+pFnY8H2ymYhCK8Cj9bTTz8h6KftvkBI9asy cI3Puy6tnY/QA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5DA6267EA0; Tue, 30 Sep 2025 17:26:49 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:45 -0600 Message-ID: <20250930232611.1564850-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6TD33V3DQJ2ONCGJTJYGAG5ATXPDPED2 X-Message-ID-Hash: 6TD33V3DQJ2ONCGJTJYGAG5ATXPDPED2 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 v2 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 --- (no changes since v1) boot/bootflow.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 4e2a227c807..488cf7b9a7e 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -247,6 +247,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) * @@ -391,18 +417,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 */