diff options
author | Stefan Berger <stefanb@linux.vnet.ibm.com> | 2016-04-18 13:26:14 -0400 |
---|---|---|
committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2016-06-25 10:26:35 -0400 |
commit | 2f9f53776dcd8ca3cc3d357d516ed76c3f038637 (patch) | |
tree | bcd27c6396a0c7e7efe38aa407afb0548b43f1c1 | |
parent | 062807f20e3f363dc5db0c7927bb6223dd1f46a2 (diff) |
tpm: Introduce TPM_CHIP_FLAG_VIRTUAL
Introduce TPM_CHIP_FLAG_VIRTUAL to be used when the chip device has no
parent device.
Prevent sysfs entries requiring a parent device from being created.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
-rw-r--r-- | drivers/char/tpm/tpm-chip.c | 7 | ||||
-rw-r--r-- | drivers/char/tpm/tpm.h | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index 57d9794dac94..1965dc780688 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c | |||
@@ -181,6 +181,9 @@ struct tpm_chip *tpm_chip_alloc(struct device *dev, | |||
181 | if (rc) | 181 | if (rc) |
182 | goto out; | 182 | goto out; |
183 | 183 | ||
184 | if (!dev) | ||
185 | chip->flags |= TPM_CHIP_FLAG_VIRTUAL; | ||
186 | |||
184 | cdev_init(&chip->cdev, &tpm_fops); | 187 | cdev_init(&chip->cdev, &tpm_fops); |
185 | chip->cdev.owner = THIS_MODULE; | 188 | chip->cdev.owner = THIS_MODULE; |
186 | chip->cdev.kobj.parent = &chip->dev.kobj; | 189 | chip->cdev.kobj.parent = &chip->dev.kobj; |
@@ -298,7 +301,7 @@ static void tpm_del_legacy_sysfs(struct tpm_chip *chip) | |||
298 | { | 301 | { |
299 | struct attribute **i; | 302 | struct attribute **i; |
300 | 303 | ||
301 | if (chip->flags & TPM_CHIP_FLAG_TPM2) | 304 | if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL)) |
302 | return; | 305 | return; |
303 | 306 | ||
304 | sysfs_remove_link(&chip->dev.parent->kobj, "ppi"); | 307 | sysfs_remove_link(&chip->dev.parent->kobj, "ppi"); |
@@ -316,7 +319,7 @@ static int tpm_add_legacy_sysfs(struct tpm_chip *chip) | |||
316 | struct attribute **i; | 319 | struct attribute **i; |
317 | int rc; | 320 | int rc; |
318 | 321 | ||
319 | if (chip->flags & TPM_CHIP_FLAG_TPM2) | 322 | if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL)) |
320 | return 0; | 323 | return 0; |
321 | 324 | ||
322 | rc = __compat_only_sysfs_link_entry_to_kobj( | 325 | rc = __compat_only_sysfs_link_entry_to_kobj( |
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 508e8e00c9c1..ff4e53cde70e 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h | |||
@@ -138,6 +138,7 @@ enum tpm_chip_flags { | |||
138 | TPM_CHIP_FLAG_REGISTERED = BIT(0), | 138 | TPM_CHIP_FLAG_REGISTERED = BIT(0), |
139 | TPM_CHIP_FLAG_TPM2 = BIT(1), | 139 | TPM_CHIP_FLAG_TPM2 = BIT(1), |
140 | TPM_CHIP_FLAG_IRQ = BIT(2), | 140 | TPM_CHIP_FLAG_IRQ = BIT(2), |
141 | TPM_CHIP_FLAG_VIRTUAL = BIT(3), | ||
141 | }; | 142 | }; |
142 | 143 | ||
143 | struct tpm_chip { | 144 | struct tpm_chip { |