/*  * First, let's erase the flash block.  */
   init_waitqueue_head(&wait_q);  erase.mtd = mtd;  erase.callback = erase_callback;  erase.addr = pos;  erase.len = len;  erase.priv = (u_long)&wait_q;
   set_current_state(TASK_INTERRUPTIBLE);  add_wait_queue(&wait_q, &wait);
   ret = MTD_ERASE(mtd, &erase);  if (ret) {   set_current_state(TASK_RUNNING);   remove_wait_queue(&wait_q, &wait);   printk (KERN_WARNING "mtdblock: erase of region [0x%lx, 0x%x] " "on \"%s\" failed\n", pos, len, mtd->name);   return ret;  }
   schedule(); /* Wait for erase to finish. */  remove_wait_queue(&wait_q, &wait);
   /*  * Next, writhe data to flash.  */
   ret = MTD_WRITE (mtd, pos, len, &retlen, buf);  if (ret)   return ret;  if (retlen != len)   return -EIO;  return 0; }
  static int write_cached_data (struct mtdblk_dev *mtdblk) {  struct mtd_info *mtd = mtdblk->mtd;  int ret;
   if (mtdblk->cache_state != STATE_DIRTY)   return 0;
   DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: writing cached data for \"%s\" " "at 0x%lx, size 0x%x\n", mtd->name,  mtdblk->cache_offset, mtdblk->cache_size);
   ret = erase_write (mtd, mtdblk->cache_offset,  mtdblk->cache_size, mtdblk->cache_data);  if (ret)   return ret;
   mtdblk->cache_state = STATE_EMPTY;  return 0; }
  static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,  int len, const char *buf) {  … }
 
  |