Skip to content

Commit

Permalink
USB: dwc2: 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: John Youn <johnyoun@synopsys.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 e8c56f2 commit fd9197e
Showing 1 changed file with 6 additions and 78 deletions.
84 changes: 6 additions & 78 deletions drivers/usb/dwc2/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,7 @@ static int state_show(struct seq_file *seq, void *v)

return 0;
}

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

static const struct file_operations state_fops = {
.owner = THIS_MODULE,
.open = state_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(state);

/**
* fifo_show - debugfs: show the fifo information
Expand Down Expand Up @@ -219,19 +207,7 @@ static int fifo_show(struct seq_file *seq, void *v)

return 0;
}

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

static const struct file_operations fifo_fops = {
.owner = THIS_MODULE,
.open = fifo_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(fifo);

static const char *decode_direction(int is_in)
{
Expand Down Expand Up @@ -303,19 +279,7 @@ static int ep_show(struct seq_file *seq, void *v)

return 0;
}

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

static const struct file_operations ep_fops = {
.owner = THIS_MODULE,
.open = ep_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(ep);

/**
* dwc2_hsotg_create_debug - create debugfs directory and files
Expand Down Expand Up @@ -770,19 +734,7 @@ static int params_show(struct seq_file *seq, void *v)

return 0;
}

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

static const struct file_operations params_fops = {
.owner = THIS_MODULE,
.open = params_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(params);

static int hw_params_show(struct seq_file *seq, void *v)
{
Expand Down Expand Up @@ -817,19 +769,7 @@ static int hw_params_show(struct seq_file *seq, void *v)

return 0;
}

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

static const struct file_operations hw_params_fops = {
.owner = THIS_MODULE,
.open = hw_params_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(hw_params);

static int dr_mode_show(struct seq_file *seq, void *v)
{
Expand All @@ -840,19 +780,7 @@ static int dr_mode_show(struct seq_file *seq, void *v)
seq_printf(seq, "%s\n", dr_mode);
return 0;
}

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

static const struct file_operations dr_mode_fops = {
.owner = THIS_MODULE,
.open = dr_mode_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
DEFINE_SHOW_ATTRIBUTE(dr_mode);

int dwc2_debugfs_init(struct dwc2_hsotg *hsotg)
{
Expand Down

0 comments on commit fd9197e

Please sign in to comment.