Skip to content

Commit 88d905e

Browse files
TinyWindzzherbertx
authored andcommitted
crypto: cavium/nitrox - convert to DEFINE_SHOW_ATTRIBUTE
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. Signed-off-by: Yangtao Li <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 8362ea1 commit 88d905e

File tree

1 file changed

+9
-39
lines changed

1 file changed

+9
-39
lines changed

drivers/crypto/cavium/nitrox/nitrox_debugfs.c

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,7 @@ static int firmware_show(struct seq_file *s, void *v)
1313
return 0;
1414
}
1515

16-
static int firmware_open(struct inode *inode, struct file *file)
17-
{
18-
return single_open(file, firmware_show, inode->i_private);
19-
}
20-
21-
static const struct file_operations firmware_fops = {
22-
.owner = THIS_MODULE,
23-
.open = firmware_open,
24-
.read = seq_read,
25-
.llseek = seq_lseek,
26-
.release = single_release,
27-
};
16+
DEFINE_SHOW_ATTRIBUTE(firmware);
2817

2918
static int device_show(struct seq_file *s, void *v)
3019
{
@@ -41,18 +30,7 @@ static int device_show(struct seq_file *s, void *v)
4130
return 0;
4231
}
4332

44-
static int nitrox_open(struct inode *inode, struct file *file)
45-
{
46-
return single_open(file, device_show, inode->i_private);
47-
}
48-
49-
static const struct file_operations nitrox_fops = {
50-
.owner = THIS_MODULE,
51-
.open = nitrox_open,
52-
.read = seq_read,
53-
.llseek = seq_lseek,
54-
.release = single_release,
55-
};
33+
DEFINE_SHOW_ATTRIBUTE(device);
5634

5735
static int stats_show(struct seq_file *s, void *v)
5836
{
@@ -69,18 +47,7 @@ static int stats_show(struct seq_file *s, void *v)
6947
return 0;
7048
}
7149

72-
static int nitrox_stats_open(struct inode *inode, struct file *file)
73-
{
74-
return single_open(file, stats_show, inode->i_private);
75-
}
76-
77-
static const struct file_operations nitrox_stats_fops = {
78-
.owner = THIS_MODULE,
79-
.open = nitrox_stats_open,
80-
.read = seq_read,
81-
.llseek = seq_lseek,
82-
.release = single_release,
83-
};
50+
DEFINE_SHOW_ATTRIBUTE(stats);
8451

8552
void nitrox_debugfs_exit(struct nitrox_device *ndev)
8653
{
@@ -97,13 +64,16 @@ int nitrox_debugfs_init(struct nitrox_device *ndev)
9764
return -ENOMEM;
9865

9966
ndev->debugfs_dir = dir;
100-
f = debugfs_create_file("firmware", 0400, dir, ndev, &firmware_fops);
67+
f = debugfs_create_file("firmware", 0400, dir, ndev,
68+
&firmware_fops);
10169
if (!f)
10270
goto err;
103-
f = debugfs_create_file("device", 0400, dir, ndev, &nitrox_fops);
71+
f = debugfs_create_file("device", 0400, dir, ndev,
72+
&device_fops);
10473
if (!f)
10574
goto err;
106-
f = debugfs_create_file("stats", 0400, dir, ndev, &nitrox_stats_fops);
75+
f = debugfs_create_file("stats", 0400, dir, ndev,
76+
&stats_fops);
10777
if (!f)
10878
goto err;
10979

0 commit comments

Comments
 (0)