From patchwork Wed Feb 15 18:02:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 9574677 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 272FC6045F for ; Wed, 15 Feb 2017 18:03:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 105132843E for ; Wed, 15 Feb 2017 18:03:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04CE9284F7; Wed, 15 Feb 2017 18:03:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 75F72284DE for ; Wed, 15 Feb 2017 18:03:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ce3ut-0005pe-7Y; Wed, 15 Feb 2017 18:02:59 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ce3us-0005pZ-O5 for tpmdd-devel@lists.sourceforge.net; Wed, 15 Feb 2017 18:02:58 +0000 X-ACL-Warn: Received: from mga11.intel.com ([192.55.52.93]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1ce3um-00078c-L9 for tpmdd-devel@lists.sourceforge.net; Wed, 15 Feb 2017 18:02:58 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Feb 2017 10:02:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.35,166,1484035200"; d="scan'208"; a="1107854619" Received: from pmurator-mobl2.ger.corp.intel.com (HELO localhost) ([10.252.21.9]) by fmsmga001.fm.intel.com with ESMTP; 15 Feb 2017 10:02:32 -0800 From: Jarkko Sakkinen To: tpmdd-devel@lists.sourceforge.net Date: Wed, 15 Feb 2017 20:02:28 +0200 Message-Id: <20170215180228.25650-1-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.9.3 X-Headers-End: 1ce3um-00078c-L9 Cc: open list , linux-security-module@vger.kernel.org Subject: [tpmdd-devel] [PATCH] tpm: declare tpm2_get_pcr_allocation() as static X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Virus-Scanned: ClamAV using ClamSMTP There's no need to export tpm2_get_pcr_alloation() because it is only a helper function for tpm2_auto_startup(). For the same reason it does not make much sense to maintain documentation for it. Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm.h | 1 - drivers/char/tpm/tpm2-cmd.c | 94 ++++++++++++++++++++++----------------------- 2 files changed, 45 insertions(+), 50 deletions(-) diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 6b4e7aa..4937b56 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -554,5 +554,4 @@ int tpm2_auto_startup(struct tpm_chip *chip); void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type); unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal); int tpm2_probe(struct tpm_chip *chip); -ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip); #endif diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index 10f97e6..881aea9 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c @@ -997,61 +997,13 @@ int tpm2_probe(struct tpm_chip *chip) } EXPORT_SYMBOL_GPL(tpm2_probe); -/** - * tpm2_auto_startup - Perform the standard automatic TPM initialization - * sequence - * @chip: TPM chip to use - * - * Returns 0 on success, < 0 in case of fatal error. - */ -int tpm2_auto_startup(struct tpm_chip *chip) -{ - int rc; - - rc = tpm_get_timeouts(chip); - if (rc) - goto out; - - rc = tpm2_do_selftest(chip); - if (rc != 0 && rc != TPM2_RC_INITIALIZE) { - dev_err(&chip->dev, "TPM self test failed\n"); - goto out; - } - - if (rc == TPM2_RC_INITIALIZE) { - rc = tpm2_startup(chip, TPM2_SU_CLEAR); - if (rc) - goto out; - - rc = tpm2_do_selftest(chip); - if (rc) { - dev_err(&chip->dev, "TPM self test failed\n"); - goto out; - } - } - - rc = tpm2_get_pcr_allocation(chip); - -out: - if (rc > 0) - rc = -ENODEV; - return rc; -} - struct tpm2_pcr_selection { __be16 hash_alg; u8 size_of_select; u8 pcr_select[3]; } __packed; -/** - * tpm2_get_pcr_allocation() - get TPM active PCR banks. - * - * @chip: TPM chip to use. - * - * Return: Same as with tpm_transmit_cmd. - */ -ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip) +static ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip) { struct tpm2_pcr_selection pcr_selection; struct tpm_buf buf; @@ -1114,3 +1066,47 @@ ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip) return rc; } + +/** + * tpm2_auto_startup - Perform the standard automatic TPM initialization + * sequence + * @chip: TPM chip to use + * + * Initializes timeout values for operation and command durations, conducts + * a self-test and reads the list of active PCR banks. + * + * Return: 0 on success. Otherwise, a system error code is returned. + */ +int tpm2_auto_startup(struct tpm_chip *chip) +{ + int rc; + + rc = tpm_get_timeouts(chip); + if (rc) + goto out; + + rc = tpm2_do_selftest(chip); + if (rc != 0 && rc != TPM2_RC_INITIALIZE) { + dev_err(&chip->dev, "TPM self test failed\n"); + goto out; + } + + if (rc == TPM2_RC_INITIALIZE) { + rc = tpm2_startup(chip, TPM2_SU_CLEAR); + if (rc) + goto out; + + rc = tpm2_do_selftest(chip); + if (rc) { + dev_err(&chip->dev, "TPM self test failed\n"); + goto out; + } + } + + rc = tpm2_get_pcr_allocation(chip); + +out: + if (rc > 0) + rc = -ENODEV; + return rc; +}