.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Swap block device support for MTDs |
---|
3 | 4 | * Turns an MTD device into a swap device with block wear leveling |
---|
.. | .. |
---|
8 | 9 | * |
---|
9 | 10 | * Based on Richard Purdie's earlier implementation in 2007. Background |
---|
10 | 11 | * 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 |
---|
25 | 12 | */ |
---|
26 | 13 | |
---|
27 | 14 | #include <linux/kernel.h> |
---|
.. | .. |
---|
1265 | 1252 | |
---|
1266 | 1253 | return 0; |
---|
1267 | 1254 | } |
---|
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); |
---|
1280 | 1256 | |
---|
1281 | 1257 | static int mtdswap_add_debugfs(struct mtdswap_dev *d) |
---|
1282 | 1258 | { |
---|
1283 | 1259 | struct dentry *root = d->mtd->dbg.dfs_dir; |
---|
1284 | | - struct dentry *dent; |
---|
1285 | 1260 | |
---|
1286 | 1261 | if (!IS_ENABLED(CONFIG_DEBUG_FS)) |
---|
1287 | 1262 | return 0; |
---|
.. | .. |
---|
1289 | 1264 | if (IS_ERR_OR_NULL(root)) |
---|
1290 | 1265 | return -1; |
---|
1291 | 1266 | |
---|
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); |
---|
1298 | 1268 | |
---|
1299 | 1269 | return 0; |
---|
1300 | 1270 | } |
---|