]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/mtd/blktrans.h
Merge tag 'pwm/for-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry...
[mirror_ubuntu-bionic-kernel.git] / include / linux / mtd / blktrans.h
CommitLineData
1da177e4 1/*
a1452a37 2 * Copyright © 2003-2010 David Woodhouse <dwmw2@infradead.org>
1da177e4 3 *
a1452a37
DW
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.
8 *
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.
13 *
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
1da177e4
LT
17 *
18 */
19
20#ifndef __MTD_TRANS_H__
21#define __MTD_TRANS_H__
22
48b19268 23#include <linux/mutex.h>
048d8719 24#include <linux/kref.h>
026ec578 25#include <linux/sysfs.h>
22a8578f 26#include <linux/workqueue.h>
1da177e4
LT
27
28struct hd_geometry;
29struct mtd_info;
30struct mtd_blktrans_ops;
31struct file;
32struct inode;
33
34struct mtd_blktrans_dev {
35 struct mtd_blktrans_ops *tr;
36 struct list_head list;
37 struct mtd_info *mtd;
48b19268 38 struct mutex lock;
1da177e4 39 int devnum;
7bf7e370 40 bool bg_stop;
1da177e4
LT
41 unsigned long size;
42 int readonly;
048d8719
ML
43 int open;
44 struct kref ref;
a8638622 45 struct gendisk *disk;
026ec578 46 struct attribute_group *disk_attributes;
22a8578f
EG
47 struct workqueue_struct *wq;
48 struct work_struct work;
a8638622
ML
49 struct request_queue *rq;
50 spinlock_t queue_lock;
51 void *priv;
70d5098a 52 fmode_t file_mode;
1da177e4
LT
53};
54
1da177e4
LT
55struct mtd_blktrans_ops {
56 char *name;
57 int major;
58 int part_bits;
19187672
RP
59 int blksize;
60 int blkshift;
1da177e4
LT
61
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);
eae9acd1
DW
67 int (*discard)(struct mtd_blktrans_dev *dev,
68 unsigned long block, unsigned nr_blocks);
c7519dbf 69 void (*background)(struct mtd_blktrans_dev *dev);
1da177e4
LT
70
71 /* Block layer ioctls */
72 int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo);
73 int (*flush)(struct mtd_blktrans_dev *dev);
74
75 /* Called with mtd_table_mutex held; no race with add/remove */
76 int (*open)(struct mtd_blktrans_dev *dev);
a8ca889e 77 void (*release)(struct mtd_blktrans_dev *dev);
1da177e4
LT
78
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);
83
84 struct list_head devs;
85 struct list_head list;
86 struct module *owner;
1da177e4
LT
87};
88
89extern int register_mtd_blktrans(struct mtd_blktrans_ops *tr);
90extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr);
91extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
92extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
c7519dbf 93extern int mtd_blktrans_cease_background(struct mtd_blktrans_dev *dev);
61ecfa87 94
1da177e4
LT
95
96#endif /* __MTD_TRANS_H__ */