Identify the kernel module that created the sysfs entry

On the Linux operating system, I want to know which device driver module created the specific sysfs entry. Is it possible to find out? I know that I can use grep for the corresponding lines in the kernel source and try to identify. But is there a way without doing this?

+7
source share
1 answer

You can find which driver created the sysfs entry by going through its source. If the driver uses device_create_file () / device_remove_file () in its init / exit sequences, then you can be sure that the sysfs attribute file was created by the driver. You can also find the DEVICE_ATTR macro (_name, _mode, _show, _store) in the source to find out what functions are provided by the sysfs file. You can usually either quote a file or an echo line for it. The cat / sys /.../ file will correspond to the _show function, and the echo / sys /.../ file will correspond to the _store function mentioned in the macro.

+2
source

All Articles