Chaining "mtd_info->read" failed !

Chagas, Jason jason.chagas at intel.com
Tue Feb 17 22:49:02 EST 2004


I wrote a kernel driver that attempts to sniff MTD flash reads but I ran
into problems. The driver first properly registers itself as an MTD user
(register_mtd_user(&notifier)), receives the expected notifications for
the [3] mtdblock devices on the system, and saves their respective
pointers to the "mtd_info" structure, and finally, replaces the 'read'
structure element with my own "my_read" routine. Here is a simplified
version of "my_read":

----
static int my_read (struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf)
{
  /* Sniff data here */

  /* Call original device function */
  return ((mtd_info_ptr)->read)(mtd, from, len, retlen, buf);
}
----

Note, "my_read" simply chains the original 'read' function call in the
"mtd_info" structure. Should have been simple enough, however, when
accessing flash, "my_read" receives a series of repeated messages with
exactly the same values in "loff_t from" and "size_t len" until the
kernel hangs and the kernel heartbeat LED stops blinking.  BTW, "size_t
len" is equal to zero.

Am I missing something? Any ideas?

Thanks,

Jason




More information about the linux-mtd mailing list