Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp83200imm; Fri, 19 Oct 2018 18:10:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV625fUsQvyp4mPpZ015sK2SGiHhSaajJTyokCnT0vrDjtj5lfu/g2c1Doe/qGVTrPXwBUtPW X-Received: by 2002:a63:e347:: with SMTP id o7-v6mr35366465pgj.251.1539997802012; Fri, 19 Oct 2018 18:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539997801; cv=none; d=google.com; s=arc-20160816; b=zlqJ+E0r4x2tOxusChBuqHQ/NhgOjnNlEeWItY6ifcPyy5Vflt8mFm3FpnhwyaBt5h c0FprppxTK8NOh+0Sn8KkLK9JEKcUvMCDEX/lGJu6958dkwXPoVZ/IVkE0DDcZBFJNkO czcFNA0xMF3n3NJHEivOdnLfJQXcIgfVVKnYHARxpNYBOCDCE7WKvOfWTVMRQhzflNWb TO8trsdw0EpXmZeIn6eX0Q0zRGk2hkiiZgT9B/+5PF4wmx2gSTnpwi+B46y4djggn7NH uAHFzqXfuZ8t8P7Y8L6pF1MqudZJ01CFLntkGllpzqvjvXsnrf19vPYqx8WXyXOm1qQa 1opA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=kNLv2N8XT+xWLA2wLfujAPfetNl2KHDAAr0nnPFePMQ=; b=m689E2c+2puBBnWnvw5DPfxKG0y8/oyCryykTcraywtNmWZvL85t5M5rn053j63L1P wUIkjz8BegRDL3+TAdz8vtiKG8f3CNuOO0vY1tvIUTouFLinXMukf+sebxUdXgc2zjpo 51uzREFC8eCJzNqcLL3hDk5O9RFV8rwjeiJmpkvJXqqZfmTQVxWSlbCPOg3etZ+7LOWS zUUKRDOR6BJgkiVXh6myKgxom9SzClfsQkV701DJ8mQnmUbKhn+W7Ugz1rSsm8Z2J0NY f75vNQAD9Pyp1kRaI2hUl/j1NdmqYdjrDyK+t8qOoOuzk33dCQp5FhySIvF1arvvSMbS 042A== 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 16-v6si6332981pgp.175.2018.10.19.18.09.46; Fri, 19 Oct 2018 18:10:01 -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 S1727240AbeJTJR4 (ORCPT + 99 others); Sat, 20 Oct 2018 05:17:56 -0400 Received: from mga07.intel.com ([134.134.136.100]:3360 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbeJTJR4 (ORCPT ); Sat, 20 Oct 2018 05:17:56 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Oct 2018 18:09:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,402,1534834800"; d="scan'208";a="272868917" Received: from kskibin-mobl.ger.corp.intel.com ([10.249.254.29]) by fmsmga005.fm.intel.com with ESMTP; 19 Oct 2018 18:09:15 -0700 Date: Sat, 20 Oct 2018 04:09:13 +0300 (EEST) From: Jarkko Sakkinen X-X-Sender: jsakkine@jsakkine-mobl1 To: Tomas Winkler cc: Jarkko Sakkinen , Jason Gunthorpe , Nayna Jain , Alexander Usyskin , Tadeusz Struk , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 13/21] tpm: add tpm_auto_startup() into tpm-interface.c In-Reply-To: <20181019182307.17745-14-tomas.winkler@intel.com> Message-ID: References: <20181019182307.17745-1-tomas.winkler@intel.com> <20181019182307.17745-14-tomas.winkler@intel.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 19 Oct 2018, Tomas Winkler wrote: > 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-7: 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 > > Reviewed-by: Jarkko Sakkinen /Jarkko