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 E8F39C433FE for ; Thu, 13 Oct 2022 12:33:37 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4D2CE84F91; Thu, 13 Oct 2022 14:31:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="M2WruRg3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 125F584F33; Thu, 13 Oct 2022 14:30:41 +0200 (CEST) Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CEA3084F45 for ; Thu, 13 Oct 2022 14:30:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd29.google.com with SMTP id h203so1189754iof.1 for ; Thu, 13 Oct 2022 05:30:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ikavWaBCjm77Gk9syLeI2/4MFFQTFRGEhiCVv/7c6S0=; b=M2WruRg3t7h+/YJ4X6tzFq+IdB4kZwBoDvp4UrSulQYgZVYwvGeFLiZc9DCLkFi4j1 9FiUU1HUwJ1LwQRZ6qwUlsslwt8Q2kduciHtfnF/YpHssW3v5COc0/TmYySoHHiVPgJ3 0Kmj+muVk0ExvoBZk7YSXal7G6OAdCgT1Eyvs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ikavWaBCjm77Gk9syLeI2/4MFFQTFRGEhiCVv/7c6S0=; b=CXhKCBwPGB0joqqlhbWCgyqW9Z9fNyry6JwbJAbulMr5N2wE6hGiNvHZrsB5NNVslI Op4Idgt5bAAdhVgRCxGFLoahQiY5KjPb/0I+MA2dWASFVyciyuAFKGBmyhm8G+cHv4kV +m86e0itCA/yX+Ds/j+o6ajiw3dWqoeEctWbJFkN7vIo+jDkQUGxndPuvAANf9vKq27s 5xsoVP0ejXa11RDAE71nCxy2NEx2jZEcHf2uhhEaBa9U5yVoTYAUYu8RTo1KKA40JzcE nRwFJwOTnTMhTw5zWSCfNZBbF4T06MKO499s6dbrl89ST4MIQswXE5of/d3jmqne8Cc9 M5Fw== X-Gm-Message-State: ACrzQf3SBob5J5egaA3cPJKd0C4/naLmzEqvGnmGR+0VSA+0rcJ4S5OF B4ir3bvnEJrS3By5ki72fiJbAO/d6x7uZg== X-Google-Smtp-Source: AMsMyM4hHmMRVemkEqZi9CRch9vv020uPvoj0kzE/PiTVVqVy6TCgNG47nORnYQcUnn93QZRAgmdKQ== X-Received: by 2002:a05:6638:d81:b0:363:9e6b:49b4 with SMTP id l1-20020a0566380d8100b003639e6b49b4mr15710964jaj.22.1665664222791; Thu, 13 Oct 2022 05:30:22 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id a9-20020a027a09000000b003635ab4a7b7sm7321626jac.3.2022.10.13.05.30.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 05:30:22 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass Subject: [PATCH v2 15/45] bootstd: Add a way to set up a bootflow Date: Thu, 13 Oct 2022 06:28:57 -0600 Message-Id: <20221013122927.636867-16-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221013122927.636867-1-sjg@chromium.org> References: <20221013122927.636867-1-sjg@chromium.org> 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 Add a function to init a bootflow, to reduce code duplication. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 5 +---- boot/bootflow.c | 9 +++++++++ boot/bootmeth-uclass.c | 5 +---- include/bootflow.h | 12 ++++++++++++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 13ac69eb392..4bde5631c34 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -440,10 +440,7 @@ int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, if (!ops->get_bootflow) return -ENOSYS; - memset(bflow, '\0', sizeof(*bflow)); - bflow->dev = dev; - bflow->method = iter->method; - bflow->state = BOOTFLOWST_BASE; + bootflow_init(bflow, dev, iter->method); return ops->get_bootflow(dev, iter, bflow); } diff --git a/boot/bootflow.c b/boot/bootflow.c index 5d94a27ff84..f9ad4099244 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -339,6 +339,15 @@ int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow) } while (1); } +void bootflow_init(struct bootflow *bflow, struct udevice *bootdev, + struct udevice *meth) +{ + memset(bflow, '\0', sizeof(*bflow)); + bflow->dev = bootdev; + bflow->method = meth; + bflow->state = BOOTFLOWST_BASE; +} + void bootflow_free(struct bootflow *bflow) { free(bflow->name); diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 2d7652edeab..25552dd96f6 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -77,10 +77,7 @@ int bootmeth_get_bootflow(struct udevice *dev, struct bootflow *bflow) if (!ops->read_bootflow) return -ENOSYS; - memset(bflow, '\0', sizeof(*bflow)); - bflow->dev = NULL; - bflow->method = dev; - bflow->state = BOOTFLOWST_BASE; + bootflow_init(bflow, NULL, dev); return ops->read_bootflow(dev, bflow); } diff --git a/include/bootflow.h b/include/bootflow.h index 6aa3d1fff8d..32dbbbbe261 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -144,6 +144,18 @@ struct bootflow_iter { bool doing_global; }; +/** + * bootflow_init() - Set up a bootflow struct + * + * The bootflow is zeroed and set to state BOOTFLOWST_BASE + * + * @bflow: Struct to set up + * @bootdev: Bootdev to use + * @meth: Bootmeth to use + */ +void bootflow_init(struct bootflow *bflow, struct udevice *bootdev, + struct udevice *meth); + /** * bootflow_iter_init() - Reset a bootflow iterator * -- 2.38.0.rc1.362.ged0d419d3c-goog