blob: 32acb6ce9df78f1297be506f44bdd4cc3d615116 [file] [log] [blame]
William Juul52c07962007-10-31 13:53:06 +01001/*
William Juul52c07962007-10-31 13:53:06 +01002 * (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
11/* XXX U-BOOT XXX */
12#if 0
13#include <linux/mutex.h>
14#else
15#include <linux/list.h>
16#endif
17
18struct hd_geometry;
19struct mtd_info;
20struct mtd_blktrans_ops;
21struct file;
22struct inode;
23
24struct mtd_blktrans_dev {
25 struct mtd_blktrans_ops *tr;
26 struct list_head list;
27 struct mtd_info *mtd;
28/* XXX U-BOOT XXX */
29#if 0
30 struct mutex lock;
31#endif
32 int devnum;
33 unsigned long size;
34 int readonly;
35 void *blkcore_priv; /* gendisk in 2.5, devfs_handle in 2.4 */
36};
37
38struct blkcore_priv; /* Differs for 2.4 and 2.5 kernels; private */
39
40struct mtd_blktrans_ops {
41 char *name;
42 int major;
43 int part_bits;
44 int blksize;
45 int blkshift;
46
47 /* Access functions */
48 int (*readsect)(struct mtd_blktrans_dev *dev,
49 unsigned long block, char *buffer);
50 int (*writesect)(struct mtd_blktrans_dev *dev,
51 unsigned long block, char *buffer);
52
53 /* Block layer ioctls */
54 int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo);
55 int (*flush)(struct mtd_blktrans_dev *dev);
56
57 /* Called with mtd_table_mutex held; no race with add/remove */
58 int (*open)(struct mtd_blktrans_dev *dev);
59 int (*release)(struct mtd_blktrans_dev *dev);
60
61 /* Called on {de,}registration and on subsequent addition/removal
62 of devices, with mtd_table_mutex held. */
63 void (*add_mtd)(struct mtd_blktrans_ops *tr, struct mtd_info *mtd);
64 void (*remove_dev)(struct mtd_blktrans_dev *dev);
65
66 struct list_head devs;
67 struct list_head list;
68 struct module *owner;
69
70 struct mtd_blkcore_priv *blkcore_priv;
71};
72
73extern int register_mtd_blktrans(struct mtd_blktrans_ops *tr);
74extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr);
75extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
76extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
77
78
79#endif /* __MTD_TRANS_H__ */