From patchwork Mon Feb 28 12:06:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 546690 Delivered-To: patch@linaro.org Received: by 2002:ac0:9f50:0:0:0:0:0 with SMTP id l16csp2675341imf; Mon, 28 Feb 2022 04:08:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxL9p8l0GVf/p2f1ejq/XOCGlAxnsmDGKSD26bzxcHcXOx/7WpFeV3OJsOMufDJ1+egBByk X-Received: by 2002:a17:906:5597:b0:6ce:f3cc:14e8 with SMTP id y23-20020a170906559700b006cef3cc14e8mr14987641ejp.426.1646050102335; Mon, 28 Feb 2022 04:08:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646050102; cv=none; d=google.com; s=arc-20160816; b=zMtEzxiTkL8trqy+z4TIonfGJMF7wgiuvdoQO9tsdkwa5Wg8Klb1KTKoGfUi8bq8y9 s+QPK2EHPj2hOyFg74q1iKZ5sORIsBBWBY1evWPBjBk/aIU9l4v5LREb/s69WbgdYiO3 JflDhWdqrWqo36gzxvPPKe3mr1rCjmYQoaoty9v/uQ6T7cTFnApRErXbes/slLgBbI94 95liuRVn8iWtSUqaPM38syOe9yWBD01u11i0PUw6QbyQIZyH0NQ0M6xh8ErjbftAZEs8 B014RrzxtGcXSTB+vFc++IRkRITFNEKKZ+GgEqN8J/+4ucOQrzU31IoSwhExaKwg+h+X utXw== 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; bh=Ciy3sS56azmcMDILPDGK7PlF8SA88R/QZx4aAUd5ZcU=; b=nIYro6AzlY5PMvC4jtRaS6uS1vEvHFagE7RIYRPUKrYsjf/K4EvwtV6UcE/JC1zdIv 57JNPSl0piGTogYoJWuC+LtijwsFum0DCFg0WhboLZ+mcm3lfJZ2maB22iDWd6tTkHzT sWW0TTlym1Ct5FOxp07wv9/oRzP3+C7nYOGH11BoaVrA6q1am9vDtKwri6Fag07Q3DI5 Z/m924Hm1xERQH268082t0Lw3zywLqd943mHdkHGdr5G3VgaBhEboLmBT/mvLHX5xdM+ YuonJuLJSvnznBp8hmM4GID0XZ6aP2ovm0nqI4EzWBF7bQU7/oGTezhvHN43tjOTP+J9 Io5Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id l21-20020a50d6d5000000b00412a7ccf5fesi7250414edj.418.2022.02.28.04.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 04:08:22 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6918183C55; Mon, 28 Feb 2022 13:08:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id BEADC83C5D; Mon, 28 Feb 2022 13:07: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=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 561078309E for ; Mon, 28 Feb 2022 13:07:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7CFFEED1; Mon, 28 Feb 2022 04:07:35 -0800 (PST) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 982153F73D; Mon, 28 Feb 2022 04:07:33 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Heinrich Schuchardt , Mario Six , Sughosh Ganu Subject: [PATCH v2 04/10] tpm: Move the TPM version detection functions to the uclass driver Date: Mon, 28 Feb 2022 17:36:32 +0530 Message-Id: <20220228120638.678137-5-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228120638.678137-1-sughosh.ganu@linaro.org> References: <20220228120638.678137-1-sughosh.ganu@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.5 at phobos.denx.de X-Virus-Status: Clean Make the TPM version detection functions as external symbols and move them to the TPM uclass driver. These are useful functions to check the TPM device version and should not be static functions. Signed-off-by: Sughosh Ganu Reviewed-by: Heinrich Schuchardt --- Changes since V1: None drivers/tpm/tpm-uclass.c | 11 +++++++++++ include/tpm_api.h | 20 ++++++++++++++++++++ lib/tpm_api.c | 10 ---------- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/drivers/tpm/tpm-uclass.c b/drivers/tpm/tpm-uclass.c index f67fe1019b..8619da89d8 100644 --- a/drivers/tpm/tpm-uclass.c +++ b/drivers/tpm/tpm-uclass.c @@ -11,10 +11,21 @@ #include #include #include +#include #include #include #include "tpm_internal.h" +bool is_tpm1(struct udevice *dev) +{ + return IS_ENABLED(CONFIG_TPM_V1) && tpm_get_version(dev) == TPM_V1; +} + +bool is_tpm2(struct udevice *dev) +{ + return IS_ENABLED(CONFIG_TPM_V2) && tpm_get_version(dev) == TPM_V2; +} + int tpm_open(struct udevice *dev) { struct tpm_ops *ops = tpm_get_ops(dev); diff --git a/include/tpm_api.h b/include/tpm_api.h index fb6ee14e23..c19639a688 100644 --- a/include/tpm_api.h +++ b/include/tpm_api.h @@ -11,6 +11,26 @@ #include #include +/** + * is_tpm1() - Check if it is a tpmv1 device + * @param dev TPM device + * + * Check if the TPM device is a TPMv1 device + * + * Return: 1 if TPMv1, 0 otherwise + */ +bool is_tpm1(struct udevice *dev); + +/** + * is_tpm2() - Check if it is a tpmv2 device + * @param dev TPM device + * + * Check if the TPM device is a TPMv2 device + * + * Return: 1 if TPMv2, 0 otherwise + */ +bool is_tpm2(struct udevice *dev); + /** * Issue a TPM_Startup command. * diff --git a/lib/tpm_api.c b/lib/tpm_api.c index b762202866..9dd9606fa8 100644 --- a/lib/tpm_api.c +++ b/lib/tpm_api.c @@ -11,16 +11,6 @@ #include #include -static bool is_tpm1(struct udevice *dev) -{ - return IS_ENABLED(CONFIG_TPM_V1) && tpm_get_version(dev) == TPM_V1; -} - -static bool is_tpm2(struct udevice *dev) -{ - return IS_ENABLED(CONFIG_TPM_V2) && tpm_get_version(dev) == TPM_V2; -} - int tpm_startup(struct udevice *dev, enum tpm_startup_type mode) { if (is_tpm1(dev)) {