yaffs_mtdif.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
  3. *
  4. * Copyright (C) 2002-2010 Aleph One Ltd.
  5. * for Toby Churchill Ltd and Brightstar Engineering
  6. *
  7. * Created by Charles Manning <charles@aleph1.co.uk>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include "yportenv.h"
  14. #include "yaffs_mtdif.h"
  15. #include "linux/mtd/mtd.h"
  16. #include "linux/types.h"
  17. #include "linux/time.h"
  18. #include "linux/mtd/nand.h"
  19. #include "yaffs_linux.h"
  20. int nandmtd_erase_block(struct yaffs_dev *dev, int block_no)
  21. {
  22. struct mtd_info *mtd = yaffs_dev_to_mtd(dev);
  23. u32 addr =
  24. ((loff_t) block_no) * dev->param.total_bytes_per_chunk
  25. * dev->param.chunks_per_block;
  26. struct erase_info ei;
  27. int retval = 0;
  28. ei.mtd = mtd;
  29. ei.addr = addr;
  30. ei.len = dev->param.total_bytes_per_chunk * dev->param.chunks_per_block;
  31. ei.time = 1000;
  32. ei.retries = 2;
  33. ei.callback = NULL;
  34. ei.priv = (u_long) dev;
  35. retval = mtd_erase(mtd, &ei);
  36. if (retval == 0)
  37. return YAFFS_OK;
  38. else
  39. return YAFFS_FAIL;
  40. }
  41. int nandmtd_initialise(struct yaffs_dev *dev)
  42. {
  43. return YAFFS_OK;
  44. }