Skip to content

Commit c3da23b

Browse files
iksaifArtem Bityutskiy
authored andcommitted
UBI: add ioctl for unmap operation
This patch adds ioctl for the LEB unmap operation (as a debugging option so far). [Re-named ioctl to make it look the same as the other one and made some minor stylistic changes. Artem Bityutskiy.] Signed-off-by: Corentin Chary <corentincj@iksaif.net> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
1 parent 141e6eb commit c3da23b

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎drivers/mtd/ubi/cdev.c‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,13 +532,26 @@ static int vol_cdev_ioctl(struct inode *inode, struct file *file,
532532
err = ubi_leb_map(desc, req.lnum, req.dtype);
533533
break;
534534
}
535+
536+
/* Logical eraseblock un-map command */
537+
case UBI_IOCEBUNMAP:
538+
{
539+
int32_t lnum;
540+
541+
err = get_user(lnum, (__user int32_t *)argp);
542+
if (err) {
543+
err = -EFAULT;
544+
break;
545+
}
546+
err = ubi_leb_unmap(desc, lnum);
547+
break;
548+
}
535549
#endif
536550

537551
default:
538552
err = -ENOTTY;
539553
break;
540554
}
541-
542555
return err;
543556
}
544557

‎include/mtd/ubi-user.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@
135135
#define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, int32_t)
136136
/* Map an eraseblock, used for debugging, disabled by default */
137137
#define UBI_IOCEBMAP _IOW(UBI_VOL_IOC_MAGIC, 3, struct ubi_map_req)
138-
138+
/* Unmap an eraseblock, used for debugging, disabled by default */
139+
#define UBI_IOCEBUNMAP _IOW(UBI_VOL_IOC_MAGIC, 4, int32_t)
139140

140141
/* Maximum MTD device name length supported by UBI */
141142
#define MAX_UBI_MTD_NAME_LEN 127

0 commit comments

Comments
 (0)