diff mbox series

[30/36] pinctrl: remove old GPIO helpers

Message ID 20231003145114.21637-31-brgl@bgdev.pl
State New
Headers show
Series pinctrl: don't use GPIOLIB global numberspace in helpers | expand

Commit Message

Bartosz Golaszewski Oct. 3, 2023, 2:51 p.m. UTC
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Old variants of pinctrl GPIO helpers are no longer used. Let's remove
them as well as convert all static functions in pinctrl/core.c that
still deal with global GPIO numbers to using the gpio_chip + offset
pairs.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/pinctrl/core.c           | 242 ++++++++++++-------------------
 include/linux/pinctrl/consumer.h |  35 -----
 2 files changed, 94 insertions(+), 183 deletions(-)

Comments

Andy Shevchenko Oct. 3, 2023, 3:20 p.m. UTC | #1
On Tue, Oct 3, 2023 at 5:51 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Old variants of pinctrl GPIO helpers are no longer used. Let's remove
> them as well as convert all static functions in pinctrl/core.c that
> still deal with global GPIO numbers to using the gpio_chip + offset
> pairs.

This patch does three thighs as I see it.

First of all, it silently converts to RAII. Please, do this separately.
Second, it shuffles a lot of code between old and new implementations.
What I prefer to see is what the subject tells: only "-" (minus)
lines.
Third, it will become easier if you name the "new" functions better to
begin with, it will help a lot here.
kernel test robot Oct. 3, 2023, 6:34 p.m. UTC | #2
Hi Bartosz,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linusw-pinctrl/devel]
[also build test WARNING on linusw-pinctrl/for-next next-20231003]
[cannot apply to brgl/gpio/for-next geert-renesas-drivers/renesas-pinctrl linus/master v6.6-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Bartosz-Golaszewski/pinctrl-remove-unneeded-extern-specifiers-from-consumer-h/20231003-225540
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
patch link:    https://lore.kernel.org/r/20231003145114.21637-31-brgl%40bgdev.pl
patch subject: [PATCH 30/36] pinctrl: remove old GPIO helpers
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20231004/202310040236.w3AOZ94W-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231004/202310040236.w3AOZ94W-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310040236.w3AOZ94W-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/pinctrl/core.c:338: warning: Excess function parameter 'offset' description in 'pinctrl_ready_for_gpio_range'


vim +338 drivers/pinctrl/core.c

2744e8afb3b763 Linus Walleij       2011-05-02  321  
51e13c2475913d Haojian Zhuang      2013-02-17  322  /**
51e13c2475913d Haojian Zhuang      2013-02-17  323   * pinctrl_ready_for_gpio_range() - check if other GPIO pins of
51e13c2475913d Haojian Zhuang      2013-02-17  324   * the same GPIO chip are in range
4b4af250917e1a Bartosz Golaszewski 2023-10-03  325   * @gc: GPIO chip structure from the GPIO subsystem
4b4af250917e1a Bartosz Golaszewski 2023-10-03  326   * @offset: hardware offset of the GPIO relative to the controller
51e13c2475913d Haojian Zhuang      2013-02-17  327   *
51e13c2475913d Haojian Zhuang      2013-02-17  328   * This function is complement of pinctrl_match_gpio_range(). If the return
51e13c2475913d Haojian Zhuang      2013-02-17  329   * value of pinctrl_match_gpio_range() is NULL, this function could be used
51e13c2475913d Haojian Zhuang      2013-02-17  330   * to check whether pinctrl device is ready or not. Maybe some GPIO pins
51e13c2475913d Haojian Zhuang      2013-02-17  331   * of the same GPIO chip don't have back-end pinctrl interface.
51e13c2475913d Haojian Zhuang      2013-02-17  332   * If the return value is true, it means that pinctrl device is ready & the
51e13c2475913d Haojian Zhuang      2013-02-17  333   * certain GPIO pin doesn't have back-end pinctrl device. If the return value
51e13c2475913d Haojian Zhuang      2013-02-17  334   * is false, it means that pinctrl device may not be ready.
51e13c2475913d Haojian Zhuang      2013-02-17  335   */
2afe8229687ec2 Haojian Zhuang      2013-03-28  336  #ifdef CONFIG_GPIOLIB
4b4af250917e1a Bartosz Golaszewski 2023-10-03  337  static bool pinctrl_ready_for_gpio_range(struct gpio_chip *gc)
51e13c2475913d Haojian Zhuang      2013-02-17 @338  {
51e13c2475913d Haojian Zhuang      2013-02-17  339  	struct pinctrl_dev *pctldev;
51e13c2475913d Haojian Zhuang      2013-02-17  340  	struct pinctrl_gpio_range *range = NULL;
942cde724075f8 Tony Lindgren       2015-09-03  341  
44d5f7bbead9e7 Linus Walleij       2013-05-16  342  	mutex_lock(&pinctrldev_list_mutex);
44d5f7bbead9e7 Linus Walleij       2013-05-16  343  
51e13c2475913d Haojian Zhuang      2013-02-17  344  	/* Loop over the pin controllers */
51e13c2475913d Haojian Zhuang      2013-02-17  345  	list_for_each_entry(pctldev, &pinctrldev_list, node) {
51e13c2475913d Haojian Zhuang      2013-02-17  346  		/* Loop over the ranges */
5ffbe2e6138732 Axel Lin            2013-08-18  347  		mutex_lock(&pctldev->mutex);
51e13c2475913d Haojian Zhuang      2013-02-17  348  		list_for_each_entry(range, &pctldev->gpio_ranges, node) {
51e13c2475913d Haojian Zhuang      2013-02-17  349  			/* Check if any gpio range overlapped with gpio chip */
4b4af250917e1a Bartosz Golaszewski 2023-10-03  350  			if (range->base + range->npins - 1 < gc->base ||
4b4af250917e1a Bartosz Golaszewski 2023-10-03  351  			    range->base > gc->base + gc->ngpio - 1)
51e13c2475913d Haojian Zhuang      2013-02-17  352  				continue;
5ffbe2e6138732 Axel Lin            2013-08-18  353  			mutex_unlock(&pctldev->mutex);
44d5f7bbead9e7 Linus Walleij       2013-05-16  354  			mutex_unlock(&pinctrldev_list_mutex);
51e13c2475913d Haojian Zhuang      2013-02-17  355  			return true;
51e13c2475913d Haojian Zhuang      2013-02-17  356  		}
5ffbe2e6138732 Axel Lin            2013-08-18  357  		mutex_unlock(&pctldev->mutex);
51e13c2475913d Haojian Zhuang      2013-02-17  358  	}
44d5f7bbead9e7 Linus Walleij       2013-05-16  359  
44d5f7bbead9e7 Linus Walleij       2013-05-16  360  	mutex_unlock(&pinctrldev_list_mutex);
44d5f7bbead9e7 Linus Walleij       2013-05-16  361  
51e13c2475913d Haojian Zhuang      2013-02-17  362  	return false;
51e13c2475913d Haojian Zhuang      2013-02-17  363  }
2afe8229687ec2 Haojian Zhuang      2013-03-28  364  #else
4b4af250917e1a Bartosz Golaszewski 2023-10-03  365  static bool pinctrl_ready_for_gpio_range(struct gpio_chip *gc) { return true; }
2afe8229687ec2 Haojian Zhuang      2013-03-28  366  #endif
51e13c2475913d Haojian Zhuang      2013-02-17  367
Bartosz Golaszewski Oct. 4, 2023, 8:49 a.m. UTC | #3
On Tue, Oct 3, 2023 at 5:21 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Tue, Oct 3, 2023 at 5:51 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > Old variants of pinctrl GPIO helpers are no longer used. Let's remove
> > them as well as convert all static functions in pinctrl/core.c that
> > still deal with global GPIO numbers to using the gpio_chip + offset
> > pairs.
>
> This patch does three thighs as I see it.
>

I'd argue it just fold the code that lived in old functions into the new ones...

> First of all, it silently converts to RAII. Please, do this separately.

... and while at it, it already switches to SBRM because why copy outdated code.

> Second, it shuffles a lot of code between old and new implementations.
> What I prefer to see is what the subject tells: only "-" (minus)
> lines.
> Third, it will become easier if you name the "new" functions better to
> begin with, it will help a lot here.
>

I'll wait for Linus to tell me if he prefers one big squashed commit
or a fine-grained history (I prefer the latter) before spending time
splitting this commit.

Bart

> --
> With Best Regards,
> Andy Shevchenko
Andy Shevchenko Oct. 4, 2023, 12:45 p.m. UTC | #4
On Wed, Oct 04, 2023 at 10:49:25AM +0200, Bartosz Golaszewski wrote:
> On Tue, Oct 3, 2023 at 5:21 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Tue, Oct 3, 2023 at 5:51 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

...

> > > Old variants of pinctrl GPIO helpers are no longer used. Let's remove
> > > them as well as convert all static functions in pinctrl/core.c that
> > > still deal with global GPIO numbers to using the gpio_chip + offset
> > > pairs.
> >
> > This patch does three thighs as I see it.
> >
> 
> I'd argue it just fold the code that lived in old functions into the new ones...
> 
> > First of all, it silently converts to RAII. Please, do this separately.
> 
> ... and while at it, it already switches to SBRM because why copy outdated code.

This is too big thing for "while at it".
If you care about that switch, do it beforehand.
But at bare minimum it should be a separate patch.

> > Second, it shuffles a lot of code between old and new implementations.
> > What I prefer to see is what the subject tells: only "-" (minus)
> > lines.
> > Third, it will become easier if you name the "new" functions better to
> > begin with, it will help a lot here.
> 
> I'll wait for Linus to tell me if he prefers one big squashed commit
> or a fine-grained history (I prefer the latter) before spending time
> splitting this commit.

Definitely, changing code to SBRM is out of scope of this series and should be
done in a separate patch at least.
diff mbox series

Patch

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 679f48c5beeb..5bad56ed8176 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -268,7 +268,8 @@  static int pinctrl_register_pins(struct pinctrl_dev *pctldev,
 /**
  * gpio_to_pin() - GPIO range GPIO number to pin number translation
  * @range: GPIO range used for the translation
- * @gpio: gpio pin to translate to a pin number
+ * @gc: GPIO chip structure from the GPIO subsystem
+ * @offset: hardware offset of the GPIO relative to the controller
  *
  * Finds the pin number for a given GPIO using the specified GPIO range
  * as a base for translation. The distinction between linear GPIO ranges
@@ -279,25 +280,28 @@  static int pinctrl_register_pins(struct pinctrl_dev *pctldev,
  * result of successful pinctrl_get_device_gpio_range calls)!
  */
 static inline int gpio_to_pin(struct pinctrl_gpio_range *range,
-				unsigned int gpio)
+			      struct gpio_chip *gc, unsigned int offset)
 {
-	unsigned int offset = gpio - range->base;
+	unsigned int pin = gc->base + offset - range->base;
+
 	if (range->pins)
-		return range->pins[offset];
+		return range->pins[pin];
 	else
-		return range->pin_base + offset;
+		return range->pin_base + pin;
 }
 
 /**
  * pinctrl_match_gpio_range() - check if a certain GPIO pin is in range
  * @pctldev: pin controller device to check
- * @gpio: gpio pin to check taken from the global GPIO pin space
+ * @gc: GPIO chip structure from the GPIO subsystem
+ * @offset: hardware offset of the GPIO relative to the controller
  *
  * Tries to match a GPIO pin number to the ranges handled by a certain pin
  * controller, return the range or NULL
  */
 static struct pinctrl_gpio_range *
-pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, unsigned gpio)
+pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, struct gpio_chip *gc,
+			 unsigned int offset)
 {
 	struct pinctrl_gpio_range *range;
 
@@ -305,8 +309,8 @@  pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, unsigned gpio)
 	/* Loop over the ranges */
 	list_for_each_entry(range, &pctldev->gpio_ranges, node) {
 		/* Check if we're in the valid range */
-		if (gpio >= range->base &&
-		    gpio < range->base + range->npins) {
+		if (gc->base + offset >= range->base &&
+		    gc->base + offset < range->base + range->npins) {
 			mutex_unlock(&pctldev->mutex);
 			return range;
 		}
@@ -318,7 +322,8 @@  pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, unsigned gpio)
 /**
  * pinctrl_ready_for_gpio_range() - check if other GPIO pins of
  * the same GPIO chip are in range
- * @gpio: gpio pin to check taken from the global GPIO pin space
+ * @gc: GPIO chip structure from the GPIO subsystem
+ * @offset: hardware offset of the GPIO relative to the controller
  *
  * This function is complement of pinctrl_match_gpio_range(). If the return
  * value of pinctrl_match_gpio_range() is NULL, this function could be used
@@ -329,19 +334,10 @@  pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, unsigned gpio)
  * is false, it means that pinctrl device may not be ready.
  */
 #ifdef CONFIG_GPIOLIB
-static bool pinctrl_ready_for_gpio_range(unsigned gpio)
+static bool pinctrl_ready_for_gpio_range(struct gpio_chip *gc)
 {
 	struct pinctrl_dev *pctldev;
 	struct pinctrl_gpio_range *range = NULL;
-	/*
-	 * FIXME: "gpio" here is a number in the global GPIO numberspace.
-	 * get rid of this from the ranges eventually and get the GPIO
-	 * descriptor from the gpio_chip.
-	 */
-	struct gpio_chip *chip = gpiod_to_chip(gpio_to_desc(gpio));
-
-	if (WARN(!chip, "no gpio_chip for gpio%i?", gpio))
-		return false;
 
 	mutex_lock(&pinctrldev_list_mutex);
 
@@ -351,8 +347,8 @@  static bool pinctrl_ready_for_gpio_range(unsigned gpio)
 		mutex_lock(&pctldev->mutex);
 		list_for_each_entry(range, &pctldev->gpio_ranges, node) {
 			/* Check if any gpio range overlapped with gpio chip */
-			if (range->base + range->npins - 1 < chip->base ||
-			    range->base > chip->base + chip->ngpio - 1)
+			if (range->base + range->npins - 1 < gc->base ||
+			    range->base > gc->base + gc->ngpio - 1)
 				continue;
 			mutex_unlock(&pctldev->mutex);
 			mutex_unlock(&pinctrldev_list_mutex);
@@ -366,12 +362,13 @@  static bool pinctrl_ready_for_gpio_range(unsigned gpio)
 	return false;
 }
 #else
-static bool pinctrl_ready_for_gpio_range(unsigned gpio) { return true; }
+static bool pinctrl_ready_for_gpio_range(struct gpio_chip *gc) { return true; }
 #endif
 
 /**
  * pinctrl_get_device_gpio_range() - find device for GPIO range
- * @gpio: the pin to locate the pin controller for
+ * @gc: GPIO chip structure from the GPIO subsystem
+ * @offset: hardware offset of the GPIO relative to the controller
  * @outdev: the pin control device if found
  * @outrange: the GPIO range if found
  *
@@ -380,7 +377,8 @@  static bool pinctrl_ready_for_gpio_range(unsigned gpio) { return true; }
  * -EPROBE_DEFER if the GPIO range could not be found in any device since it
  * may still have not been registered.
  */
-static int pinctrl_get_device_gpio_range(unsigned gpio,
+static int pinctrl_get_device_gpio_range(struct gpio_chip *gc,
+					 unsigned int offset,
 					 struct pinctrl_dev **outdev,
 					 struct pinctrl_gpio_range **outrange)
 {
@@ -392,7 +390,7 @@  static int pinctrl_get_device_gpio_range(unsigned gpio,
 	list_for_each_entry(pctldev, &pinctrldev_list, node) {
 		struct pinctrl_gpio_range *range;
 
-		range = pinctrl_match_gpio_range(pctldev, gpio);
+		range = pinctrl_match_gpio_range(pctldev, gc, offset);
 		if (range) {
 			*outdev = pctldev;
 			*outrange = range;
@@ -754,10 +752,10 @@  int pinctrl_get_group_selector(struct pinctrl_dev *pctldev,
 	return -EINVAL;
 }
 
-bool pinctrl_gpio_can_use_line(unsigned gpio)
+bool pinctrl_gpio_can_use_line_new(struct gpio_chip *gc, unsigned int offset)
 {
-	struct pinctrl_dev *pctldev;
 	struct pinctrl_gpio_range *range;
+	struct pinctrl_dev *pctldev;
 	bool result;
 	int pin;
 
@@ -766,56 +764,19 @@  bool pinctrl_gpio_can_use_line(unsigned gpio)
 	 * we're probably dealing with GPIO driver
 	 * without a backing pin controller - bail out.
 	 */
-	if (pinctrl_get_device_gpio_range(gpio, &pctldev, &range))
+	if (pinctrl_get_device_gpio_range(gc, offset, &pctldev, &range))
 		return true;
 
-	mutex_lock(&pctldev->mutex);
-
-	/* Convert to the pin controllers number space */
-	pin = gpio_to_pin(range, gpio);
-
-	result = pinmux_can_be_used_for_gpio(pctldev, pin);
-
-	mutex_unlock(&pctldev->mutex);
+	scoped_guard(mutex, &pctldev->mutex) {
+		/* Convert to the pin controllers number space */
+		pin = gpio_to_pin(range, gc, offset);
+		result = pinmux_can_be_used_for_gpio(pctldev, pin);
+	}
 
 	return result;
 }
-EXPORT_SYMBOL_GPL(pinctrl_gpio_can_use_line);
-
-bool pinctrl_gpio_can_use_line_new(struct gpio_chip *gc, unsigned int offset)
-{
-	return pinctrl_gpio_can_use_line(gc->base + offset);
-}
 EXPORT_SYMBOL_GPL(pinctrl_gpio_can_use_line_new);
 
-/* This function is deprecated and will be removed. Don't use. */
-int pinctrl_gpio_request(unsigned gpio)
-{
-	struct pinctrl_dev *pctldev;
-	struct pinctrl_gpio_range *range;
-	int ret;
-	int pin;
-
-	ret = pinctrl_get_device_gpio_range(gpio, &pctldev, &range);
-	if (ret) {
-		if (pinctrl_ready_for_gpio_range(gpio))
-			ret = 0;
-		return ret;
-	}
-
-	mutex_lock(&pctldev->mutex);
-
-	/* Convert to the pin controllers number space */
-	pin = gpio_to_pin(range, gpio);
-
-	ret = pinmux_request_gpio(pctldev, range, pin, gpio);
-
-	mutex_unlock(&pctldev->mutex);
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(pinctrl_gpio_request);
-
 /**
  * pinctrl_gpio_request_new() - request a single pin to be used as GPIO
  * @gc: GPIO chip structure from the GPIO subsystem
@@ -827,33 +788,29 @@  EXPORT_SYMBOL_GPL(pinctrl_gpio_request);
  */
 int pinctrl_gpio_request_new(struct gpio_chip *gc, unsigned int offset)
 {
-	return pinctrl_gpio_request(gc->base + offset);
+	struct pinctrl_gpio_range *range;
+	struct pinctrl_dev *pctldev;
+	int ret, pin;
+
+	ret = pinctrl_get_device_gpio_range(gc, offset, &pctldev, &range);
+	if (ret) {
+		if (pinctrl_ready_for_gpio_range(gc))
+			ret = 0;
+
+		return ret;
+	}
+
+	scoped_guard(mutex, &pctldev->mutex) {
+		/* Convert to the pin controllers number space */
+		pin = gpio_to_pin(range, gc, offset);
+		ret = pinmux_request_gpio(pctldev, range, pin,
+					  gc->base + offset);
+	}
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(pinctrl_gpio_request_new);
 
-/* This function is deprecated and will be removed. Don't use. */
-void pinctrl_gpio_free(unsigned gpio)
-{
-	struct pinctrl_dev *pctldev;
-	struct pinctrl_gpio_range *range;
-	int ret;
-	int pin;
-
-	ret = pinctrl_get_device_gpio_range(gpio, &pctldev, &range);
-	if (ret) {
-		return;
-	}
-	mutex_lock(&pctldev->mutex);
-
-	/* Convert to the pin controllers number space */
-	pin = gpio_to_pin(range, gpio);
-
-	pinmux_free_gpio(pctldev, pin, range);
-
-	mutex_unlock(&pctldev->mutex);
-}
-EXPORT_SYMBOL_GPL(pinctrl_gpio_free);
-
 /**
  * pinctrl_gpio_free_new() - free control on a single pin, currently used as GPIO
  * @gc: GPIO chip structure from the GPIO subsystem
@@ -865,40 +822,42 @@  EXPORT_SYMBOL_GPL(pinctrl_gpio_free);
  */
 void pinctrl_gpio_free_new(struct gpio_chip *gc, unsigned int offset)
 {
-	return pinctrl_gpio_free(gc->base + offset);
+	struct pinctrl_gpio_range *range;
+	struct pinctrl_dev *pctldev;
+	int ret, pin;
+
+	ret = pinctrl_get_device_gpio_range(gc, offset, &pctldev, &range);
+	if (ret)
+		return;
+
+	guard(mutex)(&pctldev->mutex);
+
+	/* Convert to the pin controllers number space */
+	pin = gpio_to_pin(range, gc, offset);
+	pinmux_free_gpio(pctldev, pin, range);
 }
 EXPORT_SYMBOL_GPL(pinctrl_gpio_free_new);
 
-static int pinctrl_gpio_direction(unsigned gpio, bool input)
+static int
+pinctrl_gpio_direction(struct gpio_chip *gc, unsigned int offset, bool input)
 {
-	struct pinctrl_dev *pctldev;
 	struct pinctrl_gpio_range *range;
-	int ret;
-	int pin;
+	struct pinctrl_dev *pctldev;
+	int ret, pin;
 
-	ret = pinctrl_get_device_gpio_range(gpio, &pctldev, &range);
-	if (ret) {
+	ret = pinctrl_get_device_gpio_range(gc, offset, &pctldev, &range);
+	if (ret)
 		return ret;
+
+	scoped_guard(mutex, &pctldev->mutex) {
+		/* Convert to the pin controllers number space */
+		pin = gpio_to_pin(range, gc, offset);
+		ret = pinmux_gpio_direction(pctldev, range, pin, input);
 	}
 
-	mutex_lock(&pctldev->mutex);
-
-	/* Convert to the pin controllers number space */
-	pin = gpio_to_pin(range, gpio);
-	ret = pinmux_gpio_direction(pctldev, range, pin, input);
-
-	mutex_unlock(&pctldev->mutex);
-
 	return ret;
 }
 
-/* This function is deprecated and will be removed. Don't use. */
-int pinctrl_gpio_direction_input(unsigned gpio)
-{
-	return pinctrl_gpio_direction(gpio, true);
-}
-EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_input);
-
 /**
  * pinctrl_gpio_direction_input_new() - request a GPIO pin to go into input mode
  * @gc: GPIO chip structure from the GPIO subsystem
@@ -910,17 +869,10 @@  EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_input);
  */
 int pinctrl_gpio_direction_input_new(struct gpio_chip *gc, unsigned int offset)
 {
-	return pinctrl_gpio_direction_input(gc->base + offset);
+	return pinctrl_gpio_direction(gc, offset, true);
 }
 EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_input_new);
 
-/* This function is deprecated and will be removed. Don't use. */
-int pinctrl_gpio_direction_output(unsigned gpio)
-{
-	return pinctrl_gpio_direction(gpio, false);
-}
-EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_output);
-
 /**
  * pinctrl_gpio_direction_output_new() - request a GPIO pin to go into output
  *                                       mode
@@ -933,31 +885,10 @@  EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_output);
  */
 int pinctrl_gpio_direction_output_new(struct gpio_chip *gc, unsigned int offset)
 {
-	return pinctrl_gpio_direction_output(gc->base + offset);
+	return pinctrl_gpio_direction(gc, offset, false);
 }
 EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_output_new);
 
-/* This function is deprecated and will be removed. Don't use. */
-int pinctrl_gpio_set_config(unsigned gpio, unsigned long config)
-{
-	unsigned long configs[] = { config };
-	struct pinctrl_gpio_range *range;
-	struct pinctrl_dev *pctldev;
-	int ret, pin;
-
-	ret = pinctrl_get_device_gpio_range(gpio, &pctldev, &range);
-	if (ret)
-		return ret;
-
-	mutex_lock(&pctldev->mutex);
-	pin = gpio_to_pin(range, gpio);
-	ret = pinconf_set_config(pctldev, pin, configs, ARRAY_SIZE(configs));
-	mutex_unlock(&pctldev->mutex);
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(pinctrl_gpio_set_config);
-
 /**
  * pinctrl_gpio_set_config_new() - Apply config to given GPIO pin
  * @gc: GPIO chip structure from the GPIO subsystem
@@ -971,7 +902,22 @@  EXPORT_SYMBOL_GPL(pinctrl_gpio_set_config);
 int pinctrl_gpio_set_config_new(struct gpio_chip *gc, unsigned int offset,
 				unsigned long config)
 {
-	return pinctrl_gpio_set_config(gc->base + offset, config);
+	unsigned long configs[] = { config };
+	struct pinctrl_gpio_range *range;
+	struct pinctrl_dev *pctldev;
+	int ret, pin;
+
+	ret = pinctrl_get_device_gpio_range(gc, offset, &pctldev, &range);
+	if (ret)
+		return ret;
+
+	scoped_guard(mutex, &pctldev->mutex) {
+		pin = gpio_to_pin(range, gc, offset);
+		ret = pinconf_set_config(pctldev, pin, configs,
+					 ARRAY_SIZE(configs));
+	}
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(pinctrl_gpio_set_config_new);
 
diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h
index c95c13983376..aa3a7a7ca52d 100644
--- a/include/linux/pinctrl/consumer.h
+++ b/include/linux/pinctrl/consumer.h
@@ -26,19 +26,13 @@  struct pinctrl_state;
 #ifdef CONFIG_PINCTRL
 
 /* External interface to pin control */
-bool pinctrl_gpio_can_use_line(unsigned gpio);
 bool pinctrl_gpio_can_use_line_new(struct gpio_chip *gc, unsigned int offset);
-int pinctrl_gpio_request(unsigned gpio);
 int pinctrl_gpio_request_new(struct gpio_chip *gc, unsigned int offset);
-void pinctrl_gpio_free(unsigned gpio);
 void pinctrl_gpio_free_new(struct gpio_chip *gc, unsigned int offset);
-int pinctrl_gpio_direction_input(unsigned gpio);
 int pinctrl_gpio_direction_input_new(struct gpio_chip *gc,
 				     unsigned int offset);
-int pinctrl_gpio_direction_output(unsigned gpio);
 int pinctrl_gpio_direction_output_new(struct gpio_chip *gc,
 				      unsigned int offset);
-int pinctrl_gpio_set_config(unsigned gpio, unsigned long config);
 int pinctrl_gpio_set_config_new(struct gpio_chip *gc, unsigned int offset,
 				unsigned long config);
 
@@ -73,64 +67,35 @@  static inline int pinctrl_pm_select_idle_state(struct device *dev)
 
 #else /* !CONFIG_PINCTRL */
 
-static inline bool pinctrl_gpio_can_use_line(unsigned gpio)
-{
-	return true;
-}
-
 static inline bool
 pinctrl_gpio_can_use_line_new(struct gpio_chip *gc, unsigned int offset)
 {
 	return true;
 }
 
-static inline int pinctrl_gpio_request(unsigned gpio)
-{
-	return 0;
-}
-
 static inline int
 pinctrl_gpio_request_new(struct gpio_chip *gc, unsigned int offset)
 {
 	return 0;
 }
 
-static inline void pinctrl_gpio_free(unsigned gpio)
-{
-}
-
 static inline void
 pinctrl_gpio_free_new(struct gpio_chip *gc, unsigned int offset)
 {
 }
 
-static inline int pinctrl_gpio_direction_input(unsigned gpio)
-{
-	return 0;
-}
-
 static inline int
 pinctrl_gpio_direction_input_new(struct gpio_chip *gc, unsigned int offset)
 {
 	return 0;
 }
 
-static inline int pinctrl_gpio_direction_output(unsigned gpio)
-{
-	return 0;
-}
-
 static inline int
 pinctrl_gpio_direction_output_new(struct gpio_chip *gc, unsigned int offset)
 {
 	return 0;
 }
 
-static inline int pinctrl_gpio_set_config(unsigned gpio, unsigned long config)
-{
-	return 0;
-}
-
 static inline int
 pinctrl_gpio_set_config_new(struct gpio_chip *gc, unsigned int offset,
 			    unsigned long config)