blktrans.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * $Id: blktrans.h,v 1.6 2005/11/07 11:14:54 gleixner Exp $
  3. *
  4. * (C) 2003 David Woodhouse <dwmw2@infradead.org>
  5. *
  6. * Interface to Linux block layer for MTD 'translation layers'.
  7. *
  8. */
  9. #ifndef __MTD_TRANS_H__
  10. #define __MTD_TRANS_H__
  11. /* XXX U-BOOT XXX */
  12. #if 0
  13. #include <linux/mutex.h>
  14. #else
  15. #include <linux/list.h>
  16. #endif
  17. struct hd_geometry;
  18. struct mtd_info;
  19. struct mtd_blktrans_ops;
  20. struct file;
  21. struct inode;
  22. struct mtd_blktrans_dev {
  23. struct mtd_blktrans_ops *tr;
  24. struct list_head list;
  25. struct mtd_info *mtd;
  26. /* XXX U-BOOT XXX */
  27. #if 0
  28. struct mutex lock;
  29. #endif
  30. int devnum;
  31. unsigned long size;
  32. int readonly;
  33. void *blkcore_priv; /* gendisk in 2.5, devfs_handle in 2.4 */
  34. };
  35. struct blkcore_priv; /* Differs for 2.4 and 2.5 kernels; private */
  36. struct mtd_blktrans_ops {
  37. char *name;
  38. int major;
  39. int part_bits;
  40. int blksize;
  41. int blkshift;
  42. /* Access functions */
  43. int (*readsect)(struct mtd_blktrans_dev *dev,
  44. unsigned long block, char *buffer);
  45. int (*writesect)(struct mtd_blktrans_dev *dev,
  46. unsigned long block, char *buffer);
  47. /* Block layer ioctls */
  48. int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo);
  49. int (*flush)(struct mtd_blktrans_dev *dev);
  50. /* Called with mtd_table_mutex held; no race with add/remove */
  51. int (*open)(struct mtd_blktrans_dev *dev);
  52. int (*release)(struct mtd_blktrans_dev *dev);
  53. /* Called on {de,}registration and on subsequent addition/removal
  54. of devices, with mtd_table_mutex held. */
  55. void (*add_mtd)(struct mtd_blktrans_ops *tr, struct mtd_info *mtd);
  56. void (*remove_dev)(struct mtd_blktrans_dev *dev);
  57. struct list_head devs;
  58. struct list_head list;
  59. struct module *owner;
  60. struct mtd_blkcore_priv *blkcore_priv;
  61. };
  62. extern int register_mtd_blktrans(struct mtd_blktrans_ops *tr);
  63. extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr);
  64. extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
  65. extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
  66. #endif /* __MTD_TRANS_H__ */