提交 66f46e37 编写于 作者: A Andy Shevchenko 提交者: Bartosz Golaszewski

gpiolib: Split out for_each_gpio_desc() macro

In some cases we want to traverse all GPIO descriptors for given
chip, let's split out for_each_gpio_desc() macro for such cases.
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
上级 57017edd
...@@ -308,15 +308,10 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name) ...@@ -308,15 +308,10 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name)
spin_lock_irqsave(&gpio_lock, flags); spin_lock_irqsave(&gpio_lock, flags);
list_for_each_entry(gdev, &gpio_devices, list) { list_for_each_entry(gdev, &gpio_devices, list) {
int i; struct gpio_desc *desc;
for (i = 0; i != gdev->ngpio; ++i) {
struct gpio_desc *desc = &gdev->descs[i];
if (!desc->name)
continue;
if (!strcmp(desc->name, name)) { for_each_gpio_desc(gdev->chip, desc) {
if (desc->name && !strcmp(desc->name, name)) {
spin_unlock_irqrestore(&gpio_lock, flags); spin_unlock_irqrestore(&gpio_lock, flags);
return desc; return desc;
} }
......
...@@ -100,10 +100,13 @@ struct gpio_array { ...@@ -100,10 +100,13 @@ struct gpio_array {
struct gpio_desc *gpiochip_get_desc(struct gpio_chip *gc, unsigned int hwnum); struct gpio_desc *gpiochip_get_desc(struct gpio_chip *gc, unsigned int hwnum);
#define for_each_gpio_desc_with_flag(gc, desc, flag) \ #define for_each_gpio_desc(gc, desc) \
for (unsigned int __i = 0; \ for (unsigned int __i = 0; \
__i < gc->ngpio && (desc = gpiochip_get_desc(gc, __i)); \ __i < gc->ngpio && (desc = gpiochip_get_desc(gc, __i)); \
__i++) \ __i++) \
#define for_each_gpio_desc_with_flag(gc, desc, flag) \
for_each_gpio_desc(gc, desc) \
if (!test_bit(flag, &desc->flags)) {} else if (!test_bit(flag, &desc->flags)) {} else
int gpiod_get_array_value_complex(bool raw, bool can_sleep, int gpiod_get_array_value_complex(bool raw, bool can_sleep,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册