]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tpm: Introduce TPM_CHIP_FLAG_VIRTUAL
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Mon, 18 Apr 2016 17:26:14 +0000 (13:26 -0400)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Sat, 25 Jun 2016 14:26:35 +0000 (17:26 +0300)
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>
drivers/char/tpm/tpm-chip.c
drivers/char/tpm/tpm.h

index 57d9794dac9473485ce1ddd886aec0be703c42a9..1965dc78068897fd0c34e861f8dce94d8deb5334 100644 (file)
@@ -181,6 +181,9 @@ struct tpm_chip *tpm_chip_alloc(struct device *dev,
        if (rc)
                goto out;
 
+       if (!dev)
+               chip->flags |= TPM_CHIP_FLAG_VIRTUAL;
+
        cdev_init(&chip->cdev, &tpm_fops);
        chip->cdev.owner = THIS_MODULE;
        chip->cdev.kobj.parent = &chip->dev.kobj;
@@ -298,7 +301,7 @@ static void tpm_del_legacy_sysfs(struct tpm_chip *chip)
 {
        struct attribute **i;
 
-       if (chip->flags & TPM_CHIP_FLAG_TPM2)
+       if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL))
                return;
 
        sysfs_remove_link(&chip->dev.parent->kobj, "ppi");
@@ -316,7 +319,7 @@ static int tpm_add_legacy_sysfs(struct tpm_chip *chip)
        struct attribute **i;
        int rc;
 
-       if (chip->flags & TPM_CHIP_FLAG_TPM2)
+       if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL))
                return 0;
 
        rc = __compat_only_sysfs_link_entry_to_kobj(
index 508e8e00c9c17608f437ca671063e73aafd7955f..ff4e53cde70ed4895461c3f0de693c4fd1c45839 100644 (file)
@@ -138,6 +138,7 @@ enum tpm_chip_flags {
        TPM_CHIP_FLAG_REGISTERED        = BIT(0),
        TPM_CHIP_FLAG_TPM2              = BIT(1),
        TPM_CHIP_FLAG_IRQ               = BIT(2),
+       TPM_CHIP_FLAG_VIRTUAL           = BIT(3),
 };
 
 struct tpm_chip {