Commit 3d37e1e6 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] jffs kdev_t cleanups

In the /proc/fs/jffs/* code we switch to passing number of mtd device
(as an integer) instead of messing with kdev_t (which would always be
mk_kdev(MTD_BLOCK_MAJOR, device_number) anyway).
parent b1cd8879
......@@ -73,14 +73,13 @@ kmem_cache_t *fm_cache = NULL;
/* Called by the VFS at mount time to initialize the whole file system. */
static int jffs_fill_super(struct super_block *sb, void *data, int silent)
{
kdev_t dev = to_kdev_t(sb->s_dev);
struct inode *root_inode;
struct jffs_control *c;
D1(printk(KERN_NOTICE "JFFS: Trying to mount device %s.\n",
sb->s_id));
if (major(dev) != MTD_BLOCK_MAJOR) {
if (MAJOR(sb->s_dev) != MTD_BLOCK_MAJOR) {
printk(KERN_WARNING "JFFS: Trying to mount a "
"non-mtd device.\n");
return -EINVAL;
......@@ -115,7 +114,7 @@ static int jffs_fill_super(struct super_block *sb, void *data, int silent)
#ifdef CONFIG_JFFS_PROC_FS
/* Set up the jffs proc file system. */
if (jffs_register_jffs_proc_dir(dev, c) < 0) {
if (jffs_register_jffs_proc_dir(MINOR(sb->s_dev), c) < 0) {
printk(KERN_WARNING "JFFS: Failed to initialize the JFFS "
"proc file system for device %s.\n",
sb->s_id);
......
......@@ -65,52 +65,39 @@ static int jffs_proc_layout_read (char *page, char **start, off_t off,
/*
* Register a JFFS partition directory (called upon mount)
*/
int jffs_register_jffs_proc_dir(kdev_t dev, struct jffs_control *c)
int jffs_register_jffs_proc_dir(int mtd, struct jffs_control *c)
{
struct jffs_partition_dir *part_dir;
struct proc_dir_entry *part_info = 0;
struct proc_dir_entry *part_layout = 0;
struct proc_dir_entry *part_root = 0;
char name[10];
sprintf(name, "%d", mtd);
/* Allocate structure for local JFFS partition table */
if (!(part_dir = (struct jffs_partition_dir *)
kmalloc (sizeof (struct jffs_partition_dir), GFP_KERNEL))) {
return -ENOMEM;
}
part_dir = (struct jffs_partition_dir *)
kmalloc(sizeof (struct jffs_partition_dir), GFP_KERNEL);
if (!part_dir)
goto out;
/* Create entry for this partition */
if ((part_root = create_proc_entry (kdevname(dev),
S_IFDIR | S_IRUGO | S_IXUGO, jffs_proc_root))) {
part_root->read_proc = jffs_proc_info_read;
part_root->data = (void *) c;
}
else {
kfree (part_dir);
return -ENOMEM;
}
part_root = proc_mkdir(name, jffs_proc_root);
if (!part_root)
goto out1;
/* Create entry for 'info' file */
if ((part_info = create_proc_entry ("info", 0, part_root))) {
part_info->read_proc = jffs_proc_info_read;
part_info->data = (void *) c;
}
else {
remove_proc_entry (part_root->name, jffs_proc_root);
kfree (part_dir);
return -ENOMEM;
}
part_info = create_proc_entry ("info", 0, part_root);
if (!part_info)
goto out2;
part_info->read_proc = jffs_proc_info_read;
part_info->data = (void *) c;
/* Create entry for 'layout' file */
if ((part_layout = create_proc_entry ("layout", 0, part_root))) {
part_layout->read_proc = jffs_proc_layout_read;
part_layout->data = (void *) c;
}
else {
remove_proc_entry (part_info->name, part_root);
remove_proc_entry (part_root->name, jffs_proc_root);
kfree (part_dir);
return -ENOMEM;
}
part_layout = create_proc_entry ("layout", 0, part_root);
if (!part_layout)
goto out3;
part_layout->read_proc = jffs_proc_layout_read;
part_layout->data = (void *) c;
/* Fill in structure for table and insert in the list */
part_dir->c = c;
......@@ -122,6 +109,15 @@ int jffs_register_jffs_proc_dir(kdev_t dev, struct jffs_control *c)
/* Return happy */
return 0;
out3:
remove_proc_entry("info", part_root);
out2:
remove_proc_entry(name, jffs_proc_root);
out1:
kfree(part_dir);
out:
return -ENOMEM;
}
......@@ -155,11 +151,7 @@ int jffs_unregister_jffs_proc_dir(struct jffs_control *c)
* if it is.
*/
if (jffs_part_dirs == part_dir->next)
#if LINUX_VERSION_CODE < 0x020300
remove_proc_entry ("jffs", &proc_root_fs);
#else
remove_proc_entry ("jffs", proc_root_fs);
#endif
/* Free memory for entry */
kfree(part_dir);
......
......@@ -22,7 +22,7 @@
/* The proc_dir_entry for jffs (defined in jffs_proc.c). */
extern struct proc_dir_entry *jffs_proc_root;
int jffs_register_jffs_proc_dir(kdev_t dev, struct jffs_control *c);
int jffs_register_jffs_proc_dir(int mtd, struct jffs_control *c);
int jffs_unregister_jffs_proc_dir(struct jffs_control *c);
#endif /* __LINUX_JFFS_PROC_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment