On Sun, Oct 01, 2023 at 11:15:12PM +0200, Richard wrote: > > > I've seen struct class defines **class_groups, but (contrary to struct > > > kobj_type) not the corresponding struct sysfs_ops, why? Where is it then? > > > > groups are used to define attributes (i.e. sysfs files). sysfs_ops is > > much "lower" in the stack. > > > > I think the description of how the driver model works in the book, Linux > > Device Drivers, 3rd edition, free online, should still represent how > > things work on this layer pretty well, although we have changed things > > in places over time since the book was written. Try looking that first. > > I looked it up and my understanding is that those attributes are actually > all embedded in instances of "struct class_attribute" and since they all > bring their own store() and show() functions it's not necesarry to contain > them in directly in "struct class". The whole mechanic with container_of() > makes sure in the end the right "subroutine" gets called. > > Is this correct? Close enough, yes :) The "fun" with attributes and sysfs files is a very tricky one, relying entirely on the location of the callbacks in memory to match up properly with some other structures and to pass around pointers like crazy. It has played havoc on some tools like CFI and will be very "interesting" to see how it every works in languages other than C (i.e. rust.) greg k-h _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies