pinctrl: pinconf-generic: Infer map type from DT property
[sfrench/cifs-2.6.git] / drivers / pinctrl / pinconf-generic.c
index f78b416d7984a848cfb6f8bb32d81007919d143b..21b3d90ebb2d1c3ed051ad79120cb1537a2725a4 100644 (file)
@@ -264,6 +264,7 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
        unsigned reserve;
        struct property *prop;
        const char *group;
+       const char *subnode_target_type = "pins";
 
        ret = of_property_read_string(np, "function", &function);
        if (ret < 0) {
@@ -284,10 +285,20 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
                reserve++;
        if (num_configs)
                reserve++;
+
        ret = of_property_count_strings(np, "pins");
        if (ret < 0) {
-               dev_err(dev, "could not parse property pins\n");
-               goto exit;
+               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;
 
@@ -296,7 +307,7 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
        if (ret < 0)
                goto exit;
 
-       of_property_for_each_string(np, "pins", prop, group) {
+       of_property_for_each_string(np, subnode_target_type, prop, group) {
                if (function) {
                        ret = pinctrl_utils_add_map_mux(pctldev, map,
                                        reserved_maps, num_maps, group,