Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7197820ybi; Mon, 8 Jul 2019 16:43:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/bDHSDj2yuVwgOdaF2cSUzyOowT20uSBXNIFkRPffjpodq/KXZ6ivzQ7cinKn+QREzPe4 X-Received: by 2002:a63:b547:: with SMTP id u7mr27446266pgo.322.1562629398991; Mon, 08 Jul 2019 16:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562629398; cv=none; d=google.com; s=arc-20160816; b=iu+/FQ1NlEyA5W9FADA2rSHahXjkefKiL6q4wPvRCDSaOPiKMVUBoziq8nCZbxnjKX 9b9nJZAEQMwqWCCz4LOX1FJm2ERB9vgaff38P/y76c1Ph2OHjYgOXoX5Xz2m0uVLz71/ +GnthUjsQD+S63h0dOhWWaqoV/94Pu3aD1TREhYG3Ww9tHvMStxBqhOSnp8aYEhdOSlf iBy2+2BIHQuyaCClST7p1xtcsqX0IKRmy3uOJ4bXV+PA5DdhiJdtUUnZbiCrmoj1kqRl KCRfnUeTOOXhyqG8isXkEbdlNHUp8sGz5raG8SFX9bPoVbHvj6WSo25ySB+zM2zVlP4j 4gmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0m3NEjwvz2dxO9bQhFlPhZbVrX0uYb3It/HKmn2RbMY=; b=JOPe8jBp7kPOBfHIKfU9XggKzz3IUkfcvTN10dYtzt9Dk4acXT8XmaV+/Usxp7+7mf 045O7PeyIzx5b1JIkQic0UuQ4sUe7h4ks+n8NhRHJgLLqanhQe+DEp3w6bRfsdneULHw 9Tt/SWPuPIFk67U0GdZxWWkN0Q/zL+ibzmjUmVEBKSQ0FiojRjWkIgsQfz8AjR7kJ8h+ BtWFCmqqX/tZChfum9O+rPSrQe44rdmM2lKL1paSPrSGIX7DLB11FEHve0LGPqBixeWX bAcxl5j8tsQ5zPnX8dzPTdJoqp2bxrEeykUdqvS/geEJINuzsb7qv4JR486/fEfAP2Vu 2dXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=JeKYvjEH; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7si21916039pfb.132.2019.07.08.16.43.03; Mon, 08 Jul 2019 16:43:18 -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; dkim=pass header.i=@ziepe.ca header.s=google header.b=JeKYvjEH; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728030AbfGHWxZ (ORCPT + 99 others); Mon, 8 Jul 2019 18:53:25 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:37436 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727899AbfGHWxZ (ORCPT ); Mon, 8 Jul 2019 18:53:25 -0400 Received: by mail-qk1-f193.google.com with SMTP id d15so14626772qkl.4 for ; Mon, 08 Jul 2019 15:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=0m3NEjwvz2dxO9bQhFlPhZbVrX0uYb3It/HKmn2RbMY=; b=JeKYvjEHv0d4lyie/kiBQRbHspieZhhHk1xlxebuNCuhUGu2Ujj2J5Hn94dfSTuN5U ib5PxKy6G0Fdrb8Kf9ZgN46yBcwla5TU9ZmG2/D+e81sTwZio+uWzaJAYYn6t99E6fno HZfkywo1Z3Y+s5YbXpcAAhsdJMHg7y81D9tjheXnlxscc6Y0jHCY1EmbsmteXyTI+F0g vZaVU90UeK6qQBW4YH523XTj9x4L3JVIFaq9mSiXf478G+zEYS7E6QoXBHxc8xOLnQh+ s6UjLSgZgRdsU1nZlZA9ZjPbJAueUs8VveDaz+i6ViBZwsNp9BacpUNiDce5RoXVLNln V29g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=0m3NEjwvz2dxO9bQhFlPhZbVrX0uYb3It/HKmn2RbMY=; b=W/qxR+v1VPMzsfhKxYEGWCIvUxcg3sa9yH4SZvXpxeMCmnBUtjyjT7YUSr+wutvDfk CR0XIGs4MfFJaXDCTKi7O+K0RSQaL5ejnk+7UFZhu3t5lbgrhCWgaZqz/qVEtVM/N3qK tpqPdkFuHOve89MNAtCoG84rs5gS1mjty9k1Y6LcOZ/1SAo6Vz1woqXFpiFYiiW1FEnX id4sHIwvGUlMy5kglfNOGmlIUeQ8lh5hYLoyFHD0bZIAEsWnLKWd4Rg5HM1ZybdL8G7q zULEGNIXS3I63GtpYgeZKtY1F/m2FmRuhG5MrNC/9pj6kseIrU4ej591rRZu97+TsHZE hLjw== X-Gm-Message-State: APjAAAUQa5V727PZKn8fN4kDQ8MMvcLth/Ea3H8xRGbyyeGwg4gPqbcV ErjsNGDgXbKoObVz+2mI4rhP/A== X-Received: by 2002:a37:4a04:: with SMTP id x4mr16546587qka.408.1562626404157; Mon, 08 Jul 2019 15:53:24 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-55-100.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.55.100]) by smtp.gmail.com with ESMTPSA id n18sm7889774qtr.28.2019.07.08.15.53.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 15:53:23 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hkcVf-000384-Ac; Mon, 08 Jul 2019 19:53:23 -0300 Date: Mon, 8 Jul 2019 19:53:23 -0300 From: Jason Gunthorpe To: Mimi Zohar Cc: Jarkko Sakkinen , Nayna Jain , linux-integrity@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Sachin Sant , George Wilson , Michael Ellerman , Michal Suchanek , Peter Huewe , Christoph Hellwig Subject: Re: [PATCH v2] tpm: tpm_ibm_vtpm: Fix unallocated banks Message-ID: <20190708225323.GG23996@ziepe.ca> References: <1562458725-15999-1-git-send-email-nayna@linux.ibm.com> <586c629b6d3c718f0c1585d77fe175fe007b27b1.camel@linux.intel.com> <1562624644.11461.66.camel@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1562624644.11461.66.camel@linux.ibm.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 08, 2019 at 06:24:04PM -0400, Mimi Zohar wrote: > Hi Jarkko, > > On Mon, 2019-07-08 at 18:11 +0300, Jarkko Sakkinen wrote: > > On Sat, 2019-07-06 at 20:18 -0400, Nayna Jain wrote: > > > +/* > > > + * tpm_get_pcr_allocation() - initialize the chip allocated banks for PCRs > > > + * @chip: TPM chip to use. > > > + */ > > > +static int tpm_get_pcr_allocation(struct tpm_chip *chip) > > > +{ > > > + int rc; > > > + > > > + if (chip->flags & TPM_CHIP_FLAG_TPM2) > > > + rc = tpm2_get_pcr_allocation(chip); > > > + else > > > + rc = tpm1_get_pcr_allocation(chip); > > > + > > > + return rc; > > > +} > > > > It is just a trivial static function, which means that kdoc comment is > > not required and neither it is useful. Please remove that. I would > > rewrite the function like: > > > > static int tpm_get_pcr_allocation(struct tpm_chip *chip) > > { > > int rc; > > > > rc = (chip->flags & TPM_CHIP_FLAG_TPM2) ? > > tpm2_get_pcr_allocation(chip) : > > tpm1_get_pcr_allocation(chip); > > > > > return rc > 0 ? -ENODEV : rc; > > } > > > > This addresses the issue that Stefan also pointed out. You have to > > deal with the TPM error codes. > > Hm, in the past I was told by Christoph not to use the ternary > operator.  Have things changed?  Other than removing the comment, the > only other difference is the return. I also dislike most use of ternary expressions.. Also, it is not so nice that TPM error codes and errno are multiplexed on the same 'int' type - very hard to get this right. I'm not sure anything actually needs the tpm error, and if it does maybe we should be mapping those special cases to errno instead. Jason