Skip to contentSkip to conversation

net/bluetooth: Change to use DEFINE_SHOW_ATTRIBUTE macro

PATCH In review Yangtao Li 3 participants 4 messages Nov 5, 2018 – Dec 18, 2018

Subsystems (4)
lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/1 net/bluetooth: Change to use DEFINE_SHOW_ATTRIBUTE macro

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

---
 net/bluetooth/l2cap_core.c  | 12 +-----------
 net/bluetooth/rfcomm/core.c | 12 +-----------
 net/bluetooth/rfcomm/sock.c | 12 +-----------
 net/bluetooth/sco.c         | 12 +-----------
 4 files changed, 4 insertions(+), 44 deletions(-)
net/bluetooth/l2cap_core.c +1 -11
index d17a4736e47c..38d92ced5fb5 100644
@@ -7615,17 +7615,7 @@ static int l2cap_debugfs_show(struct seq_file *f, void *p)
 	return 0;
 }
 
-static int l2cap_debugfs_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, l2cap_debugfs_show, inode->i_private);
-}
-
-static const struct file_operations l2cap_debugfs_fops = {
-	.open		= l2cap_debugfs_open,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(l2cap_debugfs);
 
 static struct dentry *l2cap_debugfs;
 
net/bluetooth/rfcomm/core.c +1 -11
index b98225d65e87..1a635df80643 100644
@@ -2166,17 +2166,7 @@ static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x)
 	return 0;
 }
 
-static int rfcomm_dlc_debugfs_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, rfcomm_dlc_debugfs_show, inode->i_private);
-}
-
-static const struct file_operations rfcomm_dlc_debugfs_fops = {
-	.open		= rfcomm_dlc_debugfs_open,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(rfcomm_dlc_debugfs);
 
 static struct dentry *rfcomm_dlc_debugfs;
 
net/bluetooth/rfcomm/sock.c +1 -11
index d606e9212291..aa0db1d1bd9b 100644
@@ -1020,17 +1020,7 @@ static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p)
 	return 0;
 }
 
-static int rfcomm_sock_debugfs_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, rfcomm_sock_debugfs_show, inode->i_private);
-}
-
-static const struct file_operations rfcomm_sock_debugfs_fops = {
-	.open		= rfcomm_sock_debugfs_open,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(rfcomm_sock_debugfs);
 
 static struct dentry *rfcomm_sock_debugfs;
 
net/bluetooth/sco.c +1 -11
index 8f0f9279eac9..529b38996d8b 100644
@@ -1173,17 +1173,7 @@ static int sco_debugfs_show(struct seq_file *f, void *p)
 	return 0;
 }
 
-static int sco_debugfs_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, sco_debugfs_show, inode->i_private);
-}
-
-static const struct file_operations sco_debugfs_fops = {
-	.open		= sco_debugfs_open,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(sco_debugfs);
 
 static struct dentry *sco_debugfs;
 
Signature · 1 line
2.17.0
Reviewed-by on v1 1/1
#2 lore raw
In reply to Yangtao Li
Quoted 4 lines · Yangtao Li

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

-Kees

Quoted 102 lines
---
 net/bluetooth/l2cap_core.c  | 12 +-----------
 net/bluetooth/rfcomm/core.c | 12 +-----------
 net/bluetooth/rfcomm/sock.c | 12 +-----------
 net/bluetooth/sco.c         | 12 +-----------
 4 files changed, 4 insertions(+), 44 deletions(-)
net/bluetooth/l2cap_core.c +1 -11
index d17a4736e47c..38d92ced5fb5 100644
@@ -7615,17 +7615,7 @@ static int l2cap_debugfs_show(struct seq_file *f, void *p)
        return 0;
 }
 
-static int l2cap_debugfs_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, l2cap_debugfs_show, inode->i_private);
-}
-
-static const struct file_operations l2cap_debugfs_fops = {
-       .open           = l2cap_debugfs_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(l2cap_debugfs);
 
 static struct dentry *l2cap_debugfs;
 
net/bluetooth/rfcomm/core.c +1 -11
index b98225d65e87..1a635df80643 100644
@@ -2166,17 +2166,7 @@ static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x)
        return 0;
 }
 
-static int rfcomm_dlc_debugfs_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, rfcomm_dlc_debugfs_show, inode->i_private);
-}
-
-static const struct file_operations rfcomm_dlc_debugfs_fops = {
-       .open           = rfcomm_dlc_debugfs_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(rfcomm_dlc_debugfs);
 
 static struct dentry *rfcomm_dlc_debugfs;
 
net/bluetooth/rfcomm/sock.c +1 -11
index d606e9212291..aa0db1d1bd9b 100644
@@ -1020,17 +1020,7 @@ static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p)
        return 0;
 }
 
-static int rfcomm_sock_debugfs_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, rfcomm_sock_debugfs_show, inode->i_private);
-}
-
-static const struct file_operations rfcomm_sock_debugfs_fops = {
-       .open           = rfcomm_sock_debugfs_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(rfcomm_sock_debugfs);
 
 static struct dentry *rfcomm_sock_debugfs;
 
net/bluetooth/sco.c +1 -12
index 8f0f9279eac9..529b38996d8b 100644
@@ -1173,17 +1173,7 @@ static int sco_debugfs_show(struct seq_file *f, void *p)
        return 0;
 }
 
-static int sco_debugfs_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, sco_debugfs_show, inode->i_private);
-}
-
-static const struct file_operations sco_debugfs_fops = {
-       .open           = sco_debugfs_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(sco_debugfs);
 
 static struct dentry *sco_debugfs;
 
--

2.17.0

Signature · 1 line
Kees Cook
maintainer
#3 lore raw
In reply to Yangtao Li

Hi Yangtao,

Quoted 9 lines

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

---

net/bluetooth/l2cap_core.c  | 12 +-----------
net/bluetooth/rfcomm/core.c | 12 +-----------
net/bluetooth/rfcomm/sock.c | 12 +-----------
net/bluetooth/sco.c         | 12 +-----------
4 files changed, 4 insertions(+), 44 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel