x86: Fix duplicated UV BAU interrupt vector
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / mtd / mtdblock_ro.c
blob852165f8b1c3510720cfc03ad80c2e68b4cbd728
1 /*
2 * (C) 2003 David Woodhouse <dwmw2@infradead.org>
4 * Simple read-only (writable only for RAM) mtdblock driver
5 */
7 #include <linux/init.h>
8 #include <linux/slab.h>
9 #include <linux/mtd/mtd.h>
10 #include <linux/mtd/blktrans.h>
12 static int mtdblock_readsect(struct mtd_blktrans_dev *dev,
13 unsigned long block, char *buf)
15 size_t retlen;
17 if (dev->mtd->read(dev->mtd, (block * 512), 512, &retlen, buf))
18 return 1;
19 return 0;
22 static int mtdblock_writesect(struct mtd_blktrans_dev *dev,
23 unsigned long block, char *buf)
25 size_t retlen;
27 if (dev->mtd->write(dev->mtd, (block * 512), 512, &retlen, buf))
28 return 1;
29 return 0;
32 static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
34 struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
36 if (!dev)
37 return;
39 dev->mtd = mtd;
40 dev->devnum = mtd->index;
42 dev->size = mtd->size >> 9;
43 dev->tr = tr;
44 dev->readonly = 1;
46 add_mtd_blktrans_dev(dev);
49 static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev)
51 del_mtd_blktrans_dev(dev);
52 kfree(dev);
55 static struct mtd_blktrans_ops mtdblock_tr = {
56 .name = "mtdblock",
57 .major = 31,
58 .part_bits = 0,
59 .blksize = 512,
60 .readsect = mtdblock_readsect,
61 .writesect = mtdblock_writesect,
62 .add_mtd = mtdblock_add_mtd,
63 .remove_dev = mtdblock_remove_dev,
64 .owner = THIS_MODULE,
67 static int __init mtdblock_init(void)
69 return register_mtd_blktrans(&mtdblock_tr);
72 static void __exit mtdblock_exit(void)
74 deregister_mtd_blktrans(&mtdblock_tr);
77 module_init(mtdblock_init);
78 module_exit(mtdblock_exit);
80 MODULE_LICENSE("GPL");
81 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
82 MODULE_DESCRIPTION("Simple read-only block device emulation access to MTD devices");