diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2020-01-27 20:12:13 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-01-27 20:12:13 +0300 |
commit | 189fc98efe59b9b0a49a4f29ee3d91eeded4e4d4 (patch) | |
tree | 69755085fae1d38219c9fe087c8e0357352eb82d /drivers | |
parent | f11ba7de156558ac5e78e285dbf9e9af60ceb2a8 (diff) | |
parent | 7084eddf6be94e73f8298c1a28078b91536f2975 (diff) | |
download | linux-189fc98efe59b9b0a49a4f29ee3d91eeded4e4d4.tar.xz |
Merge tag 'tpmdd-next-20200122' of git://git.infradead.org/users/jjs/linux-tpmdd
Pull tpm updates from Jarkko Sakkinen:
"This adds a new sysfs file for querying TPM major version, which can
be used by the user space the TPM protocol used to communicate with
the chip"
* tag 'tpmdd-next-20200122' of git://git.infradead.org/users/jjs/linux-tpmdd:
tpm: Add tpm_version_major sysfs file
tpm: Update mailing list contact information in sysfs-class-tpm
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/tpm/tpm-sysfs.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c index 3b53b3e5ec3e..d52bf4df0bca 100644 --- a/drivers/char/tpm/tpm-sysfs.c +++ b/drivers/char/tpm/tpm-sysfs.c @@ -310,7 +310,17 @@ static ssize_t timeouts_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(timeouts); -static struct attribute *tpm_dev_attrs[] = { +static ssize_t tpm_version_major_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct tpm_chip *chip = to_tpm_chip(dev); + + return sprintf(buf, "%s\n", chip->flags & TPM_CHIP_FLAG_TPM2 + ? "2" : "1"); +} +static DEVICE_ATTR_RO(tpm_version_major); + +static struct attribute *tpm1_dev_attrs[] = { &dev_attr_pubek.attr, &dev_attr_pcrs.attr, &dev_attr_enabled.attr, @@ -321,18 +331,28 @@ static struct attribute *tpm_dev_attrs[] = { &dev_attr_cancel.attr, &dev_attr_durations.attr, &dev_attr_timeouts.attr, + &dev_attr_tpm_version_major.attr, NULL, }; -static const struct attribute_group tpm_dev_group = { - .attrs = tpm_dev_attrs, +static struct attribute *tpm2_dev_attrs[] = { + &dev_attr_tpm_version_major.attr, + NULL +}; + +static const struct attribute_group tpm1_dev_group = { + .attrs = tpm1_dev_attrs, +}; + +static const struct attribute_group tpm2_dev_group = { + .attrs = tpm2_dev_attrs, }; void tpm_sysfs_add_device(struct tpm_chip *chip) { - if (chip->flags & TPM_CHIP_FLAG_TPM2) - return; - WARN_ON(chip->groups_cnt != 0); - chip->groups[chip->groups_cnt++] = &tpm_dev_group; + if (chip->flags & TPM_CHIP_FLAG_TPM2) + chip->groups[chip->groups_cnt++] = &tpm2_dev_group; + else + chip->groups[chip->groups_cnt++] = &tpm1_dev_group; } |