From patchwork Mon Jul 9 12:15:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 941244 X-Patchwork-Delegate: info@emk-elektronik.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Ujk3sFsq"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41PPSN5jjHz9rxs for ; Mon, 9 Jul 2018 22:16:04 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A2F49C21E18; Mon, 9 Jul 2018 12:16:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 75F45C21DF3; Mon, 9 Jul 2018 12:15:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E0B60C21DF3; Mon, 9 Jul 2018 12:15:56 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by lists.denx.de (Postfix) with ESMTPS id 7CC74C21D4A for ; Mon, 9 Jul 2018 12:15:56 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id h20-v6so4617480wmb.4 for ; Mon, 09 Jul 2018 05:15:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=oNqjYNoE707enDlD0ykyiYTikBJ6F4e/acGHOMpXhpY=; b=Ujk3sFsqc7FMxGfryQw5GJqEYfwxArZ5cEcPQgSyRNe3Oxdb8uANEO5ef5MeDbLcr6 l/eHJZBWYHq/+7FCv0vTR8tfmHjUY5oswF2fdBlxk/BIl80tusUNDt2ENzCtlJ+MfPqK mV6jkS5PWZRAGt0UzuxMMYHmtwDAOBuSrvNLg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=oNqjYNoE707enDlD0ykyiYTikBJ6F4e/acGHOMpXhpY=; b=N6OJSgnDSunXey1FnesVd//XDRFyAGaSbt0vnPfnQMUHDgtXnOQ09e+JnYWRfR0TH/ W5K5flPK5Riobp21/m7zfUGLFMBtjHl/gzbbgdetOJp5SW/DXXIrFiUWN9WSJpFQCZJz jTXYlxk5hcbP9YJIsTFl9M5hRpwkRLaG6YKtaCpeZZsdbePS5hf3iibyYR3BlG0xi0q+ 2LnqFmPI5OV2VinQd6cAQxPS3xdZgzmDPSYUxBvsmEuDBTgnCvfvOC0Gcosu5OWL1n/1 etaWodcdmZ/0Hnuphi7iAw9V4CSV7ZKk67yxxgZt+FpZbuOoLDI1OapEYCD8RaInRnk5 vLvw== X-Gm-Message-State: APt69E1MnCvXiVOV/VjaJVxO/d9cJbROe8SgjFFwrUOMNkj5/7mrcORH j9+w5o/r2zdhoNNrIpFRfV0t8idcsvY+9g== X-Google-Smtp-Source: AAOMgpccATCUYX1gKYZNVkuk/AJtKDC4B0BDuSazvXywyLz+PcnV1LsBsB0iFBFzKxhQ2c65uSNlrg== X-Received: by 2002:a1c:3282:: with SMTP id y124-v6mr11629085wmy.11.1531138555842; Mon, 09 Jul 2018 05:15:55 -0700 (PDT) Received: from localhost ([195.238.93.254]) by smtp.gmail.com with ESMTPSA id j43-v6sm30939143wrj.1.2018.07.09.05.15.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 05:15:55 -0700 (PDT) From: Igor Opaniuk To: u-boot@lists.denx.de Date: Mon, 9 Jul 2018 15:15:54 +0300 Message-Id: <1531138554-7429-1-git-send-email-igor.opaniuk@linaro.org> X-Mailer: git-send-email 2.7.4 Cc: trini@konsulko.com, praneeth@ti.com, misael.lopez@ti.com, erosca@de.adit-jv.com, joakim.bech@linaro.org Subject: [U-Boot] [PATCH 1/1] avb2.0: add get_size_of_partition() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Implement get_size_of_partition() operation, which is required by the latest upstream libavb [1]. [1] https://android.googlesource.com/platform/external/avb/+/master/README.md Signed-off-by: Igor Opaniuk Reviewed-by: Sam Protsenko --- common/avb_verify.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/common/avb_verify.c b/common/avb_verify.c index f9a00f8..5eabab0 100644 --- a/common/avb_verify.c +++ b/common/avb_verify.c @@ -699,6 +699,37 @@ static AvbIOResult get_unique_guid_for_partition(AvbOps *ops, } /** + * get_size_of_partition() - gets the size of a partition identified + * by a string name + * + * @ops: contains AVB ops handlers + * @partition: partition name (NUL-terminated UTF-8 string) + * @out_size_num_bytes: returns the value of a partition size + * + * @return: + * AVB_IO_RESULT_OK, on success (GUID found) + * AVB_IO_RESULT_ERROR_IO, out_size_num_bytes is NULL + * AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION, if partition was not found + */ +static AvbIOResult get_size_of_partition(AvbOps *ops, + const char *partition, + u64 *out_size_num_bytes) +{ + struct mmc_part *part; + + if (!out_size_num_bytes) + return AVB_IO_RESULT_ERROR_IO; + + part = get_partition(ops, partition); + if (!part) + return AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION; + + *out_size_num_bytes = part->info.blksz * part->info.size; + + return AVB_IO_RESULT_OK; +} + +/** * ============================================================================ * AVB2.0 AvbOps alloc/initialisation/free * ============================================================================ @@ -721,7 +752,7 @@ AvbOps *avb_ops_alloc(int boot_device) ops_data->ops.read_is_device_unlocked = read_is_device_unlocked; ops_data->ops.get_unique_guid_for_partition = get_unique_guid_for_partition; - + ops_data->ops.get_size_of_partition = get_size_of_partition; ops_data->mmc_dev = boot_device; return &ops_data->ops;