Skip to content

Commit 932640c

Browse files
andy-shevlinusw
authored andcommitted
pinctrl: Use DEFINE_SHOW_STORE_ATTRIBUTE() helper for debugfs
Use DEFINE_SHOW_STORE_ATTRIBUTE() helper for read-write file to reduce some duplicated code. Signed-off-by: Andy Shevchenko <[email protected]> Message-ID: <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent b5fe46e commit 932640c

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

drivers/pinctrl/pinmux.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ static int pinmux_functions_show(struct seq_file *s, void *what)
578578

579579
return 0;
580580
}
581+
DEFINE_SHOW_ATTRIBUTE(pinmux_functions);
581582

582583
static int pinmux_pins_show(struct seq_file *s, void *what)
583584
{
@@ -650,6 +651,7 @@ static int pinmux_pins_show(struct seq_file *s, void *what)
650651

651652
return 0;
652653
}
654+
DEFINE_SHOW_ATTRIBUTE(pinmux_pins);
653655

654656
void pinmux_show_map(struct seq_file *s, const struct pinctrl_map *map)
655657
{
@@ -672,10 +674,12 @@ void pinmux_show_setting(struct seq_file *s,
672674
setting->data.mux.func);
673675
}
674676

675-
DEFINE_SHOW_ATTRIBUTE(pinmux_functions);
676-
DEFINE_SHOW_ATTRIBUTE(pinmux_pins);
677+
static int pinmux_select_show(struct seq_file *s, void *unused)
678+
{
679+
return -EPERM;
680+
}
677681

678-
static ssize_t pinmux_select(struct file *file, const char __user *user_buf,
682+
static ssize_t pinmux_select_write(struct file *file, const char __user *user_buf,
679683
size_t len, loff_t *ppos)
680684
{
681685
struct seq_file *sfile = file->private_data;
@@ -749,19 +753,7 @@ static ssize_t pinmux_select(struct file *file, const char __user *user_buf,
749753

750754
return ret;
751755
}
752-
753-
static int pinmux_select_open(struct inode *inode, struct file *file)
754-
{
755-
return single_open(file, NULL, inode->i_private);
756-
}
757-
758-
static const struct file_operations pinmux_select_ops = {
759-
.owner = THIS_MODULE,
760-
.open = pinmux_select_open,
761-
.write = pinmux_select,
762-
.llseek = no_llseek,
763-
.release = single_release,
764-
};
756+
DEFINE_SHOW_STORE_ATTRIBUTE(pinmux_select);
765757

766758
void pinmux_init_device_debugfs(struct dentry *devroot,
767759
struct pinctrl_dev *pctldev)
@@ -771,7 +763,7 @@ void pinmux_init_device_debugfs(struct dentry *devroot,
771763
debugfs_create_file("pinmux-pins", 0444,
772764
devroot, pctldev, &pinmux_pins_fops);
773765
debugfs_create_file("pinmux-select", 0200,
774-
devroot, pctldev, &pinmux_select_ops);
766+
devroot, pctldev, &pinmux_select_fops);
775767
}
776768

777769
#endif /* CONFIG_DEBUG_FS */

0 commit comments

Comments
 (0)