kobject question

Greg Kroah-Hartman (gregkh@linuxfoundation.org) gregkh at linuxfoundation.org
Wed May 29 01:55:43 UTC 2013


On Tue, May 28, 2013 at 08:46:58PM -0500, H Hartley Sweeten wrote:
> Greg,
> 
> I'm trying to create a simple directory in the sysfs hierarchy following
> Documentation/kobject.txt and samples/kobject-example.c.

Hint, don't :)

> I have been able to create the subdirectory and attributes but now
> I'm stuck.

You really don't want to do this, trust me :)

> In the sample, the attribute files all use static data (foo, baz, bar).
> Is there any way to pass a pointer to the data needed by the
> attributes when using kobject_create_and_add()?

What do you mean by this?  You should be getting a callback with your
kobject in it, so that you can then dig out the needed information to
fill in the show/store data.

But let's take a step back, what are you trying to do by creating a new
sysfs directory?  You should never create a subdir in the device tree in
sysfs, that is not a 'struct device'.  That is because udev / userspace
will not see the directory, so any attribute under it will not be
accessable by the tools that users use to access them.

thanks,

greg k-h



More information about the devel mailing list