Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+2 -226
+2 -9
Documentation/pinctrl.txt
··· 203 203 stable value when nothing is driving the rail it is connected to, or when it's 204 204 unconnected. 205 205 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. 215 208 216 209 The format and meaning of the configuration parameter, PLATFORM_X_PULL_UP 217 210 above, is entirely defined by the pin controller driver.
-174
drivers/pinctrl/pinconf.c
··· 75 75 return ops->pin_config_get(pctldev, pin, config); 76 76 } 77 77 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 - 170 78 int pin_config_group_get(const char *dev_name, const char *pin_group, 171 79 unsigned long *config) 172 80 { ··· 112 204 mutex_unlock(&pctldev->mutex); 113 205 return ret; 114 206 } 115 - EXPORT_SYMBOL(pin_config_group_get); 116 - 117 - int pin_config_group_set(const char *dev_name, const char *pin_group, 118 - unsigned long config) 119 - { 120 - struct pinctrl_dev *pctldev; 121 - const struct pinconf_ops *ops; 122 - const struct pinctrl_ops *pctlops; 123 - int selector; 124 - const unsigned *pins; 125 - unsigned num_pins; 126 - int ret; 127 - int i; 128 - 129 - pctldev = get_pinctrl_dev_from_devname(dev_name); 130 - if (!pctldev) { 131 - ret = -EINVAL; 132 - return ret; 133 - } 134 - 135 - mutex_lock(&pctldev->mutex); 136 - 137 - ops = pctldev->desc->confops; 138 - pctlops = pctldev->desc->pctlops; 139 - 140 - if (!ops || (!ops->pin_config_group_set && !ops->pin_config_set)) { 141 - dev_err(pctldev->dev, "cannot configure pin group, missing " 142 - "config function in driver\n"); 143 - ret = -EINVAL; 144 - goto unlock; 145 - } 146 - 147 - selector = pinctrl_get_group_selector(pctldev, pin_group); 148 - if (selector < 0) { 149 - ret = selector; 150 - goto unlock; 151 - } 152 - 153 - ret = pctlops->get_group_pins(pctldev, selector, &pins, &num_pins); 154 - if (ret) { 155 - dev_err(pctldev->dev, "cannot configure pin group, error " 156 - "getting pins\n"); 157 - goto unlock; 158 - } 159 - 160 - /* 161 - * If the pin controller supports handling entire groups we use that 162 - * capability. 163 - */ 164 - if (ops->pin_config_group_set) { 165 - ret = ops->pin_config_group_set(pctldev, selector, config); 166 - /* 167 - * If the pin controller prefer that a certain group be handled 168 - * pin-by-pin as well, it returns -EAGAIN. 169 - */ 170 - if (ret != -EAGAIN) 171 - goto unlock; 172 - } 173 - 174 - /* 175 - * If the controller cannot handle entire groups, we configure each pin 176 - * individually. 177 - */ 178 - if (!ops->pin_config_set) { 179 - ret = 0; 180 - goto unlock; 181 - } 182 - 183 - for (i = 0; i < num_pins; i++) { 184 - ret = ops->pin_config_set(pctldev, pins[i], config); 185 - if (ret < 0) 186 - goto unlock; 187 - } 188 - 189 - ret = 0; 190 - 191 - unlock: 192 - mutex_unlock(&pctldev->mutex); 193 - 194 - return ret; 195 - } 196 - EXPORT_SYMBOL(pin_config_group_set); 197 207 198 208 int pinconf_map_to_setting(struct pinctrl_map const *map, 199 209 struct pinctrl_setting *setting)
-43
include/linux/pinctrl/consumer.h
··· 192 192 return devm_pinctrl_get_select(dev, PINCTRL_STATE_DEFAULT); 193 193 } 194 194 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 - 238 195 #endif /* __LINUX_PINCTRL_CONSUMER_H */