|
@@ -181,6 +181,9 @@ struct tpm_chip *tpm_chip_alloc(struct device *dev,
|
|
if (rc)
|
|
if (rc)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
|
|
+ if (!dev)
|
|
|
|
+ chip->flags |= TPM_CHIP_FLAG_VIRTUAL;
|
|
|
|
+
|
|
cdev_init(&chip->cdev, &tpm_fops);
|
|
cdev_init(&chip->cdev, &tpm_fops);
|
|
chip->cdev.owner = THIS_MODULE;
|
|
chip->cdev.owner = THIS_MODULE;
|
|
chip->cdev.kobj.parent = &chip->dev.kobj;
|
|
chip->cdev.kobj.parent = &chip->dev.kobj;
|
|
@@ -298,7 +301,7 @@ static void tpm_del_legacy_sysfs(struct tpm_chip *chip)
|
|
{
|
|
{
|
|
struct attribute **i;
|
|
struct attribute **i;
|
|
|
|
|
|
- if (chip->flags & TPM_CHIP_FLAG_TPM2)
|
|
|
|
|
|
+ if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL))
|
|
return;
|
|
return;
|
|
|
|
|
|
sysfs_remove_link(&chip->dev.parent->kobj, "ppi");
|
|
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;
|
|
struct attribute **i;
|
|
int rc;
|
|
int rc;
|
|
|
|
|
|
- if (chip->flags & TPM_CHIP_FLAG_TPM2)
|
|
|
|
|
|
+ if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL))
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
rc = __compat_only_sysfs_link_entry_to_kobj(
|
|
rc = __compat_only_sysfs_link_entry_to_kobj(
|