Commit 2072df40 authored by Stefan Berger's avatar Stefan Berger Committed by Jarkko Sakkinen

tpm: Get rid of module locking

Now that the tpm core has strong locking around 'ops' it is possible
to remove a TPM driver, module and all, even while user space still
has things like /dev/tpmX open. For consistency and simplicity, drop
the module locking entirely.
Signed-off-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
parent 4e26195f
...@@ -57,9 +57,6 @@ int tpm_try_get_ops(struct tpm_chip *chip) ...@@ -57,9 +57,6 @@ int tpm_try_get_ops(struct tpm_chip *chip)
if (!chip->ops) if (!chip->ops)
goto out_lock; goto out_lock;
if (!try_module_get(chip->dev.parent->driver->owner))
goto out_lock;
return 0; return 0;
out_lock: out_lock:
up_read(&chip->ops_sem); up_read(&chip->ops_sem);
...@@ -77,7 +74,6 @@ EXPORT_SYMBOL_GPL(tpm_try_get_ops); ...@@ -77,7 +74,6 @@ EXPORT_SYMBOL_GPL(tpm_try_get_ops);
*/ */
void tpm_put_ops(struct tpm_chip *chip) void tpm_put_ops(struct tpm_chip *chip)
{ {
module_put(chip->dev.parent->driver->owner);
up_read(&chip->ops_sem); up_read(&chip->ops_sem);
put_device(&chip->dev); put_device(&chip->dev);
} }
...@@ -183,7 +179,7 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev, ...@@ -183,7 +179,7 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
goto out; goto out;
cdev_init(&chip->cdev, &tpm_fops); cdev_init(&chip->cdev, &tpm_fops);
chip->cdev.owner = dev->driver->owner; chip->cdev.owner = THIS_MODULE;
chip->cdev.kobj.parent = &chip->dev.kobj; chip->cdev.kobj.parent = &chip->dev.kobj;
rc = devm_add_action(dev, (void (*)(void *)) put_device, &chip->dev); rc = devm_add_action(dev, (void (*)(void *)) put_device, &chip->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment