summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYangtao Li <tiny.windzz@gmail.com>2018-11-30 11:36:17 -0500
committerLinus Walleij <linus.walleij@linaro.org>2018-12-07 05:11:10 -0500
commit0819dc72ea70a90ad2a070e76708ee53bac47caa (patch)
treec4436ea8e1b44a790c6f905dd3f4b9f05ed24479
parent4be1eaf322f07bb9694618fd2763a3a1f0a3dd25 (diff)
pinctrl: Change to use DEFINE_SHOW_ATTRIBUTE macro
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. Signed-off-by: Yangtao Li <tiny.windzz@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/pinctrl/pinconf.c29
-rw-r--r--drivers/pinctrl/pinmux.c29
2 files changed, 8 insertions, 50 deletions
diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
index d3fe14394b73..2c7229380f08 100644
--- a/drivers/pinctrl/pinconf.c
+++ b/drivers/pinctrl/pinconf.c
@@ -366,29 +366,8 @@ static int pinconf_groups_show(struct seq_file *s, void *what)
366 return 0; 366 return 0;
367} 367}
368 368
369static int pinconf_pins_open(struct inode *inode, struct file *file) 369DEFINE_SHOW_ATTRIBUTE(pinconf_pins);
370{ 370DEFINE_SHOW_ATTRIBUTE(pinconf_groups);
371 return single_open(file, pinconf_pins_show, inode->i_private);
372}
373
374static int pinconf_groups_open(struct inode *inode, struct file *file)
375{
376 return single_open(file, pinconf_groups_show, inode->i_private);
377}
378
379static const struct file_operations pinconf_pins_ops = {
380 .open = pinconf_pins_open,
381 .read = seq_read,
382 .llseek = seq_lseek,
383 .release = single_release,
384};
385
386static const struct file_operations pinconf_groups_ops = {
387 .open = pinconf_groups_open,
388 .read = seq_read,
389 .llseek = seq_lseek,
390 .release = single_release,
391};
392 371
393#define MAX_NAME_LEN 15 372#define MAX_NAME_LEN 15
394 373
@@ -613,9 +592,9 @@ void pinconf_init_device_debugfs(struct dentry *devroot,
613 struct pinctrl_dev *pctldev) 592 struct pinctrl_dev *pctldev)
614{ 593{
615 debugfs_create_file("pinconf-pins", S_IFREG | S_IRUGO, 594 debugfs_create_file("pinconf-pins", S_IFREG | S_IRUGO,
616 devroot, pctldev, &pinconf_pins_ops); 595 devroot, pctldev, &pinconf_pins_fops);
617 debugfs_create_file("pinconf-groups", S_IFREG | S_IRUGO, 596 debugfs_create_file("pinconf-groups", S_IFREG | S_IRUGO,
618 devroot, pctldev, &pinconf_groups_ops); 597 devroot, pctldev, &pinconf_groups_fops);
619 debugfs_create_file("pinconf-config", (S_IRUGO | S_IWUSR | S_IWGRP), 598 debugfs_create_file("pinconf-config", (S_IRUGO | S_IWUSR | S_IWGRP),
620 devroot, pctldev, &pinconf_dbg_pinconfig_fops); 599 devroot, pctldev, &pinconf_dbg_pinconfig_fops);
621} 600}
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 5780442c068b..4d0cc1889dd9 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -644,37 +644,16 @@ void pinmux_show_setting(struct seq_file *s,
644 setting->data.mux.func); 644 setting->data.mux.func);
645} 645}
646 646
647static int pinmux_functions_open(struct inode *inode, struct file *file) 647DEFINE_SHOW_ATTRIBUTE(pinmux_functions);
648{ 648DEFINE_SHOW_ATTRIBUTE(pinmux_pins);
649 return single_open(file, pinmux_functions_show, inode->i_private);
650}
651
652static int pinmux_pins_open(struct inode *inode, struct file *file)
653{
654 return single_open(file, pinmux_pins_show, inode->i_private);
655}
656
657static const struct file_operations pinmux_functions_ops = {
658 .open = pinmux_functions_open,
659 .read = seq_read,
660 .llseek = seq_lseek,
661 .release = single_release,
662};
663
664static const struct file_operations pinmux_pins_ops = {
665 .open = pinmux_pins_open,
666 .read = seq_read,
667 .llseek = seq_lseek,
668 .release = single_release,
669};
670 649
671void pinmux_init_device_debugfs(struct dentry *devroot, 650void pinmux_init_device_debugfs(struct dentry *devroot,
672 struct pinctrl_dev *pctldev) 651 struct pinctrl_dev *pctldev)
673{ 652{
674 debugfs_create_file("pinmux-functions", S_IFREG | S_IRUGO, 653 debugfs_create_file("pinmux-functions", S_IFREG | S_IRUGO,
675 devroot, pctldev, &pinmux_functions_ops); 654 devroot, pctldev, &pinmux_functions_fops);
676 debugfs_create_file("pinmux-pins", S_IFREG | S_IRUGO, 655 debugfs_create_file("pinmux-pins", S_IFREG | S_IRUGO,
677 devroot, pctldev, &pinmux_pins_ops); 656 devroot, pctldev, &pinmux_pins_fops);
678} 657}
679 658
680#endif /* CONFIG_DEBUG_FS */ 659#endif /* CONFIG_DEBUG_FS */