Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031878AbdDZWkQ (ORCPT ); Wed, 26 Apr 2017 18:40:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40716 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031861AbdDZWkI (ORCPT ); Wed, 26 Apr 2017 18:40:08 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D86997F4AB Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jsnitsel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D86997F4AB From: Jerry Snitselaar To: tpmdd-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, Jarkko Sakkinen , Peter Huewe , Marcel Selhorst , Jason Gunthorpe Subject: [PATCH] tpm: print tpm error code in hex for TPM2.0 devices Date: Wed, 26 Apr 2017 15:39:54 -0700 Message-Id: <20170426223954.18365-1-jsnitsel@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 26 Apr 2017 22:40:08 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1235 Lines: 37 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); + } if (err) return err; -- 2.13.0.rc0.45.ge2cb6ab84