From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966075AbdEOQE5 (ORCPT ); Mon, 15 May 2017 12:04:57 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36088 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935096AbdEOQEz (ORCPT ); Mon, 15 May 2017 12:04:55 -0400 Subject: Re: [PATCH v4 1/2] tpm: Refactor tpm_transmit pulling out tpm_transfer function To: Jarkko Sakkinen References: <1494460462-29022-1-git-send-email-stefanb@linux.vnet.ibm.com> <1494460462-29022-2-git-send-email-stefanb@linux.vnet.ibm.com> <20170515124005.thnfzt4zz4yrba34@intel.com> Cc: tpmdd-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, jgunthorpe@obsidianresearch.com, linux-kernel@vger.kernel.org From: Stefan Berger Date: Mon, 15 May 2017 12:04:40 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170515124005.thnfzt4zz4yrba34@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17051516-0056-0000-0000-000003649C92 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007066; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000212; SDB=6.00860845; UDB=6.00426904; IPR=6.00640509; BA=6.00005350; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015465; XFM=3.00000015; UTC=2017-05-15 16:04:43 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17051516-0057-0000-0000-0000079AC808 Message-Id: <1b9e7995-8ed0-cc62-40b7-55b8d1e71ffe@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-05-15_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705150157 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/15/2017 08:40 AM, Jarkko Sakkinen wrote: > 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. I'll do that then, modifying the code to skip tpm_validate_command as well. Stefan > > /Jarkko > -- > To unsubscribe from this list: send the line "unsubscribe linux-security-module" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >