Skip to content

Commit a28e1c0

Browse files
author
Linus Walleij
committed
gpio: Move devres calls to devres file
These two devres functions devm_gpiochip_[add|remove]() were in the wrong file. They should be in gpiolib-devres.c not gpiolib.c. Link: https://lore.kernel.org/r/20200313081522.35143-1-linus.walleij@linaro.org Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 347ae6e commit a28e1c0

2 files changed

Lines changed: 46 additions & 46 deletions

File tree

‎drivers/gpio/gpiolib-devres.c‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,3 +478,49 @@ void devm_gpio_free(struct device *dev, unsigned int gpio)
478478
&gpio));
479479
}
480480
EXPORT_SYMBOL_GPL(devm_gpio_free);
481+
482+
static void devm_gpio_chip_release(struct device *dev, void *res)
483+
{
484+
struct gpio_chip *gc = *(struct gpio_chip **)res;
485+
486+
gpiochip_remove(gc);
487+
}
488+
489+
/**
490+
* devm_gpiochip_add_data() - Resource managed gpiochip_add_data()
491+
* @dev: pointer to the device that gpio_chip belongs to.
492+
* @gc: the GPIO chip to register
493+
* @data: driver-private data associated with this chip
494+
*
495+
* Context: potentially before irqs will work
496+
*
497+
* The gpio chip automatically be released when the device is unbound.
498+
*
499+
* Returns:
500+
* A negative errno if the chip can't be registered, such as because the
501+
* gc->base is invalid or already associated with a different chip.
502+
* Otherwise it returns zero as a success code.
503+
*/
504+
int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *gc,
505+
void *data)
506+
{
507+
struct gpio_chip **ptr;
508+
int ret;
509+
510+
ptr = devres_alloc(devm_gpio_chip_release, sizeof(*ptr),
511+
GFP_KERNEL);
512+
if (!ptr)
513+
return -ENOMEM;
514+
515+
ret = gpiochip_add_data(gc, data);
516+
if (ret < 0) {
517+
devres_free(ptr);
518+
return ret;
519+
}
520+
521+
*ptr = gc;
522+
devres_add(dev, ptr);
523+
524+
return 0;
525+
}
526+
EXPORT_SYMBOL_GPL(devm_gpiochip_add_data);

‎drivers/gpio/gpiolib.c‎

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,52 +1838,6 @@ void gpiochip_remove(struct gpio_chip *chip)
18381838
}
18391839
EXPORT_SYMBOL_GPL(gpiochip_remove);
18401840

1841-
static void devm_gpio_chip_release(struct device *dev, void *res)
1842-
{
1843-
struct gpio_chip *chip = *(struct gpio_chip **)res;
1844-
1845-
gpiochip_remove(chip);
1846-
}
1847-
1848-
/**
1849-
* devm_gpiochip_add_data() - Resource managed gpiochip_add_data()
1850-
* @dev: pointer to the device that gpio_chip belongs to.
1851-
* @chip: the chip to register, with chip->base initialized
1852-
* @data: driver-private data associated with this chip
1853-
*
1854-
* Context: potentially before irqs will work
1855-
*
1856-
* The gpio chip automatically be released when the device is unbound.
1857-
*
1858-
* Returns:
1859-
* A negative errno if the chip can't be registered, such as because the
1860-
* chip->base is invalid or already associated with a different chip.
1861-
* Otherwise it returns zero as a success code.
1862-
*/
1863-
int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *chip,
1864-
void *data)
1865-
{
1866-
struct gpio_chip **ptr;
1867-
int ret;
1868-
1869-
ptr = devres_alloc(devm_gpio_chip_release, sizeof(*ptr),
1870-
GFP_KERNEL);
1871-
if (!ptr)
1872-
return -ENOMEM;
1873-
1874-
ret = gpiochip_add_data(chip, data);
1875-
if (ret < 0) {
1876-
devres_free(ptr);
1877-
return ret;
1878-
}
1879-
1880-
*ptr = chip;
1881-
devres_add(dev, ptr);
1882-
1883-
return 0;
1884-
}
1885-
EXPORT_SYMBOL_GPL(devm_gpiochip_add_data);
1886-
18871841
/**
18881842
* gpiochip_find() - iterator for locating a specific gpio_chip
18891843
* @data: data to pass to match function

0 commit comments

Comments
 (0)