From patchwork Mon Jan 2 18:26:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jassi Brar X-Patchwork-Id: 638432 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp942648pvb; Mon, 2 Jan 2023 10:27:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXsQup8maQ0er1KAoH7HmYLOIAPfnoIc66xJXqT/W7oujU+aI/45cLhZ8Yurzs0CLPFiPKm6 X-Received: by 2002:a9d:7649:0:b0:670:73eb:5088 with SMTP id o9-20020a9d7649000000b0067073eb5088mr24207374otl.37.1672684022436; Mon, 02 Jan 2023 10:27:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672684022; cv=none; d=google.com; s=arc-20160816; b=OKAsCoLAPMKsuUKZ3Q6FHysTnwmSg697woc76J6p64xEQ28Oxp4JWzTCPYJ5hkW4th qmy5fMnytk6BxtObKPPz0p45333u/zuhhJz8K7M8SBixIgXtxwvGCxZvmZBSTke1RfEt fymSBCDozzJGsH7KJMscuR3jk313tq8OPsnKk8kpRwghwoB39BP7pds0O0VnsDOUB8+s qxtJStrXyYlp39uS6c1KaFvPLOBFB6PEQOrT4ggTfnKVTK4WOu+JOFFWMKQQgEIPwE/j sr2dXs0WoUbepJTN4u2aMKgkR9bqWwAVfYEo35di0g5BHUjPUsMIxhH8VGd/EnFeotoP TPgg== 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=IgnhbFDR1O4EahyVuA56qeTT9xedD31RLmbrq3fcc/c=; b=troiHV2+qWoCw7cCU4Lz5BhTl1RXHFur1sGLgeb8eJRINjUIeVyE5lcPNd4VsjWIGO ozZ2VTD9hp878cuLcT5RjiLCBMYLMEDh7P2ehPII59qdLKa5BMnb71r0uJ3iJubMqsfk xzUhpCeALH3KKitzprvQ+SH5LhofqWhRt4kzf32ipYh+4XohYJ/taZRWWYxWjPbRQfQF SZfFGq1+u5B61FZCNwf0W+0mtzAdUxxjm7FW5KfAxrhOGrnr/GBC6BT+ROw4XEQU00+L kBNXEQaPsC4+hPVaQ9ZT49+6pmsDS1Z6GlkxRQgNgW/CW3MrOAUkQI1N+TZRBj3xlEwE Xl2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=F+fkQ0GO; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id r16-20020a05683001d000b0067079c41045si20202377ota.326.2023.01.02.10.27.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jan 2023 10:27:02 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=F+fkQ0GO; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 73F2C85547; Mon, 2 Jan 2023 19:26: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=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="F+fkQ0GO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6FD508553E; Mon, 2 Jan 2023 19:26:57 +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-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (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 B49A08533F for ; Mon, 2 Jan 2023 19:26:54 +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-x135.google.com with SMTP id o13so16888419ilc.7 for ; Mon, 02 Jan 2023 10:26:54 -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=IgnhbFDR1O4EahyVuA56qeTT9xedD31RLmbrq3fcc/c=; b=F+fkQ0GOE/BstwULCGN8NzVAGaU34uqmMhTz/fSsKCApvA5i4risXZK8GzxhHz8sjR bMPRj9TtScyhoPYojiT5Y4Y+p0ivh+Ile0sY0PW8Es7nLkr1R27Cmxxf3lVliiU0KN0W 6yQdcFWPqeV/nG8chPpVykahtrq6kTGJ7dlDrZjjTa93WYUWbG9x8epjJcrzc8YJZneM ha2tN9WKo7Ju627QNd/XgX5kGzhRIsHzNEBTe99WcgYeA504f5Qpvfxop3JpYb2LSmEB hKSNX6H5XOOBwm5JgN/A6T/iKgK9M3t9HtcR8Lui+Z1Kvpxz4Yl5gq+Ak0Bt2UHWlAaM l91w== 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=IgnhbFDR1O4EahyVuA56qeTT9xedD31RLmbrq3fcc/c=; b=GYb/RRh8AFvKGUzm/5hNXg+16fmhckWOs3OrcWYNIMhiSYrTlk77xMebPHVZ5soVVF DpexaDwHS3+b0L4GWugbuPsR8feMG8GIOwwFJL3GRq+eS0Y7VUvA6EOsYrsmXdv6BKCO Q51wwF+V6OMlB9mkKYmhjDCJ6eHWcr+SIH2XXpdwNZqGQcJHOj1ud0PBXSmkoLS8oNet Z+F6TYKhs5fkl+uYFcuc+I07gClruvSLtvnJ9k3Y/Linf7dKtgFqX1kJqrdCaOCg9m7d Rdh+YkKsZ++BNtNLHe47SA4JZkUAB0qNZ02kMZAIbAMnlFTR4QoUd67cje2EfzQ+yUmZ O7dw== X-Gm-Message-State: AFqh2kqS9RoI80oraH2kdaUp+PN8EM9W6WK8v7/kUyZE/AwtuhqBK/LA dwsp+7T9NIlye3wx/FQdy/gqW//eDGA= X-Received: by 2002:a05:6e02:2169:b0:303:6d1e:e5d1 with SMTP id s9-20020a056e02216900b003036d1ee5d1mr43890169ilv.6.1672684013044; Mon, 02 Jan 2023 10:26:53 -0800 (PST) Received: from jassi-Alienware-x17-R2.. (wnpgmb0311w-ds01-45-179-115.dynamic.bellmts.net. [206.45.179.115]) by smtp.gmail.com with ESMTPSA id w9-20020a05663800c900b0036cc14af7adsm9642424jao.149.2023.01.02.10.26.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jan 2023 10:26:52 -0800 (PST) From: Jassi Brar X-Google-Original-From: Jassi Brar 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: [PATCHv3 3/5] fwu: gpt: implement read_mdata and write_mdata callbacks Date: Mon, 2 Jan 2023 12:26:49 -0600 Message-Id: <20230102182649.2411239-1-jaswinder.singh@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230102182532.2411125-1-jaswinder.singh@linaro.org> References: <20230102182532.2411125-1-jaswinder.singh@linaro.org> 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 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,