aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2017-11-22 16:15:46 -0500
committerMarcel Holtmann <marcel@holtmann.org>2017-12-13 14:20:34 -0500
commit22b371cbb949e1c8ee4accfead5ee9f3e7f0c114 (patch)
tree46d341ac93f93753e278033e08a0facc1b5df165
parent479f335c1b24b98fd1daae024d2f5d7cc355f1fc (diff)
Bluetooth: introduce DEFINE_SHOW_ATTRIBUTE() macro
This macro deduplicates a lot of similar code across the hci_debugfs.c module. Targeting to be moved to seq_file.h eventually. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--net/bluetooth/hci_debugfs.c184
1 files changed, 18 insertions, 166 deletions
diff --git a/net/bluetooth/hci_debugfs.c b/net/bluetooth/hci_debugfs.c
index e204bfdb5ba2..57403bd567d0 100644
--- a/net/bluetooth/hci_debugfs.c
+++ b/net/bluetooth/hci_debugfs.c
@@ -88,6 +88,9 @@ static int __name ## _show(struct seq_file *f, void *ptr) \
88 return 0; \ 88 return 0; \
89} \ 89} \
90 \ 90 \
91DEFINE_SHOW_ATTRIBUTE(__name)
92
93#define DEFINE_SHOW_ATTRIBUTE(__name) \
91static int __name ## _open(struct inode *inode, struct file *file) \ 94static int __name ## _open(struct inode *inode, struct file *file) \
92{ \ 95{ \
93 return single_open(file, __name ## _show, inode->i_private); \ 96 return single_open(file, __name ## _show, inode->i_private); \
@@ -115,17 +118,7 @@ static int features_show(struct seq_file *f, void *ptr)
115 return 0; 118 return 0;
116} 119}
117 120
118static int features_open(struct inode *inode, struct file *file) 121DEFINE_SHOW_ATTRIBUTE(features);
119{
120 return single_open(file, features_show, inode->i_private);
121}
122
123static const struct file_operations features_fops = {
124 .open = features_open,
125 .read = seq_read,
126 .llseek = seq_lseek,
127 .release = single_release,
128};
129 122
130static int device_id_show(struct seq_file *f, void *ptr) 123static int device_id_show(struct seq_file *f, void *ptr)
131{ 124{
@@ -139,17 +132,7 @@ static int device_id_show(struct seq_file *f, void *ptr)
139 return 0; 132 return 0;
140} 133}
141 134
142static int device_id_open(struct inode *inode, struct file *file) 135DEFINE_SHOW_ATTRIBUTE(device_id);
143{
144 return single_open(file, device_id_show, inode->i_private);
145}
146
147static const struct file_operations device_id_fops = {
148 .open = device_id_open,
149 .read = seq_read,
150 .llseek = seq_lseek,
151 .release = single_release,
152};
153 136
154static int device_list_show(struct seq_file *f, void *ptr) 137static int device_list_show(struct seq_file *f, void *ptr)
155{ 138{
@@ -169,17 +152,7 @@ static int device_list_show(struct seq_file *f, void *ptr)
169 return 0; 152 return 0;
170} 153}
171 154
172static int device_list_open(struct inode *inode, struct file *file) 155DEFINE_SHOW_ATTRIBUTE(device_list);
173{
174 return single_open(file, device_list_show, inode->i_private);
175}
176
177static const struct file_operations device_list_fops = {
178 .open = device_list_open,
179 .read = seq_read,
180 .llseek = seq_lseek,
181 .release = single_release,
182};
183 156
184static int blacklist_show(struct seq_file *f, void *p) 157static int blacklist_show(struct seq_file *f, void *p)
185{ 158{
@@ -194,17 +167,7 @@ static int blacklist_show(struct seq_file *f, void *p)
194 return 0; 167 return 0;
195} 168}
196 169
197static int blacklist_open(struct inode *inode, struct file *file) 170DEFINE_SHOW_ATTRIBUTE(blacklist);
198{
199 return single_open(file, blacklist_show, inode->i_private);
200}
201
202static const struct file_operations blacklist_fops = {
203 .open = blacklist_open,
204 .read = seq_read,
205 .llseek = seq_lseek,
206 .release = single_release,
207};
208 171
209static int uuids_show(struct seq_file *f, void *p) 172static int uuids_show(struct seq_file *f, void *p)
210{ 173{
@@ -229,17 +192,7 @@ static int uuids_show(struct seq_file *f, void *p)
229 return 0; 192 return 0;
230} 193}
231 194
232static int uuids_open(struct inode *inode, struct file *file) 195DEFINE_SHOW_ATTRIBUTE(uuids);
233{
234 return single_open(file, uuids_show, inode->i_private);
235}
236
237static const struct file_operations uuids_fops = {
238 .open = uuids_open,
239 .read = seq_read,
240 .llseek = seq_lseek,
241 .release = single_release,
242};
243 196
244static int remote_oob_show(struct seq_file *f, void *ptr) 197static int remote_oob_show(struct seq_file *f, void *ptr)
245{ 198{
@@ -258,17 +211,7 @@ static int remote_oob_show(struct seq_file *f, void *ptr)
258 return 0; 211 return 0;
259} 212}
260 213
261static int remote_oob_open(struct inode *inode, struct file *file) 214DEFINE_SHOW_ATTRIBUTE(remote_oob);
262{
263 return single_open(file, remote_oob_show, inode->i_private);
264}
265
266static const struct file_operations remote_oob_fops = {
267 .open = remote_oob_open,
268 .read = seq_read,
269 .llseek = seq_lseek,
270 .release = single_release,
271};
272 215
273static int conn_info_min_age_set(void *data, u64 val) 216static int conn_info_min_age_set(void *data, u64 val)
274{ 217{
@@ -432,17 +375,7 @@ static int inquiry_cache_show(struct seq_file *f, void *p)
432 return 0; 375 return 0;
433} 376}
434 377
435static int inquiry_cache_open(struct inode *inode, struct file *file) 378DEFINE_SHOW_ATTRIBUTE(inquiry_cache);
436{
437 return single_open(file, inquiry_cache_show, inode->i_private);
438}
439
440static const struct file_operations inquiry_cache_fops = {
441 .open = inquiry_cache_open,
442 .read = seq_read,
443 .llseek = seq_lseek,
444 .release = single_release,
445};
446 379
447static int link_keys_show(struct seq_file *f, void *ptr) 380static int link_keys_show(struct seq_file *f, void *ptr)
448{ 381{
@@ -458,17 +391,7 @@ static int link_keys_show(struct seq_file *f, void *ptr)
458 return 0; 391 return 0;
459} 392}
460 393
461static int link_keys_open(struct inode *inode, struct file *file) 394DEFINE_SHOW_ATTRIBUTE(link_keys);
462{
463 return single_open(file, link_keys_show, inode->i_private);
464}
465
466static const struct file_operations link_keys_fops = {
467 .open = link_keys_open,
468 .read = seq_read,
469 .llseek = seq_lseek,
470 .release = single_release,
471};
472 395
473static int dev_class_show(struct seq_file *f, void *ptr) 396static int dev_class_show(struct seq_file *f, void *ptr)
474{ 397{
@@ -482,17 +405,7 @@ static int dev_class_show(struct seq_file *f, void *ptr)
482 return 0; 405 return 0;
483} 406}
484 407
485static int dev_class_open(struct inode *inode, struct file *file) 408DEFINE_SHOW_ATTRIBUTE(dev_class);
486{
487 return single_open(file, dev_class_show, inode->i_private);
488}
489
490static const struct file_operations dev_class_fops = {
491 .open = dev_class_open,
492 .read = seq_read,
493 .llseek = seq_lseek,
494 .release = single_release,
495};
496 409
497static int voice_setting_get(void *data, u64 *val) 410static int voice_setting_get(void *data, u64 *val)
498{ 411{
@@ -681,17 +594,7 @@ static int identity_show(struct seq_file *f, void *p)
681 return 0; 594 return 0;
682} 595}
683 596
684static int identity_open(struct inode *inode, struct file *file) 597DEFINE_SHOW_ATTRIBUTE(identity);
685{
686 return single_open(file, identity_show, inode->i_private);
687}
688
689static const struct file_operations identity_fops = {
690 .open = identity_open,
691 .read = seq_read,
692 .llseek = seq_lseek,
693 .release = single_release,
694};
695 598
696static int rpa_timeout_set(void *data, u64 val) 599static int rpa_timeout_set(void *data, u64 val)
697{ 600{
@@ -735,17 +638,7 @@ static int random_address_show(struct seq_file *f, void *p)
735 return 0; 638 return 0;
736} 639}
737 640
738static int random_address_open(struct inode *inode, struct file *file) 641DEFINE_SHOW_ATTRIBUTE(random_address);
739{
740 return single_open(file, random_address_show, inode->i_private);
741}
742
743static const struct file_operations random_address_fops = {
744 .open = random_address_open,
745 .read = seq_read,
746 .llseek = seq_lseek,
747 .release = single_release,
748};
749 642
750static int static_address_show(struct seq_file *f, void *p) 643static int static_address_show(struct seq_file *f, void *p)
751{ 644{
@@ -758,17 +651,7 @@ static int static_address_show(struct seq_file *f, void *p)
758 return 0; 651 return 0;
759} 652}
760 653
761static int static_address_open(struct inode *inode, struct file *file) 654DEFINE_SHOW_ATTRIBUTE(static_address);
762{
763 return single_open(file, static_address_show, inode->i_private);
764}
765
766static const struct file_operations static_address_fops = {
767 .open = static_address_open,
768 .read = seq_read,
769 .llseek = seq_lseek,
770 .release = single_release,
771};
772 655
773static ssize_t force_static_address_read(struct file *file, 656static ssize_t force_static_address_read(struct file *file,
774 char __user *user_buf, 657 char __user *user_buf,
@@ -830,17 +713,7 @@ static int white_list_show(struct seq_file *f, void *ptr)
830 return 0; 713 return 0;
831} 714}
832 715
833static int white_list_open(struct inode *inode, struct file *file) 716DEFINE_SHOW_ATTRIBUTE(white_list);
834{
835 return single_open(file, white_list_show, inode->i_private);
836}
837
838static const struct file_operations white_list_fops = {
839 .open = white_list_open,
840 .read = seq_read,
841 .llseek = seq_lseek,
842 .release = single_release,
843};
844 717
845static int identity_resolving_keys_show(struct seq_file *f, void *ptr) 718static int identity_resolving_keys_show(struct seq_file *f, void *ptr)
846{ 719{
@@ -858,18 +731,7 @@ static int identity_resolving_keys_show(struct seq_file *f, void *ptr)
858 return 0; 731 return 0;
859} 732}
860 733
861static int identity_resolving_keys_open(struct inode *inode, struct file *file) 734DEFINE_SHOW_ATTRIBUTE(identity_resolving_keys);
862{
863 return single_open(file, identity_resolving_keys_show,
864 inode->i_private);
865}
866
867static const struct file_operations identity_resolving_keys_fops = {
868 .open = identity_resolving_keys_open,
869 .read = seq_read,
870 .llseek = seq_lseek,
871 .release = single_release,
872};
873 735
874static int long_term_keys_show(struct seq_file *f, void *ptr) 736static int long_term_keys_show(struct seq_file *f, void *ptr)
875{ 737{
@@ -887,17 +749,7 @@ static int long_term_keys_show(struct seq_file *f, void *ptr)
887 return 0; 749 return 0;
888} 750}
889 751
890static int long_term_keys_open(struct inode *inode, struct file *file) 752DEFINE_SHOW_ATTRIBUTE(long_term_keys);
891{
892 return single_open(file, long_term_keys_show, inode->i_private);
893}
894
895static const struct file_operations long_term_keys_fops = {
896 .open = long_term_keys_open,
897 .read = seq_read,
898 .llseek = seq_lseek,
899 .release = single_release,
900};
901 753
902static int conn_min_interval_set(void *data, u64 val) 754static int conn_min_interval_set(void *data, u64 val)
903{ 755{