Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1283564imm; Fri, 28 Sep 2018 15:36:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV60fbbrN+4sLZWINWQ8rhVj/MRjtm646LKuX/eMWH6B6nNKh5qzDAsnbk9hs6h69KJ4kmlIT X-Received: by 2002:a17:902:1681:: with SMTP id h1-v6mr596985plh.262.1538174215537; Fri, 28 Sep 2018 15:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538174215; cv=none; d=google.com; s=arc-20160816; b=t5YafeBpJpAXsofUG6KLTd1IutLOKuWh+pZWPtaYW7LrzfDWiiCwGC1E2DHgmTYfsN ggmndrcQ4GGs4pUxdSe9wg3p+cla/Ga9/XAXWKgxO4sVBOQi0rpz2tMlCUEx07t4az9g RX1ieeTOrCEVcxEHDEc4AnX2MNYctjKm0Le2GiRxDO/3APy8bXnvrWCaDoblYsJDpsI2 bvd+1uDWD8vwPqzD3Mx/CzVm5FFLx6fTnkeZwCiJcMFz+NnBn/O2bbonc9FJufrWnL2K m4km2ENP/ldQv+5NFG98GO4U3dnF7FNU5tF8S5DvvZy6/ditrrVqODtO4SsiVdfyiXaI N4tQ== 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=vY8hfY9EzvT1g3tyindLiAnel5iuIPuMYQSh+E/aB+k=; b=xj2exTopuRsE7CtiaoEcrKOTExbwyrYTkCZ01idcpmiJ/+em3SMFD9NY/Mvbwn5H3t ohl87vSQ4bEkvpEmyOTFINr+R1xZWDwAmiHt+uveA8Lca9S+2TbDJyV2/93uxf9uHHb4 eLTeNhgXb3lUd7GScFtiZaegSxqzlJtIkZ4bSlPVlEdXE05YdxnQaHZ667V0xQp6mwNk IX1NbUAhLsHjNO/cZ4HQ2cDDWBWFNAWM3c95LqjQjkTY8XH6L0xzizhoxE13KiwZEcUK RcjFbMDgjHSYsKgmXs23Jrims26PXiakuTQQSKpQFXzC41j+C7zNEWBLRvqX7rClE6Vo D+hw== 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 j24-v6si2026928pll.485.2018.09.28.15.36.41; Fri, 28 Sep 2018 15:36:55 -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 S1727619AbeI2FBH (ORCPT + 99 others); Sat, 29 Sep 2018 01:01:07 -0400 Received: from mga11.intel.com ([192.55.52.93]:9469 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727551AbeI2FBG (ORCPT ); Sat, 29 Sep 2018 01:01:06 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Sep 2018 15:35:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,316,1534834800"; d="scan'208";a="267880272" Received: from twinkler-lnx.jer.intel.com ([10.12.91.48]) by fmsmga006.fm.intel.com with ESMTP; 28 Sep 2018 15:35:12 -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 v5 13/21] tpm: add tpm_auto_startup() into tpm-interface.c Date: Sat, 29 Sep 2018 01:30:27 +0300 Message-Id: <20180928223035.14471-14-tomas.winkler@intel.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180928223035.14471-1-tomas.winkler@intel.com> References: <20180928223035.14471-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: 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 1ea83a3f1b02..fb142e229f95 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