aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdchar.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/mtdchar.c')
-rw-r--r--drivers/mtd/mtdchar.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 13cc67ad272a..963840e9b5bf 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -26,13 +26,11 @@ static void mtd_notify_add(struct mtd_info* mtd)
26 if (!mtd) 26 if (!mtd)
27 return; 27 return;
28 28
29 device_create_drvdata(mtd_class, NULL, 29 device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
30 MKDEV(MTD_CHAR_MAJOR, mtd->index*2), 30 NULL, "mtd%d", mtd->index);
31 NULL, "mtd%d", mtd->index);
32 31
33 device_create_drvdata(mtd_class, NULL, 32 device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
34 MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), 33 NULL, "mtd%dro", mtd->index);
35 NULL, "mtd%dro", mtd->index);
36} 34}
37 35
38static void mtd_notify_remove(struct mtd_info* mtd) 36static void mtd_notify_remove(struct mtd_info* mtd)
@@ -410,16 +408,20 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
410 408
411 case MEMGETREGIONINFO: 409 case MEMGETREGIONINFO:
412 { 410 {
413 struct region_info_user ur; 411 uint32_t ur_idx;
412 struct mtd_erase_region_info *kr;
413 struct region_info_user *ur = (struct region_info_user *) argp;
414 414
415 if (copy_from_user(&ur, argp, sizeof(struct region_info_user))) 415 if (get_user(ur_idx, &(ur->regionindex)))
416 return -EFAULT; 416 return -EFAULT;
417 417
418 if (ur.regionindex >= mtd->numeraseregions) 418 kr = &(mtd->eraseregions[ur_idx]);
419 return -EINVAL; 419
420 if (copy_to_user(argp, &(mtd->eraseregions[ur.regionindex]), 420 if (put_user(kr->offset, &(ur->offset))
421 sizeof(struct mtd_erase_region_info))) 421 || put_user(kr->erasesize, &(ur->erasesize))
422 || put_user(kr->numblocks, &(ur->numblocks)))
422 return -EFAULT; 423 return -EFAULT;
424
423 break; 425 break;
424 } 426 }
425 427