Skip to content

Commit ad42fc6

Browse files
author
Linus Walleij
committed
pinctrl: rip out the direct pinconf API
From the inception ot the pin config API there has been the possibility to get a handle at a pin directly and configure its electrical characteristics. For this reason we had: int pin_config_get(const char *dev_name, const char *name, unsigned long *config); int pin_config_set(const char *dev_name, const char *name, unsigned long config); int pin_config_group_get(const char *dev_name, const char *pin_group, unsigned long *config); int pin_config_group_set(const char *dev_name, const char *pin_group, unsigned long config); After the introduction of the pin control states that will control pins associated with devices, and its subsequent introduction to the device core, as well as the introduction of pin control hogs that can set up states on boot and optionally also at sleep, this direct pin control API is a thing of the past. As could be expected, it has zero in-kernel users. Let's delete this API and make our world simpler. Reported-by: Tony Lindgren <tony@atomide.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent b58f027 commit ad42fc6

3 files changed

Lines changed: 2 additions & 226 deletions

File tree

‎Documentation/pinctrl.txt‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,8 @@ using a certain resistor value - pull up and pull down - so that the pin has a
203203
stable value when nothing is driving the rail it is connected to, or when it's
204204
unconnected.
205205

206-
Pin configuration can be programmed either using the explicit APIs described
207-
immediately below, or by adding configuration entries into the mapping table;
208-
see section "Board/machine configuration" below.
209-
210-
For example, a platform may do the following to pull up a pin to VDD:
211-
212-
#include <linux/pinctrl/consumer.h>
213-
214-
ret = pin_config_set("foo-dev", "FOO_GPIO_PIN", PLATFORM_X_PULL_UP);
206+
Pin configuration can be programmed by adding configuration entries into the
207+
mapping table; see section "Board/machine configuration" below.
215208

216209
The format and meaning of the configuration parameter, PLATFORM_X_PULL_UP
217210
above, is entirely defined by the pin controller driver.

‎drivers/pinctrl/pinconf.c‎

Lines changed: 0 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -75,98 +75,6 @@ int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
7575
return ops->pin_config_get(pctldev, pin, config);
7676
}
7777

