From patchwork Fri Nov 4 02:43:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jassi Brar X-Patchwork-Id: 621359 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp765645pvb; Thu, 3 Nov 2022 19:43:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM70JRkmoS4ZOIfSKHepmNIoxmfMdx3twS1rrtYoaF2XkkM2up2ZhY3swUjcC70uDJ+oJzAr X-Received: by 2002:a05:6402:42c6:b0:462:1abc:e576 with SMTP id i6-20020a05640242c600b004621abce576mr33320719edc.223.1667529806342; Thu, 03 Nov 2022 19:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667529806; cv=none; d=google.com; s=arc-20160816; b=KSksCn+g8nTeLeOJg7ENUt2wgNBiRyb6xVd7JBJNnG6Jh3STzk/fr1pJyrZNi7MqL4 m9vMx9igQvM8g1HbrNMAXTKnKk5kHzI+7WkJWKxKXQro+jf8wZSBc8nUjw4Pc0A8fZSn FiAkSBbgHcXnSH8ZOlYezMWSrgS/aGbg3WkVlQ4YCdJYt2Lla22TEtxrcVnZCOO7TZfx N255uDS461zVRMPftKDawuzylQ8oamyZMmCT2Gj7GwzxtBVyEk+2kRJNBsnxgvWtDbCr ricSG5e5vAfJbm34k5A6+CHacD+NHNGcaCakyxyn1JVK/QhgYDf/sd7ajhMC+2BB04GD I9TA== 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=B7HPF7XcdZckEAMtgr13kYMy67THZmTd7UmnDeUXDKg=; b=ENbquiqlH7hqi1vG4Ltb29Fk4AfSa09cUMjFwrIwG06zzv0AmwxyYLzzVGiMaWmwzM YX5AqY8cdpsAskG6l6RlsGK7HelnBTIEtJXV8F+3HVIvusin/Czg/uqJxyBqNbuaXhQc WToVcFwsHjynmg3Zli3IDO5Vq0Ku0B0M2Cx1+JYpMJIk1GZJG7T1EJtdPb2ngeaSQSJg I7TmF2o6fEP0Gnq6s0q3spOqRYmT4b9o09ImoFmjuxWFz64ko4rqi22VqCHPU2vUgy/7 5iIxP7crK2+iwcXDzF3uJl7XHQvxoEDe+TYsOx1E+M9yqIQEOPgi/CVs2ODenP+iBhCt qdLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MQls33oK; 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 hb38-20020a170907162600b007307fd1b9bbsi3523959ejc.589.2022.11.03.19.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 19:43:26 -0700 (PDT) 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=MQls33oK; 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 E1DC98517F; Fri, 4 Nov 2022 03:43:24 +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="MQls33oK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6E7048519D; Fri, 4 Nov 2022 03:43:22 +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-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (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 D447B84F99 for ; Fri, 4 Nov 2022 03:43:18 +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-io1-xd33.google.com with SMTP id 11so2917673iou.0 for ; Thu, 03 Nov 2022 19:43:18 -0700 (PDT) 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=B7HPF7XcdZckEAMtgr13kYMy67THZmTd7UmnDeUXDKg=; b=MQls33oKRPsNXRBZ2zxLuHrFb//TKEl8Vi5ppuuM9akmoUvbEORy3548yCxvlD0G5d ZARbQ2iWiL0A/QLt/Pthuemn/OIx1sOdVpBI77k3R8OG/VS7bi0T+pbxWRqks+906h9n ChyqNYVbO+41H/ddZHjPj5LeVaCZ3ieXJie9/KERi1fiIdfOhsv4Za7jsbS2TtAgcKfa g1YfEdQnoDmGNlWX4UWDm/fz0WpcqQOVbbA3LRAZvhHRRMwRtjq4c+wC0TO+eZ4FhwmN ip2GoIzrFxv2EmgVXiXhtoeupIkTx5fNMuiU5mVNOmds9eJg5V33xqnfsV7wCAq4p6bY aXvA== 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=B7HPF7XcdZckEAMtgr13kYMy67THZmTd7UmnDeUXDKg=; b=aPrF2/vNtL9SR1d+wiQl0jdFqRo8OAyNaShZFXwNFtCqgXWzKhUeVs7bNueTiJD2Fb B4/+K2O18bDaeXkTAW3xYe6kfHEU1bFYR8GYR5GWTig/FVsNW6p0rzD8egnkTM8sf8Fb WbWNoOCjk0CaDYMwPQuRMvKHCJWfqru9VHNa3qixrsGBjJfA5TzOnnZDcHTpqmyXIgM/ 7y+zqmXlaloypSL96/Vxutww/YypQYYnNl57BLQq7OQj8pyhV+86CclF2zdV/6MXXpoN skw3w6gl8sl36dE8kj1Ji69gq+AI9dfqQStKlMiFlOBm4hOv5eq0GP09DaskhuDLZ7jt PgLA== X-Gm-Message-State: ACrzQf1GR0tjgkhjm4Q+mahhwzJ/rCRf212Lm0KD+rIxKRfLmmoM+Poo /5z2gS6Kpvph0H9UR/ByS/BLpJzmX1dRLg== X-Received: by 2002:a02:cf17:0:b0:375:6b39:c553 with SMTP id q23-20020a02cf17000000b003756b39c553mr13018359jar.4.1667529797027; Thu, 03 Nov 2022 19:43:17 -0700 (PDT) Received: from localhost.localdomain (wnpgmb0311w-ds01-45-179-115.dynamic.bellmts.net. [206.45.179.115]) by smtp.gmail.com with ESMTPSA id d15-20020a02620f000000b003640dc54d5asm817914jac.14.2022.11.03.19.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 19:43:16 -0700 (PDT) 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 3/4] fwu: gpt: implement read_mdata and write_mdata callbacks Date: Thu, 3 Nov 2022 21:43:12 -0500 Message-Id: <20221104024312.764840-1-jassisinghbrar@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221104024217.764612-1-jassisinghbrar@gmail.com> References: <20221104024217.764612-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 --- 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 d706e3d4e4..7fda041302 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,