#include <linux/ioctl.h>
#include <linux/init.h>
#include <linux/mtd/compatmac.h>
+#ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h>
+#endif
#include <linux/mtd/mtd.h>
/* These are exported solely for the purpose of mtd_blkdevs.c. You
should not use them for _anything_ else */
-DEFINE_MUTEX(mtd_table_mutex);
+DECLARE_MUTEX(mtd_table_mutex);
struct mtd_info *mtd_table[MAX_MTD_DEVICES];
EXPORT_SYMBOL_GPL(mtd_table_mutex);
{
int i;
- mutex_lock(&mtd_table_mutex);
+ down(&mtd_table_mutex);
for (i=0; i < MAX_MTD_DEVICES; i++)
if (!mtd_table[i]) {
not->add(mtd);
}
- mutex_unlock(&mtd_table_mutex);
+ up(&mtd_table_mutex);
/* We _know_ we aren't being removed, because
our caller is still holding us here. So none
of this try_ nonsense, and no bitching about it
return 0;
}
- mutex_unlock(&mtd_table_mutex);
+ up(&mtd_table_mutex);
return 1;
}
{
int ret;
- mutex_lock(&mtd_table_mutex);
+ down(&mtd_table_mutex);
if (mtd_table[mtd->index] != mtd) {
ret = -ENODEV;
ret = 0;
}
- mutex_unlock(&mtd_table_mutex);
+ up(&mtd_table_mutex);
return ret;
}
{
int i;
- mutex_lock(&mtd_table_mutex);
+ down(&mtd_table_mutex);
list_add(&new->list, &mtd_notifiers);
if (mtd_table[i])
new->add(mtd_table[i]);
- mutex_unlock(&mtd_table_mutex);
+ up(&mtd_table_mutex);
}
/**
{
int i;
- mutex_lock(&mtd_table_mutex);
+ down(&mtd_table_mutex);
module_put(THIS_MODULE);
old->remove(mtd_table[i]);
list_del(&old->list);
- mutex_unlock(&mtd_table_mutex);
+ up(&mtd_table_mutex);
return 0;
}
struct mtd_info *ret = NULL;
int i;
- mutex_lock(&mtd_table_mutex);
+ down(&mtd_table_mutex);
if (num == -1) {
for (i=0; i< MAX_MTD_DEVICES; i++)
if (ret)
ret->usecount++;
- mutex_unlock(&mtd_table_mutex);
+ up(&mtd_table_mutex);
return ret;
}
{
int c;
- mutex_lock(&mtd_table_mutex);
+ down(&mtd_table_mutex);
c = --mtd->usecount;
- mutex_unlock(&mtd_table_mutex);
+ up(&mtd_table_mutex);
BUG_ON(c < 0);
module_put(mtd->owner);
EXPORT_SYMBOL(default_mtd_writev);
EXPORT_SYMBOL(default_mtd_readv);
-#ifdef CONFIG_PROC_FS
-
/*====================================================================*/
/* Support for /proc/mtd */
+#ifdef CONFIG_PROC_FS
static struct proc_dir_entry *proc_mtd;
static inline int mtd_proc_info (char *buf, int i)
int len, l, i;
off_t begin = 0;
- mutex_lock(&mtd_table_mutex);
+ down(&mtd_table_mutex);
len = sprintf(page, "dev: size erasesize name\n");
for (i=0; i< MAX_MTD_DEVICES; i++) {
*eof = 1;
done:
- mutex_unlock(&mtd_table_mutex);
+ up(&mtd_table_mutex);
if (off >= len+begin)
return 0;
*start = page + (off-begin);
return ((count < begin+len-off) ? count : begin+len-off);
}
+#endif /* CONFIG_PROC_FS */
+
/*====================================================================*/
/* Init code */
static int __init init_mtd(void)
{
+#ifdef CONFIG_PROC_FS
if ((proc_mtd = create_proc_entry( "mtd", 0, NULL )))
proc_mtd->read_proc = mtd_read_proc;
+#endif
return 0;
}
static void __exit cleanup_mtd(void)
{
+#ifdef CONFIG_PROC_FS
if (proc_mtd)
remove_proc_entry( "mtd", NULL);
+#endif
}
module_init(init_mtd);
module_exit(cleanup_mtd);
-#endif /* CONFIG_PROC_FS */
-
MODULE_LICENSE("GPL");
MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");