blob: 9a6e2f953cba17292fb222bc616c70a1563b4439 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Thomas Gleixner61ecfa82005-11-07 11:15:31 +00002 * $Id: blktrans.h,v 1.6 2005/11/07 11:14:54 gleixner Exp $
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * (C) 2003 David Woodhouse <dwmw2@infradead.org>
5 *
6 * Interface to Linux block layer for MTD 'translation layers'.
7 *
8 */
9
10#ifndef __MTD_TRANS_H__
11#define __MTD_TRANS_H__
12
Ingo Molnar48b19262006-03-31 02:29:41 -080013#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
15struct hd_geometry;
16struct mtd_info;
17struct mtd_blktrans_ops;
18struct file;
19struct inode;
20
21struct mtd_blktrans_dev {
22 struct mtd_blktrans_ops *tr;
23 struct list_head list;
24 struct mtd_info *mtd;
Ingo Molnar48b19262006-03-31 02:29:41 -080025 struct mutex lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 int devnum;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 unsigned long size;
28 int readonly;
29 void *blkcore_priv; /* gendisk in 2.5, devfs_handle in 2.4 */
30};
31
32struct blkcore_priv; /* Differs for 2.4 and 2.5 kernels; private */
33
34struct 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);
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
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__ */