2 * (C) 2003 David Woodhouse <dwmw2@infradead.org>
4 * Interface to Linux block layer for MTD 'translation layers'.
8 #ifndef __MTD_TRANS_H__
9 #define __MTD_TRANS_H__
11 #include <linux/mutex.h>
12 #include <linux/kref.h>
13 #include <linux/sysfs.h>
17 struct mtd_blktrans_ops
;
21 struct mtd_blktrans_dev
{
22 struct mtd_blktrans_ops
*tr
;
23 struct list_head list
;
32 struct attribute_group
*disk_attributes
;
33 struct task_struct
*thread
;
34 struct request_queue
*rq
;
35 spinlock_t queue_lock
;
39 struct mtd_blktrans_ops
{
46 /* Access functions */
47 int (*readsect
)(struct mtd_blktrans_dev
*dev
,
48 unsigned long block
, char *buffer
);
49 int (*writesect
)(struct mtd_blktrans_dev
*dev
,
50 unsigned long block
, char *buffer
);
51 int (*discard
)(struct mtd_blktrans_dev
*dev
,
52 unsigned long block
, unsigned nr_blocks
);
54 /* Block layer ioctls */
55 int (*getgeo
)(struct mtd_blktrans_dev
*dev
, struct hd_geometry
*geo
);
56 int (*flush
)(struct mtd_blktrans_dev
*dev
);
58 /* Called with mtd_table_mutex held; no race with add/remove */
59 int (*open
)(struct mtd_blktrans_dev
*dev
);
60 int (*release
)(struct mtd_blktrans_dev
*dev
);
62 /* Called on {de,}registration and on subsequent addition/removal
63 of devices, with mtd_table_mutex held. */
64 void (*add_mtd
)(struct mtd_blktrans_ops
*tr
, struct mtd_info
*mtd
);
65 void (*remove_dev
)(struct mtd_blktrans_dev
*dev
);
67 struct list_head devs
;
68 struct list_head list
;
72 extern int register_mtd_blktrans(struct mtd_blktrans_ops
*tr
);
73 extern int deregister_mtd_blktrans(struct mtd_blktrans_ops
*tr
);
74 extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev
*dev
);
75 extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev
*dev
);
78 #endif /* __MTD_TRANS_H__ */