This source file includes following definitions.
- pinctrl_bind_pins
1
2
3
4
5
6
7
8
9
10
11
12 #include <linux/device.h>
13 #include <linux/pinctrl/devinfo.h>
14 #include <linux/pinctrl/consumer.h>
15 #include <linux/slab.h>
16
17
18
19
20
21 int pinctrl_bind_pins(struct device *dev)
22 {
23 int ret;
24
25 if (dev->of_node_reused)
26 return 0;
27
28 dev->pins = devm_kzalloc(dev, sizeof(*(dev->pins)), GFP_KERNEL);
29 if (!dev->pins)
30 return -ENOMEM;
31
32 dev->pins->p = devm_pinctrl_get(dev);
33 if (IS_ERR(dev->pins->p)) {
34 dev_dbg(dev, "no pinctrl handle\n");
35 ret = PTR_ERR(dev->pins->p);
36 goto cleanup_alloc;
37 }
38
39 dev->pins->default_state = pinctrl_lookup_state(dev->pins->p,
40 PINCTRL_STATE_DEFAULT);
41 if (IS_ERR(dev->pins->default_state)) {
42 dev_dbg(dev, "no default pinctrl state\n");
43 ret = 0;
44 goto cleanup_get;
45 }
46
47 dev->pins->init_state = pinctrl_lookup_state(dev->pins->p,
48 PINCTRL_STATE_INIT);
49 if (IS_ERR(dev->pins->init_state)) {
50
51 dev_dbg(dev, "no init pinctrl state\n");
52
53 ret = pinctrl_select_state(dev->pins->p,
54 dev->pins->default_state);
55 } else {
56 ret = pinctrl_select_state(dev->pins->p, dev->pins->init_state);
57 }
58
59 if (ret) {
60 dev_dbg(dev, "failed to activate initial pinctrl state\n");
61 goto cleanup_get;
62 }
63
64 #ifdef CONFIG_PM
65
66
67
68
69
70 dev->pins->sleep_state = pinctrl_lookup_state(dev->pins->p,
71 PINCTRL_STATE_SLEEP);
72 if (IS_ERR(dev->pins->sleep_state))
73
74 dev_dbg(dev, "no sleep pinctrl state\n");
75
76 dev->pins->idle_state = pinctrl_lookup_state(dev->pins->p,
77 PINCTRL_STATE_IDLE);
78 if (IS_ERR(dev->pins->idle_state))
79
80 dev_dbg(dev, "no idle pinctrl state\n");
81 #endif
82
83 return 0;
84
85
86
87
88
89
90 cleanup_get:
91 devm_pinctrl_put(dev->pins->p);
92 cleanup_alloc:
93 devm_kfree(dev, dev->pins);
94 dev->pins = NULL;
95
96
97 if (ret == -EPROBE_DEFER)
98 return ret;
99
100 if (ret == -EINVAL)
101 return ret;
102
103
104 return 0;
105 }