diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pinctrl/pinconf.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c index 124762b57024..57dbb4b478db 100644 --- a/drivers/pinctrl/pinconf.c +++ b/drivers/pinctrl/pinconf.c | |||
@@ -39,17 +39,22 @@ int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin, | |||
39 | 39 | ||
40 | /** | 40 | /** |
41 | * pin_config_get() - get the configuration of a single pin parameter | 41 | * pin_config_get() - get the configuration of a single pin parameter |
42 | * @pctldev: pin controller device for this pin | 42 | * @dev_name: name of the pin controller device for this pin |
43 | * @name: name of the pin to get the config for | 43 | * @name: name of the pin to get the config for |
44 | * @config: the config pointed to by this argument will be filled in with the | 44 | * @config: the config pointed to by this argument will be filled in with the |
45 | * current pin state, it can be used directly by drivers as a numeral, or | 45 | * current pin state, it can be used directly by drivers as a numeral, or |
46 | * it can be dereferenced to any struct. | 46 | * it can be dereferenced to any struct. |
47 | */ | 47 | */ |
48 | int pin_config_get(struct pinctrl_dev *pctldev, const char *name, | 48 | int pin_config_get(const char *dev_name, const char *name, |
49 | unsigned long *config) | 49 | unsigned long *config) |
50 | { | 50 | { |
51 | struct pinctrl_dev *pctldev; | ||
51 | int pin; | 52 | int pin; |
52 | 53 | ||
54 | pctldev = get_pinctrl_dev_from_dev(NULL, dev_name); | ||
55 | if (!pctldev) | ||
56 | return -EINVAL; | ||
57 | |||
53 | pin = pin_get_from_name(pctldev, name); | 58 | pin = pin_get_from_name(pctldev, name); |
54 | if (pin < 0) | 59 | if (pin < 0) |
55 | return pin; | 60 | return pin; |
@@ -82,17 +87,22 @@ int pin_config_set_for_pin(struct pinctrl_dev *pctldev, unsigned pin, | |||
82 | 87 | ||
83 | /** | 88 | /** |
84 | * pin_config_set() - set the configuration of a single pin parameter | 89 | * pin_config_set() - set the configuration of a single pin parameter |
85 | * @pctldev: pin controller device for this pin | 90 | * @dev_name: name of pin controller device for this pin |
86 | * @name: name of the pin to set the config for | 91 | * @name: name of the pin to set the config for |
87 | * @config: the config in this argument will contain the desired pin state, it | 92 | * @config: the config in this argument will contain the desired pin state, it |
88 | * can be used directly by drivers as a numeral, or it can be dereferenced | 93 | * can be used directly by drivers as a numeral, or it can be dereferenced |
89 | * to any struct. | 94 | * to any struct. |
90 | */ | 95 | */ |
91 | int pin_config_set(struct pinctrl_dev *pctldev, const char *name, | 96 | int pin_config_set(const char *dev_name, const char *name, |
92 | unsigned long config) | 97 | unsigned long config) |
93 | { | 98 | { |
99 | struct pinctrl_dev *pctldev; | ||
94 | int pin; | 100 | int pin; |
95 | 101 | ||
102 | pctldev = get_pinctrl_dev_from_dev(NULL, dev_name); | ||
103 | if (!pctldev) | ||
104 | return -EINVAL; | ||
105 | |||
96 | pin = pin_get_from_name(pctldev, name); | 106 | pin = pin_get_from_name(pctldev, name); |
97 | if (pin < 0) | 107 | if (pin < 0) |
98 | return pin; | 108 | return pin; |
@@ -101,12 +111,18 @@ int pin_config_set(struct pinctrl_dev *pctldev, const char *name, | |||
101 | } | 111 | } |
102 | EXPORT_SYMBOL(pin_config_set); | 112 | EXPORT_SYMBOL(pin_config_set); |
103 | 113 | ||
104 | int pin_config_group_get(struct pinctrl_dev *pctldev, const char *pin_group, | 114 | int pin_config_group_get(const char *dev_name, const char *pin_group, |
105 | unsigned long *config) | 115 | unsigned long *config) |
106 | { | 116 | { |
107 | const struct pinconf_ops *ops = pctldev->desc->confops; | 117 | struct pinctrl_dev *pctldev; |
118 | const struct pinconf_ops *ops; | ||
108 | int selector; | 119 | int selector; |
109 | 120 | ||
121 | pctldev = get_pinctrl_dev_from_dev(NULL, dev_name); | ||
122 | if (!pctldev) | ||
123 | return -EINVAL; | ||
124 | ops = pctldev->desc->confops; | ||
125 | |||
110 | if (!ops || !ops->pin_config_group_get) { | 126 | if (!ops || !ops->pin_config_group_get) { |
111 | dev_err(pctldev->dev, "cannot get configuration for pin " | 127 | dev_err(pctldev->dev, "cannot get configuration for pin " |
112 | "group, missing group config get function in " | 128 | "group, missing group config get function in " |
@@ -123,17 +139,24 @@ int pin_config_group_get(struct pinctrl_dev *pctldev, const char *pin_group, | |||
123 | EXPORT_SYMBOL(pin_config_group_get); | 139 | EXPORT_SYMBOL(pin_config_group_get); |
124 | 140 | ||
125 | 141 | ||
126 | int pin_config_group_set(struct pinctrl_dev *pctldev, const char *pin_group, | 142 | int pin_config_group_set(const char *dev_name, const char *pin_group, |
127 | unsigned long config) | 143 | unsigned long config) |
128 | { | 144 | { |
129 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; | 145 | struct pinctrl_dev *pctldev; |
130 | const struct pinconf_ops *ops = pctldev->desc->confops; | 146 | const struct pinconf_ops *ops; |
147 | const struct pinctrl_ops *pctlops; | ||
131 | int selector; | 148 | int selector; |
132 | const unsigned *pins; | 149 | const unsigned *pins; |
133 | unsigned num_pins; | 150 | unsigned num_pins; |
134 | int ret; | 151 | int ret; |
135 | int i; | 152 | int i; |
136 | 153 | ||
154 | pctldev = get_pinctrl_dev_from_dev(NULL, dev_name); | ||
155 | if (!pctldev) | ||
156 | return -EINVAL; | ||
157 | ops = pctldev->desc->confops; | ||
158 | pctlops = pctldev->desc->pctlops; | ||
159 | |||
137 | if (!ops || (!ops->pin_config_group_set && !ops->pin_config_set)) { | 160 | if (!ops || (!ops->pin_config_group_set && !ops->pin_config_set)) { |
138 | dev_err(pctldev->dev, "cannot configure pin group, missing " | 161 | dev_err(pctldev->dev, "cannot configure pin group, missing " |
139 | "config function in driver\n"); | 162 | "config function in driver\n"); |