From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758341AbdEOMkK (ORCPT ); Mon, 15 May 2017 08:40:10 -0400 Received: from mga07.intel.com ([134.134.136.100]:16148 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750935AbdEOMkI (ORCPT ); Mon, 15 May 2017 08:40:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,345,1491289200"; d="scan'208";a="87553619" Date: Mon, 15 May 2017 15:40:05 +0300 From: Jarkko Sakkinen To: Stefan Berger Cc: tpmdd-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, jgunthorpe@obsidianresearch.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/2] tpm: Refactor tpm_transmit pulling out tpm_transfer function Message-ID: <20170515124005.thnfzt4zz4yrba34@intel.com> References: <1494460462-29022-1-git-send-email-stefanb@linux.vnet.ibm.com> <1494460462-29022-2-git-send-email-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1494460462-29022-2-git-send-email-stefanb@linux.vnet.ibm.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 10, 2017 at 07:54:21PM -0400, Stefan Berger wrote: > Refactor tpm_transmit and pull out code sending the command > and receiving the response and put this into tpm_transfer. > > Signed-off-by: Stefan Berger > --- > drivers/char/tpm/tpm-interface.c | 121 +++++++++++++++++++++++---------------- > 1 file changed, 73 insertions(+), 48 deletions(-) > > diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c > index 158c1db..263b6d1 100644 > --- a/drivers/char/tpm/tpm-interface.c > +++ b/drivers/char/tpm/tpm-interface.c > @@ -370,67 +370,29 @@ static bool tpm_validate_command(struct tpm_chip *chip, > } > > /** > - * tmp_transmit - Internal kernel interface to transmit TPM commands. > + * tmp_transfer - Send a TPM command to the TPM and receive response > * > * @chip: TPM chip to use > * @buf: TPM command buffer > + * @count: size of the TPM command > * @bufsiz: length of the TPM command buffer > - * @flags: tpm transmit flags - bitmap > * > * Return: > - * 0 when the operation is successful. > + * >0 when the operation is successful; returns response length > * A negative number for system errors (errno). > */ > -ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space, > - u8 *buf, size_t bufsiz, unsigned int flags) > +ssize_t tpm_transfer(struct tpm_chip *chip, u8 *buf, u32 count, size_t bufsiz) Add instead a flag TPM_TRANSMIT_RAW (this name is just a suggestion) that skips "prepare" and "commit" parts. That would save us from a new export. Better way to make it less messy would be to add static functions tpm_prepare_command and tpm_commit_command that would be always called and would return immediately if flags contain TPM_TRANSMIT_RAW. /Jarkko