From: Stefan Berger Date: Mon, 29 Feb 2016 13:53:01 +0000 (-0500) Subject: tpm: Get rid of module locking X-Git-Tag: v4.8-rc1~95^2~84 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=2072df40ec19d9703adfcdbd15f30c879bb65b2a;p=karo-tx-linux.git 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: Stefan Berger Reviewed-by: Jason Gunthorpe Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen --- diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index 5793ea1b454c..66367286deea 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -57,9 +57,6 @@ int tpm_try_get_ops(struct tpm_chip *chip) if (!chip->ops) goto out_lock; - if (!try_module_get(chip->dev.parent->driver->owner)) - goto out_lock; - return 0; out_lock: up_read(&chip->ops_sem); @@ -77,7 +74,6 @@ EXPORT_SYMBOL_GPL(tpm_try_get_ops); */ void tpm_put_ops(struct tpm_chip *chip) { - module_put(chip->dev.parent->driver->owner); up_read(&chip->ops_sem); put_device(&chip->dev); } @@ -183,7 +179,7 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev, goto out; cdev_init(&chip->cdev, &tpm_fops); - chip->cdev.owner = dev->driver->owner; + chip->cdev.owner = THIS_MODULE; chip->cdev.kobj.parent = &chip->dev.kobj; rc = devm_add_action(dev, (void (*)(void *)) put_device, &chip->dev);