On 27/06/11 00:29, Eli Billauer wrote:
The brute-force way to do this is to check a device-global flag every
invocation of read(), write(), and other relevant methods. Maybe also
before returning a successful value. If the flag is set ( = problem
detected) return some -EDROPDEAD, so that application software reacts,
and maybe someone will go to /var/log/messages to get a better idea of
what happened. (I think I'll settle for -ENODEV)
Nobody expects ENODEV on an already opened device. I'd go for EIO, myself.
So here comes my question: Is there a convention for how a device
driver can tell the kernel that certain devices (as in /dev/something)
have turned unusable, in particular when some of them are already
open? I guess this is related to hotpluggable devices, but in the
latter case I suppose it's the kernel informing the device driver
about the event, and not vice versa.
I don't think you need to do anything beyond that, unless the situation
is recoverable without a reboot (say - by sending a reset to the chip).
If that's the case, I'd reset the chip, return EIO to any connection
opened before the reset, and treat new connection like I always would.
Of course, if there is a way for you to make the old connections still
function, even better.
Shachar
--
Shachar Shemesh
Lingnu Open Source Consulting Ltd.
http://www.lingnu.com
_______________________________________________
Haifux mailing list
Haifux@haifux.org
http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux