Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4998147imm; Tue, 18 Sep 2018 02:40:15 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYUYMtnmnDKff41FSP6lneLrGp7f9Rgxrvsc36GD36uaZWBVLAzA8udFaJqBruTuDnbOFpB X-Received: by 2002:a63:a35f:: with SMTP id v31-v6mr27161713pgn.261.1537263615566; Tue, 18 Sep 2018 02:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537263615; cv=none; d=google.com; s=arc-20160816; b=BzdRytZxw9amPTqNdVXsIZKes/T+mxgNi0k1FYjs0hyhEqKOtpTO7wB0qAUmdLvjDh YrSdCFRWYqV1dt+Frd0Amot6duOot4OkplhmV2U/wdqnAQNJRVRIEnYCTlLF67qYDSlV syII/MvyZkuNTzFZfIJcF+Jyw2/fO6bvsPsO9yFQXx5dNRh4fxgPQe3IqkNghSQOfxj6 /Bsdq+yXW3vYvgizxeZq/x9B9rlehVFMK+EwGj/lLODwg6wnVQ0GI1NspPQGA6LRmjKP Z5SwIzL1qdqApsH3C/Xs5m5D4kdCqqOtpPAGFnzKAcM0fv4nr/QLz+VsAbdFqQgHd6YA 6XYw== 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=D5hPZxeYv1c2jYxe8PxU8EHbqji/eM4/Y57WOLfMz5U=; b=Md25eMkW0NZrDKh2W82jg6ED0y4+RbFKrhsUZhxnYc9KtEtJWQaQP/jh0SyTfc4c1O 31n7qsNv/F8U0pFef17DWx5MDlDign6gPTb+xvU2NlsWsIIw5fzGJwe6S2+H6l9zjwYG r7U5uQc4U3OSs2kCOPBwt1PgNGRCCc4/1JeXnFcyl/JWeebsbnUNWrmcDRl4LMlIBnFS +7RF13lPS8E4dYt48ygbhooR/0fjjn/SteVdBMf9WOtbFXz726eHlB9vPT955ej1KKQo +v91zzaIrG3I/PUm5xzGQDy1K9EgHcNMDuKIdGX2kqS5dz3+kumMGYxkLdbZnB31w+/V tukA== 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 v38-v6si21155809plg.179.2018.09.18.02.40.00; Tue, 18 Sep 2018 02:40:15 -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 S1729843AbeIRPKO (ORCPT + 99 others); Tue, 18 Sep 2018 11:10:14 -0400 Received: from mga01.intel.com ([192.55.52.88]:59397 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729794AbeIRPKN (ORCPT ); Tue, 18 Sep 2018 11:10:13 -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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Sep 2018 02:38:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,389,1531810800"; d="scan'208";a="71724188" Received: from twinkler-lnx.jer.intel.com ([10.12.91.48]) by fmsmga008.fm.intel.com with ESMTP; 18 Sep 2018 02:38:23 -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 v3 13/20] tpm: add tpm_auto_startup into tpm-interface Date: Tue, 18 Sep 2018 12:34:52 +0300 Message-Id: <20180918093459.19165-14-tomas.winkler@intel.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180918093459.19165-1-tomas.winkler@intel.com> References: <20180918093459.19165-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.2 and tpm 2.0 in tpm-chip.c Signed-off-by: Tomas Winkler --- V3: new in the series 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 54e2cc592bd9..a8f8e0bcb434 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -520,6 +520,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