Dmitry, you're not viewing this correctly.
Adding a new release() callback would solve the problem by creating
another. Drivers need to release their data as soon as possible after
they unbind from a device, not when the device itself goes away. Think
about what would happen if you tried to rmmod a driver. The rmmod process
would block until the device was unregistered.
Oliver, your idea won't work either. Think about what would happen if
someone did
rmmod driver_module </sys/devices/.../attribute_file
The rmmod process would never actually read the attribute, so until it
exited the private data structure would have a positive refcount. But
rmmod can't exit until the driver has been unloaded from memory, and it
can't be unloaded while its data structure is still allocated. Thus we
would end up with deadlock; rmmod would hang forever.
It might be better to keep your earlier patch and fix the deadlock you
mentioned earlier, the one that occurs when unbinding a driver through
sysfs. How exactly does that deadlock work?
Alan Stern
-