78-
/**
79-
* pin_config_get() - get the configuration of a single pin parameter
80-
* @dev_name: name of the pin controller device for this pin
81-
* @name: name of the pin to get the config for
82-
* @config: the config pointed to by this argument will be filled in with the
83-
* current pin state, it can be used directly by drivers as a numeral, or
84-
* it can be dereferenced to any struct.
85-
*/
86-
int pin_config_get(const char *dev_name, const char *name,
87-
unsigned long *config)
88-
{
89-
struct pinctrl_dev *pctldev;
90-
int pin;
91-
92-
pctldev = get_pinctrl_dev_from_devname(dev_name);
93-
if (!pctldev) {
94-
pin = -EINVAL;
95-
return pin;
96-
}
97-
98-
mutex_lock(&pctldev->mutex);
99-
100-
pin = pin_get_from_name(pctldev, name);
101-
if (pin < 0)
102-
goto unlock;
103-
104-
pin = pin_config_get_for_pin(pctldev, pin, config);
105-
106-
unlock:
107-
mutex_unlock(&pctldev->mutex);
108-
return pin;
109-
}
110-
EXPORT_SYMBOL(pin_config_get);
111-
112-
static int pin_config_set_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
113-
unsigned long config)
114-
{
115-
const struct pinconf_ops *ops = pctldev->desc->confops;
116-
int ret;
117-
118-
if (!ops || !ops->pin_config_set) {
119-
dev_err(pctldev->dev, "cannot configure pin, missing "
120-
"config function in driver\n");
121-
return -EINVAL;
122-
}
123-
124-
ret = ops->pin_config_set(pctldev, pin, config);
125-
if (ret) {
126-
dev_err(pctldev->dev,
127-
"unable to set pin configuration on pin %d\n", pin);
128-
return ret;
129-
}
130-
131-
return 0;
132-
}
133-
134-
/**
135-
* pin_config_set() - set the configuration of a single pin parameter
136-
* @dev_name: name of pin controller device for this pin
137-
* @name: name of the pin to set the config for
138-
* @config: the config in this argument will contain the desired pin state, it
139-
* can be used directly by drivers as a numeral, or it can be dereferenced
140-
* to any struct.
141-
*/
142-
int pin_config_set(const char *dev_name, const char *name,
143-
unsigned long config)
144-
{
145-
struct pinctrl_dev *pctldev;
146-
int pin, ret;
147-
148-
pctldev = get_pinctrl_dev_from_devname(dev_name);
149-
if (!pctldev) {
150-
ret = -EINVAL;
151-
return ret;
152-
}
153-
154-
mutex_lock(&pctldev->mutex);
155-
156-
pin = pin_get_from_name(pctldev, name);
157-
if (pin < 0) {
158-
ret = pin;
159-
goto unlock;
160-
}
161-
162-
ret = pin_config_set_for_pin(pctldev, pin, config);
163-
164-
unlock:
165-
mutex_unlock(&pctldev->mutex);
166-
return ret;
167-
}
168-
EXPORT_SYMBOL(pin_config_set);
169-
17078
int pin_config_group_get(const char *dev_name, const char *pin_group,
17179
unsigned long *config)
17280
{
@@ -204,88 +112,6 @@ int pin_config_group_get(const char *dev_name, const char *pin_group,
204112
mutex_unlock(&pctldev->mutex);
205113
return ret;
206114
}
207-
EXPORT_SYMBOL(pin_config_group_get);
208-
209-
int pin_config_group_set(const char *dev_name, const char *pin_group,
210-
unsigned long config)
211-
{
212-
struct pinctrl_dev *pctldev;
213-
const struct pinconf_ops *ops;
214-
const struct pinctrl_ops *pctlops;
215-
int selector;
216-
const unsigned *pins;
217-
unsigned num_pins;
218-
int ret;
219-
int i;
220-
221-
pctldev = get_pinctrl_dev_from_devname(dev_name);
222-
if (!pctldev) {
223-
ret = -EINVAL;
224-
return ret;
225-
}
226-
227-
mutex_lock(&pctldev->mutex);
228-
229-
ops = pctldev->desc->confops;
230-
pctlops = pctldev->desc->pctlops;
231-
232-
if (!ops || (!ops->pin_config_group_set && !ops->pin_config_set)) {
233-
dev_err(pctldev->dev, "cannot configure pin group, missing "
234-
"config function in driver\n");
235-
ret = -EINVAL;
236-
goto unlock;
237-
}
238-
239-
selector = pinctrl_get_group_selector(pctldev, pin_group);
240-
if (selector < 0) {
241-
ret = selector;
242-
goto unlock;
243-
}
244-
245-
ret = pctlops->get_group_pins(pctldev, selector, &pins, &num_pins);
246-
if (ret) {
247-
dev_err(pctldev->dev, "cannot configure pin group, error "
248-
"getting pins\n");
249-
goto unlock;
250-
}
251-
252-
/*
253-
* If the pin controller supports handling entire groups we use that
254-
* capability.
255-
*/
256-
if (ops->pin_config_group_set) {
257-
ret = ops->pin_config_group_set(pctldev, selector, config);
258-
/*
259-
* If the pin controller prefer that a certain group be handled
260-
* pin-by-pin as well, it returns -EAGAIN.
261-
*/
262-
if (ret != -EAGAIN)
263-
goto unlock;
264-
}
265-
266-
/*
267-
* If the controller cannot handle entire groups, we configure each pin
268-
* individually.
269-
*/
270-
if (!ops->pin_config_set) {
271-
ret = 0;
272-
goto unlock;
273-
}
274-
275-
for (i = 0; i < num_pins; i++) {
276-
ret = ops->pin_config_set(pctldev, pins[i], config);
277-
if (ret < 0)
278-
goto unlock;
279-
}
280-
281-
ret = 0;
282-
283-
unlock:
284-
mutex_unlock(&pctldev->mutex);
285-
286-
return ret;
287-
}
288-
EXPORT_SYMBOL(pin_config_group_set);
289115

290116
int pinconf_map_to_setting(struct pinctrl_map const *map,
291117
struct pinctrl_setting *setting)

‎include/linux/pinctrl/consumer.h‎

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -192,47 +192,4 @@ static inline struct pinctrl * __must_check devm_pinctrl_get_select_default(
192192
return devm_pinctrl_get_select(dev, PINCTRL_STATE_DEFAULT);
193193
}
194194

195-
#ifdef CONFIG_PINCONF
196-
197-
extern int pin_config_get(const char *dev_name, const char *name,
198-
unsigned long *config);
199-
extern int pin_config_set(const char *dev_name, const char *name,
200-
unsigned long config);
201-
extern int pin_config_group_get(const char *dev_name,
202-
const char *pin_group,
203-
unsigned long *config);
204-
extern int pin_config_group_set(const char *dev_name,
205-
const char *pin_group,
206-
unsigned long config);
207-
208-
#else
209-
210-
static inline int pin_config_get(const char *dev_name, const char *name,
211-
unsigned long *config)
212-
{
213-
return 0;
214-
}
215-
216-
static inline int pin_config_set(const char *dev_name, const char *name,
217-
unsigned long config)
218-
{
219-
return 0;
220-
}
221-
222-
static inline int pin_config_group_get(const char *dev_name,
223-
const char *pin_group,
224-
unsigned long *config)
225-
{
226-
return 0;
227-
}
228-
229-
static inline int pin_config_group_set(const char *dev_name,
230-
const char *pin_group,
231-
unsigned long config)
232-
{
233-
return 0;
234-
}
235-
236-
#endif
237-
238195
#endif /* __LINUX_PINCTRL_CONSUMER_H */

0 commit comments

Comments
 (0)