mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
pinctrl: introduce pinctrl_gpio_get_config()
This is a counterpart of pinctrl_gpio_set_config(), which will be used to implement the ->get() interface in a GPIO driver for SCMI. This also requires that we create a stub so pin_config_get_for_pin() can build when CONFIG_PINCONF is disabled. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Linus Walleij <linusw@kernel.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Linus Walleij <linusw@kernel.org>
This commit is contained in:
parent
6de23f81a5
commit
96b76f7bc5
|
|
@ -30,6 +30,7 @@
|
|||
#include <linux/pinctrl/consumer.h>
|
||||
#include <linux/pinctrl/devinfo.h>
|
||||
#include <linux/pinctrl/machine.h>
|
||||
#include <linux/pinctrl/pinconf.h>
|
||||
#include <linux/pinctrl/pinctrl.h>
|
||||
|
||||
#include "core.h"
|
||||
|
|
@ -938,6 +939,36 @@ int pinctrl_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(pinctrl_gpio_set_config);
|
||||
|
||||
/**
|
||||
* pinctrl_gpio_get_config() - Get the config for a given GPIO pin
|
||||
* @gc: GPIO chip structure from the GPIO subsystem
|
||||
* @offset: hardware offset of the GPIO relative to the controller
|
||||
* @config: the configuration to query. On success it holds the result
|
||||
* Return: 0 on success, negative errno otherwise
|
||||
*/
|
||||
int pinctrl_gpio_get_config(struct gpio_chip *gc, unsigned int offset, unsigned long *config)
|
||||
{
|
||||
struct pinctrl_gpio_range *range;
|
||||
struct pinctrl_dev *pctldev;
|
||||
int ret, pin;
|
||||
|
||||
ret = pinctrl_get_device_gpio_range(gc, offset, &pctldev, &range);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&pctldev->mutex);
|
||||
pin = gpio_to_pin(range, gc, offset);
|
||||
ret = pin_config_get_for_pin(pctldev, pin, config);
|
||||
mutex_unlock(&pctldev->mutex);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
*config = pinconf_to_config_argument(*config);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pinctrl_gpio_get_config);
|
||||
|
||||
static struct pinctrl_state *find_state(struct pinctrl *p,
|
||||
const char *name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,6 +74,12 @@ static inline int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned int p
|
|||
return -ENOTSUPP;
|
||||
}
|
||||
|
||||
static inline int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned int pin,
|
||||
unsigned long *config)
|
||||
{
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_PINCONF) && defined(CONFIG_DEBUG_FS)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ int pinctrl_gpio_direction_output(struct gpio_chip *gc,
|
|||
unsigned int offset);
|
||||
int pinctrl_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
|
||||
unsigned long config);
|
||||
int pinctrl_gpio_get_config(struct gpio_chip *gc, unsigned int offset,
|
||||
unsigned long *config);
|
||||
|
||||
struct pinctrl * __must_check pinctrl_get(struct device *dev);
|
||||
void pinctrl_put(struct pinctrl *p);
|
||||
|
|
@ -101,6 +103,13 @@ pinctrl_gpio_direction_output(struct gpio_chip *gc, unsigned int offset)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
pinctrl_gpio_get_config(struct gpio_chip *gc, unsigned int offset,
|
||||
unsigned long *config)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
pinctrl_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
|
||||
unsigned long config)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user