Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp706703imm; Fri, 21 Sep 2018 07:03:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdatNxxv+400vQOQGVPx9qx4sYAZg4fzX8xTUhMhaI4VP8XBgCSCc1z/17e0XjkWC7cAf8iW X-Received: by 2002:a62:6690:: with SMTP id s16-v6mr46749618pfj.152.1537538590792; Fri, 21 Sep 2018 07:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537538590; cv=none; d=google.com; s=arc-20160816; b=Ffbo/hr7BcEUmBrZc7egPD2PWHL9bxhIru/MB9Re0U8ZM6LWkmXvJoDVCbWbPFOMNE DiNGVF9i1IGwuNHudMC0pXarQOvdk3J0smCJUdokXNIilR8tkfgA5vkAU+i0vizwugOF FNAJTt+mVER57GfyMHKA3Y+Rs8msSxdmoc/2ucR57dntXVLYp8qRV7i6D123QDcb1y6x 9sYWC55R75W4o0ovF4bGHN6MP8WPEqMZGILGne93ztAqTUNbabfhef4c3Wi3df34FfTB iWJC34la7gUW9XZfcyfT2Y10MI/a7T9BgFXvL5ljvZ6DNceuW/hAfy37oMajAEGdGDHb uimw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=rJZcxn0FLDtZyxywg56ZXXZPF5H6kdpF8LiGVyzKvYU=; b=C0pI2ZS9w0hM3nYhC56DUOonDk2iO7uVMUsaSJXD7W2EX3D6Bf8LMbby1saJrbX4cN /N5w0/zZ4umLuunKLbW+ZOo9d0YsbjQrbAA52TWtfs58u56uJqmFsn5bIVg0vZ1jvFDr C7belrdfgImnBVdyPArJ0r5rukQ/w2HZiEv3ygu9c3FlYCosDOx5QYJFWZsOzzvGNYMa OlERQwbncO9PMJ9IesAWmOgpdS0KkReMB1D2U7Mq1UwWGY/joliE6SPHaTie33yLapPo inO8Re1HMrws8/GGpd14qNjU20Se5Ov45toKiYwz3xCHQv7gBE7ao5gx2k01pc3Y4VoF h/UQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u20-v6si26932296plq.210.2018.09.21.07.02.53; Fri, 21 Sep 2018 07:03:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390391AbeIUTvX (ORCPT + 99 others); Fri, 21 Sep 2018 15:51:23 -0400 Received: from mga18.intel.com ([134.134.136.126]:4682 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389657AbeIUTvW (ORCPT ); Fri, 21 Sep 2018 15:51:22 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2018 07:02:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,285,1534834800"; d="scan'208";a="71839154" Received: from twinkler-lnx.jer.intel.com ([10.12.91.48]) by fmsmga007.fm.intel.com with ESMTP; 21 Sep 2018 07:02:19 -0700 From: Tomas Winkler To: Jarkko Sakkinen , Jason Gunthorpe Cc: Alexander Usyskin , Tadeusz Struk , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Tomas Winkler Subject: [PATCH v4 13/21] tpm: add tpm_auto_startup() into tpm-interface.c Date: Fri, 21 Sep 2018 16:58:12 +0300 Message-Id: <20180921135820.20549-14-tomas.winkler@intel.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180921135820.20549-1-tomas.winkler@intel.com> References: <20180921135820.20549-1-tomas.winkler@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add wrapper tpm_auto_startup() to tpm-interface.c instead of open coded decision between TPM 1.x and TPM 2.x in tpm-chip.c Signed-off-by: Tomas Winkler Tested-by: Jarkko Sakkinen --- V3: New in the series. V4: Fix the commit message. drivers/char/tpm/tpm-chip.c | 11 +++-------- drivers/char/tpm/tpm-interface.c | 15 +++++++++++++++ drivers/char/tpm/tpm.h | 1 + 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index 46caadca916a..32db84683c40 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -451,14 +451,9 @@ int tpm_chip_register(struct tpm_chip *chip) { int rc; - if (chip->ops->flags & TPM_OPS_AUTO_STARTUP) { - if (chip->flags & TPM_CHIP_FLAG_TPM2) - rc = tpm2_auto_startup(chip); - else - rc = tpm1_auto_startup(chip); - if (rc) - return rc; - } + rc = tpm_auto_startup(chip); + if (rc) + return rc; tpm_sysfs_add_device(chip); diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index d18d9103a867..6cd3aed1e190 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -530,6 +530,21 @@ int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen) } EXPORT_SYMBOL_GPL(tpm_send); +int tpm_auto_startup(struct tpm_chip *chip) +{ + int rc; + + if (!(chip->ops->flags & TPM_OPS_AUTO_STARTUP)) + return 0; + + if (chip->flags & TPM_CHIP_FLAG_TPM2) + rc = tpm2_auto_startup(chip); + else + rc = tpm1_auto_startup(chip); + + return rc; +} + /* * We are about to suspend. Save the TPM state * so that it can be restored. diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index f0963a0a8acd..4ccffbb56864 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -541,6 +541,7 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space, size_t min_rsp_body_length, unsigned int flags, const char *desc); int tpm_get_timeouts(struct tpm_chip *); +int tpm_auto_startup(struct tpm_chip *chip); int tpm1_pm_suspend(struct tpm_chip *chip, int tpm_suspend_pcr); int tpm1_do_selftest(struct tpm_chip *chip); -- 2.14.4