mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-07-05 13:25:20 +02:00
gpiolib: legacy: Consolidate devm_gpio_*() with other legacy APIs
There is no reason to keep deprecated legacy API implementations in the gpiolib-devres.c. Consolidate devm_gpio_*() with other legacy APIs. While at it, clean up header inclusion block in gpiolib-devres.c. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240828151357.2677340-1-andriy.shevchenko@linux.intel.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
94bd9ce160
commit
d25f9ab17d
|
@ -6,15 +6,19 @@
|
||||||
* Copyright (c) 2011 John Crispin <john@phrozen.org>
|
* Copyright (c) 2011 John Crispin <john@phrozen.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/module.h>
|
|
||||||
#include <linux/err.h>
|
|
||||||
#include <linux/gpio.h>
|
|
||||||
#include <linux/gpio/consumer.h>
|
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
|
#include <linux/err.h>
|
||||||
|
#include <linux/export.h>
|
||||||
#include <linux/gfp.h>
|
#include <linux/gfp.h>
|
||||||
|
#include <linux/types.h>
|
||||||
|
|
||||||
|
#include <linux/gpio/consumer.h>
|
||||||
|
|
||||||
#include "gpiolib.h"
|
#include "gpiolib.h"
|
||||||
|
|
||||||
|
struct fwnode_handle;
|
||||||
|
struct lock_class_key;
|
||||||
|
|
||||||
static void devm_gpiod_release(struct device *dev, void *res)
|
static void devm_gpiod_release(struct device *dev, void *res)
|
||||||
{
|
{
|
||||||
struct gpio_desc **desc = res;
|
struct gpio_desc **desc = res;
|
||||||
|
@ -354,76 +358,6 @@ void devm_gpiod_put_array(struct device *dev, struct gpio_descs *descs)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(devm_gpiod_put_array);
|
EXPORT_SYMBOL_GPL(devm_gpiod_put_array);
|
||||||
|
|
||||||
static void devm_gpio_release(struct device *dev, void *res)
|
|
||||||
{
|
|
||||||
unsigned *gpio = res;
|
|
||||||
|
|
||||||
gpio_free(*gpio);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* devm_gpio_request - request a GPIO for a managed device
|
|
||||||
* @dev: device to request the GPIO for
|
|
||||||
* @gpio: GPIO to allocate
|
|
||||||
* @label: the name of the requested GPIO
|
|
||||||
*
|
|
||||||
* Except for the extra @dev argument, this function takes the
|
|
||||||
* same arguments and performs the same function as
|
|
||||||
* gpio_request(). GPIOs requested with this function will be
|
|
||||||
* automatically freed on driver detach.
|
|
||||||
*/
|
|
||||||
int devm_gpio_request(struct device *dev, unsigned gpio, const char *label)
|
|
||||||
{
|
|
||||||
unsigned *dr;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
dr = devres_alloc(devm_gpio_release, sizeof(unsigned), GFP_KERNEL);
|
|
||||||
if (!dr)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
rc = gpio_request(gpio, label);
|
|
||||||
if (rc) {
|
|
||||||
devres_free(dr);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
*dr = gpio;
|
|
||||||
devres_add(dev, dr);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL_GPL(devm_gpio_request);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* devm_gpio_request_one - request a single GPIO with initial setup
|
|
||||||
* @dev: device to request for
|
|
||||||
* @gpio: the GPIO number
|
|
||||||
* @flags: GPIO configuration as specified by GPIOF_*
|
|
||||||
* @label: a literal description string of this GPIO
|
|
||||||
*/
|
|
||||||
int devm_gpio_request_one(struct device *dev, unsigned gpio,
|
|
||||||
unsigned long flags, const char *label)
|
|
||||||
{
|
|
||||||
unsigned *dr;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
dr = devres_alloc(devm_gpio_release, sizeof(unsigned), GFP_KERNEL);
|
|
||||||
if (!dr)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
rc = gpio_request_one(gpio, flags, label);
|
|
||||||
if (rc) {
|
|
||||||
devres_free(dr);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
*dr = gpio;
|
|
||||||
devres_add(dev, dr);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL_GPL(devm_gpio_request_one);
|
|
||||||
|
|
||||||
static void devm_gpio_chip_release(void *data)
|
static void devm_gpio_chip_release(void *data)
|
||||||
{
|
{
|
||||||
struct gpio_chip *gc = data;
|
struct gpio_chip *gc = data;
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
#include <linux/bitops.h>
|
||||||
|
#include <linux/device.h>
|
||||||
|
#include <linux/errno.h>
|
||||||
|
#include <linux/export.h>
|
||||||
|
#include <linux/gfp.h>
|
||||||
|
|
||||||
#include <linux/gpio/consumer.h>
|
#include <linux/gpio/consumer.h>
|
||||||
#include <linux/gpio/driver.h>
|
#include <linux/gpio/driver.h>
|
||||||
|
|
||||||
|
@ -74,3 +80,83 @@ int gpio_request(unsigned gpio, const char *label)
|
||||||
return gpiod_request(desc, label);
|
return gpiod_request(desc, label);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(gpio_request);
|
EXPORT_SYMBOL_GPL(gpio_request);
|
||||||
|
|
||||||
|
static void devm_gpio_release(struct device *dev, void *res)
|
||||||
|
{
|
||||||
|
unsigned *gpio = res;
|
||||||
|
|
||||||
|
gpio_free(*gpio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* devm_gpio_request - request a GPIO for a managed device
|
||||||
|
* @dev: device to request the GPIO for
|
||||||
|
* @gpio: GPIO to allocate
|
||||||
|
* @label: the name of the requested GPIO
|
||||||
|
*
|
||||||
|
* Except for the extra @dev argument, this function takes the
|
||||||
|
* same arguments and performs the same function as gpio_request().
|
||||||
|
* GPIOs requested with this function will be automatically freed
|
||||||
|
* on driver detach.
|
||||||
|
*
|
||||||
|
* **DEPRECATED** This function is deprecated and must not be used in new code.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* 0 on success, or negative errno on failure.
|
||||||
|
*/
|
||||||
|
int devm_gpio_request(struct device *dev, unsigned gpio, const char *label)
|
||||||
|
{
|
||||||
|
unsigned *dr;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
dr = devres_alloc(devm_gpio_release, sizeof(unsigned), GFP_KERNEL);
|
||||||
|
if (!dr)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
rc = gpio_request(gpio, label);
|
||||||
|
if (rc) {
|
||||||
|
devres_free(dr);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
*dr = gpio;
|
||||||
|
devres_add(dev, dr);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(devm_gpio_request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* devm_gpio_request_one - request a single GPIO with initial setup
|
||||||
|
* @dev: device to request for
|
||||||
|
* @gpio: the GPIO number
|
||||||
|
* @flags: GPIO configuration as specified by GPIOF_*
|
||||||
|
* @label: a literal description string of this GPIO
|
||||||
|
*
|
||||||
|
* **DEPRECATED** This function is deprecated and must not be used in new code.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* 0 on success, or negative errno on failure.
|
||||||
|
*/
|
||||||
|
int devm_gpio_request_one(struct device *dev, unsigned gpio,
|
||||||
|
unsigned long flags, const char *label)
|
||||||
|
{
|
||||||
|
unsigned *dr;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
dr = devres_alloc(devm_gpio_release, sizeof(unsigned), GFP_KERNEL);
|
||||||
|
if (!dr)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
rc = gpio_request_one(gpio, flags, label);
|
||||||
|
if (rc) {
|
||||||
|
devres_free(dr);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
*dr = gpio;
|
||||||
|
devres_add(dev, dr);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(devm_gpio_request_one);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user