aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/core.c
diff options
context:
space:
mode:
authorAntoine Ténart <antoine.tenart@free-electrons.com>2014-04-10 09:07:50 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-04-22 08:47:02 -0400
commite5b3b2d9ed202697a937c282f9c4d93b1e3e0848 (patch)
tree787cdc0ff48a468a7a1f466c4bf60019eb99a30e /drivers/pinctrl/core.c
parenteb171a997de8b746f4d52b23108d64e9f88f0a09 (diff)
pinctrl: allows not to define the get_group_pins operation
When using a group only pinctrl driver, which does not have any information on the pins it is useless to define a get_group_pins always returning an empty list of pins. When not using get_group_pin[1], a driver must implement it so pins = NULL and num_pins = 0. This patch makes it the default behaviour if not defined in the pinctrl driver when used in pinmux enable and disable funtions and in pinctrl_groups_show. It also adds a check in pinctrl_get_group_pins and return -EINVAL if not defined. This function is called in the gpiolib when adding when pingroup range. It cannot be used if no group is defined, so this seams reasonable. [1] get_group_pin(struct pinctrl_dev *pctldev, unsigned selector, const unsigned **pins, unsigned *num_pins); Signed-off-by: Antoine Ténart <antoine.tenart@free-electrons.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/core.c')
-rw-r--r--drivers/pinctrl/core.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index c0fe6091566a..e09474ecde23 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -468,6 +468,9 @@ int pinctrl_get_group_pins(struct pinctrl_dev *pctldev, const char *pin_group,
468 const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; 468 const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
469 int gs; 469 int gs;
470 470
471 if (!pctlops->get_group_pins)
472 return -EINVAL;
473
471 gs = pinctrl_get_group_selector(pctldev, pin_group); 474 gs = pinctrl_get_group_selector(pctldev, pin_group);
472 if (gs < 0) 475 if (gs < 0)
473 return gs; 476 return gs;
@@ -1362,15 +1365,16 @@ static int pinctrl_groups_show(struct seq_file *s, void *what)
1362 1365
1363 seq_puts(s, "registered pin groups:\n"); 1366 seq_puts(s, "registered pin groups:\n");
1364 while (selector < ngroups) { 1367 while (selector < ngroups) {
1365 const unsigned *pins; 1368 const unsigned *pins = NULL;
1366 unsigned num_pins; 1369 unsigned num_pins = 0;
1367 const char *gname = ops->get_group_name(pctldev, selector); 1370 const char *gname = ops->get_group_name(pctldev, selector);
1368 const char *pname; 1371 const char *pname;
1369 int ret; 1372 int ret = 0;
1370 int i; 1373 int i;
1371 1374
1372 ret = ops->get_group_pins(pctldev, selector, 1375 if (ops->get_group_pins)
1373 &pins, &num_pins); 1376 ret = ops->get_group_pins(pctldev, selector,
1377 &pins, &num_pins);
1374 if (ret) 1378 if (ret)
1375 seq_printf(s, "%s [ERROR GETTING PINS]\n", 1379 seq_printf(s, "%s [ERROR GETTING PINS]\n",
1376 gname); 1380 gname);
@@ -1694,8 +1698,7 @@ static int pinctrl_check_ops(struct pinctrl_dev *pctldev)
1694 1698
1695 if (!ops || 1699 if (!ops ||
1696 !ops->get_groups_count || 1700 !ops->get_groups_count ||
1697 !ops->get_group_name || 1701 !ops->get_group_name)
1698 !ops->get_group_pins)
1699 return -EINVAL; 1702 return -EINVAL;
1700 1703
1701 if (ops->dt_node_to_map && !ops->dt_free_map) 1704 if (ops->dt_node_to_map && !ops->dt_free_map)