Skip to content

Commit

Permalink
USB: chipidea: Re-use DEFINE_SHOW_ATTRIBUTE() macro
Browse files Browse the repository at this point in the history
...instead of open coding file operations followed by custom ->open()
callbacks per each attribute.

Cc: Peter Chen <Peter.Chen@nxp.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Andy Shevchenko authored and Greg Kroah-Hartman committed Mar 9, 2018
1 parent 02cad96 commit e8c56f2
Showing 1 changed file with 5 additions and 60 deletions.
65 changes: 5 additions & 60 deletions drivers/usb/chipidea/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,7 @@ static int ci_device_show(struct seq_file *s, void *data)

return 0;
}

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

static const struct file_operations ci_device_fops = {
.open = ci_device_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(ci_device);

/**
* ci_port_test_show: reads port test mode
Expand Down Expand Up @@ -156,18 +145,7 @@ static int ci_qheads_show(struct seq_file *s, void *data)

return 0;
}

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

static const struct file_operations ci_qheads_fops = {
.open = ci_qheads_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(ci_qheads);

/**
* ci_requests_show: DMA contents of all requests currently queued (all endpts)
Expand Down Expand Up @@ -204,18 +182,7 @@ static int ci_requests_show(struct seq_file *s, void *data)

return 0;
}

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

static const struct file_operations ci_requests_fops = {
.open = ci_requests_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(ci_requests);

static int ci_otg_show(struct seq_file *s, void *unused)
{
Expand Down Expand Up @@ -278,18 +245,7 @@ static int ci_otg_show(struct seq_file *s, void *unused)

return 0;
}

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

static const struct file_operations ci_otg_fops = {
.open = ci_otg_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(ci_otg);

static int ci_role_show(struct seq_file *s, void *data)
{
Expand Down Expand Up @@ -376,18 +332,7 @@ static int ci_registers_show(struct seq_file *s, void *unused)

return 0;
}

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

static const struct file_operations ci_registers_fops = {
.open = ci_registers_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(ci_registers);

/**
* dbg_create_files: initializes the attribute interface
Expand Down

0 comments on commit e8c56f2

Please sign in to comment.