Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2993053AbdD1MCD (ORCPT ); Fri, 28 Apr 2017 08:02:03 -0400 Received: from mga14.intel.com ([192.55.52.115]:44868 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753862AbdD1MBy (ORCPT ); Fri, 28 Apr 2017 08:01:54 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,388,1488873600"; d="scan'208";a="80056539" Date: Fri, 28 Apr 2017 15:01:49 +0300 From: Jarkko Sakkinen To: Jerry Snitselaar Cc: tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Peter Huewe , Marcel Selhorst , Jason Gunthorpe Subject: Re: [PATCH] tpm: print tpm error code in hex for TPM2.0 devices Message-ID: <20170428120149.jjxwbp6nmthk4y3q@intel.com> References: <20170426223954.18365-1-jsnitsel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170426223954.18365-1-jsnitsel@redhat.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 Content-Length: 1446 Lines: 44 On Wed, Apr 26, 2017 at 03:39:54PM -0700, Jerry Snitselaar wrote: > For easier decoding, output the error code returned > from the tpm device in hex when the device is TPM2.0. > > Cc: Jarkko Sakkinen > Cc: Peter Huewe > Cc: Marcel Selhorst > Cc: Jason Gunthorpe > Reported-by: Ken Goldman > Signed-off-by: Jerry Snitselaar > --- > drivers/char/tpm/tpm-interface.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c > index bd2128e0b56c..b6c67eef9ae7 100644 > --- a/drivers/char/tpm/tpm-interface.c > +++ b/drivers/char/tpm/tpm-interface.c > @@ -453,9 +453,14 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *buf, > return -EFAULT; > > err = be32_to_cpu(header->return_code); > - if (err != 0 && desc) > - dev_err(&chip->dev, "A TPM error (%d) occurred %s\n", err, > - desc); > + if (err != 0 && desc) { > + if (chip->flags & TPM_CHIP_FLAG_TPM2) > + dev_err(&chip->dev, "A TPM 2.0 error (0x%x) occurred %s\n", > + err, desc); > + else > + dev_err(&chip->dev, "A TPM error (%d) occurred %s\n", > + err, desc); > + } Is there a reason for not to apply this also to TPM 1.2? /Jarkko > if (err) > return err; > > -- > 2.13.0.rc0.45.ge2cb6ab84 >