Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1275037imm; Tue, 3 Jul 2018 08:22:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLjfZYSJ+8Z1QBDLZeTDZU42bgl1b19fc0rPOK5b6lLU2i/vwHMrYmXQZOn6ol5MJuypt6K X-Received: by 2002:a17:902:d716:: with SMTP id w22-v6mr30360123ply.98.1530631349086; Tue, 03 Jul 2018 08:22:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530631349; cv=none; d=google.com; s=arc-20160816; b=m7IxYzR+HWbPtdYhREZIPF7E2pib8vx1MP0JoOkirCwKArY73oWV9zFePokWpsSYaH NFeNB9he96tudNCHGvWPkeF3lUMwXIqSXOOMH4WtgujzLNSOIKMIEg1783J42JwJfkxK GXOpojiIBixWxrlv69K0lYG6NTEJ3TDIJR2ePKBoel/c7D8MGcF9KIt+jVTScDN064Bu zriWwvPwaWiWGqE9kilxjO5nQe8afyyiLUQ8SUwasDUAZETIR3QeBNlmsZoEW3zcqp40 Zydsx9JJt0td9XJbsK6nLKzXjK4o1lJSj2bVLCJyDopQK+Rrrc48wyA5Rj3m9wm8ur2c XF/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=pO6/fKkjIQmQtsLpLKHoCn3oy6neJ+BPRk2i0B2x1bU=; b=bEjj+9yhePT+2p620sPLmRq5w/oV0frvOpl6jsr/WinxFgQgSfMJoC7sJNeYW7L8gA Qsceev3bdKnWWAvK2lGSDM6T+Tvjx8y/MYVbL2vJ5SUO2k59UktpOZGNkzjjbcSWFBVk p0YhQCo+3GU0O9tvRTvMcGBTMKEDu2emubOy/vTFU73gwiMilqRHKQz9CbYQojVQ2Dbo oiTZdCNe151BRPW2y44brBuPFWkzppU4iM60cbGrxBBtSlhppEkIiKKSgAExFsOVjSyL qOP1/OeM7dLJBfDoG9/e7Pgy2GdFkW4nQn+GySI6jfRlTexGZIje5z31sk0RhynFq8lH cghQ== 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 d18-v6si1142165pgv.248.2018.07.03.08.22.14; Tue, 03 Jul 2018 08:22:29 -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 S933679AbeGCPVi (ORCPT + 99 others); Tue, 3 Jul 2018 11:21:38 -0400 Received: from mga02.intel.com ([134.134.136.20]:19262 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933358AbeGCPVg (ORCPT ); Tue, 3 Jul 2018 11:21:36 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jul 2018 08:21:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,304,1526367600"; d="scan'208";a="213108251" Received: from cdikicix-mobl.ger.corp.intel.com ([10.249.254.69]) by orsmga004.jf.intel.com with ESMTP; 03 Jul 2018 08:21:30 -0700 Message-ID: <4789ea0ee11f0a87afcd89ad2814ad0964dd4809.camel@linux.intel.com> Subject: Re: [PATCH 1/2] tpm: Implement public tpm_put_chip() to release reference to chip From: Jarkko Sakkinen To: Stefan Berger , linux-integrity@vger.kernel.org, zohar@linux.vnet.ibm.com, jejb@linux.vnet.ibm.com Cc: jgg@ziepe.ca, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, dhowells@redhat.com, keyrings@vger.kernel.org, Stefan Berger Date: Tue, 03 Jul 2018 18:21:29 +0300 In-Reply-To: <20180626193040.2509798-2-stefanb@linux.vnet.ibm.com> References: <20180626193040.2509798-1-stefanb@linux.vnet.ibm.com> <20180626193040.2509798-2-stefanb@linux.vnet.ibm.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-06-26 at 15:30 -0400, Stefan Berger wrote: > Some subsystems that got a hold of a TPM chip through tpm_default_chip() > need a way to release the reference to the TPM chip when they shut down. > The tpm_put_chip() function enables this. > > Signed-off-by: Stefan Berger > --- > drivers/char/tpm/tpm-chip.c | 10 ++++++++++ > include/linux/tpm.h | 4 ++++ > 2 files changed, 14 insertions(+) > > diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c > index 46caadca916a..c744289d82e0 100644 > --- a/drivers/char/tpm/tpm-chip.c > +++ b/drivers/char/tpm/tpm-chip.c > @@ -80,6 +80,16 @@ void tpm_put_ops(struct tpm_chip *chip) > } > EXPORT_SYMBOL_GPL(tpm_put_ops); > > +/** > + * tpm_put_chip() - Releae a ref to the tpm_chip > + * @chip: Chip to put > + */ > +void tpm_put_chip(struct tpm_chip *chip) > +{ > + put_device(&chip->dev); > +} > +EXPORT_SYMBOL_GPL(tpm_put_chip); > + > /** > * tpm_default_chip() - find a TPM chip and get a reference to it > */ > diff --git a/include/linux/tpm.h b/include/linux/tpm.h > index e0e51c49a0e6..889dafe739e1 100644 > --- a/include/linux/tpm.h > +++ b/include/linux/tpm.h > @@ -62,6 +62,7 @@ extern int tpm_unseal_trusted(struct tpm_chip *chip, > struct trusted_key_payload *payload, > struct trusted_key_options *options); > extern struct tpm_chip *tpm_default_chip(void); > +extern void tpm_put_chip(struct tpm_chip *chip); > #else > static inline int tpm_is_tpm2(struct tpm_chip *chip) > { > @@ -101,5 +102,8 @@ static inline struct tpm_chip *tpm_default_chip(void) > { > return NULL; > } > +static inline void tpm_put_chip(struct tpm_chip *chip) > +{ > +} > #endif > #endif Reviewed-by: Jarkko Sakkinen /Jarkko