How to correctly setup a sysfs class
Hello-
I am trying to create a class in the sysfs filesystem for the tpm device driver to use. It was brought to my attention that my first attempts were missing a release function and thus causing ugly messages in /var/log/messages. The problem I have is I do not know what I need to put in the release function. The class_simple was recommended to me put I don't think it meets my needs.
What I'd like to do is that when an application is built on top of this driver and needs to know where to find the sysfs files for the device, it doesn't have to look on all the different buses in /sys. Today TPMs are pci devices but in the future they could be usb devices as well. By createing the tpm class and adding each device to the class the device link that is created can be followed to find the necessary files. When using class_simple it seems the only file that can be created in the class is dev which contains the major and minor number. There is no link to the actual device created and since you don't have access to the actual struct class you can't create the link either. Please direct me if there is another way to do this.
Thanks,
Kylie Hall
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 8 lines · Kylene Hall
Hello-
I am trying to create a class in the sysfs filesystem for the tpm device driver to use. It was brought to my attention that my first attempts were missing a release function and thus causing ugly messages in
/var/log/messages. The problem I have is I do not know what I need to put in the release function. Theclass_simplewas recommended to me put I don't think it meets my needs.
I think linux-kernel is the best place for this... But anyway...
Quoted 3 lines
What I'd like to do is that when an application is built on top of this driver and needs to know where to find the sysfs files for the device, it doesn't have to look on all the different buses in /sys.
But you are using the misc device interface, right? Why not just use that class interface? You have a pointer to the class_device offered to you in the misc structure that is for you to put sysfs files into the tree. Just make sure to clean them up when you are done.
Quoted 2 lines
Today TPMs are pci devices but in the future they could be usb devices as well.
Ok, you could hang your files off of the struct device if you want too. All depends on what you feel comfortable with.
Quoted 4 lines
By createing the tpm class and adding each device to the class the device link that is created can be followed to find the necessary files. When using
class_simpleit seems the only file that can be created in the class is dev which contains the major and minor number.
No, you have a pointer to the class device that you can then pass to the "create a class device file" function, right? That's why you are passed back a pointer.
Quoted 3 lines
There is no link to the actual device created and since you don't have access to the actual struct class you can't create the link either. Please direct me if there is another way to do this.
See above.
thanks,
greg k-h
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel