All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: Move devres calls to devres file
@ 2020-03-13  8:15 Linus Walleij
  2020-03-13 18:18 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2020-03-13  8:15 UTC (permalink / raw)
  To: linux-gpio; +Cc: Bartosz Golaszewski, Linus Walleij

These two devres functions devm_gpiochip_[add|remove]()
were in the wrong file. They should be in gpiolib-devres.c
not gpiolib.c.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpiolib-devres.c | 46 +++++++++++++++++++++++++++++++++++
 drivers/gpio/gpiolib.c        | 46 -----------------------------------
 2 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/drivers/gpio/gpiolib-devres.c b/drivers/gpio/gpiolib-devres.c
index 72b6001c56ef..5c91c4365da1 100644
--- a/drivers/gpio/gpiolib-devres.c
+++ b/drivers/gpio/gpiolib-devres.c
@@ -478,3 +478,49 @@ void devm_gpio_free(struct device *dev, unsigned int gpio)
 		&gpio));
 }
 EXPORT_SYMBOL_GPL(devm_gpio_free);
+
+static void devm_gpio_chip_release(struct device *dev, void *res)
+{
+	struct gpio_chip *gc = *(struct gpio_chip **)res;
+
+	gpiochip_remove(gc);
+}
+
+/**
+ * devm_gpiochip_add_data() - Resource managed gpiochip_add_data()
+ * @dev: pointer to the device that gpio_chip belongs to.
+ * @gc: the GPIO chip to register
+ * @data: driver-private data associated with this chip
+ *
+ * Context: potentially before irqs will work
+ *
+ * The gpio chip automatically be released when the device is unbound.
+ *
+ * Returns:
+ * A negative errno if the chip can't be registered, such as because the
+ * gc->base is invalid or already associated with a different chip.
+ * Otherwise it returns zero as a success code.
+ */
+int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *gc,
+			   void *data)
+{
+	struct gpio_chip **ptr;
+	int ret;
+
+	ptr = devres_alloc(devm_gpio_chip_release, sizeof(*ptr),
+			     GFP_KERNEL);
+	if (!ptr)
+		return -ENOMEM;
+
+	ret = gpiochip_add_data(gc, data);
+	if (ret < 0) {
+		devres_free(ptr);
+		return ret;
+	}
+
+	*ptr = gc;
+	devres_add(dev, ptr);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(devm_gpiochip_add_data);
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 02f8b2b81199..00890f38f95f 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1838,52 +1838,6 @@ void gpiochip_remove(struct gpio_chip *chip)
 }
 EXPORT_SYMBOL_GPL(gpiochip_remove);
 
