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