19 #include <linux/device.h>
22 #include <linux/slab.h>
40 static void dt_free_map(
struct pinctrl_dev *pctldev,
44 struct pinctrl_ops *
ops = pctldev->
desc->pctlops;
45 ops->dt_free_map(pctldev, map, num_maps);
64 of_node_put(p->
dev->of_node);
67 static int dt_remember_or_free_map(
struct pinctrl *
p,
const char *statename,
77 map[
i].
name = statename;
85 dev_err(p->
dev,
"failed to alloc struct pinctrl_dt_map\n");
86 dt_free_map(pctldev, map, num_maps);
103 if (pctldev->
dev->of_node == np)
114 struct pinctrl_ops *
ops;
120 np_pctldev = of_node_get(np_config);
123 if (!np_pctldev || of_node_is_root(np_pctldev)) {
124 dev_info(p->dev,
"could not find pctldev for node %s, deferring probe\n",
125 np_config->full_name);
126 of_node_put(np_pctldev);
130 pctldev = find_pinctrl_by_of_node(np_pctldev);
134 of_node_put(np_pctldev);
140 ops = pctldev->
desc->pctlops;
141 if (!ops->dt_node_to_map) {
142 dev_err(p->dev,
"pctldev %s doesn't support DT\n",
146 ret = ops->dt_node_to_map(pctldev, np_config, &map, &num_maps);
151 return dt_remember_or_free_map(p, statename, pctldev, map, num_maps);
154 static int dt_remember_dummy_state(
struct pinctrl *p,
const char *statename)
160 dev_err(p->
dev,
"failed to alloc struct pinctrl_map\n");
167 return dt_remember_or_free_map(p, statename, NULL, map, 1);
176 const char *statename;
184 dev_dbg(p->
dev,
"no of_node; not parsing pinctrl DT\n");
192 for (state = 0; ; state++) {
200 size /=
sizeof(*list);
212 statename = prop->
name + 8;
216 for (config = 0; config <
size; config++) {
223 "prop %s index %i invalid phandle\n",
230 ret = dt_to_map_one_config(p, statename, np_config);
231 of_node_put(np_config);
238 ret = dt_remember_dummy_state(p, statename);