[v2,31/62] pinctrl: remove pinctrl_gpio_request()

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

Commit Message

Bartosz Golaszewski Oct. 11, 2023, 12:07 p.m. UTC
  From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

There are no more users of pinctrl_gpio_request() so remove it.

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

Comments

Andy Shevchenko Oct. 11, 2023, 4:54 p.m. UTC | #1
On Wed, Oct 11, 2023 at 02:07:59PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> There are no more users of pinctrl_gpio_request() so remove it.

My question was and still is why can't we preserve most of the code?
It seems with changing a prototype to a new one and using a temporary variable
will reduce the diff noise quite a lot.

Another question is can we actually derive old functions from _new ones?

Like

foo_new(struct gpio_chip *gc, unsigned int offset)
{
	...real implementation...
}

foo(unsigned gpio)
{
	...something to get gpio chip and offset...
	foo_new(gc, offset);
}

?
  
Bartosz Golaszewski Oct. 12, 2023, 7:43 p.m. UTC | #2
On Wed, Oct 11, 2023 at 6:55 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Wed, Oct 11, 2023 at 02:07:59PM +0200, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > There are no more users of pinctrl_gpio_request() so remove it.
>
> My question was and still is why can't we preserve most of the code?
> It seems with changing a prototype to a new one and using a temporary variable
> will reduce the diff noise quite a lot.
>
> Another question is can we actually derive old functions from _new ones?
>
> Like
>
> foo_new(struct gpio_chip *gc, unsigned int offset)
> {
>         ...real implementation...
> }
>
> foo(unsigned gpio)
> {
>         ...something to get gpio chip and offset...
>         foo_new(gc, offset);
> }
>
> ?

Why would we do it? This is irrelevant for the final outcome.

Bart

>
> --
> With Best Regards,
> Andy Shevchenko
>
>
  

Patch

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 024e3825fa98..837d35b0e5c3 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -783,34 +783,6 @@  bool pinctrl_gpio_can_use_line_new(struct gpio_chip *gc, unsigned int 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
@@ -822,7 +794,28 @@  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->base + offset, &pctldev,
+					    &range);
+	if (ret) {
+		if (pinctrl_ready_for_gpio_range(gc->base + offset))
+			ret = 0;
+		return ret;
+	}
+
+	mutex_lock(&pctldev->mutex);
+
+	/* Convert to the pin controllers number space */
+	pin = gpio_to_pin(range, gc->base + offset);
+
+	ret = pinmux_request_gpio(pctldev, range, pin, gc->base + offset);
+
+	mutex_unlock(&pctldev->mutex);
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(pinctrl_gpio_request_new);
 
diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h
index 105a4b0c1c14..ffce8d7dd0d3 100644
--- a/include/linux/pinctrl/consumer.h
+++ b/include/linux/pinctrl/consumer.h
@@ -27,7 +27,6 @@  struct pinctrl_state;
 
 /* External interface to pin control */
 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);