Skip to contentSkip to conversation

pktcdvd: Convert to DEFINE_SHOW_ATTRIBUTE

PATCH Superseded Qinglang Miao 1 participant 1 message Sep 19, 2020 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pktcdvd: Convert to DEFINE_SHOW_ATTRIBUTE

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/block/pktcdvd.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/block/pktcdvd.c +4 -15
index 17f2e6ff1..a40c397c7 100644
@@ -452,23 +452,12 @@ static void pkt_sysfs_cleanup(void)
 
  *******************************************************************/
 
-static int pkt_debugfs_seq_show(struct seq_file *m, void *p)
+static int pkt_debugfs_show(struct seq_file *m, void *p)
 {
 	return pkt_seq_show(m, p);
 }
 
-static int pkt_debugfs_fops_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, pkt_debugfs_seq_show, inode->i_private);
-}
-
-static const struct file_operations debug_fops = {
-	.open		= pkt_debugfs_fops_open,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= single_release,
-	.owner		= THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(pkt_debugfs);
 
 static void pkt_debugfs_dev_new(struct pktcdvd_device *pd)
 {
@@ -478,8 +467,8 @@ static void pkt_debugfs_dev_new(struct pktcdvd_device *pd)
 	if (!pd->dfs_d_root)
 		return;
 
-	pd->dfs_f_info = debugfs_create_file("info", 0444,
-					     pd->dfs_d_root, pd, &debug_fops);
+	pd->dfs_f_info = debugfs_create_file("info", 0444, pd->dfs_d_root,
+					     pd, &pkt_debugfs_fops);
 }
 
 static void pkt_debugfs_dev_remove(struct pktcdvd_device *pd)
Signature · 1 line
2.23.0