Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * (C) 2003 David Woodhouse <dwmw2@infradead.org> |
| 3 | * |
| 4 | * Interface to Linux block layer for MTD 'translation layers'. |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef __MTD_TRANS_H__ |
| 9 | #define __MTD_TRANS_H__ |
| 10 | |
Ingo Molnar | 48b1926 | 2006-03-31 02:29:41 -0800 | [diff] [blame] | 11 | #include <linux/mutex.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
| 13 | struct hd_geometry; |
| 14 | struct mtd_info; |
| 15 | struct mtd_blktrans_ops; |
| 16 | struct file; |
| 17 | struct inode; |
| 18 | |
| 19 | struct mtd_blktrans_dev { |
| 20 | struct mtd_blktrans_ops *tr; |
| 21 | struct list_head list; |
| 22 | struct mtd_info *mtd; |
Ingo Molnar | 48b1926 | 2006-03-31 02:29:41 -0800 | [diff] [blame] | 23 | struct mutex lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | int devnum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | unsigned long size; |
| 26 | int readonly; |
| 27 | void *blkcore_priv; /* gendisk in 2.5, devfs_handle in 2.4 */ |
| 28 | }; |
| 29 | |
| 30 | struct blkcore_priv; /* Differs for 2.4 and 2.5 kernels; private */ |
| 31 | |
| 32 | struct mtd_blktrans_ops { |
| 33 | char *name; |
| 34 | int major; |
| 35 | int part_bits; |
Richard Purdie | 1918767 | 2006-10-27 09:09:33 +0100 | [diff] [blame] | 36 | int blksize; |
| 37 | int blkshift; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
| 39 | /* Access functions */ |
| 40 | int (*readsect)(struct mtd_blktrans_dev *dev, |
| 41 | unsigned long block, char *buffer); |
| 42 | int (*writesect)(struct mtd_blktrans_dev *dev, |
| 43 | unsigned long block, char *buffer); |
David Woodhouse | eae9acd | 2008-08-05 18:08:25 +0100 | [diff] [blame] | 44 | int (*discard)(struct mtd_blktrans_dev *dev, |
| 45 | unsigned long block, unsigned nr_blocks); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 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 | |
| 51 | /* Called with mtd_table_mutex held; no race with add/remove */ |
| 52 | int (*open)(struct mtd_blktrans_dev *dev); |
| 53 | int (*release)(struct mtd_blktrans_dev *dev); |
| 54 | |
| 55 | /* Called on {de,}registration and on subsequent addition/removal |
| 56 | of devices, with mtd_table_mutex held. */ |
| 57 | void (*add_mtd)(struct mtd_blktrans_ops *tr, struct mtd_info *mtd); |
| 58 | void (*remove_dev)(struct mtd_blktrans_dev *dev); |
| 59 | |
| 60 | struct list_head devs; |
| 61 | struct list_head list; |
| 62 | struct module *owner; |
| 63 | |
| 64 | struct mtd_blkcore_priv *blkcore_priv; |
| 65 | }; |
| 66 | |
| 67 | extern int register_mtd_blktrans(struct mtd_blktrans_ops *tr); |
| 68 | extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr); |
| 69 | extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); |
| 70 | extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); |
Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 71 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
| 73 | #endif /* __MTD_TRANS_H__ */ |