From patchwork Sun Feb 5 03:01:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jassi Brar X-Patchwork-Id: 650897 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp1637237pva; Sat, 4 Feb 2023 19:02:18 -0800 (PST) X-Google-Smtp-Source: AK7set8Zj5Gc8HoMgeq2prsKDbPou1uKneEDwXgaGtKJx/Z+2IXYVi4rXQAlWFjJfeSPSc/uQMEn X-Received: by 2002:a05:6870:3326:b0:16a:1615:3fbd with SMTP id x38-20020a056870332600b0016a16153fbdmr2518469oae.32.1675566138216; Sat, 04 Feb 2023 19:02:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675566138; cv=none; d=google.com; s=arc-20160816; b=kSKRIt6/O27QwSRkWNJf1LkKS0SZ/qeSJ04O4L22VBDKLZPKrfdAw9CbumIzHNHSob MU+8j0lQxAEl3JTO8M3f8f/PCje4dyrgXEUT4Ae6O/frrkhS5gecD/0CkqNtvaoRJbq0 5npI5f3plkrXLsGCTGCYvYdNB72iwzRRoCj7dSdHPGkfS5qDEr+rPd2XKnd3WOSDIGOs LMY6AmKH+xNHZ7272lZcfmtbK5HZdxDRRBho7yIkmO3GxSRO6sBRwT9qaXqs4R0ofELQ er4PevltqDxVK6wsw8DzM4lt9qrIvaaW/LfB8L60ichoQkPzJGBsjBuisuBu8lDR68Mh 873Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vMBaPXUfwrp8Po5BjBFcEBxWJmd/y9wTJ28/fIMdIRw=; b=rWDm1MnbAE+hyiNFWPFfg2KcZ7eCj0BWPy9ThWfq7C3yB5ACWVk9pNWBZQzjxSMFxQ BIYbR+IJTxqYkMwzBdO44TMbSFVh/2kR+hHKqDW1M7+ekzF7CLP1w9wvwi6rM1aZnXRy 1nHcFo2Jh6rZSJVQIW1aqjoFHkOKSLLayHM7/afeSTPn/tUucW08p8GPrP/oa+8zykmv XIRsxbqjXQUNrU9a8QRITtibt+GwaTGyolpsuUHv0vPGAJkXfyGQ7ZI8/1ibTovmWUjc blouV5qQPkK70Si9Rmv4TUgJSiD1SesHJPcOT0iH5JhZXiCQsuAFyUf+3MIVX/nnCP23 kJhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=K7gIRoZP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id em18-20020a0568705b9200b0014449bd3279si6633786oab.194.2023.02.04.19.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 19:02:18 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=K7gIRoZP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 36A778590D; Sun, 5 Feb 2023 04:02:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="K7gIRoZP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 349588575D; Sun, 5 Feb 2023 04:02:05 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) (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 9735C8575D for ; Sun, 5 Feb 2023 04:01:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jassisinghbrar@gmail.com Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-163bd802238so11430143fac.1 for ; Sat, 04 Feb 2023 19:01:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=vMBaPXUfwrp8Po5BjBFcEBxWJmd/y9wTJ28/fIMdIRw=; b=K7gIRoZPszU8drLgJ7OPGYLwYy+2VIvpOaVcQyPAtUjEIP0rVU6+YxBbIAaCYUrw4N I5gnDHeMfnKqG4Go+K5QfS2Pou0zATQY51/rP9snw6TMTYI3xH4kbVNhuZHG5mRM98/G bQH0VLE5+WBBaaYazrAoghPDIEva68QHCJdhBZaMlLgy8WVEnoLdWB9WVuLxMzP2KOqU K1DmcsanDJbZp9ZDSCH6QUmQUGzNU8/BtuOKl+fDpyZdzqhojZK4HJF5TKeWiayHjmO9 Ddd6wDma6yhN1+vRnIi8uGJc4hVaT6vCXon0i1mb8fz6v72ja4w/8WGYxl20z2UXhaPm ulyw== 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=vMBaPXUfwrp8Po5BjBFcEBxWJmd/y9wTJ28/fIMdIRw=; b=uiUSZRuaxMYvow2tcNAod4TWmevwiTVQAI7h5t+a7wLAXOxH31hJ8D7y065pM4kH0A Ou6LNkjK74gjslMa2yMhx3mAq7dHdnbb7SWlKNOs+nKs1wCQECWcyKBS4Yw9kmfRiLxy orSaapkbHyub9kqmsIPrBS4PtiEdyOHJZy1FlbiyIFgP1q8ydc6n5sLnkpkbRCETBfW9 3hhuxFjjmNh3r3KC287j9T3OY+6H77ngOXn8ZLT3VnuktFrAebx54ByaYjx3e0rGuDdU VaM5RxREMwhaD+em5m2IWIk36FdsR0Btan0fwcTeoFuwTaOfgXycNxSk+4tCb2PZrluv HNqw== X-Gm-Message-State: AO0yUKVe5oEs6/u4NVgMxxZOEewKUnjVFxnXHVR+jx3wiNrhSquD5dxU tOR5cHqizwD8d9pN7eQL6Rzx578ZGEE= X-Received: by 2002:a05:6871:606:b0:163:9477:f248 with SMTP id w6-20020a056871060600b001639477f248mr9083325oan.20.1675566117878; Sat, 04 Feb 2023 19:01:57 -0800 (PST) Received: from jassi-Alienware-x17-R2.. (wnpgmb0311w-ds01-45-177-228.dynamic.bellmts.net. [206.45.177.228]) by smtp.gmail.com with ESMTPSA id z18-20020a4a9c92000000b0051a317b5687sm2767178ooj.27.2023.02.04.19.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 19:01:57 -0800 (PST) From: jassisinghbrar@gmail.com To: u-boot@lists.denx.de Cc: ilias.apalodimas@linaro.org, etienne.carriere@linaro.org, trini@konsulko.com, sjg@chromium.org, sughosh.ganu@linaro.org, xypron.glpk@gmx.de, patrick.delaunay@foss.st.com, patrice.chotard@foss.st.com, Jassi Brar Subject: [PATCHv4 3/5] fwu: gpt: implement read_mdata and write_mdata callbacks Date: Sat, 4 Feb 2023 21:01:54 -0600 Message-Id: <20230205030154.61452-1-jassisinghbrar@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230205030056.61345-1-jassisinghbrar@gmail.com> References: <20230205030056.61345-1-jassisinghbrar@gmail.com> MIME-Version: 1.0 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 From: Jassi Brar Moving towards using common code for meta-data management, implement the read/write mdata hooks. Signed-off-by: Jassi Brar Reviewed-by: Etienne Carriere Reviewed-by: Ilias Apalodimas --- drivers/fwu-mdata/gpt_blk.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/fwu-mdata/gpt_blk.c b/drivers/fwu-mdata/gpt_blk.c index 28f5d23e1e..bdaa10cd1d 100644 --- a/drivers/fwu-mdata/gpt_blk.c +++ b/drivers/fwu-mdata/gpt_blk.c @@ -272,7 +272,43 @@ static int fwu_mdata_gpt_blk_probe(struct udevice *dev) return 0; } +static int fwu_gpt_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, + bool primary) +{ + struct fwu_mdata_gpt_blk_priv *priv = dev_get_priv(dev); + struct blk_desc *desc = dev_get_uclass_plat(priv->blk_dev); + int ret; + + ret = gpt_get_mdata_partitions(desc); + if (ret < 0) { + log_debug("Error getting the FWU metadata partitions\n"); + return -ENOENT; + } + + return gpt_read_write_mdata(desc, mdata, MDATA_READ, + primary ? g_mdata_part[0] : g_mdata_part[1]); +} + +static int fwu_gpt_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, + bool primary) +{ + struct fwu_mdata_gpt_blk_priv *priv = dev_get_priv(dev); + struct blk_desc *desc = dev_get_uclass_plat(priv->blk_dev); + int ret; + + ret = gpt_get_mdata_partitions(desc); + if (ret < 0) { + log_debug("Error getting the FWU metadata partitions\n"); + return -ENOENT; + } + + return gpt_read_write_mdata(desc, mdata, MDATA_WRITE, + primary ? g_mdata_part[0] : g_mdata_part[1]); +} + static const struct fwu_mdata_ops fwu_gpt_blk_ops = { + .read_mdata = fwu_gpt_read_mdata, + .write_mdata = fwu_gpt_write_mdata, .get_mdata = fwu_gpt_get_mdata, .update_mdata = fwu_gpt_update_mdata, .get_mdata_part_num = fwu_gpt_get_mdata_partitions,