aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdsuper.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/mtdsuper.c')
-rw-r--r--drivers/mtd/mtdsuper.c54
1 files changed, 22 insertions, 32 deletions
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c
index 38e2ab07e7a3..16b02a1fc100 100644
--- a/drivers/mtd/mtdsuper.c
+++ b/drivers/mtd/mtdsuper.c
@@ -54,11 +54,10 @@ static int get_sb_mtd_set(struct super_block *sb, void *_mtd)
54/* 54/*
55 * get a superblock on an MTD-backed filesystem 55 * get a superblock on an MTD-backed filesystem
56 */ 56 */
57static int get_sb_mtd_aux(struct file_system_type *fs_type, int flags, 57static struct dentry *mount_mtd_aux(struct file_system_type *fs_type, int flags,
58 const char *dev_name, void *data, 58 const char *dev_name, void *data,
59 struct mtd_info *mtd, 59 struct mtd_info *mtd,
60 int (*fill_super)(struct super_block *, void *, int), 60 int (*fill_super)(struct super_block *, void *, int))
61 struct vfsmount *mnt)
62{ 61{
63 struct super_block *sb; 62 struct super_block *sb;
64 int ret; 63 int ret;
@@ -79,57 +78,49 @@ static int get_sb_mtd_aux(struct file_system_type *fs_type, int flags,
79 ret = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); 78 ret = fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
80 if (ret < 0) { 79 if (ret < 0) {
81 deactivate_locked_super(sb); 80 deactivate_locked_super(sb);
82 return ret; 81 return ERR_PTR(ret);
83 } 82 }
84 83
85 /* go */ 84 /* go */
86 sb->s_flags |= MS_ACTIVE; 85 sb->s_flags |= MS_ACTIVE;
87 simple_set_mnt(mnt, sb); 86 return dget(sb->s_root);
88
89 return 0;
90 87
91 /* new mountpoint for an already mounted superblock */ 88 /* new mountpoint for an already mounted superblock */
92already_mounted: 89already_mounted:
93 DEBUG(1, "MTDSB: Device %d (\"%s\") is already mounted\n", 90 DEBUG(1, "MTDSB: Device %d (\"%s\") is already mounted\n",
94 mtd->index, mtd->name); 91 mtd->index, mtd->name);
95 simple_set_mnt(mnt, sb); 92 put_mtd_device(mtd);
96 ret = 0; 93 return dget(sb->s_root);
97 goto out_put;
98 94
99out_error: 95out_error:
100 ret = PTR_ERR(sb);
101out_put:
102 put_mtd_device(mtd); 96 put_mtd_device(mtd);
103 return ret; 97 return ERR_CAST(sb);
104} 98}
105 99
106/* 100/*
107 * get a superblock on an MTD-backed filesystem by MTD device number 101 * get a superblock on an MTD-backed filesystem by MTD device number
108 */ 102 */
109static int get_sb_mtd_nr(struct file_system_type *fs_type, int flags, 103static struct dentry *mount_mtd_nr(struct file_system_type *fs_type, int flags,
110 const char *dev_name, void *data, int mtdnr, 104 const char *dev_name, void *data, int mtdnr,
111 int (*fill_super)(struct super_block *, void *, int), 105 int (*fill_super)(struct super_block *, void *, int))
112 struct vfsmount *mnt)
113{ 106{
114 struct mtd_info *mtd; 107 struct mtd_info *mtd;
115 108
116 mtd = get_mtd_device(NULL, mtdnr); 109 mtd = get_mtd_device(NULL, mtdnr);
117 if (IS_ERR(mtd)) { 110 if (IS_ERR(mtd)) {
118 DEBUG(0, "MTDSB: Device #%u doesn't appear to exist\n", mtdnr); 111 DEBUG(0, "MTDSB: Device #%u doesn't appear to exist\n", mtdnr);
119 return PTR_ERR(mtd); 112 return ERR_CAST(mtd);
120 } 113 }
121 114
122 return get_sb_mtd_aux(fs_type, flags, dev_name, data, mtd, fill_super, 115 return mount_mtd_aux(fs_type, flags, dev_name, data, mtd, fill_super);
123 mnt);
124} 116}
125 117
126/* 118/*
127 * set up an MTD-based superblock 119 * set up an MTD-based superblock
128 */ 120 */
129int get_sb_mtd(struct file_system_type *fs_type, int flags, 121struct dentry *mount_mtd(struct file_system_type *fs_type, int flags,
130 const char *dev_name, void *data, 122 const char *dev_name, void *data,
131 int (*fill_super)(struct super_block *, void *, int), 123 int (*fill_super)(struct super_block *, void *, int))
132 struct vfsmount *mnt)
133{ 124{
134#ifdef CONFIG_BLOCK 125#ifdef CONFIG_BLOCK
135 struct block_device *bdev; 126 struct block_device *bdev;
@@ -138,7 +129,7 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
138 int mtdnr; 129 int mtdnr;
139 130
140 if (!dev_name) 131 if (!dev_name)
141 return -EINVAL; 132 return ERR_PTR(-EINVAL);
142 133
143 DEBUG(2, "MTDSB: dev_name \"%s\"\n", dev_name); 134 DEBUG(2, "MTDSB: dev_name \"%s\"\n", dev_name);
144 135
@@ -156,10 +147,10 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
156 147
157 mtd = get_mtd_device_nm(dev_name + 4); 148 mtd = get_mtd_device_nm(dev_name + 4);
158 if (!IS_ERR(mtd)) 149 if (!IS_ERR(mtd))
159 return get_sb_mtd_aux( 150 return mount_mtd_aux(
160 fs_type, flags, 151 fs_type, flags,
161 dev_name, data, mtd, 152 dev_name, data, mtd,
162 fill_super, mnt); 153 fill_super);
163 154
164 printk(KERN_NOTICE "MTD:" 155 printk(KERN_NOTICE "MTD:"
165 " MTD device with name \"%s\" not found.\n", 156 " MTD device with name \"%s\" not found.\n",
@@ -174,9 +165,9 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
174 /* It was a valid number */ 165 /* It was a valid number */
175 DEBUG(1, "MTDSB: mtd%%d, mtdnr %d\n", 166 DEBUG(1, "MTDSB: mtd%%d, mtdnr %d\n",
176 mtdnr); 167 mtdnr);
177 return get_sb_mtd_nr(fs_type, flags, 168 return mount_mtd_nr(fs_type, flags,
178 dev_name, data, 169 dev_name, data,
179 mtdnr, fill_super, mnt); 170 mtdnr, fill_super);
180 } 171 }
181 } 172 }
182 } 173 }
@@ -189,7 +180,7 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
189 if (IS_ERR(bdev)) { 180 if (IS_ERR(bdev)) {
190 ret = PTR_ERR(bdev); 181 ret = PTR_ERR(bdev);
191 DEBUG(1, "MTDSB: lookup_bdev() returned %d\n", ret); 182 DEBUG(1, "MTDSB: lookup_bdev() returned %d\n", ret);
192 return ret; 183 return ERR_PTR(ret);
193 } 184 }
194 DEBUG(1, "MTDSB: lookup_bdev() returned 0\n"); 185 DEBUG(1, "MTDSB: lookup_bdev() returned 0\n");
195 186
@@ -202,8 +193,7 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
202 if (major != MTD_BLOCK_MAJOR) 193 if (major != MTD_BLOCK_MAJOR)
203 goto not_an_MTD_device; 194 goto not_an_MTD_device;
204 195
205 return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super, 196 return mount_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super);
206 mnt);
207 197
208not_an_MTD_device: 198not_an_MTD_device:
209#endif /* CONFIG_BLOCK */ 199#endif /* CONFIG_BLOCK */
@@ -212,10 +202,10 @@ not_an_MTD_device:
212 printk(KERN_NOTICE 202 printk(KERN_NOTICE
213 "MTD: Attempt to mount non-MTD device \"%s\"\n", 203 "MTD: Attempt to mount non-MTD device \"%s\"\n",
214 dev_name); 204 dev_name);
215 return -EINVAL; 205 return ERR_PTR(-EINVAL);
216} 206}
217 207
218EXPORT_SYMBOL_GPL(get_sb_mtd); 208EXPORT_SYMBOL_GPL(mount_mtd);
219 209
220/* 210/*
221 * destroy an MTD-based superblock 211 * destroy an MTD-based superblock