Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp305704imm; Tue, 16 Oct 2018 23:52:40 -0700 (PDT) X-Google-Smtp-Source: ACcGV62aPPGOhJRXW1wLX+wKZOzKsLOLuEQeriEt65xSrFnOB1TJk6wYDC4eLxoJcVjwTprXvs1X X-Received: by 2002:a63:9d01:: with SMTP id i1-v6mr21755774pgd.98.1539759160102; Tue, 16 Oct 2018 23:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539759160; cv=none; d=google.com; s=arc-20160816; b=PU5zUtTmZdntlab3Nr1IeIISKf5WJVmUgIfQF1KMcsxiLwiDDzyNFsRi7ZOzCD5RKw fl5ZPY0hm+IB6yibD2Rn8ssSMG1Hes1DVEvVhIHfkcmA8kbCh9RHbmk0diremM965SVl wSl+y7ZYyHSCu4NPfiIMZdbl2OEsK/GYSXwfXcxqYWkLiwAL1zUvPUedtTZVFwBcO8IN ympddcxYOZliZqtjSs12ViuWAtOWax5/D2rLTTuBhQKKsXpOk/4ik5GH/CFTbBgy4ifw V2VAB5yF1YuHusT7tMcWtA/4RHw/e1sAUCD493o4RNWBINjH8kMKKc6ivzoy71DmnjWT bobg== 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=DJ/DJyWxHBoF+jv8hKJWyMTyU9urSvhVJH7SuiDx2aA=; b=cbRZtQyLPW836TLnm1EXzVJAFOBwOn73vIg2fWLqDHkXFgBqJfXd+g3VnfyNTev1xL 2iGaOhznMS4eX9WSHUXrATATheB0NDc2Q1i9u+Hrvk3fEzyhc99nzfG7XXY5w8NRiQWq Y0EMgNjHADhgjlIuMDhehrfZIGeqlXWgGbFNdMKcUCjCCzTN5upIc9T8FbGdIyDlcImk sIajSiWyBWzDbTQkOty4iq4upYpSEHnyk3FvP3CeAtxQYqSMs0RoLKNXG1v2ByqPZPKv Iu+tZjIiPWHN/eZ3CeoSPHCR454ZOpyWKpkd6VFBsGNrnVNGzwZRmONQp2X4fNOeEVsQ OkdA== 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 bj3-v6si16077928plb.12.2018.10.16.23.52.24; Tue, 16 Oct 2018 23:52:40 -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 S1727718AbeJQOo5 (ORCPT + 99 others); Wed, 17 Oct 2018 10:44:57 -0400 Received: from mga18.intel.com ([134.134.136.126]:4116 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727570AbeJQOo4 (ORCPT ); Wed, 17 Oct 2018 10:44:56 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2018 23:50:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,391,1534834800"; d="scan'208";a="79371241" Received: from twinkler-lnx.jer.intel.com ([10.12.91.48]) by fmsmga008.fm.intel.com with ESMTP; 16 Oct 2018 23:50:43 -0700 From: Tomas Winkler To: Jarkko Sakkinen , Jason Gunthorpe Cc: Nayna Jain , Alexander Usyskin , Tadeusz Struk , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Tomas Winkler Subject: [PATCH v6 12/20] tpm: add tpm_auto_startup() into tpm-interface.c Date: Wed, 17 Oct 2018 09:46:05 +0300 Message-Id: <20181017064613.19746-13-tomas.winkler@intel.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20181017064613.19746-1-tomas.winkler@intel.com> References: <20181017064613.19746-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. V5-V6: Resend. 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 54b81700561b..69e007a198ce 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -545,6 +545,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 2eb73f6966c3..daca1d0190b1 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_auto_startup(struct tpm_chip *chip); -- 2.14.4