linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jerry Snitselaar <jsnitsel@redhat.com>
To: tpmdd-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org,
	Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	Peter Huewe <peterhuewe@gmx.de>,
	Marcel Selhorst <tpmdd@selhorst.net>,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Subject: [PATCH] tpm: print tpm error code in hex for TPM2.0 devices
Date: Wed, 26 Apr 2017 15:39:54 -0700	[thread overview]
Message-ID: <20170426223954.18365-1-jsnitsel@redhat.com> (raw)

For easier decoding, output the error code returned
from the tpm device in hex when the device is TPM2.0.

Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Peter Huewe <peterhuewe@gmx.de>
Cc: Marcel Selhorst <tpmdd@selhorst.net>
Cc: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reported-by: Ken Goldman <kgoldman@us.ibm.com>
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
---
 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

             reply	other threads:[~2017-04-26 22:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26 22:39 Jerry Snitselaar [this message]
2017-04-28 12:01 ` [PATCH] tpm: print tpm error code in hex for TPM2.0 devices Jarkko Sakkinen
2017-04-28 17:18   ` Jerry Snitselaar
2017-04-29 11:17     ` Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170426223954.18365-1-jsnitsel@redhat.com \
    --to=jsnitsel@redhat.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=tpmdd-devel@lists.sourceforge.net \
    --cc=tpmdd@selhorst.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).