Hello,
I am writing a block device driver to access Secure Digital (SD) cards over
an SPI interface for an embedded (ppc) product.
If the SD card is removed while it is still mounted, the kernel will
continue to generate read and write requests for the driver, which it
obviously can't perform successfully. I am wondering how to tell the kernel
that this device is no longer available, and to cancel all pending
requests. Should I un-register my gendisk from inside the request handler?
Is there a way to clear out the queue and close down the device?
I have loosely based my driver on the 'sbull' driver outlined in "Linux
Device Drivers", by Corbet, Rubini, and Kroah-Hartman, using the simplest
possible, synchronous request handler. I have attached some pseudo-code for
that at the end of this message.
Thanks in advance for any recomendations,
Matthew
=== Pseudo-code for request handler: ===
static void sdcard_request(request_queue_t *q)
{
struct request *req;
while ((req = elv_next_request(q)) != NULL)
{
if (!blk_fs_request(req))
{
//printk (KERN_DEBUG "Skipping non-fs request\n");
end_request(req, 0);
continue;
}
if (!SD_Card_Present())
{
//somehow handle the missing card?
}
if (rq_data_dir(req))
{
//write data to sd card
}
else
{
//read data from sd card
}
}
}
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