From patchwork Fri Nov 20 13:32:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 7667861 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B3637BF90C for ; Fri, 20 Nov 2015 13:33:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 00C3820429 for ; Fri, 20 Nov 2015 13:33:03 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 18B68203F7 for ; Fri, 20 Nov 2015 13:33:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZzloC-0000Sg-Hz; Fri, 20 Nov 2015 13:33:00 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZzloB-0000SX-1K for tpmdd-devel@lists.sourceforge.net; Fri, 20 Nov 2015 13:32:59 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of ts.fujitsu.com designates 80.70.172.49 as permitted sender) client-ip=80.70.172.49; envelope-from=martin.wilck@ts.fujitsu.com; helo=dgate10.ts.fujitsu.com; Received: from dgate10.ts.fujitsu.com ([80.70.172.49]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1ZzloA-0003TO-4c for tpmdd-devel@lists.sourceforge.net; Fri, 20 Nov 2015 13:32:59 +0000 X-SBRSScore: None Received: from unknown (HELO abgdgate60u.abg.fsc.net) ([172.25.138.90]) by dgate10u.abg.fsc.net with ESMTP; 20 Nov 2015 14:32:45 +0100 Received: from unknown (HELO pdbcooper.pdb.fsc.net) ([172.25.111.126]) by abgdgate60u.abg.fsc.net with ESMTP; 20 Nov 2015 14:32:45 +0100 Received: from pdbcooper.pdb.fsc.net (localhost [127.0.0.1]) by pdbcooper.pdb.fsc.net (8.14.9/8.14.8) with ESMTP id tAKDWduo006845; Fri, 20 Nov 2015 14:32:40 +0100 From: martin.wilck@ts.fujitsu.com To: tpmdd-devel@lists.sourceforge.net Date: Fri, 20 Nov 2015 14:32:33 +0100 Message-Id: <1448026354-6807-5-git-send-email-martin.wilck@ts.fujitsu.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1448026354-6807-1-git-send-email-martin.wilck@ts.fujitsu.com> References: <20151105170005.GA11530@intel.com> <1448026354-6807-1-git-send-email-martin.wilck@ts.fujitsu.com> X-Spam-Score: -2.2 (--) X-Headers-End: 1ZzloA-0003TO-4c Cc: Martin Wilck Subject: [tpmdd-devel] [PATCH 4/5] tpm_tis: further simplify calculation of ordinal duration 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-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, HK_RANDOM_ENVFROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Martin Wilck commit 07b133e6060b ("char/tpm: simplify duration calculation and eliminate smatch warning.") includes a misleading test that is always false. The tpm_ordinal_duration table is only valid for TPM_PROTECTED ordinals where the higher 16 bits are all 0, anyway. v2: avoid misleading masking of the ordinal index, add comment. Signed-off-by: Martin Wilck Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm-interface.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index c50637d..afdc836 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -310,10 +310,12 @@ unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, { int duration_idx = TPM_UNDEFINED; int duration = 0; - u8 category = (ordinal >> 24) & 0xFF; - if ((category == TPM_PROTECTED_COMMAND && ordinal < TPM_MAX_ORDINAL) || - (category == TPM_CONNECTION_COMMAND && ordinal < TSC_MAX_ORDINAL)) + /* + * We only have a duration table for protected commands, where the upper + * 16 bits are 0. For the few other ordinals the fallback will be used. + */ + if (ordinal < TPM_MAX_ORDINAL) duration_idx = tpm_ordinal_duration[ordinal]; if (duration_idx != TPM_UNDEFINED)