From: PrasannaKumar Muralidharan Subject: Re: [tpmdd-devel] [PATCH] tpm: remove chip_num parameter from in-kernel API Date: Tue, 24 Oct 2017 23:26:52 +0530 Message-ID: References: <20171023123817.18559-1-jarkko.sakkinen@linux.intel.com> <20171023163139.GA17394@obsidianresearch.com> <20171024154440.3jeupmus43jcgbbz@linux.intel.com> <20171024155526.GA32250@obsidianresearch.com> <20171024161118.GA348@obsidianresearch.com> <20171024174637.GB1806@obsidianresearch.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: Jarkko Sakkinen , Stefan Berger , linux-integrity@vger.kernel.org, David Howells , Herbert Xu , "open list:INTEGRITY MEASUREMENT ARCHITECTURE IMA" , Dmitry Kasatkin , open list , linux-security-module@vger.kernel.org, "moderated list:TPM DEVICE DRIVER" , "open list:KEYS-TRUSTED" , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , James Morris , Matt Mackall , "open list:INTEGRITY MEASUREMENT ARCHITECTURE IMA" To: Jason Gunthorpe Return-path: In-Reply-To: <20171024174637.GB1806@obsidianresearch.com> Sender: owner-linux-security-module@vger.kernel.org List-Id: linux-crypto.vger.kernel.org Hi Jason, On 24 October 2017 at 23:16, Jason Gunthorpe wrote: > On Tue, Oct 24, 2017 at 09:44:30PM +0530, PrasannaKumar Muralidharan wrote: > >> I am wondering why it is wrong. Isn't the chip id valid till it is >> unregistered? If so the rfc is correct. Please explain, may be I am >> missing something. > > The lifetime is a bit complicated, but the general rule in the kernel > for things like this it to use pointers, not ids, and certainly not > string ids. > > For that patch it could just use container_of to get the chip.. > > Jason hwrng requires a unique name for every device. In that patch "tpm-rng-" is used. chip_num is nothing but dev->dev_num. This way more than 1 tpm chip can be used as rng provider. tpm_get_random uses chip_num as its parameter. This is why chip->dev_num was used. Is that reasoning correct? Please feel free to correct me if I am wrong. Thanks, PrasannaKumar