Skip to content

Commit

Permalink
Bluetooth: introduce DEFINE_SHOW_ATTRIBUTE() macro
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andy Shevchenko authored and Marcel Holtmann committed Dec 13, 2017
1 parent 479f335 commit 22b371c
Showing 1 changed file with 18 additions and 166 deletions.
184 changes: 18 additions & 166 deletions net/bluetooth/hci_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ static int __name ## _show(struct seq_file *f, void *ptr) \
return 0; \
} \
\
DEFINE_SHOW_ATTRIBUTE(__name)

#define DEFINE_SHOW_ATTRIBUTE(__name) \
static int __name ## _open(struct inode *inode, struct file *file) \
{ \
return single_open(file, __name ## _show, inode->i_private); \
Expand Down Expand Up @@ -115,17 +118,7 @@ static int features_show(struct seq_file *f, void *ptr)
return 0;
}

static int features_open(struct inode *inode, struct file *file)
{
return single_open(file, features_show, inode->i_private);
}

static const struct file_operations features_fops = {
.open = features_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(features);

static int device_id_show(struct seq_file *f, void *ptr)
{
Expand All @@ -139,17 +132,7 @@ static int device_id_show(struct seq_file *f, void *ptr)
return 0;
}

static int device_id_open(struct inode *inode, struct file *file)
{
return single_open(file, device_id_show, inode->i_private);
}

static const struct file_operations device_id_fops = {
.open = device_id_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(device_id);

static int device_list_show(struct seq_file *f, void *ptr)
{
Expand All @@ -169,17 +152,7 @@ static int device_list_show(struct seq_file *f, void *ptr)
return 0;
}

static int device_list_open(struct inode *inode, struct file *file)
{
return single_open(file, device_list_show, inode->i_private);
}

static const struct file_operations device_list_fops = {
.open = device_list_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(device_list);

static int blacklist_show(struct seq_file *f, void *p)
{
Expand All @@ -194,17 +167,7 @@ static int blacklist_show(struct seq_file *f, void *p)
return 0;
}

static int blacklist_open(struct inode *inode, struct file *file)
{
return single_open(file, blacklist_show, inode->i_private);
}

static const struct file_operations blacklist_fops = {
.open = blacklist_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(blacklist);

static int uuids_show(struct seq_file *f, void *p)
{
Expand All @@ -229,17 +192,7 @@ static int uuids_show(struct seq_file *f, void *p)
return 0;
}

static int uuids_open(struct inode *inode, struct file *file)
{
return single_open(file, uuids_show, inode->i_private);
}

static const struct file_operations uuids_fops = {
.open = uuids_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(uuids);

static int remote_oob_show(struct seq_file *f, void *ptr)
{
Expand All @@ -258,17 +211,7 @@ static int remote_oob_show(struct seq_file *f, void *ptr)
return 0;
}

static int remote_oob_open(struct inode *inode, struct file *file)
{
return single_open(file, remote_oob_show, inode->i_private);
}

static const struct file_operations remote_oob_fops = {
.open = remote_oob_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(remote_oob);

static int conn_info_min_age_set(void *data, u64 val)
{
Expand Down Expand Up @@ -432,17 +375,7 @@ static int inquiry_cache_show(struct seq_file *f, void *p)
return 0;
}

static int inquiry_cache_open(struct inode *inode, struct file *file)
{
return single_open(file, inquiry_cache_show, inode->i_private);
}

static const struct file_operations inquiry_cache_fops = {
.open = inquiry_cache_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(inquiry_cache);

static int link_keys_show(struct seq_file *f, void *ptr)
{
Expand All @@ -458,17 +391,7 @@ static int link_keys_show(struct seq_file *f, void *ptr)
return 0;
}

static int link_keys_open(struct inode *inode, struct file *file)
{
return single_open(file, link_keys_show, inode->i_private);
}

static const struct file_operations link_keys_fops = {
.open = link_keys_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(link_keys);

static int dev_class_show(struct seq_file *f, void *ptr)
{
Expand All @@ -482,17 +405,7 @@ static int dev_class_show(struct seq_file *f, void *ptr)
return 0;
}

static int dev_class_open(struct inode *inode, struct file *file)
{
return single_open(file, dev_class_show, inode->i_private);
}

static const struct file_operations dev_class_fops = {
.open = dev_class_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(dev_class);

static int voice_setting_get(void *data, u64 *val)
{
Expand Down Expand Up @@ -681,17 +594,7 @@ static int identity_show(struct seq_file *f, void *p)
return 0;
}

static int identity_open(struct inode *inode, struct file *file)
{
return single_open(file, identity_show, inode->i_private);
}

static const struct file_operations identity_fops = {
.open = identity_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(identity);

static int rpa_timeout_set(void *data, u64 val)
{
Expand Down Expand Up @@ -735,17 +638,7 @@ static int random_address_show(struct seq_file *f, void *p)
return 0;
}

static int random_address_open(struct inode *inode, struct file *file)
{
return single_open(file, random_address_show, inode->i_private);
}

static const struct file_operations random_address_fops = {
.open = random_address_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(random_address);

static int static_address_show(struct seq_file *f, void *p)
{
Expand All @@ -758,17 +651,7 @@ static int static_address_show(struct seq_file *f, void *p)
return 0;
}

static int static_address_open(struct inode *inode, struct file *file)
{
return single_open(file, static_address_show, inode->i_private);
}

static const struct file_operations static_address_fops = {
.open = static_address_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(static_address);

static ssize_t force_static_address_read(struct file *file,
char __user *user_buf,
Expand Down Expand Up @@ -830,17 +713,7 @@ static int white_list_show(struct seq_file *f, void *ptr)
return 0;
}

static int white_list_open(struct inode *inode, struct file *file)
{
return single_open(file, white_list_show, inode->i_private);
}

static const struct file_operations white_list_fops = {
.open = white_list_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(white_list);

static int identity_resolving_keys_show(struct seq_file *f, void *ptr)
{
Expand All @@ -858,18 +731,7 @@ static int identity_resolving_keys_show(struct seq_file *f, void *ptr)
return 0;
}

static int identity_resolving_keys_open(struct inode *inode, struct file *file)
{
return single_open(file, identity_resolving_keys_show,
inode->i_private);
}

static const struct file_operations identity_resolving_keys_fops = {
.open = identity_resolving_keys_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(identity_resolving_keys);

static int long_term_keys_show(struct seq_file *f, void *ptr)
{
Expand All @@ -887,17 +749,7 @@ static int long_term_keys_show(struct seq_file *f, void *ptr)
return 0;
}

static int long_term_keys_open(struct inode *inode, struct file *file)
{
return single_open(file, long_term_keys_show, inode->i_private);
}

static const struct file_operations long_term_keys_fops = {
.open = long_term_keys_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(long_term_keys);

static int conn_min_interval_set(void *data, u64 val)
{
Expand Down

0 comments on commit 22b371c

Please sign in to comment.