aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdcore.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/mtdcore.c')
-rw-r--r--drivers/mtd/mtdcore.c50
1 files changed, 19 insertions, 31 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index a50348b60d79..d162426416de 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -24,6 +24,7 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/ptrace.h> 26#include <linux/ptrace.h>
27#include <linux/seq_file.h>
27#include <linux/string.h> 28#include <linux/string.h>
28#include <linux/timer.h> 29#include <linux/timer.h>
29#include <linux/major.h> 30#include <linux/major.h>
@@ -705,44 +706,32 @@ EXPORT_SYMBOL_GPL(mtd_kmalloc_up_to);
705 706
706static struct proc_dir_entry *proc_mtd; 707static struct proc_dir_entry *proc_mtd;
707 708
708static inline int mtd_proc_info(char *buf, struct mtd_info *this) 709static int mtd_proc_show(struct seq_file *m, void *v)
709{
710 return sprintf(buf, "mtd%d: %8.8llx %8.8x \"%s\"\n", this->index,
711 (unsigned long long)this->size,
712 this->erasesize, this->name);
713}
714
715static int mtd_read_proc (char *page, char **start, off_t off, int count,
716 int *eof, void *data_unused)
717{ 710{
718 struct mtd_info *mtd; 711 struct mtd_info *mtd;
719 int len, l;
720 off_t begin = 0;
721 712
713 seq_puts(m, "dev: size erasesize name\n");
722 mutex_lock(&mtd_table_mutex); 714 mutex_lock(&mtd_table_mutex);
723
724 len = sprintf(page, "dev: size erasesize name\n");
725 mtd_for_each_device(mtd) { 715 mtd_for_each_device(mtd) {
726 l = mtd_proc_info(page + len, mtd); 716 seq_printf(m, "mtd%d: %8.8llx %8.8x \"%s\"\n",
727 len += l; 717 mtd->index, (unsigned long long)mtd->size,
728 if (len+begin > off+count) 718 mtd->erasesize, mtd->name);
729 goto done;
730 if (len+begin < off) {
731 begin += len;
732 len = 0;
733 }
734 } 719 }
735
736 *eof = 1;
737
738done:
739 mutex_unlock(&mtd_table_mutex); 720 mutex_unlock(&mtd_table_mutex);
740 if (off >= len+begin) 721 return 0;
741 return 0;
742 *start = page + (off-begin);
743 return ((count < begin+len-off) ? count : begin+len-off);
744} 722}
745 723
724static int mtd_proc_open(struct inode *inode, struct file *file)
725{
726 return single_open(file, mtd_proc_show, NULL);
727}
728
729static const struct file_operations mtd_proc_ops = {
730 .open = mtd_proc_open,
731 .read = seq_read,
732 .llseek = seq_lseek,
733 .release = single_release,
734};
746#endif /* CONFIG_PROC_FS */ 735#endif /* CONFIG_PROC_FS */
747 736
748/*====================================================================*/ 737/*====================================================================*/
@@ -783,8 +772,7 @@ static int __init init_mtd(void)
783 goto err_bdi3; 772 goto err_bdi3;
784 773
785#ifdef CONFIG_PROC_FS 774#ifdef CONFIG_PROC_FS
786 if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) 775 proc_mtd = proc_create("mtd", 0, NULL, &mtd_proc_ops);
787 proc_mtd->read_proc = mtd_read_proc;
788#endif /* CONFIG_PROC_FS */ 776#endif /* CONFIG_PROC_FS */
789 return 0; 777 return 0;
790 778