blob: a4b392868b548c371023767fe2cb647767bbd0dc [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * (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 Molnar48b19262006-03-31 02:29:41 -080011#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
13struct hd_geometry;
14struct mtd_info;
15struct mtd_blktrans_ops;
16struct file;
17struct inode;
18
19struct mtd_blktrans_dev {
20 struct mtd_blktrans_ops *tr;
21 struct list_head list;
22 struct mtd_info *mtd;
Ingo Molnar48b19262006-03-31 02:29:41 -080023 struct mutex lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 int devnum;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 unsigned long size;
26 int readonly;
Maxim Levitskya8638622010-02-22 20:39:29 +020027 struct gendisk *disk;
28 struct task_struct *thread;
29 struct request_queue *rq;
30 spinlock_t queue_lock;
31 void *priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -070032};
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034struct mtd_blktrans_ops {
35 char *name;
36 int major;
37 int part_bits;
Richard Purdie19187672006-10-27 09:09:33 +010038 int blksize;
39 int blkshift;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41 /* Access functions */
42 int (*readsect)(struct mtd_blktrans_dev *dev,
43 unsigned long block, char *buffer);
44 int (*writesect)(struct mtd_blktrans_dev *dev,
45 unsigned long block, char *buffer);
David Woodhouseeae9acd2008-08-05 18:08:25 +010046 int (*discard)(struct mtd_blktrans_dev *dev,
47 unsigned long block, unsigned nr_blocks);
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49 /* Block layer ioctls */
50 int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo);
51 int (*flush)(struct mtd_blktrans_dev *dev);
52
53 /* Called with mtd_table_mutex held; no race with add/remove */
54 int (*open)(struct mtd_blktrans_dev *dev);
55 int (*release)(struct mtd_blktrans_dev *dev);
56
57 /* Called on {de,}registration and on subsequent addition/removal
58 of devices, with mtd_table_mutex held. */
59 void (*add_mtd)(struct mtd_blktrans_ops *tr, struct mtd_info *mtd);
60 void (*remove_dev)(struct mtd_blktrans_dev *dev);
61
62 struct list_head devs;
63 struct list_head list;
64 struct module *owner;
Linus Torvalds1da177e2005-04-16 15:20:36 -070065};
66
67extern int register_mtd_blktrans(struct mtd_blktrans_ops *tr);
68extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr);
69extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
70extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
Thomas Gleixner61ecfa82005-11-07 11:15:31 +000071
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73#endif /* __MTD_TRANS_H__ */