.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) International Business Machines Corp., 2006 |
---|
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 |
---|
12 | | - * the 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
17 | 4 | * |
---|
18 | 5 | * Author: Artem Bityutskiy (Битюцкий Артём) |
---|
19 | 6 | */ |
---|
.. | .. |
---|
974 | 961 | break; |
---|
975 | 962 | } |
---|
976 | 963 | |
---|
| 964 | + /* Check a specific PEB for bitflips and scrub it if needed */ |
---|
| 965 | + case UBI_IOCRPEB: |
---|
| 966 | + { |
---|
| 967 | + int pnum; |
---|
| 968 | + |
---|
| 969 | + err = get_user(pnum, (__user int32_t *)argp); |
---|
| 970 | + if (err) { |
---|
| 971 | + err = -EFAULT; |
---|
| 972 | + break; |
---|
| 973 | + } |
---|
| 974 | + |
---|
| 975 | + err = ubi_bitflip_check(ubi, pnum, 0); |
---|
| 976 | + break; |
---|
| 977 | + } |
---|
| 978 | + |
---|
| 979 | + /* Force scrubbing for a specific PEB */ |
---|
| 980 | + case UBI_IOCSPEB: |
---|
| 981 | + { |
---|
| 982 | + int pnum; |
---|
| 983 | + |
---|
| 984 | + err = get_user(pnum, (__user int32_t *)argp); |
---|
| 985 | + if (err) { |
---|
| 986 | + err = -EFAULT; |
---|
| 987 | + break; |
---|
| 988 | + } |
---|
| 989 | + |
---|
| 990 | + err = ubi_bitflip_check(ubi, pnum, 1); |
---|
| 991 | + break; |
---|
| 992 | + } |
---|
| 993 | + |
---|
977 | 994 | default: |
---|
978 | 995 | err = -ENOTTY; |
---|
979 | 996 | break; |
---|
.. | .. |
---|
1061 | 1078 | return err; |
---|
1062 | 1079 | } |
---|
1063 | 1080 | |
---|
1064 | | -#ifdef CONFIG_COMPAT |
---|
1065 | | -static long vol_cdev_compat_ioctl(struct file *file, unsigned int cmd, |
---|
1066 | | - unsigned long arg) |
---|
1067 | | -{ |
---|
1068 | | - unsigned long translated_arg = (unsigned long)compat_ptr(arg); |
---|
1069 | | - |
---|
1070 | | - return vol_cdev_ioctl(file, cmd, translated_arg); |
---|
1071 | | -} |
---|
1072 | | - |
---|
1073 | | -static long ubi_cdev_compat_ioctl(struct file *file, unsigned int cmd, |
---|
1074 | | - unsigned long arg) |
---|
1075 | | -{ |
---|
1076 | | - unsigned long translated_arg = (unsigned long)compat_ptr(arg); |
---|
1077 | | - |
---|
1078 | | - return ubi_cdev_ioctl(file, cmd, translated_arg); |
---|
1079 | | -} |
---|
1080 | | - |
---|
1081 | | -static long ctrl_cdev_compat_ioctl(struct file *file, unsigned int cmd, |
---|
1082 | | - unsigned long arg) |
---|
1083 | | -{ |
---|
1084 | | - unsigned long translated_arg = (unsigned long)compat_ptr(arg); |
---|
1085 | | - |
---|
1086 | | - return ctrl_cdev_ioctl(file, cmd, translated_arg); |
---|
1087 | | -} |
---|
1088 | | -#else |
---|
1089 | | -#define vol_cdev_compat_ioctl NULL |
---|
1090 | | -#define ubi_cdev_compat_ioctl NULL |
---|
1091 | | -#define ctrl_cdev_compat_ioctl NULL |
---|
1092 | | -#endif |
---|
1093 | | - |
---|
1094 | 1081 | /* UBI volume character device operations */ |
---|
1095 | 1082 | const struct file_operations ubi_vol_cdev_operations = { |
---|
1096 | 1083 | .owner = THIS_MODULE, |
---|
.. | .. |
---|
1101 | 1088 | .write = vol_cdev_write, |
---|
1102 | 1089 | .fsync = vol_cdev_fsync, |
---|
1103 | 1090 | .unlocked_ioctl = vol_cdev_ioctl, |
---|
1104 | | - .compat_ioctl = vol_cdev_compat_ioctl, |
---|
| 1091 | + .compat_ioctl = compat_ptr_ioctl, |
---|
1105 | 1092 | }; |
---|
1106 | 1093 | |
---|
1107 | 1094 | /* UBI character device operations */ |
---|
.. | .. |
---|
1109 | 1096 | .owner = THIS_MODULE, |
---|
1110 | 1097 | .llseek = no_llseek, |
---|
1111 | 1098 | .unlocked_ioctl = ubi_cdev_ioctl, |
---|
1112 | | - .compat_ioctl = ubi_cdev_compat_ioctl, |
---|
| 1099 | + .compat_ioctl = compat_ptr_ioctl, |
---|
1113 | 1100 | }; |
---|
1114 | 1101 | |
---|
1115 | 1102 | /* UBI control character device operations */ |
---|
1116 | 1103 | const struct file_operations ubi_ctrl_cdev_operations = { |
---|
1117 | 1104 | .owner = THIS_MODULE, |
---|
1118 | 1105 | .unlocked_ioctl = ctrl_cdev_ioctl, |
---|
1119 | | - .compat_ioctl = ctrl_cdev_compat_ioctl, |
---|
| 1106 | + .compat_ioctl = compat_ptr_ioctl, |
---|
1120 | 1107 | .llseek = no_llseek, |
---|
1121 | 1108 | }; |
---|