kernel: add a ubi forced detach ioctl
[openwrt/staging/chunkeey.git] / target / linux / generic / patches-3.10 / 413-mtd-ubi-forced-detach.patch
1 --- a/drivers/mtd/ubi/cdev.c
2 +++ b/drivers/mtd/ubi/cdev.c
3 @@ -974,7 +974,7 @@ static long ubi_cdev_ioctl(struct file *
4 static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd,
5 unsigned long arg)
6 {
7 - int err = 0;
8 + int err = 0, force = 0;
9 void __user *argp = (void __user *)arg;
10
11 if (!capable(CAP_SYS_RESOURCE))
12 @@ -1024,6 +1024,10 @@ static long ctrl_cdev_ioctl(struct file
13 }
14
15 /* Detach an MTD device command */
16 + case UBI_IOCFDET:
17 + force = 1;
18 + /* no break */
19 +
20 case UBI_IOCDET:
21 {
22 int ubi_num;
23 @@ -1036,7 +1040,7 @@ static long ctrl_cdev_ioctl(struct file
24 }
25
26 mutex_lock(&ubi_devices_mutex);
27 - err = ubi_detach_mtd_dev(ubi_num, 0);
28 + err = ubi_detach_mtd_dev(ubi_num, force);
29 mutex_unlock(&ubi_devices_mutex);
30 break;
31 }
32 --- a/include/uapi/mtd/ubi-user.h
33 +++ b/include/uapi/mtd/ubi-user.h
34 @@ -168,6 +168,7 @@
35 #define UBI_IOCATT _IOW(UBI_CTRL_IOC_MAGIC, 64, struct ubi_attach_req)
36 /* Detach an MTD device */
37 #define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, __s32)
38 +#define UBI_IOCFDET _IOW(UBI_CTRL_IOC_MAGIC, 99, __s32)
39
40 /* ioctl commands of UBI volume character devices */
41