From patchwork Thu Feb 24 18:05:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 545594 Delivered-To: patch@linaro.org Received: by 2002:ac0:d8d1:0:0:0:0:0 with SMTP id b17csp437416imj; Thu, 24 Feb 2022 10:07:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVtvULvWaMl0R9xrXpiqXEAqdc3QLVTAmrl1YLXgKFlY3e73sKSwdq9BWi2Z4/zYGvar3G X-Received: by 2002:a50:bf0f:0:b0:410:c512:cb6f with SMTP id f15-20020a50bf0f000000b00410c512cb6fmr3449121edk.262.1645726024352; Thu, 24 Feb 2022 10:07:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645726024; cv=none; d=google.com; s=arc-20160816; b=LRLAGWt1YW6FSW1nyc4sJ+xwlA42afMs3Oxlpe8szxwvSMIpWf8iFOpu5jkwTHOOdN 1fsW7HZKmTj2wrGwNJiYp/8OqB0zr1QsIxnIKQVrjkQrCXZXZZUnv3NC+OYv7EWZfXLS RdjJSSuXN+XwADXCqr2EmkcR2FOwutjV8r3Ah+qaM3MykYSijA6rBxRXAfpaLF5u0vqI nUmHXXiVWjBcaao634CWwudoopPdI80cseMJa3URu59YT9VS0sfRIr9Ga457gdNjrDzw ZZTzPtLwh1Rf1E4pCfcZ6ebj8OeBVkkQ+MKgzQN/wOnJnJM9znEMoEoR2qWZAy/NOAht MGPw== 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:references:in-reply-to :message-id:date:subject:cc:to:from; bh=16cl6pk7oJ1dQ1nXgAzUcaj5tWZKPmyhlSRQRQopPTQ=; b=ZlccJpfJuuq9ScvzFWppKog/S4TYxoQdN2Jg1uXAwfZ1TJUo3bSgxjRmMO5zniC5Pu QYuaSGq3VFL3Yfd1A23qqbVQD14m4sTsLhE7R8ZtweAmDC5V3qszAVc8SzCFeM1gVLXf WRf02v7jY5NdRAID/Qxk88G/Z5Cw05SKYvMVi+4P2/RAgOVw/dFtMwo+aHExqRIlVRi+ mVtD90JXZrPqyEQTumYGgykkWvLya8HWbjmCQwwFZwAFN4HkYKbhDEWT5a80KeCb7OMt PLFgHpHy/iFytGP4qKsDqspFPnCpMbJ8SlL+XrYzmG2gHcOBUiOctw9Q+zNHBV7sgWP4 dnpg== 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 k12-20020a170906970c00b006d12c094e63si37446ejx.735.2022.02.24.10.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 10:07:04 -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 765DB83CE3; Thu, 24 Feb 2022 19:06:38 +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 1537483CBA; Thu, 24 Feb 2022 19:06:31 +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 AC35383CB1 for ; Thu, 24 Feb 2022 19:06:25 +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 E08EA106F; Thu, 24 Feb 2022 10:06:24 -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 7E2C93F70D; Thu, 24 Feb 2022 10:06:22 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Heinrich Schuchardt , Mario Six , Sughosh Ganu Subject: [PATCH 04/10] tpm: Move the TPM version detection functions to the uclass driver Date: Thu, 24 Feb 2022 23:35:46 +0530 Message-Id: <20220224180552.26901-5-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224180552.26901-1-sughosh.ganu@linaro.org> References: <20220224180552.26901-1-sughosh.ganu@linaro.org> 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 --- 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)) {