Commit 33d28eee authored by Hongzhan Chen's avatar Hongzhan Chen Committed by Jan Kiszka
Browse files

drivers/gpio: core: Introduce helper to find gpiochip



To find gpiochip for non-OF platforms like x86
Signed-off-by: default avatarHongzhan Chen <hongzhan.chen@intel.com>
[Jan: adjust parameter name 'compat' to 'label', reindent]
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent fc4b4fcc
......@@ -62,6 +62,11 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
int rtdm_gpiochip_post_event(struct rtdm_gpio_chip *rgc,
unsigned int offset);
int rtdm_gpiochip_find(struct device_node *from, const char *label, int type);
int rtdm_gpiochip_array_find(struct device_node *from, const char *label[],
int nentries, int type);
#ifdef CONFIG_OF
int rtdm_gpiochip_scan_of(struct device_node *from,
......
......@@ -531,6 +531,46 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
}
EXPORT_SYMBOL_GPL(rtdm_gpiochip_add_by_name);
int rtdm_gpiochip_find(struct device_node *from, const char *label, int type)
{
struct rtdm_gpio_chip *rgc;
struct gpio_chip *chip;
int ret = -ENODEV;
if (!rtdm_available())
return -ENOSYS;
chip = find_chip_by_name(label);
if (chip == NULL)
return ret;
ret = 0;
rgc = rtdm_gpiochip_alloc(chip, type);
if (IS_ERR(rgc))
ret = PTR_ERR(rgc);
return ret;
}
EXPORT_SYMBOL_GPL(rtdm_gpiochip_find);
int rtdm_gpiochip_array_find(struct device_node *from, const char *label[],
int nentries, int type)
{
int ret = -ENODEV, _ret, n;
for (n = 0; n < nentries; n++) {
_ret = rtdm_gpiochip_find(from, label[n], type);
if (_ret) {
if (_ret != -ENODEV)
return _ret;
} else
ret = 0;
}
return ret;
}
EXPORT_SYMBOL_GPL(rtdm_gpiochip_array_find);
#ifdef CONFIG_OF
#include <linux/of_platform.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment