summaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-11-28 03:58:46 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-11-28 03:58:46 +0000
commitb63ad0882a16a5d28003e57f2b0b81dee3fb322b (patch)
tree0a343ce219e2b8b38a5d702d66032c57b83d9720 /drivers/mtd
parenta9d7bff9a84dba79609a0002e5321b74c4d64c64 (diff)
Merge with 2.4.0-test11.
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/Makefile2
-rw-r--r--drivers/mtd/cfi_cmdset_0001.c40
-rw-r--r--drivers/mtd/cfi_cmdset_0002.c34
-rw-r--r--drivers/mtd/cfi_probe.c44
-rw-r--r--drivers/mtd/doc2000.c23
-rw-r--r--drivers/mtd/doc2001.c21
-rw-r--r--drivers/mtd/docprobe.c47
-rw-r--r--drivers/mtd/map_ram.c30
8 files changed, 160 insertions, 81 deletions
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index fcbfd3175..3f28868e3 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -44,7 +44,7 @@ SUB_DIRS :=
ALL_SUB_DIRS :=
MOD_SUB_DIRS :=
-export-objs := mtdcore.o doc2000.o doc2001.o cfi_probe.o cfi_cmdset_0001.o cfi_cmdset_0002.o
+export-objs := mtdcore.o
list-multi :=
# MTD devices
diff --git a/drivers/mtd/cfi_cmdset_0001.c b/drivers/mtd/cfi_cmdset_0001.c
index 8c26d43b4..e765d91fc 100644
--- a/drivers/mtd/cfi_cmdset_0001.c
+++ b/drivers/mtd/cfi_cmdset_0001.c
@@ -32,12 +32,20 @@ static void cfi_intelext_resume (struct mtd_info *);
static void cfi_intelext_destroy(struct mtd_info *);
-void cfi_cmdset_0001(struct map_info *, int, unsigned long);
-EXPORT_SYMBOL(cfi_cmdset_0001);
+static void cfi_cmdset_0001(struct map_info *, int, unsigned long);
-struct mtd_info *cfi_intelext_setup (struct map_info *);
+static struct mtd_info *cfi_intelext_setup (struct map_info *);
-void cfi_cmdset_0001(struct map_info *map, int primary, unsigned long base)
+static const char im_name[] = "cfi_cmdset_0001";
+
+/* This routine is made available to other mtd code via
+ * inter_module_register. It must only be accessed through
+ * inter_module_get which will bump the use count of this module. The
+ * addresses passed back in cfi are valid as long as the use count of
+ * this module is non-zero, i.e. between inter_module_get and
+ * inter_module_put. Keith Owens <kaos@ocs.com.au> 29 Oct 2000.
+ */
+static void cfi_cmdset_0001(struct map_info *map, int primary, unsigned long base)
{
struct cfi_private *cfi = map->fldrv_priv;
int i;
@@ -144,7 +152,7 @@ void cfi_cmdset_0001(struct map_info *map, int primary, unsigned long base)
/* If there was an old setup function, decrease its use count */
if (cfi->cmdset_setup)
- put_module_symbol((unsigned long)cfi->cmdset_setup);
+ inter_module_put(cfi->im_name);
if (cfi->cmdset_priv)
kfree(cfi->cmdset_priv);
@@ -156,14 +164,13 @@ void cfi_cmdset_0001(struct map_info *map, int primary, unsigned long base)
cfi->cmdset_setup = cfi_intelext_setup;
+ cfi->im_name = im_name;
cfi->cmdset_priv = extp;
- MOD_INC_USE_COUNT; /* So the setup function is still there
- * by the time it's called */
return;
}
-struct mtd_info *cfi_intelext_setup(struct map_info *map)
+static struct mtd_info *cfi_intelext_setup(struct map_info *map)
{
struct cfi_private *cfi = map->fldrv_priv;
struct mtd_info *mtd;
@@ -763,6 +770,8 @@ static void cfi_intelext_sync (struct mtd_info *mtd)
spin_unlock_bh(chip->mutex);
schedule();
+ remove_wait_queue(&chip->wq, &wait);
+
goto retry;
}
}
@@ -862,6 +871,21 @@ static void cfi_intelext_destroy(struct mtd_info *mtd)
struct map_info *map = mtd->priv;
struct cfi_private *cfi = map->fldrv_priv;
kfree(cfi->cmdset_priv);
+ inter_module_put(cfi->im_name);
kfree(cfi);
}
+
+static int __init cfi_intelext_init(void)
+{
+ inter_module_register(im_name, THIS_MODULE, &cfi_cmdset_0001);
+ return 0;
+}
+
+static void __exit cfi_intelext_exit(void)
+{
+ inter_module_unregister(im_name);
+}
+
+module_init(cfi_intelext_init);
+module_exit(cfi_intelext_exit);
diff --git a/drivers/mtd/cfi_cmdset_0002.c b/drivers/mtd/cfi_cmdset_0002.c
index 2797c768e..d6cce6474 100644
--- a/drivers/mtd/cfi_cmdset_0002.c
+++ b/drivers/mtd/cfi_cmdset_0002.c
@@ -36,12 +36,13 @@ static void cfi_amdext_resume (struct mtd_info *);
static void cfi_amdext_destroy(struct mtd_info *);
-void cfi_cmdset_0002(struct map_info *, int, unsigned long);
-EXPORT_SYMBOL(cfi_cmdset_0002);
+static void cfi_cmdset_0002(struct map_info *, int, unsigned long);
-struct mtd_info *cfi_amdext_setup (struct map_info *);
+static struct mtd_info *cfi_amdext_setup (struct map_info *);
-void cfi_cmdset_0002(struct map_info *map, int primary, unsigned long base)
+static const char im_name[] = "cfi_cmdset_0002";
+
+static void cfi_cmdset_0002(struct map_info *map, int primary, unsigned long base)
{
struct cfi_private *cfi = map->fldrv_priv;
int i;
@@ -54,7 +55,7 @@ void cfi_cmdset_0002(struct map_info *map, int primary, unsigned long base)
/* If there was an old setup function, decrease its use count */
if (cfi->cmdset_setup)
- put_module_symbol((unsigned long)cfi->cmdset_setup);
+ inter_module_put(cfi->im_name);
if (cfi->cmdset_priv)
kfree(cfi->cmdset_priv);
@@ -66,14 +67,13 @@ void cfi_cmdset_0002(struct map_info *map, int primary, unsigned long base)
cfi->cmdset_setup = cfi_amdext_setup;
+ cfi->im_name = im_name;
// cfi->cmdset_priv = extp;
- MOD_INC_USE_COUNT; /* So the setup function is still there
- * by the time it's called */
return;
}
-struct mtd_info *cfi_amdext_setup(struct map_info *map)
+static struct mtd_info *cfi_amdext_setup(struct map_info *map)
{
struct cfi_private *cfi = map->fldrv_priv;
struct mtd_info *mtd;
@@ -501,8 +501,11 @@ printk("sync\n");
add_wait_queue(&chip->wq, &wait);
spin_unlock_bh(chip->mutex);
+
schedule();
+ remove_wait_queue(&chip->wq, &wait);
+
goto retry;
}
}
@@ -605,6 +608,21 @@ static void cfi_amdext_destroy(struct mtd_info *mtd)
struct map_info *map = mtd->priv;
struct cfi_private *cfi = map->fldrv_priv;
kfree(cfi->cmdset_priv);
+ inter_module_put(cfi->im_name);
kfree(cfi);
}
+
+static int __init cfi_amdext_init(void)
+{
+ inter_module_register(im_name, THIS_MODULE, &cfi_cmdset_0002);
+ return 0;
+}
+
+static void __exit cfi_amdext_exit(void)
+{
+ inter_module_unregister(im_name);
+}
+
+module_init(cfi_amdext_init);
+module_exit(cfi_amdext_exit);
diff --git a/drivers/mtd/cfi_probe.c b/drivers/mtd/cfi_probe.c
index ccd33fb3c..392f7aa57 100644
--- a/drivers/mtd/cfi_probe.c
+++ b/drivers/mtd/cfi_probe.c
@@ -17,14 +17,22 @@
#include <linux/mtd/cfi.h>
-struct mtd_info *cfi_probe(struct map_info *);
-EXPORT_SYMBOL(cfi_probe);
+static struct mtd_info *cfi_probe(struct map_info *);
static void print_cfi_ident(struct cfi_ident *);
static void check_cmd_set(struct map_info *, int, unsigned long);
static struct cfi_private *cfi_cfi_probe(struct map_info *);
-struct mtd_info *cfi_probe(struct map_info *map)
+static const char im_name[] = "cfi_probe";
+
+/* This routine is made available to other mtd code via
+ * inter_module_register. It must only be accessed through
+ * inter_module_get which will bump the use count of this module. The
+ * addresses passed back in mtd are valid as long as the use count of
+ * this module is non-zero, i.e. between inter_module_get and
+ * inter_module_put. Keith Owens <kaos@ocs.com.au> 29 Oct 2000.
+ */
+static struct mtd_info *cfi_probe(struct map_info *map)
{
struct mtd_info *mtd = NULL;
struct cfi_private *cfi;
@@ -35,13 +43,14 @@ struct mtd_info *cfi_probe(struct map_info *map)
return NULL;
map->fldrv_priv = cfi;
+ map->im_name = im_name;
/* OK we liked it. Now find a driver for the command set it talks */
check_cmd_set(map, 1, cfi->chips[0].start); /* First the primary cmdset */
check_cmd_set(map, 0, cfi->chips[0].start); /* Then the secondary */
- /* check_cmd_set() will have used get_module_symbol to increase
+ /* check_cmd_set() will have used inter_module_get to increase
the use count of the module which provides the command set
driver. If we're quitting, we have to decrease it again.
*/
@@ -51,7 +60,7 @@ struct mtd_info *cfi_probe(struct map_info *map)
if (mtd)
return mtd;
- put_module_symbol((unsigned long)cfi->cmdset_setup);
+ inter_module_put(cfi->im_name);
}
printk("No supported Vendor Command Set found\n");
@@ -239,7 +248,7 @@ static int cfi_probe_new_chip(struct map_info *map, unsigned long base,
}
}
default:
- printk(KERN_WARNING "cfi_cfi_probe called with strange buswidth %d\n", map->buswidth);
+ printk(KERN_WARNING "cfi_probe called with strange buswidth %d\n", map->buswidth);
return 0;
}
}
@@ -465,16 +474,9 @@ static void check_cmd_set(struct map_info *map, int primary, unsigned long base)
sprintf(probename, "cfi_cmdset_%4.4X", type);
- probe_function = (void *)get_module_symbol(NULL, probename);
- if (!probe_function) {
- request_module(probename);
-
- probe_function = (void *)get_module_symbol(NULL, probename);
- }
-
+ probe_function = inter_module_get_request(probename, probename);
if (probe_function) {
(*probe_function)(map, primary, base);
- put_module_symbol((unsigned long)probe_function);
return;
}
@@ -499,3 +501,17 @@ static void check_cmd_set(struct map_info *map, int primary, unsigned long base)
map->read8(map,base+((adr+4)*map->buswidth)));
}
}
+
+static int __init cfi_probe_init(void)
+{
+ inter_module_register(im_name, THIS_MODULE, &cfi_probe);
+ return 0;
+}
+
+static void __exit cfi_probe_exit(void)
+{
+ inter_module_unregister(im_name);
+}
+
+module_init(cfi_probe_init);
+module_exit(cfi_probe_exit);
diff --git a/drivers/mtd/doc2000.c b/drivers/mtd/doc2000.c
index eeb49a4eb..cef67512b 100644
--- a/drivers/mtd/doc2000.c
+++ b/drivers/mtd/doc2000.c
@@ -392,7 +392,16 @@ static int DoC2k_is_alias(struct DiskOnChip *doc1, struct DiskOnChip *doc2)
}
-void DoC2k_init(struct mtd_info *mtd)
+static const char im_name[] = "DoC2k_init";
+
+/* This routine is made available to other mtd code via
+ * inter_module_register. It must only be accessed through
+ * inter_module_get which will bump the use count of this module. The
+ * addresses passed back in mtd are valid as long as the use count of
+ * this module is non-zero, i.e. between inter_module_get and
+ * inter_module_put. Keith Owens <kaos@ocs.com.au> 29 Oct 2000.
+ */
+static void DoC2k_init(struct mtd_info *mtd)
{
struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
struct DiskOnChip *old = NULL;
@@ -460,8 +469,6 @@ void DoC2k_init(struct mtd_info *mtd)
}
-EXPORT_SYMBOL(DoC2k_init);
-
static int doc_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
{
/* Just a special case of doc_read_ecc */
@@ -805,6 +812,12 @@ int doc_erase (struct mtd_info *mtd, struct erase_info *instr)
*
****************************************************************************/
+static int __init init_doc2000(void)
+{
+ inter_module_register(im_name, THIS_MODULE, &DoC2k_init);
+ return 0;
+}
+
#if LINUX_VERSION_CODE < 0x20300
#ifdef MODULE
#define cleanup_doc2000 cleanup_module
@@ -828,10 +841,12 @@ static void __exit cleanup_doc2000(void)
kfree(this->chips);
kfree(mtd);
}
+ inter_module_unregister(im_name);
}
+module_init(init_doc2000);
+
#if LINUX_VERSION_CODE > 0x20300
module_exit(cleanup_doc2000);
#endif
-
diff --git a/drivers/mtd/doc2001.c b/drivers/mtd/doc2001.c
index 26a107722..8a9f03235 100644
--- a/drivers/mtd/doc2001.c
+++ b/drivers/mtd/doc2001.c
@@ -321,6 +321,15 @@ static int DoCMil_is_alias(struct DiskOnChip *doc1, struct DiskOnChip *doc2)
return retval;
}
+static const char im_name[] = "DoCMil_init";
+
+/* This routine is made available to other mtd code via
+ * inter_module_register. It must only be accessed through
+ * inter_module_get which will bump the use count of this module. The
+ * addresses passed back in mtd are valid as long as the use count of
+ * this module is non-zero, i.e. between inter_module_get and
+ * inter_module_put. Keith Owens <kaos@ocs.com.au> 29 Oct 2000.
+ */
void DoCMil_init(struct mtd_info *mtd)
{
struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
@@ -386,8 +395,6 @@ void DoCMil_init(struct mtd_info *mtd)
}
}
-EXPORT_SYMBOL(DoCMil_init);
-
static int doc_read (struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf)
{
@@ -780,6 +787,12 @@ int doc_erase (struct mtd_info *mtd, struct erase_info *instr)
*
****************************************************************************/
+static int __init init_doc2001(void)
+{
+ inter_module_register(im_name, THIS_MODULE, &DoCMil_init);
+ return 0;
+}
+
#if LINUX_VERSION_CODE < 0x20300
#ifdef MODULE
#define cleanup_doc2001 cleanup_module
@@ -803,10 +816,12 @@ static void __exit cleanup_doc2001(void)
kfree(this->chips);
kfree(mtd);
}
+ inter_module_unregister(im_name);
}
+module_init(init_doc2001);
+
#if LINUX_VERSION_CODE > 0x20300
module_exit(cleanup_doc2001);
#endif
-
diff --git a/drivers/mtd/docprobe.c b/drivers/mtd/docprobe.c
index 7ab0a2d74..b38b4352d 100644
--- a/drivers/mtd/docprobe.c
+++ b/drivers/mtd/docprobe.c
@@ -26,11 +26,8 @@
#define DOC_PASSIVE_PROBE
*/
-
-#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
-#include <linux/kmod.h>
#include <asm/errno.h>
#include <asm/io.h>
#include <asm/uaccess.h>
@@ -62,12 +59,6 @@ static unsigned long __initdata doc_locations[] = {
#warning Unknown architecture for DiskOnChip. No default probe locations defined
#endif
-#ifdef CONFIG_MTD_DOC2000
-extern void DoC2k_init(struct mtd_info *);
-#endif
-#ifdef CONFIG_MTD_DOC2001
-extern void DoCMil_init(struct mtd_info *);
-#endif
/* doccheck: Probe a given memory window to see if there's a DiskOnChip present */
@@ -157,8 +148,9 @@ static void DoC_Probe(unsigned long physadr)
int ChipID;
char namebuf[15];
char *name = namebuf;
+ char *im_funcname = NULL;
+ char *im_modname = NULL;
void (*initroutine)(struct mtd_info *) = NULL;
- int initroutinedynamic = 0;
docptr = (unsigned long)ioremap(physadr, 0x2000);
@@ -189,42 +181,21 @@ static void DoC_Probe(unsigned long physadr)
switch(ChipID) {
case DOC_ChipID_Doc2k:
name="2000";
-#ifdef CONFIG_MTD_DOC2000
- initroutine = &DoC2k_init;
-#elif CONFIG_MODULES
- initroutinedynamic=1;
- initroutine = (void *)get_module_symbol(NULL, "DoC2k_init");
-#ifdef CONFIG_KMOD
- if (!initroutine) {
- request_module("doc2000");
- initroutine = (void *)get_module_symbol("doc2000", "DoC2k_init");
- }
-#endif /* CONFIG_KMOD */
-#endif
+ im_funcname = "DoC2k_init";
+ im_modname = "doc2000";
break;
case DOC_ChipID_DocMil:
name="Millennium";
-#ifdef CONFIG_MTD_DOC2001
- initroutine = &DoCMil_init;
-#elif CONFIG_MODULES
- initroutinedynamic=1;
- initroutine = (void *)get_module_symbol(NULL, "DoCMil_init");
-#ifdef CONFIG_KMOD
- if (!initroutine) {
- request_module("doc2001");
- initroutine = (void *)get_module_symbol("doc2001", "DoCMil_init");
- }
-#endif /* CONFIG_KMOD */
-#endif
+ im_funcname = "DoCMil_init";
+ im_modname = "doc2001";
break;
}
+ if (im_funcname)
+ initroutine = inter_module_get_request(im_funcname, im_modname);
if (initroutine) {
(*initroutine)(mtd);
-#if defined(CONFIG_MODULES) && LINUX_VERSION_CODE >= 0x20400
- if (initroutinedynamic)
- put_module_symbol(initroutine);
-#endif
+ inter_module_put(im_funcname);
return;
}
printk("Cannot find driver for DiskOnChip %s at 0x%X\n", name, physadr);
diff --git a/drivers/mtd/map_ram.c b/drivers/mtd/map_ram.c
index 706f7f5ff..c62515406 100644
--- a/drivers/mtd/map_ram.c
+++ b/drivers/mtd/map_ram.c
@@ -20,10 +20,16 @@ static int mapram_write (struct mtd_info *, loff_t, size_t, size_t *, const u_ch
static int mapram_erase (struct mtd_info *, struct erase_info *);
static void mapram_nop (struct mtd_info *);
-struct mtd_info *map_ram_probe(struct map_info *);
-EXPORT_SYMBOL(map_ram_probe);
-
-struct mtd_info *map_ram_probe(struct map_info *map)
+static const char im_name[] = "map_ram_probe";
+
+/* This routine is made available to other mtd code via
+ * inter_module_register. It must only be accessed through
+ * inter_module_get which will bump the use count of this module. The
+ * addresses passed back in mtd are valid as long as the use count of
+ * this module is non-zero, i.e. between inter_module_get and
+ * inter_module_put. Keith Owens <kaos@ocs.com.au> 29 Oct 2000.
+ */
+static struct mtd_info *map_ram_probe(struct map_info *map)
{
struct mtd_info *mtd;
@@ -63,9 +69,9 @@ struct mtd_info *map_ram_probe(struct map_info *map)
mtd->read = mapram_read;
mtd->write = mapram_write;
mtd->sync = mapram_nop;
+ mtd->im_name = im_name;
mtd->flags = MTD_CAP_RAM | MTD_VOLATILE;
- MOD_INC_USE_COUNT;
return mtd;
}
@@ -108,3 +114,17 @@ static void mapram_nop(struct mtd_info *mtd)
{
/* Nothing to see here */
}
+
+static int __init map_ram_init(void)
+{
+ inter_module_register(im_name, THIS_MODULE, &map_ram_probe);
+ return 0;
+}
+
+static void __exit map_ram_exit(void)
+{
+ inter_module_unregister(im_name);
+}
+
+module_init(map_ram_init);
+module_exit(map_ram_exit);