From patchwork Sat Dec 3 03:17: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: 630641 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1309513pvb; Fri, 2 Dec 2022 19:17:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf6aqy9Jc4veXqfZGhlAtZRPo6O24/0TzmxRPPEeMfNTrw7oxs6cQEjZCcFoTtKjgsA1hie1 X-Received: by 2002:a92:cd43:0:b0:303:2fd2:f612 with SMTP id v3-20020a92cd43000000b003032fd2f612mr6682797ilq.144.1670037448641; Fri, 02 Dec 2022 19:17:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670037448; cv=none; d=google.com; s=arc-20160816; b=hsILSEyCNKBTpjZ7ncbFRyfEtBvmDDCAyP/H659M7b/KKoVkeA8RolVbzaVRlNnz0s G/iApjSdSOKlAAhYEK7mL6ZMFlUqK1And8bkun+qGEhWKVft1xhQqj7QulPumXjcL0tW vAJLh/RaHXBL9mPUYVp9rmMY7SYX+eItuYnU4Bxbzivv09g35N8S7+tWu3PcqBdkokK5 V9m/e1+dAH20F2qH+sDsitQugAXQHEHHUQk2QeLotoQ/cfsgtxwgZV3JkqS6k7IKk6FM AXi+W49LIP5RHS7kqp4UyS2Lf3Gqc2fXKXqBLsjzh7pK2FUls+LFYf6J0YrQUeDMoafz EZ5w== 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=yxx+lPcc6HpCrpOjtiZZmI+xsx6f/Gz95GkXuwJbivA=; b=ncpxdMskylJUQjJi1e1W695OzL18kah8KQj91iMi0akmRZFLYGn9mEGogawhBw1yje K4+UfAAKIl1k5E2hhBKeU/rU4yOqmAW1aE1H3SmKZ95dtZnRB5mdouJ8Gz0vG9eK3u+c 2h9PUJzf+ZQQTSyIZGk2V57gQ6g2FUrO/ck8LabEJmyxL3TKUPEN/JK5YqQk8mUz2pxc ATBjzUcgo01d+45hry/jDJABeSwFU45RDE2TK+ltOs+apGJVEuCFDuA5gwRhS1sijlUi jX3Hz6dMRVppHSdJ11o1Wh+uVLuUBVZO4XKu7S49iaR+0NphCXxvI9+6IVaJ+QBZW7j+ EMmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VIqbh2jh; 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 e6-20020a926906000000b00302c0283792si5329978ilc.110.2022.12.02.19.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 19:17:28 -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=VIqbh2jh; 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 6B83A851B5; Sat, 3 Dec 2022 04:17:25 +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="VIqbh2jh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E750984FF0; Sat, 3 Dec 2022 04:17: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-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (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 E7B9685111 for ; Sat, 3 Dec 2022 04:17:17 +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-xd2d.google.com with SMTP id n188so4279038iof.8 for ; Fri, 02 Dec 2022 19:17:17 -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=yxx+lPcc6HpCrpOjtiZZmI+xsx6f/Gz95GkXuwJbivA=; b=VIqbh2jhEK1CxKp2L4HSRtwlX403hsvXguj56lcLTp53KgSmdG6N15wkIgrvTS37iV 1aaTrg1LVK/7t8TYzd5se/mSrhx4GuZmPIgvIlseh5tUXipnILDBkULeGd9URlocQ9BD SugvEKz8JX2tD07ivjl8TFClvH0dDxsFryORx5R1luY3HxLi4Nmb+AmC73F9QC5lB1Zs W6/YNq8ABnyydD0vFoHVDjoJ5deZ4H0ydRcMQkPtp9pc999fnznbl2kEFY4Sgo3zvBdM vslpLcfl5g+ynl7SNF+bPPvPutG3qIZP+CUy1+dC5fUHVO+fUCON88ZGTv2jh1VNmXEa Z/8w== 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=yxx+lPcc6HpCrpOjtiZZmI+xsx6f/Gz95GkXuwJbivA=; b=0ZXBSDovpWZ+90bo2XJBeyNku6Vc10iJgp5mtvabP92uRVx9yRFcke2+sVcVZk/laU jq20V9/P2tKiazNk5IdQhFbHcO0tZqOpnVZ99EMfyrHicT6OQeisWC5EsM12mZ7e7BA1 RnW0y9eODgFKPp6PCrGp940t/SNlzbP883asQ7aWF9v8Chen+Ljn1y4zmIKvR0xvEx+i izfWXmZiOOtOCKkxvr6pHGnD9YzN2ndoDGMN7o61AVGfAsVRI8v8TQ6EgUi7SJHAqxpJ 02Bmt/EwLhOAZImOzSIsqZtG3r67O+dpmq6tEIefErxWCktkBYxKi/77AxkaCri6VVX/ DLnw== X-Gm-Message-State: ANoB5pkMgf0o5mJlUmi8hMjc30bS2beZEP3yONcIIFbLy1IqhQxrhIg/ nGLCrkkVCQ94EI5L1K/FQP4QWlCZ1gc= X-Received: by 2002:a5d:804e:0:b0:6dc:30bd:ed8f with SMTP id b14-20020a5d804e000000b006dc30bded8fmr27614305ior.130.1670037436039; Fri, 02 Dec 2022 19:17:16 -0800 (PST) Received: from jassi-desktop.. (wnpgmb0311w-ds01-45-179-115.dynamic.bellmts.net. [206.45.179.115]) by smtp.gmail.com with ESMTPSA id i41-20020a056638382900b00363fbcad265sm3381698jav.25.2022.12.02.19.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 19:17:15 -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: [PATCHv2 3/4] fwu: gpt: implement read_mdata and write_mdata callbacks Date: Fri, 2 Dec 2022 21:17:12 -0600 Message-Id: <20221203031712.579809-1-jassisinghbrar@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221203031557.579632-1-jassisinghbrar@gmail.com> References: <20221203031557.579632-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: Ilias Apalodimas Reviewed-by: Etienne Carriere with --- drivers/fwu-mdata/gpt_blk.c | 40 +++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/fwu-mdata/gpt_blk.c b/drivers/fwu-mdata/gpt_blk.c index 28f5d23e1e..35239c0a4f 100644 --- a/drivers/fwu-mdata/gpt_blk.c +++ b/drivers/fwu-mdata/gpt_blk.c @@ -222,7 +222,7 @@ static int fwu_gpt_read_mdata_partition(struct udevice *dev, struct fwu_mdata_gpt_blk_priv *priv = dev_get_priv(dev); return gpt_read_write_mdata(dev_get_uclass_plat(priv->blk_dev), - mdata, MDATA_READ, part_num); + mdata, MDATA_READ, part_num); } static int fwu_gpt_write_mdata_partition(struct udevice *dev, @@ -231,7 +231,7 @@ static int fwu_gpt_write_mdata_partition(struct udevice *dev, struct fwu_mdata_gpt_blk_priv *priv = dev_get_priv(dev); return gpt_read_write_mdata(dev_get_uclass_plat(priv->blk_dev), - mdata, MDATA_WRITE, part_num); + mdata, MDATA_WRITE, part_num); } static int fwu_get_mdata_device(struct udevice *dev, struct udevice **mdata_dev) @@ -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,