1 /* SPDX-License-Identifier: GPL-2.0 */ 2 3 #ifndef GPIOLIB_OF_H 4 #define GPIOLIB_OF_H 5 6 #include <linux/err.h> 7 #include <linux/errno.h> 8 #include <linux/types.h> 9 10 #include <linux/notifier.h> 11 12 struct device; 13 14 struct gpio_chip; 15 struct gpio_desc; 16 struct gpio_device; 17 18 #ifdef CONFIG_OF_GPIO 19 struct gpio_desc *of_find_gpio(struct device *dev, 20 const char *con_id, 21 unsigned int idx, 22 unsigned long *lookupflags); 23 int of_gpiochip_add(struct gpio_chip *gc); 24 void of_gpiochip_remove(struct gpio_chip *gc); 25 int of_gpio_get_count(struct device *dev, const char *con_id); 26 bool of_gpio_need_valid_mask(const struct gpio_chip *gc); 27 void of_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev); 28 #else 29 static inline struct gpio_desc *of_find_gpio(struct device *dev, 30 const char *con_id, 31 unsigned int idx, 32 unsigned long *lookupflags) 33 { 34 return ERR_PTR(-ENOENT); 35 } 36 static inline int of_gpiochip_add(struct gpio_chip *gc) { return 0; } 37 static inline void of_gpiochip_remove(struct gpio_chip *gc) { } 38 static inline int of_gpio_get_count(struct device *dev, const char *con_id) 39 { 40 return 0; 41 } 42 static inline bool of_gpio_need_valid_mask(const struct gpio_chip *gc) 43 { 44 return false; 45 } 46 static inline void of_gpio_dev_init(struct gpio_chip *gc, 47 struct gpio_device *gdev) 48 { 49 } 50 #endif /* CONFIG_OF_GPIO */ 51 52 extern struct notifier_block gpio_of_notifier; 53 54 #endif /* GPIOLIB_OF_H */ 55