2 * Copyright © 2003-2010 David Woodhouse <dwmw2@infradead.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef __MTD_TRANS_H__
21 #define __MTD_TRANS_H__
23 #include <linux/mutex.h>
24 #include <linux/kref.h>
25 #include <linux/sysfs.h>
26 #include <linux/workqueue.h>
30 struct mtd_blktrans_ops
;
34 struct mtd_blktrans_dev
{
35 struct mtd_blktrans_ops
*tr
;
36 struct list_head list
;
46 struct attribute_group
*disk_attributes
;
47 struct workqueue_struct
*wq
;
48 struct work_struct work
;
49 struct request_queue
*rq
;
50 spinlock_t queue_lock
;
55 struct mtd_blktrans_ops
{
62 /* Access functions */
63 int (*readsect
)(struct mtd_blktrans_dev
*dev
,
64 unsigned long block
, char *buffer
);
65 int (*writesect
)(struct mtd_blktrans_dev
*dev
,
66 unsigned long block
, char *buffer
);
67 int (*discard
)(struct mtd_blktrans_dev
*dev
,
68 unsigned long block
, unsigned nr_blocks
);
69 void (*background
)(struct mtd_blktrans_dev
*dev
);
71 /* Block layer ioctls */
72 int (*getgeo
)(struct mtd_blktrans_dev
*dev
, struct hd_geometry
*geo
);
73 int (*flush
)(struct mtd_blktrans_dev
*dev
);
75 /* Called with mtd_table_mutex held; no race with add/remove */
76 int (*open
)(struct mtd_blktrans_dev
*dev
);
77 void (*release
)(struct mtd_blktrans_dev
*dev
);
79 /* Called on {de,}registration and on subsequent addition/removal
80 of devices, with mtd_table_mutex held. */
81 void (*add_mtd
)(struct mtd_blktrans_ops
*tr
, struct mtd_info
*mtd
);
82 void (*remove_dev
)(struct mtd_blktrans_dev
*dev
);
84 struct list_head devs
;
85 struct list_head list
;
89 extern int register_mtd_blktrans(struct mtd_blktrans_ops
*tr
);
90 extern int deregister_mtd_blktrans(struct mtd_blktrans_ops
*tr
);
91 extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev
*dev
);
92 extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev
*dev
);
93 extern int mtd_blktrans_cease_background(struct mtd_blktrans_dev
*dev
);
96 #endif /* __MTD_TRANS_H__ */