hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/mtd/ubi/cdev.c
....@@ -1,19 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * 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
174 *
185 * Author: Artem Bityutskiy (Битюцкий Артём)
196 */
....@@ -974,6 +961,36 @@
974961 break;
975962 }
976963
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
+
977994 default:
978995 err = -ENOTTY;
979996 break;
....@@ -1061,36 +1078,6 @@
10611078 return err;
10621079 }
10631080
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
-
10941081 /* UBI volume character device operations */
10951082 const struct file_operations ubi_vol_cdev_operations = {
10961083 .owner = THIS_MODULE,
....@@ -1101,7 +1088,7 @@
11011088 .write = vol_cdev_write,
11021089 .fsync = vol_cdev_fsync,
11031090 .unlocked_ioctl = vol_cdev_ioctl,
1104
- .compat_ioctl = vol_cdev_compat_ioctl,
1091
+ .compat_ioctl = compat_ptr_ioctl,
11051092 };
11061093
11071094 /* UBI character device operations */
....@@ -1109,13 +1096,13 @@
11091096 .owner = THIS_MODULE,
11101097 .llseek = no_llseek,
11111098 .unlocked_ioctl = ubi_cdev_ioctl,
1112
- .compat_ioctl = ubi_cdev_compat_ioctl,
1099
+ .compat_ioctl = compat_ptr_ioctl,
11131100 };
11141101
11151102 /* UBI control character device operations */
11161103 const struct file_operations ubi_ctrl_cdev_operations = {
11171104 .owner = THIS_MODULE,
11181105 .unlocked_ioctl = ctrl_cdev_ioctl,
1119
- .compat_ioctl = ctrl_cdev_compat_ioctl,
1106
+ .compat_ioctl = compat_ptr_ioctl,
11201107 .llseek = no_llseek,
11211108 };