}
 EXPORT_SYMBOL(of_get_named_gpio_flags);
 
+struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
+                              unsigned int idx,
+                              enum gpio_lookup_flags *flags)
+{
+       char prop_name[32]; /* 32 is max size of property name */
+       enum of_gpio_flags of_flags;
+       struct gpio_desc *desc;
+       unsigned int i;
+
+       for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
+               if (con_id)
+                       snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id,
+                                gpio_suffixes[i]);
+               else
+                       snprintf(prop_name, sizeof(prop_name), "%s",
+                                gpio_suffixes[i]);
+
+               desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx,
+                                               &of_flags);
+               if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
+                       break;
+       }
+
+       if (IS_ERR(desc))
+               return desc;
+
+       if (of_flags & OF_GPIO_ACTIVE_LOW)
+               *flags |= GPIO_ACTIVE_LOW;
+
+       if (of_flags & OF_GPIO_SINGLE_ENDED) {
+               if (of_flags & OF_GPIO_ACTIVE_LOW)
+                       *flags |= GPIO_OPEN_DRAIN;
+               else
+                       *flags |= GPIO_OPEN_SOURCE;
+       }
+
+       return desc;
+}
+
 /**
  * of_parse_own_gpio() - Get a GPIO hog descriptor, names and flags for GPIO API
  * @np:                device node to get GPIO from
 
        mutex_unlock(&gpio_lookup_lock);
 }
 
-static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
-                                     unsigned int idx,
-                                     enum gpio_lookup_flags *flags)
-{
-       char prop_name[32]; /* 32 is max size of property name */
-       enum of_gpio_flags of_flags;
-       struct gpio_desc *desc;
-       unsigned int i;
-
-       for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
-               if (con_id)
-                       snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id,
-                                gpio_suffixes[i]);
-               else
-                       snprintf(prop_name, sizeof(prop_name), "%s",
-                                gpio_suffixes[i]);
-
-               desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx,
-                                               &of_flags);
-               if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
-                       break;
-       }
-
-       if (IS_ERR(desc))
-               return desc;
-
-       if (of_flags & OF_GPIO_ACTIVE_LOW)
-               *flags |= GPIO_ACTIVE_LOW;
-
-       if (of_flags & OF_GPIO_SINGLE_ENDED) {
-               if (of_flags & OF_GPIO_ACTIVE_LOW)
-                       *flags |= GPIO_OPEN_DRAIN;
-               else
-                       *flags |= GPIO_OPEN_SOURCE;
-       }
-
-       return desc;
-}
-
 static struct gpio_desc *acpi_find_gpio(struct device *dev,
                                        const char *con_id,
                                        unsigned int idx,
 
 
 enum of_gpio_flags;
 enum gpiod_flags;
+enum gpio_lookup_flags;
 struct acpi_device;
 
 /**
 /* gpio suffixes used for ACPI and device tree lookup */
 static const char * const gpio_suffixes[] = { "gpios", "gpio" };
 
+#ifdef CONFIG_OF_GPIO
+struct gpio_desc *of_find_gpio(struct device *dev,
+                              const char *con_id,
+                              unsigned int idx,
+                              enum gpio_lookup_flags *flags);
+#else
+static inline struct gpio_desc *of_find_gpio(struct device *dev,
+                                            const char *con_id,
+                                            unsigned int idx,
+                                            enum gpio_lookup_flags *flags)
+{
+       return ERR_PTR(-ENOENT);
+}
+#endif /* CONFIG_OF_GPIO */
+
 #ifdef CONFIG_ACPI
 void acpi_gpiochip_add(struct gpio_chip *chip);
 void acpi_gpiochip_remove(struct gpio_chip *chip);