forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 072de836f53be56a70cecf70b43ae43b7ce17376
kernel/drivers/mtd/tests/readtest.c
....@@ -1,18 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2006-2008 Nokia Corporation
3
- *
4
- * This program is free software; you can redistribute it and/or modify it
5
- * under the terms of the GNU General Public License version 2 as published by
6
- * the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful, but WITHOUT
9
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
- * more details.
12
- *
13
- * You should have received a copy of the GNU General Public License along with
14
- * this program; see the file COPYING. If not, write to the Free Software
15
- * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
164 *
175 * Check MTD device read.
186 *
....@@ -34,6 +22,11 @@
3422 static int dev = -EINVAL;
3523 module_param(dev, int, S_IRUGO);
3624 MODULE_PARM_DESC(dev, "MTD device number to use");
25
+
26
+static unsigned int cycles_count = 1;
27
+module_param(cycles_count, uint, S_IRUGO);
28
+MODULE_PARM_DESC(cycles_count, "how many erase cycles to do "
29
+ "(infinite by default)");
3730
3831 static struct mtd_info *mtd;
3932 static unsigned char *iobuf;
....@@ -179,22 +172,25 @@
179172
180173 /* Read all eraseblocks 1 page at a time */
181174 pr_info("testing page read\n");
182
- for (i = 0; i < ebcnt; ++i) {
183
- int ret;
175
+ while (cycles_count--) {
176
+ pr_info("Number of remaining cycles %d\n", cycles_count);
177
+ for (i = 0; i < ebcnt; ++i) {
178
+ int ret;
184179
185
- if (bbt[i])
186
- continue;
187
- ret = read_eraseblock_by_page(i);
188
- if (ret) {
189
- dump_eraseblock(i);
190
- if (!err)
180
+ if (bbt[i])
181
+ continue;
182
+ ret = read_eraseblock_by_page(i);
183
+ if (ret) {
184
+ dump_eraseblock(i);
185
+ if (!err)
186
+ err = ret;
187
+ }
188
+
189
+ ret = mtdtest_relax();
190
+ if (ret) {
191191 err = ret;
192
- }
193
-
194
- ret = mtdtest_relax();
195
- if (ret) {
196
- err = ret;
197
- goto out;
192
+ goto out;
193
+ }
198194 }
199195 }
200196