linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] pinctrl: pinconf-generic: scan also referenced phandle node
@ 2015-03-19 20:17 Baruch Siach
  2015-03-19 20:17 ` [PATCH 2/2] pinctrl: pinconf-generic: add dt node names to error messages Baruch Siach
  2015-03-27  8:52 ` [PATCH 1/2] pinctrl: pinconf-generic: scan also referenced phandle node Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Baruch Siach @ 2015-03-19 20:17 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, Baruch Siach

Make pinconf_generic_dt_node_to_map() also scan the dt pin configuration node
directly referenced by phandle, not only its child nodes.

The "parent scan" feature needs a few other changes:

   * Move the pinconf_generic_dt_node_to_map() error handling code to a common
     place, under the 'exit' label.

   * Move the pins/groups strings count earlier in
     pinconf_generic_dt_subnode_to_map(), to allow us to bail out early when
     these properties are missing or wrong

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 drivers/pinctrl/pinconf-generic.c | 48 +++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index 4db92f64b4de..b5fbfb3584d9 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -283,11 +283,26 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
 	struct device *dev = pctldev->dev;
 	unsigned long *configs = NULL;
 	unsigned num_configs = 0;
-	unsigned reserve;
+	unsigned reserve, strings_count;
 	struct property *prop;
 	const char *group;
 	const char *subnode_target_type = "pins";
 
+	ret = of_property_count_strings(np, "pins");
+	if (ret < 0) {
+		ret = of_property_count_strings(np, "groups");
+		if (ret < 0)
+			/* skip this node; may contain config child nodes */
+			return 0;
+		if (type == PIN_MAP_TYPE_INVALID)
+			type = PIN_MAP_TYPE_CONFIGS_GROUP;
+		subnode_target_type = "groups";
+	} else {
+		if (type == PIN_MAP_TYPE_INVALID)
+			type = PIN_MAP_TYPE_CONFIGS_PIN;
+	}
+	strings_count = ret;
+
 	ret = of_property_read_string(np, "function", &function);
 	if (ret < 0) {
 		/* EINVAL=missing, which is fine since it's optional */
@@ -309,21 +324,7 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
 	if (num_configs)
 		reserve++;
 
-	ret = of_property_count_strings(np, "pins");
-	if (ret < 0) {
-		ret = of_property_count_strings(np, "groups");
-		if (ret < 0) {
-			dev_err(dev, "could not parse property pins/groups\n");
-			goto exit;
-		}
-		if (type == PIN_MAP_TYPE_INVALID)
-			type = PIN_MAP_TYPE_CONFIGS_GROUP;
-		subnode_target_type = "groups";
-	} else {
-		if (type == PIN_MAP_TYPE_INVALID)
-			type = PIN_MAP_TYPE_CONFIGS_PIN;
-	}
-	reserve *= ret;
+	reserve *= strings_count;
 
 	ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps,
 			num_maps, reserve);
@@ -367,15 +368,22 @@ int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*map = NULL;
 	*num_maps = 0;
 
+	ret = pinconf_generic_dt_subnode_to_map(pctldev, np_config, map,
+						&reserved_maps, num_maps, type);
+	if (ret < 0)
+		goto exit;
+
 	for_each_child_of_node(np_config, np) {
 		ret = pinconf_generic_dt_subnode_to_map(pctldev, np, map,
 					&reserved_maps, num_maps, type);
-		if (ret < 0) {
-			pinctrl_utils_dt_free_map(pctldev, *map, *num_maps);
-			return ret;
-		}
+		if (ret < 0)
+			goto exit;
 	}
 	return 0;
+
+exit:
+	pinctrl_utils_dt_free_map(pctldev, *map, *num_maps);
+	return ret;
 }
 EXPORT_SYMBOL_GPL(pinconf_generic_dt_node_to_map);
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] pinctrl: pinconf-generic: add dt node names to error messages
  2015-03-19 20:17 [PATCH 1/2] pinctrl: pinconf-generic: scan also referenced phandle node Baruch Siach
@ 2015-03-19 20:17 ` Baruch Siach
  2015-03-27  8:53   ` Linus Walleij
  2015-03-27  8:52 ` [PATCH 1/2] pinctrl: pinconf-generic: scan also referenced phandle node Linus Walleij
  1 sibling, 1 reply; 4+ messages in thread
From: Baruch Siach @ 2015-03-19 20:17 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, Baruch Siach

This makes the error message much more useful.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 drivers/pinctrl/pinconf-generic.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index b5fbfb3584d9..e63ad9fbd388 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -307,14 +307,16 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
 	if (ret < 0) {
 		/* EINVAL=missing, which is fine since it's optional */
 		if (ret != -EINVAL)
-			dev_err(dev, "could not parse property function\n");
+			dev_err(dev, "%s: could not parse property function\n",
+				of_node_full_name(np));
 		function = NULL;
 	}
 
 	ret = pinconf_generic_parse_dt_config(np, pctldev, &configs,
 					      &num_configs);
 	if (ret < 0) {
-		dev_err(dev, "could not parse node property\n");
+		dev_err(dev, "%s: could not parse node property\n",
+			of_node_full_name(np));
 		return ret;
 	}
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] pinctrl: pinconf-generic: scan also referenced phandle node
  2015-03-19 20:17 [PATCH 1/2] pinctrl: pinconf-generic: scan also referenced phandle node Baruch Siach
  2015-03-19 20:17 ` [PATCH 2/2] pinctrl: pinconf-generic: add dt node names to error messages Baruch Siach
@ 2015-03-27  8:52 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2015-03-27  8:52 UTC (permalink / raw)
  To: Baruch Siach; +Cc: linux-gpio@vger.kernel.org

On Thu, Mar 19, 2015 at 9:17 PM, Baruch Siach <baruch@tkos.co.il> wrote:

> Make pinconf_generic_dt_node_to_map() also scan the dt pin configuration node
> directly referenced by phandle, not only its child nodes.
>
> The "parent scan" feature needs a few other changes:
>
>    * Move the pinconf_generic_dt_node_to_map() error handling code to a common
>      place, under the 'exit' label.
>
>    * Move the pins/groups strings count earlier in
>      pinconf_generic_dt_subnode_to_map(), to allow us to bail out early when
>      these properties are missing or wrong
>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>

phandle? Is's the parent node right?

Patch applied anyway, the code looks exactly like what I wanted.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] pinctrl: pinconf-generic: add dt node names to error messages
  2015-03-19 20:17 ` [PATCH 2/2] pinctrl: pinconf-generic: add dt node names to error messages Baruch Siach
@ 2015-03-27  8:53   ` Linus Walleij
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2015-03-27  8:53 UTC (permalink / raw)
  To: Baruch Siach; +Cc: linux-gpio@vger.kernel.org

On Thu, Mar 19, 2015 at 9:17 PM, Baruch Siach <baruch@tkos.co.il> wrote:

> This makes the error message much more useful.
>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>

Patch applied.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-27  8:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-19 20:17 [PATCH 1/2] pinctrl: pinconf-generic: scan also referenced phandle node Baruch Siach
2015-03-19 20:17 ` [PATCH 2/2] pinctrl: pinconf-generic: add dt node names to error messages Baruch Siach
2015-03-27  8:53   ` Linus Walleij
2015-03-27  8:52 ` [PATCH 1/2] pinctrl: pinconf-generic: scan also referenced phandle node Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).