diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2020-07-30 18:16:13 +0200 |
---|---|---|
committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2020-10-01 23:21:03 +0200 |
commit | e08c6d3b19930f84a8da8c18710eefdfa48a9ceb (patch) | |
tree | ef7c41d2fc29ad838683b21205bbc7a18d6c553a /drivers/char | |
parent | dt-bindings: Add SynQucer TPM MMIO as a trivial device (diff) | |
download | linux-e08c6d3b19930f84a8da8c18710eefdfa48a9ceb.tar.xz linux-e08c6d3b19930f84a8da8c18710eefdfa48a9ceb.zip |
tpm: use %*ph to print small buffer
Use %*ph format to print small buffer as hex string.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/tpm/tpm-sysfs.c | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c index d52bf4df0bca..e2ff0b273a0f 100644 --- a/drivers/char/tpm/tpm-sysfs.c +++ b/drivers/char/tpm/tpm-sysfs.c @@ -56,31 +56,20 @@ static ssize_t pubek_show(struct device *dev, struct device_attribute *attr, out = (struct tpm_readpubek_out *)&tpm_buf.data[10]; str += sprintf(str, - "Algorithm: %02X %02X %02X %02X\n" - "Encscheme: %02X %02X\n" - "Sigscheme: %02X %02X\n" - "Parameters: %02X %02X %02X %02X " - "%02X %02X %02X %02X " - "%02X %02X %02X %02X\n" + "Algorithm: %4ph\n" + "Encscheme: %2ph\n" + "Sigscheme: %2ph\n" + "Parameters: %12ph\n" "Modulus length: %d\n" "Modulus:\n", - out->algorithm[0], out->algorithm[1], out->algorithm[2], - out->algorithm[3], - out->encscheme[0], out->encscheme[1], - out->sigscheme[0], out->sigscheme[1], - out->parameters[0], out->parameters[1], - out->parameters[2], out->parameters[3], - out->parameters[4], out->parameters[5], - out->parameters[6], out->parameters[7], - out->parameters[8], out->parameters[9], - out->parameters[10], out->parameters[11], + out->algorithm, + out->encscheme, + out->sigscheme, + out->parameters, be32_to_cpu(out->keysize)); - for (i = 0; i < 256; i++) { - str += sprintf(str, "%02X ", out->modulus[i]); - if ((i + 1) % 16 == 0) - str += sprintf(str, "\n"); - } + for (i = 0; i < 256; i += 16) + str += sprintf(str, "%16ph\n", &out->modulus[i]); out_buf: tpm_buf_destroy(&tpm_buf); |