From patchwork Mon Mar 6 23:18:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jassi Brar X-Patchwork-Id: 659273 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2085394wrb; Mon, 6 Mar 2023 15:19:10 -0800 (PST) X-Google-Smtp-Source: AK7set8GkcfPxY9bLTHgZML9PdYYlMK1hcF1I9n2eutxVlriafUrNfmm4SX3tYKG4m3iHJypeT2O X-Received: by 2002:a5d:5189:0:b0:2c3:be89:7c2b with SMTP id k9-20020a5d5189000000b002c3be897c2bmr11029603wrv.14.1678144750133; Mon, 06 Mar 2023 15:19:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678144750; cv=none; d=google.com; s=arc-20160816; b=Qu1kVxayCgUcOSvfe2ThJr0JLKhgZC2jf0HztLHK91OJnjNbbctEhZYb0j7TdTczEg b0ljfW5foGeakCOG74FkSnnDHzH997G7VGhuJFVt2yNg+2Ke68qd+QrLT8l8+QLcPxl+ ACoOnWhAbD+q3YIUvLFyGOfDKUhjMhnBB1YqIdQcz5MaS9TwQEDuoKaBrPaHoU1rRq76 +bwM61NYfzpD6HHy2+fkS4Jh/uGee7EAKEKGGK7f6iiWbxV3hRtt2U3AzDozd+7GBI6V cbnw2X6J/phzkBAKe1BBVbZfjQpP/7bDeZcM0nPpBCcDN7b8S7UzS608fldRI7RcXur0 3ilg== 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=YGXbkehIdjqgFBEKopTjhJ2ANKQhzUussChlRIPjR3Q=; b=bOC4bpWO6v6sUjNz7cKwrhpUHz5JT2Bcw9H7wmmR+zeuZGPK00hjxq3+oEWLqHjYlN KPFJIFJVdsLtQ5KBKG76U0j+Dqk0AJcjOKSQEZGuYZ1C+eNdbdqoja4MEJBzOBlHuT58 FRFulR7aHeSOtRWda6PnvSXo30Yp73WB3giBaKJDFTG+rUianC8wdKNviNkekDDPh4ry mEPg54fw5Hqx3FVDLMibmJ4P5NWqYLj9QhwRLrI5F7Q5QWiDPbhQiCCE1NIvF7ElgSlf CXnyZ1Pey4jyc255SF7SzxDEt1nTx1MEk0/5ixhmqH780NJtJhg91AXMq+kyZTDWbOqb msig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UGMnZxGH; 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 e11-20020a5d4e8b000000b002c71d268567si8647992wru.1049.2023.03.06.15.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 15:19:10 -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=UGMnZxGH; 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 13F8B85B23; Tue, 7 Mar 2023 00:18:49 +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="UGMnZxGH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2C7D8858FF; Tue, 7 Mar 2023 00:18:46 +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-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) (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 0D1CD859E2 for ; Tue, 7 Mar 2023 00:18:40 +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-qt1-x831.google.com with SMTP id d7so12563496qtr.12 for ; Mon, 06 Mar 2023 15:18:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678144719; 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=YGXbkehIdjqgFBEKopTjhJ2ANKQhzUussChlRIPjR3Q=; b=UGMnZxGHdDjbaQlloubfoYgnkZ1wpbKWbM0ws/tdvoC+DD3MTXpmfOFQbVrsRPkpGY InfC6sTL3WgHOJP5icxc4yAyyTX4Ri6iTWIslfOmVTAukzZ/b3MemgN8aeEdBCMoQm/v TCrlSq0TAACleBQit6fK2SxG2L8EJP6nMjtb3u99kpYj1BUTQW8ktStwJT0pHpQpNdTE 3BavzHlZhwDyptT6qQA6RKQfPDvp3OJF9XtsGwL5ySf7lo/5XOJjqmXVXq/r/lSVKoJu Vis3VCxTJIq5oS0XsQ7O22j9rvtIXxmQU39OcLilBPFRsrtyLRilZ0E7PeaxXhhFNwhk Z1qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678144719; 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=YGXbkehIdjqgFBEKopTjhJ2ANKQhzUussChlRIPjR3Q=; b=Bd0hbk/MUAoyrKRd0QHdRsclPZ7veUzQXRAXvSEr3YXtMniw+h441oqr85303lIkSp iF+DPquyTUcFBY1Sbj7I1WHX7E/weue2JPsqMDkc3Kd9u1NIav/EzFohObreB5go/M4S rTqlCya0HOusF3YQmG/CHe8X5XiQuqkWp0yLPq8RT/pt0s1Kc3rgk1G8xiZknlSUBwEy 4+Zo9kz3VZCKz2ecYmFpSEa07IoSlj1zvFWOQVd0LHQaAGCQ433d+EotxQGoiQK1qZGr WNL8lCpyO8Gv1CTIOR8bVSJjDjdXLJE26ZQAFxKl20RgzU1lN8jUldxKqKaSSLvf7Ser dmHQ== X-Gm-Message-State: AO0yUKU84E5sWCcUZGArDq8BV7qJ0LIGWf8LHhHdBxeOukKtEPbnOZ/E SP5cqscW35gREy56q0pug6FwfBd5Lxw= X-Received: by 2002:ac8:5f96:0:b0:3b8:6b3c:a37 with SMTP id j22-20020ac85f96000000b003b86b3c0a37mr19975528qta.6.1678144719270; Mon, 06 Mar 2023 15:18:39 -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 17-20020ac85651000000b003b62bc6cd1csm8399608qtt.82.2023.03.06.15.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 15:18:38 -0800 (PST) From: jassisinghbrar@gmail.com To: u-boot@lists.denx.de Cc: ilias.apalodimas@linaro.org, sughosh.ganu@linaro.org, etienne.carriere@linaro.org, trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, patrick.delaunay@foss.st.com, patrice.chotard@foss.st.com, Jassi Brar Subject: [PATCH v6 4/7] fwu: gpt: implement read_mdata and write_mdata callbacks Date: Mon, 6 Mar 2023 17:18:35 -0600 Message-Id: <20230306231835.1888595-1-jassisinghbrar@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306231747.1888513-1-jassisinghbrar@gmail.com> References: <20230306231747.1888513-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.8 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..be1a6b03a1 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,