ia64/linux-2.6.18-xen.hg

annotate drivers/mtd/chips/chipreg.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 * $Id: chipreg.c,v 1.17 2004/11/16 18:29:00 dwmw2 Exp $
ian@0 3 *
ian@0 4 * Registration for chip drivers
ian@0 5 *
ian@0 6 */
ian@0 7
ian@0 8 #include <linux/kernel.h>
ian@0 9 #include <linux/module.h>
ian@0 10 #include <linux/kmod.h>
ian@0 11 #include <linux/spinlock.h>
ian@0 12 #include <linux/slab.h>
ian@0 13 #include <linux/mtd/map.h>
ian@0 14 #include <linux/mtd/mtd.h>
ian@0 15 #include <linux/mtd/compatmac.h>
ian@0 16
ian@0 17 static DEFINE_SPINLOCK(chip_drvs_lock);
ian@0 18 static LIST_HEAD(chip_drvs_list);
ian@0 19
ian@0 20 void register_mtd_chip_driver(struct mtd_chip_driver *drv)
ian@0 21 {
ian@0 22 spin_lock(&chip_drvs_lock);
ian@0 23 list_add(&drv->list, &chip_drvs_list);
ian@0 24 spin_unlock(&chip_drvs_lock);
ian@0 25 }
ian@0 26
ian@0 27 void unregister_mtd_chip_driver(struct mtd_chip_driver *drv)
ian@0 28 {
ian@0 29 spin_lock(&chip_drvs_lock);
ian@0 30 list_del(&drv->list);
ian@0 31 spin_unlock(&chip_drvs_lock);
ian@0 32 }
ian@0 33
ian@0 34 static struct mtd_chip_driver *get_mtd_chip_driver (const char *name)
ian@0 35 {
ian@0 36 struct list_head *pos;
ian@0 37 struct mtd_chip_driver *ret = NULL, *this;
ian@0 38
ian@0 39 spin_lock(&chip_drvs_lock);
ian@0 40
ian@0 41 list_for_each(pos, &chip_drvs_list) {
ian@0 42 this = list_entry(pos, typeof(*this), list);
ian@0 43
ian@0 44 if (!strcmp(this->name, name)) {
ian@0 45 ret = this;
ian@0 46 break;
ian@0 47 }
ian@0 48 }
ian@0 49 if (ret && !try_module_get(ret->module))
ian@0 50 ret = NULL;
ian@0 51
ian@0 52 spin_unlock(&chip_drvs_lock);
ian@0 53
ian@0 54 return ret;
ian@0 55 }
ian@0 56
ian@0 57 /* Hide all the horrid details, like some silly person taking
ian@0 58 get_module_symbol() away from us, from the caller. */
ian@0 59
ian@0 60 struct mtd_info *do_map_probe(const char *name, struct map_info *map)
ian@0 61 {
ian@0 62 struct mtd_chip_driver *drv;
ian@0 63 struct mtd_info *ret;
ian@0 64
ian@0 65 drv = get_mtd_chip_driver(name);
ian@0 66
ian@0 67 if (!drv && !request_module("%s", name))
ian@0 68 drv = get_mtd_chip_driver(name);
ian@0 69
ian@0 70 if (!drv)
ian@0 71 return NULL;
ian@0 72
ian@0 73 ret = drv->probe(map);
ian@0 74
ian@0 75 /* We decrease the use count here. It may have been a
ian@0 76 probe-only module, which is no longer required from this
ian@0 77 point, having given us a handle on (and increased the use
ian@0 78 count of) the actual driver code.
ian@0 79 */
ian@0 80 module_put(drv->module);
ian@0 81
ian@0 82 if (ret)
ian@0 83 return ret;
ian@0 84
ian@0 85 return NULL;
ian@0 86 }
ian@0 87 /*
ian@0 88 * Destroy an MTD device which was created for a map device.
ian@0 89 * Make sure the MTD device is already unregistered before calling this
ian@0 90 */
ian@0 91 void map_destroy(struct mtd_info *mtd)
ian@0 92 {
ian@0 93 struct map_info *map = mtd->priv;
ian@0 94
ian@0 95 if (map->fldrv->destroy)
ian@0 96 map->fldrv->destroy(mtd);
ian@0 97
ian@0 98 module_put(map->fldrv->module);
ian@0 99
ian@0 100 kfree(mtd);
ian@0 101 }
ian@0 102
ian@0 103 EXPORT_SYMBOL(register_mtd_chip_driver);
ian@0 104 EXPORT_SYMBOL(unregister_mtd_chip_driver);
ian@0 105 EXPORT_SYMBOL(do_map_probe);
ian@0 106 EXPORT_SYMBOL(map_destroy);
ian@0 107
ian@0 108 MODULE_LICENSE("GPL");
ian@0 109 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
ian@0 110 MODULE_DESCRIPTION("Core routines for registering and invoking MTD chip drivers");