ia64/linux-2.6.18-xen.hg

annotate drivers/mtd/chips/map_absent.c @ 893:f994bfe9b93b

linux/blktap2: reduce TLB flush scope

c/s 885 added very coarse TLB flushing. Since these flushes always
follow single page updates, single page flushes (when available) are
sufficient.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 04 10:32:57 2009 +0100 (2009-06-04)
parents 831230e53067
children
rev   line source
ian@0 1 /*
ian@0 2 * Common code to handle absent "placeholder" devices
ian@0 3 * Copyright 2001 Resilience Corporation <ebrower@resilience.com>
ian@0 4 * $Id: map_absent.c,v 1.6 2005/11/07 11:14:23 gleixner Exp $
ian@0 5 *
ian@0 6 * This map driver is used to allocate "placeholder" MTD
ian@0 7 * devices on systems that have socketed/removable media.
ian@0 8 * Use of this driver as a fallback preserves the expected
ian@0 9 * registration of MTD device nodes regardless of probe outcome.
ian@0 10 * A usage example is as follows:
ian@0 11 *
ian@0 12 * my_dev[i] = do_map_probe("cfi", &my_map[i]);
ian@0 13 * if(NULL == my_dev[i]) {
ian@0 14 * my_dev[i] = do_map_probe("map_absent", &my_map[i]);
ian@0 15 * }
ian@0 16 *
ian@0 17 * Any device 'probed' with this driver will return -ENODEV
ian@0 18 * upon open.
ian@0 19 */
ian@0 20
ian@0 21 #include <linux/module.h>
ian@0 22 #include <linux/types.h>
ian@0 23 #include <linux/kernel.h>
ian@0 24 #include <linux/errno.h>
ian@0 25 #include <linux/slab.h>
ian@0 26 #include <linux/init.h>
ian@0 27 #include <linux/mtd/mtd.h>
ian@0 28 #include <linux/mtd/map.h>
ian@0 29 #include <linux/mtd/compatmac.h>
ian@0 30
ian@0 31 static int map_absent_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
ian@0 32 static int map_absent_write (struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
ian@0 33 static int map_absent_erase (struct mtd_info *, struct erase_info *);
ian@0 34 static void map_absent_sync (struct mtd_info *);
ian@0 35 static struct mtd_info *map_absent_probe(struct map_info *map);
ian@0 36 static void map_absent_destroy (struct mtd_info *);
ian@0 37
ian@0 38
ian@0 39 static struct mtd_chip_driver map_absent_chipdrv = {
ian@0 40 .probe = map_absent_probe,
ian@0 41 .destroy = map_absent_destroy,
ian@0 42 .name = "map_absent",
ian@0 43 .module = THIS_MODULE
ian@0 44 };
ian@0 45
ian@0 46 static struct mtd_info *map_absent_probe(struct map_info *map)
ian@0 47 {
ian@0 48 struct mtd_info *mtd;
ian@0 49
ian@0 50 mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
ian@0 51 if (!mtd) {
ian@0 52 return NULL;
ian@0 53 }
ian@0 54
ian@0 55 memset(mtd, 0, sizeof(*mtd));
ian@0 56
ian@0 57 map->fldrv = &map_absent_chipdrv;
ian@0 58 mtd->priv = map;
ian@0 59 mtd->name = map->name;
ian@0 60 mtd->type = MTD_ABSENT;
ian@0 61 mtd->size = map->size;
ian@0 62 mtd->erase = map_absent_erase;
ian@0 63 mtd->read = map_absent_read;
ian@0 64 mtd->write = map_absent_write;
ian@0 65 mtd->sync = map_absent_sync;
ian@0 66 mtd->flags = 0;
ian@0 67 mtd->erasesize = PAGE_SIZE;
ian@0 68 mtd->writesize = 1;
ian@0 69
ian@0 70 __module_get(THIS_MODULE);
ian@0 71 return mtd;
ian@0 72 }
ian@0 73
ian@0 74
ian@0 75 static int map_absent_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
ian@0 76 {
ian@0 77 *retlen = 0;
ian@0 78 return -ENODEV;
ian@0 79 }
ian@0 80
ian@0 81 static int map_absent_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
ian@0 82 {
ian@0 83 *retlen = 0;
ian@0 84 return -ENODEV;
ian@0 85 }
ian@0 86
ian@0 87 static int map_absent_erase(struct mtd_info *mtd, struct erase_info *instr)
ian@0 88 {
ian@0 89 return -ENODEV;
ian@0 90 }
ian@0 91
ian@0 92 static void map_absent_sync(struct mtd_info *mtd)
ian@0 93 {
ian@0 94 /* nop */
ian@0 95 }
ian@0 96
ian@0 97 static void map_absent_destroy(struct mtd_info *mtd)
ian@0 98 {
ian@0 99 /* nop */
ian@0 100 }
ian@0 101
ian@0 102 static int __init map_absent_init(void)
ian@0 103 {
ian@0 104 register_mtd_chip_driver(&map_absent_chipdrv);
ian@0 105 return 0;
ian@0 106 }
ian@0 107
ian@0 108 static void __exit map_absent_exit(void)
ian@0 109 {
ian@0 110 unregister_mtd_chip_driver(&map_absent_chipdrv);
ian@0 111 }
ian@0 112
ian@0 113 module_init(map_absent_init);
ian@0 114 module_exit(map_absent_exit);
ian@0 115
ian@0 116 MODULE_LICENSE("GPL");
ian@0 117 MODULE_AUTHOR("Resilience Corporation - Eric Brower <ebrower@resilience.com>");
ian@0 118 MODULE_DESCRIPTION("Placeholder MTD chip driver for 'absent' chips");