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 CCABEC54EE9 for ; Sun, 25 Sep 2022 15:06:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AA61E84D74; Sun, 25 Sep 2022 17:04:09 +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="hm1ewv9E"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E3A1C84BE1; Sun, 25 Sep 2022 17:03:38 +0200 (CEST) Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) (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 E64D284B0C for ; Sun, 25 Sep 2022 17:03:32 +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-il1-x131.google.com with SMTP id r5so988723ilm.10 for ; Sun, 25 Sep 2022 08:03:32 -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; bh=tBzXY5u26Dc4TR6E3xfQw+iKLtl83o+AB+ePHbRD5Z4=; b=hm1ewv9EO+vpEyFgA8L39OKdVxCbxbW3DqkUQ0wRuQOHi+1nmv3UMQX+QRs07zrZ+J W8/RDyN5foZxc8Vo21Zb1v5KN3JrUFPogQo/YSbJ4/jwViOW5BC6Xjfcbqa1z3KIL9qP OoHkOIA9gD1Sa7Qeid9TvIAwRS9OyDyUlM7Qg= 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; bh=tBzXY5u26Dc4TR6E3xfQw+iKLtl83o+AB+ePHbRD5Z4=; b=GGOzqAejjRJrBMdyLZFFqhsuo9w4rPXpZO+0wX6OQAmfXUQQ4vQ3CpOn4CPPsogX7j xazmfSQQstXVA7QXXDq+b28LrbZhqWbSuiEMPsf/ebxSR1LxFjnweBMdFht2GEGqcCPP BTa4eniFqpgRKXywRsDEYNGDLtcsWqTIUsYNWi38bewG1o4QRgMB+QYpk+8bGSWbT54C UlG7nF5nQhfls1FZX7ApzSYcKKvjy3G33rPoNN2GqirQZBDGk3I4Ev0qfxDk7s97mkSM uQBeon8D+nkVyezGw6q2SPAYV3rJZ5E2XW6hqojqOQFrZvySgRmYZ0mtlX5eFCncRQHS 9p6w== X-Gm-Message-State: ACrzQf2GPKVEJ8MWwwla0qv+u8laTPGC+4O+BPm3u/aNpJqIcSNVQs9r E6xethpZ7vber1C/7lalg4gCrU372PguNA== X-Google-Smtp-Source: AMsMyM4grV+UHL5Cd5g1G2bhWFXHKJOGTiTZgfa2aAvhmNTA+4YsKHUDII+Ek122sfwfOFRPVOYC9w== X-Received: by 2002:a05:6e02:2143:b0:2f6:59f:6450 with SMTP id d3-20020a056e02214300b002f6059f6450mr8247424ilv.277.1664118212181; Sun, 25 Sep 2022 08:03:32 -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 u19-20020a926013000000b002f19d9838c6sm5360578ilb.25.2022.09.25.08.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 08:03:31 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass Subject: [PATCH 21/45] bootstd: Add a way to set up a bootflow Date: Sun, 25 Sep 2022 09:02:24 -0600 Message-Id: <20220925150248.2524421-22-sjg@chromium.org> X-Mailer: git-send-email 2.37.3.998.g577e59143f-goog In-Reply-To: <20220925150248.2524421-1-sjg@chromium.org> References: <20220925150248.2524421-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 --- 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.37.3.998.g577e59143f-goog