From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from quartz.orcorp.ca ([184.70.90.242]:42985 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750908AbdJXSwX (ORCPT ); Tue, 24 Oct 2017 14:52:23 -0400 Date: Tue, 24 Oct 2017 12:52:08 -0600 From: Jason Gunthorpe To: Jarkko Sakkinen Cc: linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Matt Mackall , Herbert Xu , Peter Huewe , Marcel Selhorst , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , David Howells , Jerry Snitselaar , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , open list , "open list:KEYS-TRUSTED" Subject: Re: [PATCH] tpm: remove chip_num parameter from in-kernel API Message-ID: <20171024185208.GD1806@obsidianresearch.com> References: <20171023123817.18559-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <20171023123817.18559-1-jarkko.sakkinen@linux.intel.com> Sender: linux-integrity-owner@vger.kernel.org List-ID: On Mon, Oct 23, 2017 at 02:38:14PM +0200, Jarkko Sakkinen wrote: > The reasoning is simple and obvious. Since every call site passes the > value TPM_ANY_NUM (0xFFFF) the parameter does not have right to exist. > Refined the documentation of the corresponding functions. I like this patch, but how about a slightly different take, make this change instead: -struct tpm_chip *tpm_chip_find_get(int chip_num) +struct tpm_chip *tpm_chip_find_get(struct tpm_chip *chip); Where chip == NULL means the default TPM. And then at all call sites swap TPM_ANY_NUM to NULL and instead of flowing an 'int chip_num' to tpm_chip_find_get, flow the 'struct tpm_chip *' directly. This gets us much closer to the desired API with about the same amount of churn as this patch has. Jason