From patchwork Tue Jul 19 23:45:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 650507 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3rvGs04WDpz9ssP for ; Wed, 20 Jul 2016 09:46:12 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1bPeiH-0004Og-5w; Tue, 19 Jul 2016 23:46:09 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1bPeiF-0004Ob-Ty for tpmdd-devel@lists.sourceforge.net; Tue, 19 Jul 2016 23:46:07 +0000 X-ACL-Warn: Received: from mga14.intel.com ([192.55.52.115]) by sog-mx-4.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1bPeiF-0004IF-3M for tpmdd-devel@lists.sourceforge.net; Tue, 19 Jul 2016 23:46:07 +0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 19 Jul 2016 16:46:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,391,1464678000"; d="scan'208";a="736897364" Received: from pjgubbin-mobl2.ger.corp.intel.com (HELO localhost) ([10.252.3.191]) by FMSMGA003.fm.intel.com with ESMTP; 19 Jul 2016 16:45:57 -0700 From: Jarkko Sakkinen To: Peter Huewe , Jason Gunthorpe Date: Wed, 20 Jul 2016 02:45:00 +0300 Message-Id: <1468971906-6528-6-git-send-email-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468971906-6528-1-git-send-email-jarkko.sakkinen@linux.intel.com> References: <1468971906-6528-1-git-send-email-jarkko.sakkinen@linux.intel.com> X-Spam-Score: -1.3 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.3 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1bPeiF-0004IF-3M Cc: open list , linux-security-module@vger.kernel.org, "moderated list:TPM DEVICE DRIVER" Subject: [tpmdd-devel] [PATCH v4 5/5] tpm: use tpm_pcr_read_dev() in tpm_do_selftest() 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 Instead of a ad-hoc protocol message construction it is better to call tpm_pcr_read_dev(). Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm-interface.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index f43cc3f..ef5ad80 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -777,7 +777,7 @@ int tpm_do_selftest(struct tpm_chip *chip) unsigned int loops; unsigned int delay_msec = 100; unsigned long duration; - struct tpm_cmd_t cmd; + u8 dummy[TPM_DIGEST_SIZE]; duration = tpm_calc_ordinal_duration(chip, TPM_ORD_CONTINUE_SELFTEST); @@ -792,9 +792,7 @@ int tpm_do_selftest(struct tpm_chip *chip) do { /* Attempt to read a PCR value */ - cmd.header.in = pcrread_header; - cmd.params.pcrread_in.pcr_idx = cpu_to_be32(0); - rc = tpm_transmit(chip, (u8 *) &cmd, READ_PCR_RESULT_SIZE); + rc = tpm_pcr_read_dev(chip, 0, dummy); /* Some buggy TPMs will not respond to tpm_tis_ready() for * around 300ms while the self test is ongoing, keep trying * until the self test duration expires. */ @@ -809,7 +807,6 @@ int tpm_do_selftest(struct tpm_chip *chip) if (rc < TPM_HEADER_SIZE) return -EFAULT; - rc = be32_to_cpu(cmd.header.out.return_code); if (rc == TPM_ERR_DISABLED || rc == TPM_ERR_DEACTIVATED) { dev_info(&chip->dev, "TPM is disabled/deactivated (0x%X)\n", rc);