-static void devm_gpio_chip_release(struct device *dev, void *res)
-{
-	struct gpio_chip *chip = *(struct gpio_chip **)res;
-
-	gpiochip_remove(chip);
-}
-
-/**
- * devm_gpiochip_add_data() - Resource managed gpiochip_add_data()
- * @dev: pointer to the device that gpio_chip belongs to.
- * @chip: the chip to register, with chip->base initialized
- * @data: driver-private data associated with this chip
- *
- * Context: potentially before irqs will work
- *
- * The gpio chip automatically be released when the device is unbound.
- *
- * Returns:
- * A negative errno if the chip can't be registered, such as because the
- * chip->base is invalid or already associated with a different chip.
- * Otherwise it returns zero as a success code.
- */
-int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *chip,
-			   void *data)
-{
-	struct gpio_chip **ptr;
-	int ret;
-
-	ptr = devres_alloc(devm_gpio_chip_release, sizeof(*ptr),
-			     GFP_KERNEL);
-	if (!ptr)
-		return -ENOMEM;
-
-	ret = gpiochip_add_data(chip, data);
-	if (ret < 0) {
-		devres_free(ptr);
-		return ret;
-	}
-
-	*ptr = chip;
-	devres_add(dev, ptr);
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(devm_gpiochip_add_data);
-
 /**
  * gpiochip_find() - iterator for locating a specific gpio_chip
  * @data: data to pass to match function
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpio: Move devres calls to devres file
  2020-03-13  8:15 [PATCH] gpio: Move devres calls to devres file Linus Walleij
@ 2020-03-13 18:18 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2020-03-13 18:18 UTC (permalink / raw)
  To: Linus Walleij; +Cc: open list:GPIO SUBSYSTEM, Bartosz Golaszewski

pt., 13 mar 2020 o 09:15 Linus Walleij <linus.walleij@linaro.org> napisał(a):
>
> These two devres functions devm_gpiochip_[add|remove]()
> were in the wrong file. They should be in gpiolib-devres.c
> not gpiolib.c.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/gpio/gpiolib-devres.c | 46 +++++++++++++++++++++++++++++++++++
>  drivers/gpio/gpiolib.c        | 46 -----------------------------------
>  2 files changed, 46 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-devres.c b/drivers/gpio/gpiolib-devres.c
> index 72b6001c56ef..5c91c4365da1 100644
> --- a/drivers/gpio/gpiolib-devres.c
> +++ b/drivers/gpio/gpiolib-devres.c
> @@ -478,3 +478,49 @@ void devm_gpio_free(struct device *dev, unsigned int gpio)
>                 &gpio));
>  }
>  EXPORT_SYMBOL_GPL(devm_gpio_free);
> +
> +static void devm_gpio_chip_release(struct device *dev, void *res)
> +{
> +       struct gpio_chip *gc = *(struct gpio_chip **)res;
> +
> +       gpiochip_remove(gc);
> +}
> +
> +/**
> + * devm_gpiochip_add_data() - Resource managed gpiochip_add_data()
> + * @dev: pointer to the device that gpio_chip belongs to.
> + * @gc: the GPIO chip to register
> + * @data: driver-private data associated with this chip
> + *
> + * Context: potentially before irqs will work
> + *
> + * The gpio chip automatically be released when the device is unbound.
> + *
> + * Returns:
> + * A negative errno if the chip can't be registered, such as because the
> + * gc->base is invalid or already associated with a different chip.
> + * Otherwise it returns zero as a success code.
> + */
> +int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *gc,
> +                          void *data)
> +{
> +       struct gpio_chip **ptr;
> +       int ret;
> +
> +       ptr = devres_alloc(devm_gpio_chip_release, sizeof(*ptr),
> +                            GFP_KERNEL);
> +       if (!ptr)
> +               return -ENOMEM;
> +
> +       ret = gpiochip_add_data(gc, data);
> +       if (ret < 0) {
> +               devres_free(ptr);
> +               return ret;
> +       }
> +
> +       *ptr = gc;
> +       devres_add(dev, ptr);
> +
> +       return 0;
> +}
> +EXPORT_SYMBOL_GPL(devm_gpiochip_add_data);
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 02f8b2b81199..00890f38f95f 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -1838,52 +1838,6 @@ void gpiochip_remove(struct gpio_chip *chip)
>  }
>  EXPORT_SYMBOL_GPL(gpiochip_remove);
>
> -static void devm_gpio_chip_release(struct device *dev, void *res)
> -{
> -       struct gpio_chip *chip = *(struct gpio_chip **)res;
> -
> -       gpiochip_remove(chip);
> -}
> -
> -/**
> - * devm_gpiochip_add_data() - Resource managed gpiochip_add_data()
> - * @dev: pointer to the device that gpio_chip belongs to.
> - * @chip: the chip to register, with chip->base initialized
> - * @data: driver-private data associated with this chip
> - *
> - * Context: potentially before irqs will work
> - *
> - * The gpio chip automatically be released when the device is unbound.
> - *
> - * Returns:
> - * A negative errno if the chip can't be registered, such as because the
> - * chip->base is invalid or already associated with a different chip.
> - * Otherwise it returns zero as a success code.
> - */
> -int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *chip,
> -                          void *data)
> -{
> -       struct gpio_chip **ptr;
> -       int ret;
> -
> -       ptr = devres_alloc(devm_gpio_chip_release, sizeof(*ptr),
> -                            GFP_KERNEL);
> -       if (!ptr)
> -               return -ENOMEM;
> -
> -       ret = gpiochip_add_data(chip, data);
> -       if (ret < 0) {
> -               devres_free(ptr);
> -               return ret;
> -       }
> -
> -       *ptr = chip;
> -       devres_add(dev, ptr);
> -
> -       return 0;
> -}
> -EXPORT_SYMBOL_GPL(devm_gpiochip_add_data);
> -
>  /**
>   * gpiochip_find() - iterator for locating a specific gpio_chip
>   * @data: data to pass to match function
> --
> 2.24.1
>

Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-13 18:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-13  8:15 [PATCH] gpio: Move devres calls to devres file Linus Walleij
2020-03-13 18:18 ` Bartosz Golaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.