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

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>

+46 -46
+46
drivers/gpio/gpiolib-devres.c
··· 478 478 &gpio)); 479 479 } 480 480 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);
-46
drivers/gpio/gpiolib.c
··· 1838 1838 } 1839 1839 EXPORT_SYMBOL_GPL(gpiochip_remove); 1840 1840 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 - 1887 1841 /** 1888 1842 * gpiochip_find() - iterator for locating a specific gpio_chip 1889 1843 * @data: data to pass to match function