hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/mtd/mtdswap.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Swap block device support for MTDs
34 * Turns an MTD device into a swap device with block wear leveling
....@@ -8,20 +9,6 @@
89 *
910 * Based on Richard Purdie's earlier implementation in 2007. Background
1011 * support and lock-less operation written by Adrian Hunter.
11
- *
12
- * This program is free software; you can redistribute it and/or
13
- * modify it under the terms of the GNU General Public License
14
- * version 2 as published by the Free Software Foundation.
15
- *
16
- * This program is distributed in the hope that it will be useful, but
17
- * WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
- * General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU General Public License
22
- * along with this program; if not, write to the Free Software
23
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24
- * 02110-1301 USA
2512 */
2613
2714 #include <linux/kernel.h>
....@@ -1265,23 +1252,11 @@
12651252
12661253 return 0;
12671254 }
1268
-
1269
-static int mtdswap_open(struct inode *inode, struct file *file)
1270
-{
1271
- return single_open(file, mtdswap_show, inode->i_private);
1272
-}
1273
-
1274
-static const struct file_operations mtdswap_fops = {
1275
- .open = mtdswap_open,
1276
- .read = seq_read,
1277
- .llseek = seq_lseek,
1278
- .release = single_release,
1279
-};
1255
+DEFINE_SHOW_ATTRIBUTE(mtdswap);
12801256
12811257 static int mtdswap_add_debugfs(struct mtdswap_dev *d)
12821258 {
12831259 struct dentry *root = d->mtd->dbg.dfs_dir;
1284
- struct dentry *dent;
12851260
12861261 if (!IS_ENABLED(CONFIG_DEBUG_FS))
12871262 return 0;
....@@ -1289,12 +1264,7 @@
12891264 if (IS_ERR_OR_NULL(root))
12901265 return -1;
12911266
1292
- dent = debugfs_create_file("mtdswap_stats", S_IRUSR, root, d,
1293
- &mtdswap_fops);
1294
- if (!dent) {
1295
- dev_err(d->dev, "debugfs_create_file failed\n");
1296
- return -1;
1297
- }
1267
+ debugfs_create_file("mtdswap_stats", S_IRUSR, root, d, &mtdswap_fops);
12981268
12991269 return 0;
13001270 }