Skip to content

Commit 2f9f537

Browse files
stefanbergerJarkko Sakkinen
authored andcommitted
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>
1 parent 062807f commit 2f9f537

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

drivers/char/tpm/tpm-chip.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ struct tpm_chip *tpm_chip_alloc(struct device *dev,
181181
if (rc)
182182
goto out;
183183

184+
if (!dev)
185+
chip->flags |= TPM_CHIP_FLAG_VIRTUAL;
186+
184187
cdev_init(&chip->cdev, &tpm_fops);
185188
chip->cdev.owner = THIS_MODULE;
186189
chip->cdev.kobj.parent = &chip->dev.kobj;
@@ -298,7 +301,7 @@ static void tpm_del_legacy_sysfs(struct tpm_chip *chip)
298301
{
299302
struct attribute **i;
300303

301-
if (chip->flags & TPM_CHIP_FLAG_TPM2)
304+
if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL))
302305
return;
303306

304307
sysfs_remove_link(&chip->dev.parent->kobj, "ppi");
@@ -316,7 +319,7 @@ static int tpm_add_legacy_sysfs(struct tpm_chip *chip)
316319
struct attribute **i;
317320
int rc;
318321

319-
if (chip->flags & TPM_CHIP_FLAG_TPM2)
322+
if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL))
320323
return 0;
321324

322325
rc = __compat_only_sysfs_link_entry_to_kobj(

drivers/char/tpm/tpm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ enum tpm_chip_flags {
138138
TPM_CHIP_FLAG_REGISTERED = BIT(0),
139139
TPM_CHIP_FLAG_TPM2 = BIT(1),
140140
TPM_CHIP_FLAG_IRQ = BIT(2),
141+
TPM_CHIP_FLAG_VIRTUAL = BIT(3),
141142
};
142143

143144
struct tpm_chip {

0 commit comments

Comments
 (0)