Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
a1452a37 DW |
2 | * Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org> |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, write to the Free Software | |
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
1da177e4 LT |
17 | * |
18 | */ | |
19 | ||
15fdc52f TG |
20 | #include <linux/device.h> |
21 | #include <linux/fs.h> | |
0c1eafdb | 22 | #include <linux/mm.h> |
9c74034f | 23 | #include <linux/err.h> |
15fdc52f | 24 | #include <linux/init.h> |
1da177e4 LT |
25 | #include <linux/kernel.h> |
26 | #include <linux/module.h> | |
15fdc52f TG |
27 | #include <linux/slab.h> |
28 | #include <linux/sched.h> | |
6071239e | 29 | #include <linux/smp_lock.h> |
402d3265 | 30 | #include <linux/backing-dev.h> |
97718540 | 31 | #include <linux/compat.h> |
cd874237 | 32 | #include <linux/mount.h> |
15fdc52f | 33 | |
1da177e4 | 34 | #include <linux/mtd/mtd.h> |
dd02b67d | 35 | #include <linux/mtd/map.h> |
1da177e4 | 36 | |
15fdc52f | 37 | #include <asm/uaccess.h> |
9bc7b387 | 38 | |
cd874237 KS |
39 | #define MTD_INODE_FS_MAGIC 0x11307854 |
40 | static struct vfsmount *mtd_inode_mnt __read_mostly; | |
1da177e4 | 41 | |
045e9a5d | 42 | /* |
f1a28c02 TG |
43 | * Data structure to hold the pointer to the mtd device as well |
44 | * as mode information ofr various use cases. | |
045e9a5d | 45 | */ |
f1a28c02 TG |
46 | struct mtd_file_info { |
47 | struct mtd_info *mtd; | |
cd874237 | 48 | struct inode *ino; |
f1a28c02 TG |
49 | enum mtd_file_modes mode; |
50 | }; | |
31f4233b | 51 | |
1da177e4 LT |
52 | static loff_t mtd_lseek (struct file *file, loff_t offset, int orig) |
53 | { | |
f1a28c02 TG |
54 | struct mtd_file_info *mfi = file->private_data; |
55 | struct mtd_info *mtd = mfi->mtd; | |
1da177e4 LT |
56 | |
57 | switch (orig) { | |
ea59830d | 58 | case SEEK_SET: |
1da177e4 | 59 | break; |
ea59830d | 60 | case SEEK_CUR: |
8b491d75 | 61 | offset += file->f_pos; |
1da177e4 | 62 | break; |
ea59830d | 63 | case SEEK_END: |
8b491d75 | 64 | offset += mtd->size; |
1da177e4 LT |
65 | break; |
66 | default: | |
67 | return -EINVAL; | |
68 | } | |
69 | ||
1887f517 | 70 | if (offset >= 0 && offset <= mtd->size) |
8b491d75 | 71 | return file->f_pos = offset; |
1da177e4 | 72 | |
8b491d75 | 73 | return -EINVAL; |
1da177e4 LT |
74 | } |
75 | ||
76 | ||
77 | ||
78 | static int mtd_open(struct inode *inode, struct file *file) | |
79 | { | |
80 | int minor = iminor(inode); | |
81 | int devnum = minor >> 1; | |
6071239e | 82 | int ret = 0; |
1da177e4 | 83 | struct mtd_info *mtd; |
f1a28c02 | 84 | struct mtd_file_info *mfi; |
cd874237 | 85 | struct inode *mtd_ino; |
1da177e4 LT |
86 | |
87 | DEBUG(MTD_DEBUG_LEVEL0, "MTD_open\n"); | |
88 | ||
1da177e4 | 89 | /* You can't open the RO devices RW */ |
aeb5d727 | 90 | if ((file->f_mode & FMODE_WRITE) && (minor & 1)) |
1da177e4 LT |
91 | return -EACCES; |
92 | ||
6071239e | 93 | lock_kernel(); |
1da177e4 | 94 | mtd = get_mtd_device(NULL, devnum); |
97894cda | 95 | |
6071239e JC |
96 | if (IS_ERR(mtd)) { |
97 | ret = PTR_ERR(mtd); | |
98 | goto out; | |
99 | } | |
97894cda | 100 | |
402d3265 | 101 | if (mtd->type == MTD_ABSENT) { |
1da177e4 | 102 | put_mtd_device(mtd); |
6071239e JC |
103 | ret = -ENODEV; |
104 | goto out; | |
1da177e4 LT |
105 | } |
106 | ||
cd874237 KS |
107 | mtd_ino = iget_locked(mtd_inode_mnt->mnt_sb, devnum); |
108 | if (!mtd_ino) { | |
109 | put_mtd_device(mtd); | |
110 | ret = -ENOMEM; | |
111 | goto out; | |
112 | } | |
113 | if (mtd_ino->i_state & I_NEW) { | |
114 | mtd_ino->i_private = mtd; | |
115 | mtd_ino->i_mode = S_IFCHR; | |
116 | mtd_ino->i_data.backing_dev_info = mtd->backing_dev_info; | |
117 | unlock_new_inode(mtd_ino); | |
118 | } | |
119 | file->f_mapping = mtd_ino->i_mapping; | |
402d3265 | 120 | |
1da177e4 | 121 | /* You can't open it RW if it's not a writeable device */ |
aeb5d727 | 122 | if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) { |
cd874237 | 123 | iput(mtd_ino); |
1da177e4 | 124 | put_mtd_device(mtd); |
6071239e JC |
125 | ret = -EACCES; |
126 | goto out; | |
1da177e4 | 127 | } |
97894cda | 128 | |
f1a28c02 TG |
129 | mfi = kzalloc(sizeof(*mfi), GFP_KERNEL); |
130 | if (!mfi) { | |
cd874237 | 131 | iput(mtd_ino); |
f1a28c02 | 132 | put_mtd_device(mtd); |
6071239e JC |
133 | ret = -ENOMEM; |
134 | goto out; | |
f1a28c02 | 135 | } |
cd874237 | 136 | mfi->ino = mtd_ino; |
f1a28c02 TG |
137 | mfi->mtd = mtd; |
138 | file->private_data = mfi; | |
139 | ||
6071239e JC |
140 | out: |
141 | unlock_kernel(); | |
142 | return ret; | |
1da177e4 LT |
143 | } /* mtd_open */ |
144 | ||
145 | /*====================================================================*/ | |
146 | ||
147 | static int mtd_close(struct inode *inode, struct file *file) | |
148 | { | |
f1a28c02 TG |
149 | struct mtd_file_info *mfi = file->private_data; |
150 | struct mtd_info *mtd = mfi->mtd; | |
1da177e4 LT |
151 | |
152 | DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n"); | |
153 | ||
7eafaed5 | 154 | /* Only sync if opened RW */ |
aeb5d727 | 155 | if ((file->f_mode & FMODE_WRITE) && mtd->sync) |
1da177e4 | 156 | mtd->sync(mtd); |
97894cda | 157 | |
cd874237 KS |
158 | iput(mfi->ino); |
159 | ||
1da177e4 | 160 | put_mtd_device(mtd); |
f1a28c02 TG |
161 | file->private_data = NULL; |
162 | kfree(mfi); | |
1da177e4 LT |
163 | |
164 | return 0; | |
165 | } /* mtd_close */ | |
166 | ||
167 | /* FIXME: This _really_ needs to die. In 2.5, we should lock the | |
168 | userspace buffer down and use it directly with readv/writev. | |
169 | */ | |
170 | #define MAX_KMALLOC_SIZE 0x20000 | |
171 | ||
172 | static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t *ppos) | |
173 | { | |
f1a28c02 TG |
174 | struct mtd_file_info *mfi = file->private_data; |
175 | struct mtd_info *mtd = mfi->mtd; | |
1da177e4 LT |
176 | size_t retlen=0; |
177 | size_t total_retlen=0; | |
178 | int ret=0; | |
179 | int len; | |
180 | char *kbuf; | |
97894cda | 181 | |
1da177e4 LT |
182 | DEBUG(MTD_DEBUG_LEVEL0,"MTD_read\n"); |
183 | ||
184 | if (*ppos + count > mtd->size) | |
185 | count = mtd->size - *ppos; | |
186 | ||
187 | if (!count) | |
188 | return 0; | |
97894cda | 189 | |
1da177e4 LT |
190 | /* FIXME: Use kiovec in 2.5 to lock down the user's buffers |
191 | and pass them directly to the MTD functions */ | |
b802c074 TG |
192 | |
193 | if (count > MAX_KMALLOC_SIZE) | |
194 | kbuf=kmalloc(MAX_KMALLOC_SIZE, GFP_KERNEL); | |
195 | else | |
196 | kbuf=kmalloc(count, GFP_KERNEL); | |
197 | ||
198 | if (!kbuf) | |
199 | return -ENOMEM; | |
200 | ||
1da177e4 | 201 | while (count) { |
b802c074 | 202 | |
97894cda | 203 | if (count > MAX_KMALLOC_SIZE) |
1da177e4 LT |
204 | len = MAX_KMALLOC_SIZE; |
205 | else | |
206 | len = count; | |
207 | ||
f1a28c02 TG |
208 | switch (mfi->mode) { |
209 | case MTD_MODE_OTP_FACTORY: | |
31f4233b NP |
210 | ret = mtd->read_fact_prot_reg(mtd, *ppos, len, &retlen, kbuf); |
211 | break; | |
212 | case MTD_MODE_OTP_USER: | |
213 | ret = mtd->read_user_prot_reg(mtd, *ppos, len, &retlen, kbuf); | |
214 | break; | |
f1a28c02 TG |
215 | case MTD_MODE_RAW: |
216 | { | |
217 | struct mtd_oob_ops ops; | |
218 | ||
219 | ops.mode = MTD_OOB_RAW; | |
220 | ops.datbuf = kbuf; | |
221 | ops.oobbuf = NULL; | |
222 | ops.len = len; | |
223 | ||
224 | ret = mtd->read_oob(mtd, *ppos, &ops); | |
225 | retlen = ops.retlen; | |
226 | break; | |
227 | } | |
31f4233b | 228 | default: |
f4a43cfc | 229 | ret = mtd->read(mtd, *ppos, len, &retlen, kbuf); |
31f4233b | 230 | } |
1da177e4 LT |
231 | /* Nand returns -EBADMSG on ecc errors, but it returns |
232 | * the data. For our userspace tools it is important | |
97894cda | 233 | * to dump areas with ecc errors ! |
9a1fcdfd TG |
234 | * For kernel internal usage it also might return -EUCLEAN |
235 | * to signal the caller that a bitflip has occured and has | |
236 | * been corrected by the ECC algorithm. | |
1da177e4 LT |
237 | * Userspace software which accesses NAND this way |
238 | * must be aware of the fact that it deals with NAND | |
239 | */ | |
9a1fcdfd | 240 | if (!ret || (ret == -EUCLEAN) || (ret == -EBADMSG)) { |
1da177e4 LT |
241 | *ppos += retlen; |
242 | if (copy_to_user(buf, kbuf, retlen)) { | |
f4a43cfc | 243 | kfree(kbuf); |
1da177e4 LT |
244 | return -EFAULT; |
245 | } | |
246 | else | |
247 | total_retlen += retlen; | |
248 | ||
249 | count -= retlen; | |
250 | buf += retlen; | |
31f4233b NP |
251 | if (retlen == 0) |
252 | count = 0; | |
1da177e4 LT |
253 | } |
254 | else { | |
255 | kfree(kbuf); | |
256 | return ret; | |
257 | } | |
97894cda | 258 | |
1da177e4 LT |
259 | } |
260 | ||
b802c074 | 261 | kfree(kbuf); |
1da177e4 LT |
262 | return total_retlen; |
263 | } /* mtd_read */ | |
264 | ||
265 | static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count,loff_t *ppos) | |
266 | { | |
f1a28c02 TG |
267 | struct mtd_file_info *mfi = file->private_data; |
268 | struct mtd_info *mtd = mfi->mtd; | |
1da177e4 LT |
269 | char *kbuf; |
270 | size_t retlen; | |
271 | size_t total_retlen=0; | |
272 | int ret=0; | |
273 | int len; | |
274 | ||
275 | DEBUG(MTD_DEBUG_LEVEL0,"MTD_write\n"); | |
97894cda | 276 | |
1da177e4 LT |
277 | if (*ppos == mtd->size) |
278 | return -ENOSPC; | |
97894cda | 279 | |
1da177e4 LT |
280 | if (*ppos + count > mtd->size) |
281 | count = mtd->size - *ppos; | |
282 | ||
283 | if (!count) | |
284 | return 0; | |
285 | ||
b802c074 TG |
286 | if (count > MAX_KMALLOC_SIZE) |
287 | kbuf=kmalloc(MAX_KMALLOC_SIZE, GFP_KERNEL); | |
288 | else | |
289 | kbuf=kmalloc(count, GFP_KERNEL); | |
290 | ||
291 | if (!kbuf) | |
292 | return -ENOMEM; | |
293 | ||
1da177e4 | 294 | while (count) { |
b802c074 | 295 | |
97894cda | 296 | if (count > MAX_KMALLOC_SIZE) |
1da177e4 LT |
297 | len = MAX_KMALLOC_SIZE; |
298 | else | |
299 | len = count; | |
300 | ||
1da177e4 LT |
301 | if (copy_from_user(kbuf, buf, len)) { |
302 | kfree(kbuf); | |
303 | return -EFAULT; | |
304 | } | |
97894cda | 305 | |
f1a28c02 TG |
306 | switch (mfi->mode) { |
307 | case MTD_MODE_OTP_FACTORY: | |
31f4233b NP |
308 | ret = -EROFS; |
309 | break; | |
310 | case MTD_MODE_OTP_USER: | |
311 | if (!mtd->write_user_prot_reg) { | |
312 | ret = -EOPNOTSUPP; | |
313 | break; | |
314 | } | |
315 | ret = mtd->write_user_prot_reg(mtd, *ppos, len, &retlen, kbuf); | |
316 | break; | |
f1a28c02 TG |
317 | |
318 | case MTD_MODE_RAW: | |
319 | { | |
320 | struct mtd_oob_ops ops; | |
321 | ||
322 | ops.mode = MTD_OOB_RAW; | |
323 | ops.datbuf = kbuf; | |
324 | ops.oobbuf = NULL; | |
325 | ops.len = len; | |
326 | ||
327 | ret = mtd->write_oob(mtd, *ppos, &ops); | |
328 | retlen = ops.retlen; | |
329 | break; | |
330 | } | |
331 | ||
31f4233b NP |
332 | default: |
333 | ret = (*(mtd->write))(mtd, *ppos, len, &retlen, kbuf); | |
334 | } | |
1da177e4 LT |
335 | if (!ret) { |
336 | *ppos += retlen; | |
337 | total_retlen += retlen; | |
338 | count -= retlen; | |
339 | buf += retlen; | |
340 | } | |
341 | else { | |
342 | kfree(kbuf); | |
343 | return ret; | |
344 | } | |
1da177e4 LT |
345 | } |
346 | ||
b802c074 | 347 | kfree(kbuf); |
1da177e4 LT |
348 | return total_retlen; |
349 | } /* mtd_write */ | |
350 | ||
351 | /*====================================================================== | |
352 | ||
353 | IOCTL calls for getting device parameters. | |
354 | ||
355 | ======================================================================*/ | |
356 | static void mtdchar_erase_callback (struct erase_info *instr) | |
357 | { | |
358 | wake_up((wait_queue_head_t *)instr->priv); | |
359 | } | |
360 | ||
34a82443 | 361 | #ifdef CONFIG_HAVE_MTD_OTP |
f1a28c02 TG |
362 | static int otp_select_filemode(struct mtd_file_info *mfi, int mode) |
363 | { | |
364 | struct mtd_info *mtd = mfi->mtd; | |
365 | int ret = 0; | |
366 | ||
367 | switch (mode) { | |
368 | case MTD_OTP_FACTORY: | |
369 | if (!mtd->read_fact_prot_reg) | |
370 | ret = -EOPNOTSUPP; | |
371 | else | |
372 | mfi->mode = MTD_MODE_OTP_FACTORY; | |
373 | break; | |
374 | case MTD_OTP_USER: | |
375 | if (!mtd->read_fact_prot_reg) | |
376 | ret = -EOPNOTSUPP; | |
377 | else | |
378 | mfi->mode = MTD_MODE_OTP_USER; | |
379 | break; | |
380 | default: | |
381 | ret = -EINVAL; | |
382 | case MTD_OTP_OFF: | |
383 | break; | |
384 | } | |
385 | return ret; | |
386 | } | |
387 | #else | |
388 | # define otp_select_filemode(f,m) -EOPNOTSUPP | |
389 | #endif | |
390 | ||
97718540 KC |
391 | static int mtd_do_writeoob(struct file *file, struct mtd_info *mtd, |
392 | uint64_t start, uint32_t length, void __user *ptr, | |
393 | uint32_t __user *retp) | |
394 | { | |
395 | struct mtd_oob_ops ops; | |
396 | uint32_t retlen; | |
397 | int ret = 0; | |
398 | ||
399 | if (!(file->f_mode & FMODE_WRITE)) | |
400 | return -EPERM; | |
401 | ||
402 | if (length > 4096) | |
403 | return -EINVAL; | |
404 | ||
405 | if (!mtd->write_oob) | |
406 | ret = -EOPNOTSUPP; | |
407 | else | |
0040476b | 408 | ret = access_ok(VERIFY_READ, ptr, length) ? 0 : -EFAULT; |
97718540 KC |
409 | |
410 | if (ret) | |
411 | return ret; | |
412 | ||
413 | ops.ooblen = length; | |
414 | ops.ooboffs = start & (mtd->oobsize - 1); | |
415 | ops.datbuf = NULL; | |
416 | ops.mode = MTD_OOB_PLACE; | |
417 | ||
418 | if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) | |
419 | return -EINVAL; | |
420 | ||
df1f1d1c JL |
421 | ops.oobbuf = memdup_user(ptr, length); |
422 | if (IS_ERR(ops.oobbuf)) | |
423 | return PTR_ERR(ops.oobbuf); | |
97718540 KC |
424 | |
425 | start &= ~((uint64_t)mtd->oobsize - 1); | |
426 | ret = mtd->write_oob(mtd, start, &ops); | |
427 | ||
428 | if (ops.oobretlen > 0xFFFFFFFFU) | |
429 | ret = -EOVERFLOW; | |
430 | retlen = ops.oobretlen; | |
431 | if (copy_to_user(retp, &retlen, sizeof(length))) | |
432 | ret = -EFAULT; | |
433 | ||
434 | kfree(ops.oobbuf); | |
435 | return ret; | |
436 | } | |
437 | ||
438 | static int mtd_do_readoob(struct mtd_info *mtd, uint64_t start, | |
439 | uint32_t length, void __user *ptr, uint32_t __user *retp) | |
440 | { | |
441 | struct mtd_oob_ops ops; | |
442 | int ret = 0; | |
443 | ||
444 | if (length > 4096) | |
445 | return -EINVAL; | |
446 | ||
447 | if (!mtd->read_oob) | |
448 | ret = -EOPNOTSUPP; | |
449 | else | |
450 | ret = access_ok(VERIFY_WRITE, ptr, | |
451 | length) ? 0 : -EFAULT; | |
452 | if (ret) | |
453 | return ret; | |
454 | ||
455 | ops.ooblen = length; | |
456 | ops.ooboffs = start & (mtd->oobsize - 1); | |
457 | ops.datbuf = NULL; | |
458 | ops.mode = MTD_OOB_PLACE; | |
459 | ||
460 | if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) | |
461 | return -EINVAL; | |
462 | ||
463 | ops.oobbuf = kmalloc(length, GFP_KERNEL); | |
464 | if (!ops.oobbuf) | |
465 | return -ENOMEM; | |
466 | ||
467 | start &= ~((uint64_t)mtd->oobsize - 1); | |
468 | ret = mtd->read_oob(mtd, start, &ops); | |
469 | ||
470 | if (put_user(ops.oobretlen, retp)) | |
471 | ret = -EFAULT; | |
472 | else if (ops.oobretlen && copy_to_user(ptr, ops.oobbuf, | |
473 | ops.oobretlen)) | |
474 | ret = -EFAULT; | |
475 | ||
476 | kfree(ops.oobbuf); | |
477 | return ret; | |
478 | } | |
479 | ||
55929332 | 480 | static int mtd_ioctl(struct file *file, u_int cmd, u_long arg) |
1da177e4 | 481 | { |
f1a28c02 TG |
482 | struct mtd_file_info *mfi = file->private_data; |
483 | struct mtd_info *mtd = mfi->mtd; | |
1da177e4 LT |
484 | void __user *argp = (void __user *)arg; |
485 | int ret = 0; | |
486 | u_long size; | |
73c619ea | 487 | struct mtd_info_user info; |
97894cda | 488 | |
1da177e4 LT |
489 | DEBUG(MTD_DEBUG_LEVEL0, "MTD_ioctl\n"); |
490 | ||
491 | size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT; | |
492 | if (cmd & IOC_IN) { | |
493 | if (!access_ok(VERIFY_READ, argp, size)) | |
494 | return -EFAULT; | |
495 | } | |
496 | if (cmd & IOC_OUT) { | |
497 | if (!access_ok(VERIFY_WRITE, argp, size)) | |
498 | return -EFAULT; | |
499 | } | |
97894cda | 500 | |
1da177e4 LT |
501 | switch (cmd) { |
502 | case MEMGETREGIONCOUNT: | |
503 | if (copy_to_user(argp, &(mtd->numeraseregions), sizeof(int))) | |
504 | return -EFAULT; | |
505 | break; | |
506 | ||
507 | case MEMGETREGIONINFO: | |
508 | { | |
b67c5f87 ZW |
509 | uint32_t ur_idx; |
510 | struct mtd_erase_region_info *kr; | |
bcc98a46 | 511 | struct region_info_user __user *ur = argp; |
1da177e4 | 512 | |
b67c5f87 | 513 | if (get_user(ur_idx, &(ur->regionindex))) |
1da177e4 LT |
514 | return -EFAULT; |
515 | ||
b67c5f87 ZW |
516 | kr = &(mtd->eraseregions[ur_idx]); |
517 | ||
518 | if (put_user(kr->offset, &(ur->offset)) | |
519 | || put_user(kr->erasesize, &(ur->erasesize)) | |
520 | || put_user(kr->numblocks, &(ur->numblocks))) | |
1da177e4 | 521 | return -EFAULT; |
b67c5f87 | 522 | |
1da177e4 LT |
523 | break; |
524 | } | |
525 | ||
526 | case MEMGETINFO: | |
73c619ea JE |
527 | info.type = mtd->type; |
528 | info.flags = mtd->flags; | |
529 | info.size = mtd->size; | |
530 | info.erasesize = mtd->erasesize; | |
531 | info.writesize = mtd->writesize; | |
532 | info.oobsize = mtd->oobsize; | |
64f60710 AB |
533 | /* The below fields are obsolete */ |
534 | info.ecctype = -1; | |
535 | info.eccsize = 0; | |
73c619ea | 536 | if (copy_to_user(argp, &info, sizeof(struct mtd_info_user))) |
1da177e4 LT |
537 | return -EFAULT; |
538 | break; | |
539 | ||
540 | case MEMERASE: | |
0dc54e9f | 541 | case MEMERASE64: |
1da177e4 LT |
542 | { |
543 | struct erase_info *erase; | |
544 | ||
aeb5d727 | 545 | if(!(file->f_mode & FMODE_WRITE)) |
1da177e4 LT |
546 | return -EPERM; |
547 | ||
95b93a0c | 548 | erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL); |
1da177e4 LT |
549 | if (!erase) |
550 | ret = -ENOMEM; | |
551 | else { | |
552 | wait_queue_head_t waitq; | |
553 | DECLARE_WAITQUEUE(wait, current); | |
554 | ||
555 | init_waitqueue_head(&waitq); | |
556 | ||
0dc54e9f KC |
557 | if (cmd == MEMERASE64) { |
558 | struct erase_info_user64 einfo64; | |
559 | ||
560 | if (copy_from_user(&einfo64, argp, | |
561 | sizeof(struct erase_info_user64))) { | |
562 | kfree(erase); | |
563 | return -EFAULT; | |
564 | } | |
565 | erase->addr = einfo64.start; | |
566 | erase->len = einfo64.length; | |
567 | } else { | |
568 | struct erase_info_user einfo32; | |
569 | ||
570 | if (copy_from_user(&einfo32, argp, | |
571 | sizeof(struct erase_info_user))) { | |
572 | kfree(erase); | |
573 | return -EFAULT; | |
574 | } | |
575 | erase->addr = einfo32.start; | |
576 | erase->len = einfo32.length; | |
1da177e4 LT |
577 | } |
578 | erase->mtd = mtd; | |
579 | erase->callback = mtdchar_erase_callback; | |
580 | erase->priv = (unsigned long)&waitq; | |
97894cda | 581 | |
1da177e4 LT |
582 | /* |
583 | FIXME: Allow INTERRUPTIBLE. Which means | |
584 | not having the wait_queue head on the stack. | |
97894cda | 585 | |
1da177e4 LT |
586 | If the wq_head is on the stack, and we |
587 | leave because we got interrupted, then the | |
588 | wq_head is no longer there when the | |
589 | callback routine tries to wake us up. | |
590 | */ | |
591 | ret = mtd->erase(mtd, erase); | |
592 | if (!ret) { | |
593 | set_current_state(TASK_UNINTERRUPTIBLE); | |
594 | add_wait_queue(&waitq, &wait); | |
595 | if (erase->state != MTD_ERASE_DONE && | |
596 | erase->state != MTD_ERASE_FAILED) | |
597 | schedule(); | |
598 | remove_wait_queue(&waitq, &wait); | |
599 | set_current_state(TASK_RUNNING); | |
600 | ||
601 | ret = (erase->state == MTD_ERASE_FAILED)?-EIO:0; | |
602 | } | |
603 | kfree(erase); | |
604 | } | |
605 | break; | |
606 | } | |
607 | ||
608 | case MEMWRITEOOB: | |
609 | { | |
610 | struct mtd_oob_buf buf; | |
97718540 | 611 | struct mtd_oob_buf __user *buf_user = argp; |
1da177e4 | 612 | |
97718540 KC |
613 | /* NOTE: writes return length to buf_user->length */ |
614 | if (copy_from_user(&buf, argp, sizeof(buf))) | |
1da177e4 | 615 | ret = -EFAULT; |
97718540 KC |
616 | else |
617 | ret = mtd_do_writeoob(file, mtd, buf.start, buf.length, | |
618 | buf.ptr, &buf_user->length); | |
1da177e4 | 619 | break; |
1da177e4 LT |
620 | } |
621 | ||
622 | case MEMREADOOB: | |
623 | { | |
624 | struct mtd_oob_buf buf; | |
97718540 | 625 | struct mtd_oob_buf __user *buf_user = argp; |
8593fbc6 | 626 | |
97718540 KC |
627 | /* NOTE: writes return length to buf_user->start */ |
628 | if (copy_from_user(&buf, argp, sizeof(buf))) | |
1da177e4 | 629 | ret = -EFAULT; |
97718540 KC |
630 | else |
631 | ret = mtd_do_readoob(mtd, buf.start, buf.length, | |
632 | buf.ptr, &buf_user->start); | |
1da177e4 LT |
633 | break; |
634 | } | |
635 | ||
aea7cea9 KC |
636 | case MEMWRITEOOB64: |
637 | { | |
638 | struct mtd_oob_buf64 buf; | |
639 | struct mtd_oob_buf64 __user *buf_user = argp; | |
640 | ||
641 | if (copy_from_user(&buf, argp, sizeof(buf))) | |
642 | ret = -EFAULT; | |
643 | else | |
644 | ret = mtd_do_writeoob(file, mtd, buf.start, buf.length, | |
645 | (void __user *)(uintptr_t)buf.usr_ptr, | |
646 | &buf_user->length); | |
647 | break; | |
648 | } | |
649 | ||
650 | case MEMREADOOB64: | |
651 | { | |
652 | struct mtd_oob_buf64 buf; | |
653 | struct mtd_oob_buf64 __user *buf_user = argp; | |
654 | ||
655 | if (copy_from_user(&buf, argp, sizeof(buf))) | |
656 | ret = -EFAULT; | |
657 | else | |
658 | ret = mtd_do_readoob(mtd, buf.start, buf.length, | |
659 | (void __user *)(uintptr_t)buf.usr_ptr, | |
660 | &buf_user->length); | |
661 | break; | |
662 | } | |
663 | ||
1da177e4 LT |
664 | case MEMLOCK: |
665 | { | |
175428b2 | 666 | struct erase_info_user einfo; |
1da177e4 | 667 | |
175428b2 | 668 | if (copy_from_user(&einfo, argp, sizeof(einfo))) |
1da177e4 LT |
669 | return -EFAULT; |
670 | ||
671 | if (!mtd->lock) | |
672 | ret = -EOPNOTSUPP; | |
673 | else | |
175428b2 | 674 | ret = mtd->lock(mtd, einfo.start, einfo.length); |
1da177e4 LT |
675 | break; |
676 | } | |
677 | ||
678 | case MEMUNLOCK: | |
679 | { | |
175428b2 | 680 | struct erase_info_user einfo; |
1da177e4 | 681 | |
175428b2 | 682 | if (copy_from_user(&einfo, argp, sizeof(einfo))) |
1da177e4 LT |
683 | return -EFAULT; |
684 | ||
685 | if (!mtd->unlock) | |
686 | ret = -EOPNOTSUPP; | |
687 | else | |
175428b2 | 688 | ret = mtd->unlock(mtd, einfo.start, einfo.length); |
1da177e4 LT |
689 | break; |
690 | } | |
691 | ||
9938424f RC |
692 | case MEMISLOCKED: |
693 | { | |
694 | struct erase_info_user einfo; | |
695 | ||
696 | if (copy_from_user(&einfo, argp, sizeof(einfo))) | |
697 | return -EFAULT; | |
698 | ||
699 | if (!mtd->is_locked) | |
700 | ret = -EOPNOTSUPP; | |
701 | else | |
702 | ret = mtd->is_locked(mtd, einfo.start, einfo.length); | |
703 | break; | |
704 | } | |
705 | ||
5bd34c09 | 706 | /* Legacy interface */ |
1da177e4 LT |
707 | case MEMGETOOBSEL: |
708 | { | |
5bd34c09 TG |
709 | struct nand_oobinfo oi; |
710 | ||
711 | if (!mtd->ecclayout) | |
712 | return -EOPNOTSUPP; | |
713 | if (mtd->ecclayout->eccbytes > ARRAY_SIZE(oi.eccpos)) | |
714 | return -EINVAL; | |
715 | ||
716 | oi.useecc = MTD_NANDECC_AUTOPLACE; | |
717 | memcpy(&oi.eccpos, mtd->ecclayout->eccpos, sizeof(oi.eccpos)); | |
718 | memcpy(&oi.oobfree, mtd->ecclayout->oobfree, | |
719 | sizeof(oi.oobfree)); | |
d25ade71 | 720 | oi.eccbytes = mtd->ecclayout->eccbytes; |
5bd34c09 TG |
721 | |
722 | if (copy_to_user(argp, &oi, sizeof(struct nand_oobinfo))) | |
1da177e4 LT |
723 | return -EFAULT; |
724 | break; | |
725 | } | |
726 | ||
727 | case MEMGETBADBLOCK: | |
728 | { | |
729 | loff_t offs; | |
97894cda | 730 | |
1da177e4 LT |
731 | if (copy_from_user(&offs, argp, sizeof(loff_t))) |
732 | return -EFAULT; | |
733 | if (!mtd->block_isbad) | |
734 | ret = -EOPNOTSUPP; | |
735 | else | |
736 | return mtd->block_isbad(mtd, offs); | |
737 | break; | |
738 | } | |
739 | ||
740 | case MEMSETBADBLOCK: | |
741 | { | |
742 | loff_t offs; | |
743 | ||
744 | if (copy_from_user(&offs, argp, sizeof(loff_t))) | |
745 | return -EFAULT; | |
746 | if (!mtd->block_markbad) | |
747 | ret = -EOPNOTSUPP; | |
748 | else | |
749 | return mtd->block_markbad(mtd, offs); | |
750 | break; | |
751 | } | |
752 | ||
34a82443 | 753 | #ifdef CONFIG_HAVE_MTD_OTP |
31f4233b NP |
754 | case OTPSELECT: |
755 | { | |
756 | int mode; | |
757 | if (copy_from_user(&mode, argp, sizeof(int))) | |
758 | return -EFAULT; | |
f1a28c02 TG |
759 | |
760 | mfi->mode = MTD_MODE_NORMAL; | |
761 | ||
762 | ret = otp_select_filemode(mfi, mode); | |
763 | ||
81dba488 | 764 | file->f_pos = 0; |
31f4233b NP |
765 | break; |
766 | } | |
767 | ||
768 | case OTPGETREGIONCOUNT: | |
769 | case OTPGETREGIONINFO: | |
770 | { | |
771 | struct otp_info *buf = kmalloc(4096, GFP_KERNEL); | |
772 | if (!buf) | |
773 | return -ENOMEM; | |
774 | ret = -EOPNOTSUPP; | |
f1a28c02 TG |
775 | switch (mfi->mode) { |
776 | case MTD_MODE_OTP_FACTORY: | |
31f4233b NP |
777 | if (mtd->get_fact_prot_info) |
778 | ret = mtd->get_fact_prot_info(mtd, buf, 4096); | |
779 | break; | |
780 | case MTD_MODE_OTP_USER: | |
781 | if (mtd->get_user_prot_info) | |
782 | ret = mtd->get_user_prot_info(mtd, buf, 4096); | |
783 | break; | |
f1a28c02 TG |
784 | default: |
785 | break; | |
31f4233b NP |
786 | } |
787 | if (ret >= 0) { | |
788 | if (cmd == OTPGETREGIONCOUNT) { | |
789 | int nbr = ret / sizeof(struct otp_info); | |
790 | ret = copy_to_user(argp, &nbr, sizeof(int)); | |
791 | } else | |
792 | ret = copy_to_user(argp, buf, ret); | |
793 | if (ret) | |
794 | ret = -EFAULT; | |
795 | } | |
796 | kfree(buf); | |
797 | break; | |
798 | } | |
799 | ||
800 | case OTPLOCK: | |
801 | { | |
175428b2 | 802 | struct otp_info oinfo; |
31f4233b | 803 | |
f1a28c02 | 804 | if (mfi->mode != MTD_MODE_OTP_USER) |
31f4233b | 805 | return -EINVAL; |
175428b2 | 806 | if (copy_from_user(&oinfo, argp, sizeof(oinfo))) |
31f4233b NP |
807 | return -EFAULT; |
808 | if (!mtd->lock_user_prot_reg) | |
809 | return -EOPNOTSUPP; | |
175428b2 | 810 | ret = mtd->lock_user_prot_reg(mtd, oinfo.start, oinfo.length); |
31f4233b NP |
811 | break; |
812 | } | |
813 | #endif | |
814 | ||
f1a28c02 TG |
815 | case ECCGETLAYOUT: |
816 | { | |
817 | if (!mtd->ecclayout) | |
818 | return -EOPNOTSUPP; | |
819 | ||
d25ade71 | 820 | if (copy_to_user(argp, mtd->ecclayout, |
f1a28c02 TG |
821 | sizeof(struct nand_ecclayout))) |
822 | return -EFAULT; | |
823 | break; | |
824 | } | |
825 | ||
826 | case ECCGETSTATS: | |
827 | { | |
828 | if (copy_to_user(argp, &mtd->ecc_stats, | |
829 | sizeof(struct mtd_ecc_stats))) | |
830 | return -EFAULT; | |
831 | break; | |
832 | } | |
833 | ||
834 | case MTDFILEMODE: | |
835 | { | |
836 | mfi->mode = 0; | |
837 | ||
838 | switch(arg) { | |
839 | case MTD_MODE_OTP_FACTORY: | |
840 | case MTD_MODE_OTP_USER: | |
841 | ret = otp_select_filemode(mfi, arg); | |
842 | break; | |
843 | ||
844 | case MTD_MODE_RAW: | |
845 | if (!mtd->read_oob || !mtd->write_oob) | |
846 | return -EOPNOTSUPP; | |
847 | mfi->mode = arg; | |
848 | ||
849 | case MTD_MODE_NORMAL: | |
850 | break; | |
851 | default: | |
852 | ret = -EINVAL; | |
853 | } | |
854 | file->f_pos = 0; | |
855 | break; | |
856 | } | |
857 | ||
1da177e4 LT |
858 | default: |
859 | ret = -ENOTTY; | |
860 | } | |
861 | ||
862 | return ret; | |
863 | } /* memory_ioctl */ | |
864 | ||
55929332 AB |
865 | static long mtd_unlocked_ioctl(struct file *file, u_int cmd, u_long arg) |
866 | { | |
867 | int ret; | |
868 | ||
869 | lock_kernel(); | |
870 | ret = mtd_ioctl(file, cmd, arg); | |
871 | unlock_kernel(); | |
872 | ||
873 | return ret; | |
874 | } | |
875 | ||
97718540 KC |
876 | #ifdef CONFIG_COMPAT |
877 | ||
878 | struct mtd_oob_buf32 { | |
879 | u_int32_t start; | |
880 | u_int32_t length; | |
881 | compat_caddr_t ptr; /* unsigned char* */ | |
882 | }; | |
883 | ||
884 | #define MEMWRITEOOB32 _IOWR('M', 3, struct mtd_oob_buf32) | |
885 | #define MEMREADOOB32 _IOWR('M', 4, struct mtd_oob_buf32) | |
886 | ||
887 | static long mtd_compat_ioctl(struct file *file, unsigned int cmd, | |
888 | unsigned long arg) | |
889 | { | |
890 | struct mtd_file_info *mfi = file->private_data; | |
891 | struct mtd_info *mtd = mfi->mtd; | |
0b6585ce | 892 | void __user *argp = compat_ptr(arg); |
97718540 KC |
893 | int ret = 0; |
894 | ||
895 | lock_kernel(); | |
896 | ||
897 | switch (cmd) { | |
898 | case MEMWRITEOOB32: | |
899 | { | |
900 | struct mtd_oob_buf32 buf; | |
901 | struct mtd_oob_buf32 __user *buf_user = argp; | |
902 | ||
903 | if (copy_from_user(&buf, argp, sizeof(buf))) | |
904 | ret = -EFAULT; | |
905 | else | |
906 | ret = mtd_do_writeoob(file, mtd, buf.start, | |
907 | buf.length, compat_ptr(buf.ptr), | |
908 | &buf_user->length); | |
909 | break; | |
910 | } | |
911 | ||
912 | case MEMREADOOB32: | |
913 | { | |
914 | struct mtd_oob_buf32 buf; | |
915 | struct mtd_oob_buf32 __user *buf_user = argp; | |
916 | ||
917 | /* NOTE: writes return length to buf->start */ | |
918 | if (copy_from_user(&buf, argp, sizeof(buf))) | |
919 | ret = -EFAULT; | |
920 | else | |
921 | ret = mtd_do_readoob(mtd, buf.start, | |
922 | buf.length, compat_ptr(buf.ptr), | |
923 | &buf_user->start); | |
924 | break; | |
925 | } | |
926 | default: | |
55929332 | 927 | ret = mtd_ioctl(file, cmd, (unsigned long)argp); |
97718540 KC |
928 | } |
929 | ||
930 | unlock_kernel(); | |
931 | ||
932 | return ret; | |
933 | } | |
934 | ||
935 | #endif /* CONFIG_COMPAT */ | |
936 | ||
402d3265 DH |
937 | /* |
938 | * try to determine where a shared mapping can be made | |
939 | * - only supported for NOMMU at the moment (MMU can't doesn't copy private | |
940 | * mappings) | |
941 | */ | |
942 | #ifndef CONFIG_MMU | |
943 | static unsigned long mtd_get_unmapped_area(struct file *file, | |
944 | unsigned long addr, | |
945 | unsigned long len, | |
946 | unsigned long pgoff, | |
947 | unsigned long flags) | |
948 | { | |
949 | struct mtd_file_info *mfi = file->private_data; | |
950 | struct mtd_info *mtd = mfi->mtd; | |
951 | ||
952 | if (mtd->get_unmapped_area) { | |
953 | unsigned long offset; | |
954 | ||
955 | if (addr != 0) | |
956 | return (unsigned long) -EINVAL; | |
957 | ||
958 | if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT)) | |
959 | return (unsigned long) -EINVAL; | |
960 | ||
961 | offset = pgoff << PAGE_SHIFT; | |
962 | if (offset > mtd->size - len) | |
963 | return (unsigned long) -EINVAL; | |
964 | ||
965 | return mtd->get_unmapped_area(mtd, len, offset, flags); | |
966 | } | |
967 | ||
968 | /* can't map directly */ | |
969 | return (unsigned long) -ENOSYS; | |
970 | } | |
971 | #endif | |
972 | ||
973 | /* | |
974 | * set up a mapping for shared memory segments | |
975 | */ | |
976 | static int mtd_mmap(struct file *file, struct vm_area_struct *vma) | |
977 | { | |
978 | #ifdef CONFIG_MMU | |
979 | struct mtd_file_info *mfi = file->private_data; | |
980 | struct mtd_info *mtd = mfi->mtd; | |
dd02b67d AG |
981 | struct map_info *map = mtd->priv; |
982 | unsigned long start; | |
983 | unsigned long off; | |
984 | u32 len; | |
985 | ||
986 | if (mtd->type == MTD_RAM || mtd->type == MTD_ROM) { | |
987 | off = vma->vm_pgoff << PAGE_SHIFT; | |
988 | start = map->phys; | |
989 | len = PAGE_ALIGN((start & ~PAGE_MASK) + map->size); | |
990 | start &= PAGE_MASK; | |
991 | if ((vma->vm_end - vma->vm_start + off) > len) | |
992 | return -EINVAL; | |
993 | ||
994 | off += start; | |
995 | vma->vm_pgoff = off >> PAGE_SHIFT; | |
996 | vma->vm_flags |= VM_IO | VM_RESERVED; | |
997 | ||
998 | #ifdef pgprot_noncached | |
999 | if (file->f_flags & O_DSYNC || off >= __pa(high_memory)) | |
1000 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); | |
1001 | #endif | |
1002 | if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT, | |
1003 | vma->vm_end - vma->vm_start, | |
1004 | vma->vm_page_prot)) | |
1005 | return -EAGAIN; | |
402d3265 | 1006 | |
402d3265 | 1007 | return 0; |
dd02b67d | 1008 | } |
402d3265 DH |
1009 | return -ENOSYS; |
1010 | #else | |
1011 | return vma->vm_flags & VM_SHARED ? 0 : -ENOSYS; | |
1012 | #endif | |
1013 | } | |
1014 | ||
d54b1fdb | 1015 | static const struct file_operations mtd_fops = { |
1da177e4 LT |
1016 | .owner = THIS_MODULE, |
1017 | .llseek = mtd_lseek, | |
1018 | .read = mtd_read, | |
1019 | .write = mtd_write, | |
55929332 | 1020 | .unlocked_ioctl = mtd_unlocked_ioctl, |
97718540 KC |
1021 | #ifdef CONFIG_COMPAT |
1022 | .compat_ioctl = mtd_compat_ioctl, | |
1023 | #endif | |
1da177e4 LT |
1024 | .open = mtd_open, |
1025 | .release = mtd_close, | |
402d3265 DH |
1026 | .mmap = mtd_mmap, |
1027 | #ifndef CONFIG_MMU | |
1028 | .get_unmapped_area = mtd_get_unmapped_area, | |
1029 | #endif | |
1da177e4 LT |
1030 | }; |
1031 | ||
cd874237 KS |
1032 | static int mtd_inodefs_get_sb(struct file_system_type *fs_type, int flags, |
1033 | const char *dev_name, void *data, | |
1034 | struct vfsmount *mnt) | |
1035 | { | |
1036 | return get_sb_pseudo(fs_type, "mtd_inode:", NULL, MTD_INODE_FS_MAGIC, | |
1037 | mnt); | |
1038 | } | |
1039 | ||
1040 | static struct file_system_type mtd_inodefs_type = { | |
1041 | .name = "mtd_inodefs", | |
1042 | .get_sb = mtd_inodefs_get_sb, | |
1043 | .kill_sb = kill_anon_super, | |
1044 | }; | |
1045 | ||
1046 | static void mtdchar_notify_add(struct mtd_info *mtd) | |
1047 | { | |
1048 | } | |
1049 | ||
1050 | static void mtdchar_notify_remove(struct mtd_info *mtd) | |
1051 | { | |
1052 | struct inode *mtd_ino = ilookup(mtd_inode_mnt->mnt_sb, mtd->index); | |
1053 | ||
1054 | if (mtd_ino) { | |
1055 | /* Destroy the inode if it exists */ | |
1056 | mtd_ino->i_nlink = 0; | |
1057 | iput(mtd_ino); | |
1058 | } | |
1059 | } | |
1060 | ||
1061 | static struct mtd_notifier mtdchar_notifier = { | |
1062 | .add = mtdchar_notify_add, | |
1063 | .remove = mtdchar_notify_remove, | |
1064 | }; | |
1065 | ||
1da177e4 LT |
1066 | static int __init init_mtdchar(void) |
1067 | { | |
cd874237 | 1068 | int ret; |
1f24b5a8 | 1069 | |
cd874237 | 1070 | ret = __register_chrdev(MTD_CHAR_MAJOR, 0, 1 << MINORBITS, |
dad0db31 | 1071 | "mtd", &mtd_fops); |
cd874237 KS |
1072 | if (ret < 0) { |
1073 | pr_notice("Can't allocate major number %d for " | |
1074 | "Memory Technology Devices.\n", MTD_CHAR_MAJOR); | |
1075 | return ret; | |
9bc7b387 TP |
1076 | } |
1077 | ||
cd874237 KS |
1078 | ret = register_filesystem(&mtd_inodefs_type); |
1079 | if (ret) { | |
1080 | pr_notice("Can't register mtd_inodefs filesystem: %d\n", ret); | |
1081 | goto err_unregister_chdev; | |
1082 | } | |
1083 | ||
1084 | mtd_inode_mnt = kern_mount(&mtd_inodefs_type); | |
1085 | if (IS_ERR(mtd_inode_mnt)) { | |
1086 | ret = PTR_ERR(mtd_inode_mnt); | |
1087 | pr_notice("Error mounting mtd_inodefs filesystem: %d\n", ret); | |
1088 | goto err_unregister_filesystem; | |
1089 | } | |
1090 | register_mtd_user(&mtdchar_notifier); | |
1091 | ||
1092 | return ret; | |
1093 | ||
1094 | err_unregister_filesystem: | |
1095 | unregister_filesystem(&mtd_inodefs_type); | |
1096 | err_unregister_chdev: | |
1097 | __unregister_chrdev(MTD_CHAR_MAJOR, 0, 1 << MINORBITS, "mtd"); | |
1098 | return ret; | |
1da177e4 LT |
1099 | } |
1100 | ||
1101 | static void __exit cleanup_mtdchar(void) | |
1102 | { | |
cd874237 KS |
1103 | unregister_mtd_user(&mtdchar_notifier); |
1104 | mntput(mtd_inode_mnt); | |
1105 | unregister_filesystem(&mtd_inodefs_type); | |
dad0db31 | 1106 | __unregister_chrdev(MTD_CHAR_MAJOR, 0, 1 << MINORBITS, "mtd"); |
1da177e4 LT |
1107 | } |
1108 | ||
1109 | module_init(init_mtdchar); | |
1110 | module_exit(cleanup_mtdchar); | |
1111 | ||
1f24b5a8 | 1112 | MODULE_ALIAS_CHARDEV_MAJOR(MTD_CHAR_MAJOR); |
1da177e4 LT |
1113 | |
1114 | MODULE_LICENSE("GPL"); | |
1115 | MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); | |
1116 | MODULE_DESCRIPTION("Direct character-device access to MTD devices"); | |
90160e13 | 1117 | MODULE_ALIAS_CHARDEV_MAJOR(MTD_CHAR_MAJOR); |