Re: [PATCH v3 4/6] tpm: TPM 2.0 sysfs attributes
From: Jarkko Sakkinen <hidden>
Date: 2014-10-16 16:04:34
Also in:
lkml
On Thu, Oct 16, 2014 at 11:31:46AM +0200, Greg KH wrote:
On Wed, Oct 15, 2014 at 01:35:14PM +0200, Jarkko Sakkinen wrote:quoted
+int tpm2_sysfs_add_device(struct tpm_chip *chip) +{ + struct pcr_bank *pcr_bank; + struct kobject *pcrs_kobj; + struct device *dev = chip->dev; + int rc; + + rc = sysfs_create_group(&chip->vendor.miscdev.this_device->kobj, + &tpm_dev_group); + if (rc) { + dev_err(dev, "failed to create sysfs attributes, %d\n", rc); + return rc; + }You just raced and created sysfs files _after_ userspace saw that your device was enabled.
Here the options are limited because misc_register already spawns KOBJ_ADD. Not much to do unless we would wipe the current use of misc driver completely.
quoted
+ pcrs_kobj = kobject_create_and_add("pcrs", + &chip->vendor.miscdev.this_device->kobj);Ick, no no no no. Never create a kobject under a 'struct device'. You just lost all libudev support for any attribute you created under here, not good at all. Use a "real" device if you really want a sub-device, not a kobject.
Ack, will rework this.
thanks, greg k-h
/Jarkko