]> Git Repo - linux.git/commitdiff
tpm: Fix initialization of the cdev
authorJason Gunthorpe <[email protected]>
Tue, 30 Jun 2015 19:15:31 +0000 (13:15 -0600)
committerPeter Huewe <[email protected]>
Mon, 13 Jul 2015 21:33:57 +0000 (23:33 +0200)
When a cdev is contained in a dynamic structure the cdev parent kobj
should be set to the kobj that controls the lifetime of the enclosing
structure. In TPM's case this is the embedded struct device.

Also, cdev_init 0's the whole structure, so all sets must be after,
not before. This fixes module ref counting and cdev.

Cc: <[email protected]>
Fixes: 313d21eeab92 ("tpm: device class for tpm")
Signed-off-by: Jason Gunthorpe <[email protected]>
Reviewed-by: Dmitry Torokhov <[email protected]>
Reviewed-by: Jarkko Sakkinen <[email protected]>
Tested-by: Jarkko Sakkinen <[email protected]>
Signed-off-by: Peter Huewe <[email protected]>
drivers/char/tpm/tpm-chip.c

index 283f00a7f03629c12f8294e2aee67e1e598acf4d..1082d4bb016a9e4d7caf795a5128509780134916 100644 (file)
@@ -129,8 +129,9 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
 
        device_initialize(&chip->dev);
 
-       chip->cdev.owner = chip->pdev->driver->owner;
        cdev_init(&chip->cdev, &tpm_fops);
+       chip->cdev.owner = chip->pdev->driver->owner;
+       chip->cdev.kobj.parent = &chip->dev.kobj;
 
        return chip;
 }
This page took 0.055335 seconds and 4 git commands to generate.