From patchwork Tue Feb 28 00:52:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jassi Brar X-Patchwork-Id: 657468 Delivered-To: patch@linaro.org Received: by 2002:a05:6504:1b90:b0:222:2e2e:b2c3 with SMTP id e16csp3401971lty; Mon, 27 Feb 2023 16:53:22 -0800 (PST) X-Google-Smtp-Source: AK7set9cv4YPtIBErpdAeqNR4HLfTuXI2Z56HrR34T4v9KFQfQYkS8Nlf07bNZ+i2x7lsLAXBIkh X-Received: by 2002:a62:30c1:0:b0:5e4:5b2d:5864 with SMTP id w184-20020a6230c1000000b005e45b2d5864mr846746pfw.5.1677545601970; Mon, 27 Feb 2023 16:53:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677545601; cv=none; d=google.com; s=arc-20160816; b=TZwGRWbtZ12Kc78Hka4tq+wbd6OxA6Abq9bpNTvlvxNhfoBM4fmXiUrMnkOaxXOU2O ZGKx+Gj54mEBhM5r2uL343qlBTFX3sjmLJt/AgLFNljIxlpxR+Y8PnHM55Ai9p0ReKla v/xmdv9UhSoOlSPtb4zNXeYhGz4ceyC0FQtgeZJea5eqOb/fGweXuLqd958i5yV8i5vt 8LRXwttjGd+5zHaHZN+CVsuMypaov5I5peofmQxpMsrtc+1hClznm6wYzrsyIfH7mrdp HJVv2TQyin/KVWDuzC6kxyE0/Zzli523tYPmCYNCZ3OLsSjLgXa7OcPwRLp42dVCqINV kIXw== 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=XswIGLpxPOsDmeoXufyNi05lm8qTjy7iRxicG9KFL3z87zWjjloQguBh6iefsDVfVB jOEjsjlB0wsO0Aj2j2p2AivCcmAjPTIphHif3t4j0RYgm7SVF4EkEPmGmfmpiK4/ytp9 itnZWrvIngaQE1+cBf4wymmVeCYydOogDJoS36ogF1SlfoBEMsVt7AzpIbgYLlXVGU0p AW7Bu6Ak3C8hWC4sWYQ55IB7LMsRhwDEYzR4Qwc8pgdh5HSP/URZAsj4lpmcFVRYAsHx We+nfaguw91WxPp2wMwlPzP8K+enDi95Odg1j3rnK9/r5h7dGOzit9quPfb+6imSt8FQ o+5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XHvhEqjQ; 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 b10-20020a056a000cca00b005a8d360de63si9079256pfv.336.2023.02.27.16.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 16:53:21 -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=XHvhEqjQ; 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 5D23485B9A; Tue, 28 Feb 2023 01:52:51 +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="XHvhEqjQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 90AC885B96; Tue, 28 Feb 2023 01:52:47 +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-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 0C7BA85B84 for ; Tue, 28 Feb 2023 01:52:45 +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-il1-x12d.google.com with SMTP id h10so5391539ila.11 for ; Mon, 27 Feb 2023 16:52:44 -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=XHvhEqjQ8ij8WpHnaYMNlhDOZsM4q44UBsuviH+jbgUuyWh0aXNgWAJolPHWC09QFL t2REGwCw6izBdcxPx+eRYf3Xz/9h1NjNZOTzXP2UC9y1fV6i4ewUe+k/JX/PagvoQiCr OCx9Yvj3Iuk/7tL45EmIIH9vKqeoYsO8UefJrwSBiH4pz3N4sOzvkq2fMXqs/l8U0RJA ucXb9YfWs7S9Ngb1btd52qGkMgbnZnXEag0p8pXQpakI1R/NQPGYbSN6NjGoopC02dSI X9E9XoCqJhEthvPkWLSt5rtBzh+F8U4gHF5jWhm2JJiDhX2m3PfofVd+noE92X+XOAhx IUnQ== 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=MHF+1pU4uNOBYq8jKwx1TNct5HujFfBkEd+cGMrPvzDfQPhPpVlP5BgFtrOm1VkMF8 z1gLVhXC3E64FnKzHBum4q8Z/ma/VqNtS7x2D/pA+ZdsimMu/D9Pn3eG1ZJ8uh51UciK EjdG5ViX++ejvb6iCBx2kaw8R9DhvvSAMiWtm3uSuKSH3f6/dRjGlG4HOimX3t2WVh8X 2CtRDB1p5KN6cHEbk3Aylpp64Bgp+r550KVfNC+MVT2xGDF7w5H21u5GTudvqpBZd6TC HEibBvenoQn6fKHRCMtt8DZrEySCoZ2vMbHM+/ap9xPNxNBLnS4nz17L0I6Vyky4xAl8 42Ng== X-Gm-Message-State: AO0yUKXYoycV4QMsyWNJNIQ7qbDniPT8tkvHve3G7Qg15TfH+kTRnctu Voychf7lUlhn+E7GC6Xy+/qnF0Hy9Yw= X-Received: by 2002:a05:6e02:1a87:b0:315:4169:c5ac with SMTP id k7-20020a056e021a8700b003154169c5acmr1045449ilv.30.1677545563345; Mon, 27 Feb 2023 16:52:43 -0800 (PST) Received: from jassi-desktop.. (wnpgmb0311w-ds01-45-177-228.dynamic.bellmts.net. [206.45.177.228]) by smtp.gmail.com with ESMTPSA id n18-20020a92d9d2000000b00315327197d4sm2420505ilq.23.2023.02.27.16.52.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 16:52:42 -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: [PATCH v5 4/6] fwu: gpt: implement read_mdata and write_mdata callbacks Date: Mon, 27 Feb 2023 18:52:40 -0600 Message-Id: <20230228005240.1635841-1-jassisinghbrar@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230228005135.1635726-1-jassisinghbrar@gmail.com> References: <20230228005135.1635726-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,