Then, I see /sys/devices/mydev/ in sysfs. I openI actually forgot to formulate my question: why module's refcount is not increased when somebody opens a sysfs file which belongs to this module? How to withstan to an unexpected module unload?
pre-defined /sys/devices/mydev/power/state in userspace and don't close it.
Then I run lsmod, and see zero refcount to my module. Well, I run rmmod
mymod, module is unloaded.
Then I close /sys/devices/mydev/power/state, and enjoy segfault.