2 //#include <linux/err.h>
3 #include <asm/arch/gpio.h>
4 #include <linux/gpio.h>
6 #include <asm/bitops.h>
8 /* Optional implementation infrastructure for GPIO interfaces.
10 * Platforms may want to use this if they tend to use very many GPIOs
11 * that aren't part of a System-On-Chip core; or across I2C/SPI/etc.
13 * When kernel footprint or instruction count is an issue, simpler
14 * implementations may be preferred. The GPIO programming interface
15 * allows for inlining speed-critical get/set operations for common
16 * cases, so that access to SOC-integrated GPIOs can sometimes cost
17 * only an instruction or two per bit.
21 /* When debugging, extend minimal trust to callers and platform code.
22 * Also emit diagnostic messages that may help initial bringup, when
23 * board setup or driver bugs are most common.
25 * Otherwise, minimize overhead in what may be bitbanging codepaths.
28 #define extra_checks 1
30 #define extra_checks 0
33 /* gpio_lock prevents conflicts during gpio_desc[] table updates.
34 * While any GPIO is requested, its gpio_chip is not removable;
35 * each GPIO's "requested" flag serves as a lock and refcount.
37 static DEFINE_SPINLOCK(gpio_lock);
40 struct gpio_chip *chip;
42 /* flag symbols are bit numbers */
43 #define FLAG_REQUESTED 0
45 #define FLAG_RESERVED 2
46 #define FLAG_EXPORT 3 /* protected by sysfs_lock */
47 #define FLAG_SYSFS 4 /* exported via /sys/class/gpio/control */
48 #define FLAG_TRIG_FALL 5 /* trigger on falling edge */
49 #define FLAG_TRIG_RISE 6 /* trigger on rising edge */
50 #define FLAG_ACTIVE_LOW 7 /* sysfs value has active low */
51 #define FLAG_OPEN_DRAIN 8 /* Gpio is open drain type */
52 #define FLAG_OPEN_SOURCE 9 /* Gpio is open source type */
54 #define ID_SHIFT 16 /* add new flags before this one */
56 #define GPIO_FLAGS_MASK ((1 << ID_SHIFT) - 1)
57 #define GPIO_TRIGGER_MASK (BIT(FLAG_TRIG_FALL) | BIT(FLAG_TRIG_RISE))
59 #ifdef CONFIG_DEBUG_FS
63 static struct gpio_desc gpio_desc[ARCH_NR_GPIOS];
65 #ifdef CONFIG_GPIO_SYSFS
66 static DEFINE_IDR(dirent_idr);
69 static inline void desc_set_label(struct gpio_desc *d, const char *label)
71 #ifdef CONFIG_DEBUG_FS
76 /* Warn when drivers omit gpio_request() calls -- legal but ill-advised
77 * when setting direction, and otherwise illegal. Until board setup code
78 * and drivers use explicit requests everywhere (which won't happen when
79 * those calls have no teeth) we can't avoid autorequesting. This nag
80 * message should motivate switching to explicit requests... so should
81 * the weaker cleanup after faults, compared to gpio_request().
83 * NOTE: the autorequest mechanism is going away; at this point it's
84 * only "legal" in the sense that (old) code using it won't break yet,
85 * but instead only triggers a WARN() stack dump.
87 static int gpio_ensure_requested(struct gpio_desc *desc, unsigned offset)
89 const struct gpio_chip *chip = desc->chip;
90 const int gpio = chip->base + offset;
92 if (WARN(test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0,
93 "autorequest GPIO-%d\n", gpio)) {
94 if (!try_module_get(chip->owner)) {
95 pr_err("GPIO-%d: module can't be gotten \n", gpio);
96 clear_bit(FLAG_REQUESTED, &desc->flags);
100 desc_set_label(desc, "[auto]");
101 /* caller must chip->request() w/o spinlock */
108 /* caller holds gpio_lock *OR* gpio is marked as requested */
109 struct gpio_chip *gpio_to_chip(unsigned gpio)
111 return gpio_desc[gpio].chip;
114 /* dynamic allocation of GPIOs, e.g. on a hotplugged device */
115 static int gpiochip_find_base(int ngpio)
121 for (i = ARCH_NR_GPIOS - 1; i >= 0 ; i--) {
122 struct gpio_desc *desc = &gpio_desc[i];
123 struct gpio_chip *chip = desc->chip;
125 if (!chip && !test_bit(FLAG_RESERVED, &desc->flags)) {
127 if (spare == ngpio) {
134 i -= chip->ngpio - 1;
138 if (gpio_is_valid(base))
139 pr_debug("%s: found new base at %d\n", __func__, base);
144 * gpiochip_reserve() - reserve range of gpios to use with platform code only
145 * @start: starting gpio number
146 * @ngpio: number of gpios to reserve
147 * Context: platform init, potentially before irqs or kmalloc will work
149 * Returns a negative errno if any gpio within the range is already reserved
150 * or registered, else returns zero as a success code. Use this function
151 * to mark a range of gpios as unavailable for dynamic gpio number allocation,
152 * for example because its driver support is not yet loaded.
154 int __init gpiochip_reserve(int start, int ngpio)
160 if (!gpio_is_valid(start) || !gpio_is_valid(start + ngpio - 1))
163 spin_lock_irqsave(&gpio_lock, flags);
165 for (i = start; i < start + ngpio; i++) {
166 struct gpio_desc *desc = &gpio_desc[i];
168 if (desc->chip || test_bit(FLAG_RESERVED, &desc->flags)) {
173 set_bit(FLAG_RESERVED, &desc->flags);
176 pr_debug("%s: reserved gpios from %d to %d\n",
177 __func__, start, start + ngpio - 1);
179 spin_unlock_irqrestore(&gpio_lock, flags);
185 * gpiochip_add() - register a gpio_chip
186 * @chip: the chip to register, with chip->base initialized
187 * Context: potentially before irqs or kmalloc will work
189 * Returns a negative errno if the chip can't be registered, such as
190 * because the chip->base is invalid or already associated with a
191 * different chip. Otherwise it returns zero as a success code.
193 * When gpiochip_add() is called very early during boot, so that GPIOs
194 * can be freely used, the chip->dev device must be registered before
195 * the gpio framework's arch_initcall(). Otherwise sysfs initialization
196 * for GPIOs will fail rudely.
198 * If chip->base is negative, this requests dynamic assignment of
199 * a range of valid GPIOs.
201 int gpiochip_add(struct gpio_chip *chip)
206 int base = chip->base;
208 if ((!gpio_is_valid(base) || !gpio_is_valid(base + chip->ngpio - 1))
214 spin_lock_irqsave(&gpio_lock, flags);
217 base = gpiochip_find_base(chip->ngpio);
225 /* these GPIO numbers must not be managed by another gpio_chip */
226 for (id = base; id < base + chip->ngpio; id++) {
227 if (gpio_desc[id].chip != NULL) {
233 for (id = base; id < base + chip->ngpio; id++) {
234 gpio_desc[id].chip = chip;
236 /* REVISIT: most hardware initializes GPIOs as
237 * inputs (often with pullups enabled) so power
238 * usage is minimized. Linux code should set the
239 * gpio direction first thing; but until it does,
240 * we may expose the wrong direction in sysfs.
242 gpio_desc[id].flags = !chip->direction_input
249 spin_unlock_irqrestore(&gpio_lock, flags);
254 pr_info("gpiochip_add: registered GPIOs %d to %d on device: %s\n",
255 chip->base, chip->base + chip->ngpio - 1,
256 chip->label ? : "generic");
260 /* failures here can mean systems won't boot... */
261 pr_err("gpiochip_add: gpios %d..%d (%s) failed to register\n",
262 chip->base, chip->base + chip->ngpio - 1,
263 chip->label ? : "generic");
266 EXPORT_SYMBOL_GPL(gpiochip_add);
269 * gpiochip_remove() - unregister a gpio_chip
270 * @chip: the chip to unregister
272 * A gpio_chip with any GPIOs still requested may not be removed.
274 int gpiochip_remove(struct gpio_chip *chip)
280 spin_lock_irqsave(&gpio_lock, flags);
282 for (id = chip->base; id < chip->base + chip->ngpio; id++) {
283 if (test_bit(FLAG_REQUESTED, &gpio_desc[id].flags)) {
289 for (id = chip->base; id < chip->base + chip->ngpio; id++)
290 gpio_desc[id].chip = NULL;
293 spin_unlock_irqrestore(&gpio_lock, flags);
297 EXPORT_SYMBOL_GPL(gpiochip_remove);
300 * gpiochip_find() - iterator for locating a specific gpio_chip
301 * @data: data to pass to match function
302 * @callback: Callback function to check gpio_chip
304 * Similar to bus_find_device. It returns a reference to a gpio_chip as
305 * determined by a user supplied @match callback. The callback should return
306 * 0 if the device doesn't match and non-zero if it does. If the callback is
307 * non-zero, this function will return to the caller and not iterate over any
310 struct gpio_chip *gpiochip_find(const void *data,
311 int (*match)(struct gpio_chip *chip,
314 struct gpio_chip *chip = NULL;
318 spin_lock_irqsave(&gpio_lock, flags);
319 for (i = 0; i < ARCH_NR_GPIOS; i++) {
320 if (!gpio_desc[i].chip)
323 if (match(gpio_desc[i].chip, data)) {
324 chip = gpio_desc[i].chip;
328 spin_unlock_irqrestore(&gpio_lock, flags);
332 EXPORT_SYMBOL_GPL(gpiochip_find);
334 /* These "optional" allocation calls help prevent drivers from stomping
335 * on each other, and help provide better diagnostics in debugfs.
336 * They're called even less than the "set direction" calls.
338 int gpio_request(unsigned gpio, const char *label)
340 struct gpio_desc *desc;
341 struct gpio_chip *chip;
342 int status = -EINVAL;
345 spin_lock_irqsave(&gpio_lock, flags);
347 if (!gpio_is_valid(gpio))
349 desc = &gpio_desc[gpio];
354 if (!try_module_get(chip->owner))
357 /* NOTE: gpio_request() can be called in early boot,
358 * before IRQs are enabled, for non-sleeping (SOC) GPIOs.
361 if (test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0) {
362 desc_set_label(desc, label ? : "?");
366 module_put(chip->owner);
371 /* chip->request may sleep */
372 spin_unlock_irqrestore(&gpio_lock, flags);
373 status = chip->request(chip, gpio - chip->base);
374 spin_lock_irqsave(&gpio_lock, flags);
377 desc_set_label(desc, NULL);
378 module_put(chip->owner);
379 clear_bit(FLAG_REQUESTED, &desc->flags);
385 pr_debug("gpio_request: gpio-%d (%s) status %d\n",
386 gpio, label ? : "?", status);
387 spin_unlock_irqrestore(&gpio_lock, flags);
390 EXPORT_SYMBOL_GPL(gpio_request);
392 void gpio_free(unsigned gpio)
395 struct gpio_desc *desc;
396 struct gpio_chip *chip;
398 if (!gpio_is_valid(gpio)) {
399 WARN_ON(extra_checks);
404 spin_lock_irqsave(&gpio_lock, flags);
406 desc = &gpio_desc[gpio];
408 if (chip && test_bit(FLAG_REQUESTED, &desc->flags)) {
410 spin_unlock_irqrestore(&gpio_lock, flags);
411 might_sleep_if(chip->can_sleep);
412 chip->free(chip, gpio - chip->base);
413 spin_lock_irqsave(&gpio_lock, flags);
415 desc_set_label(desc, NULL);
416 module_put(desc->chip->owner);
417 clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
418 clear_bit(FLAG_REQUESTED, &desc->flags);
419 clear_bit(FLAG_OPEN_DRAIN, &desc->flags);
420 clear_bit(FLAG_OPEN_SOURCE, &desc->flags);
422 WARN_ON(extra_checks);
424 spin_unlock_irqrestore(&gpio_lock, flags);
426 EXPORT_SYMBOL_GPL(gpio_free);
429 * gpio_request_one - request a single GPIO with initial configuration
430 * @gpio: the GPIO number
431 * @flags: GPIO configuration as specified by GPIOF_*
432 * @label: a literal description string of this GPIO
434 int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
438 err = gpio_request(gpio, label);
442 if (flags & GPIOF_OPEN_DRAIN)
443 set_bit(FLAG_OPEN_DRAIN, &gpio_desc[gpio].flags);
445 if (flags & GPIOF_OPEN_SOURCE)
446 set_bit(FLAG_OPEN_SOURCE, &gpio_desc[gpio].flags);
448 if (flags & GPIOF_DIR_IN)
449 err = gpio_direction_input(gpio);
451 err = gpio_direction_output(gpio,
452 (flags & GPIOF_INIT_HIGH) ? 1 : 0);
459 EXPORT_SYMBOL_GPL(gpio_request_one);
462 * gpio_request_array - request multiple GPIOs in a single call
463 * @array: array of the 'struct gpio'
464 * @num: how many GPIOs in the array
466 int gpio_request_array(const struct gpio *array, size_t num)
470 for (i = 0; i < num; i++, array++) {
471 err = gpio_request_one(array->gpio, array->flags, array->label);
479 gpio_free((--array)->gpio);
482 EXPORT_SYMBOL_GPL(gpio_request_array);
485 * gpio_free_array - release multiple GPIOs in a single call
486 * @array: array of the 'struct gpio'
487 * @num: how many GPIOs in the array
489 void gpio_free_array(const struct gpio *array, size_t num)
492 gpio_free((array++)->gpio);
494 EXPORT_SYMBOL_GPL(gpio_free_array);
497 * gpiochip_is_requested - return string iff signal was requested
498 * @chip: controller managing the signal
499 * @offset: of signal within controller's 0..(ngpio - 1) range
501 * Returns NULL if the GPIO is not currently requested, else a string.
502 * If debugfs support is enabled, the string returned is the label passed
503 * to gpio_request(); otherwise it is a meaningless constant.
505 * This function is for use by GPIO controller drivers. The label can
506 * help with diagnostics, and knowing that the signal is used as a GPIO
507 * can help avoid accidentally multiplexing it to another controller.
509 const char *gpiochip_is_requested(struct gpio_chip *chip, unsigned offset)
511 unsigned gpio = chip->base + offset;
513 if (!gpio_is_valid(gpio) || gpio_desc[gpio].chip != chip)
515 if (test_bit(FLAG_REQUESTED, &gpio_desc[gpio].flags) == 0)
517 #ifdef CONFIG_DEBUG_FS
518 return gpio_desc[gpio].label;
523 EXPORT_SYMBOL_GPL(gpiochip_is_requested);
526 /* Drivers MUST set GPIO direction before making get/set calls. In
527 * some cases this is done in early boot, before IRQs are enabled.
529 * As a rule these aren't called more than once (except for drivers
530 * using the open-drain emulation idiom) so these are natural places
531 * to accumulate extra debugging checks. Note that we can't (yet)
532 * rely on gpio_request() having been called beforehand.
535 int gpio_direction_input(unsigned gpio)
538 struct gpio_chip *chip;
539 struct gpio_desc *desc = &gpio_desc[gpio];
540 int status = -EINVAL;
542 spin_lock_irqsave(&gpio_lock, flags);
544 if (!gpio_is_valid(gpio))
547 if (!chip || !chip->get || !chip->direction_input)
550 if (gpio >= chip->ngpio)
552 status = gpio_ensure_requested(desc, gpio);
556 /* now we know the gpio is valid and chip won't vanish */
558 spin_unlock_irqrestore(&gpio_lock, flags);
560 might_sleep_if(chip->can_sleep);
563 status = chip->request(chip, gpio);
565 pr_debug("GPIO-%d: chip request fail, %d\n",
566 chip->base + gpio, status);
567 /* and it's not available to anyone else ...
568 * gpio_request() is the fully clean solution.
574 status = chip->direction_input(chip, gpio);
576 clear_bit(FLAG_IS_OUT, &desc->flags);
578 trace_gpio_direction(chip->base + gpio, 1, status);
582 spin_unlock_irqrestore(&gpio_lock, flags);
584 pr_debug("%s: gpio-%d status %d\n",
585 __func__, gpio, status);
588 EXPORT_SYMBOL_GPL(gpio_direction_input);
590 int gpio_direction_output(unsigned gpio, int value)
593 struct gpio_chip *chip;
594 struct gpio_desc *desc = &gpio_desc[gpio];
595 int status = -EINVAL;
597 /* Open drain pin should not be driven to 1 */
598 if (value && test_bit(FLAG_OPEN_DRAIN, &desc->flags))
599 return gpio_direction_input(gpio);
601 /* Open source pin should not be driven to 0 */
602 if (!value && test_bit(FLAG_OPEN_SOURCE, &desc->flags))
603 return gpio_direction_input(gpio);
605 spin_lock_irqsave(&gpio_lock, flags);
607 if (!gpio_is_valid(gpio))
610 if (!chip || !chip->set || !chip->direction_output)
613 if (gpio >= chip->ngpio)
615 status = gpio_ensure_requested(desc, gpio);
619 /* now we know the gpio is valid and chip won't vanish */
621 spin_unlock_irqrestore(&gpio_lock, flags);
623 might_sleep_if(chip->can_sleep);
626 status = chip->request(chip, gpio);
628 pr_debug("GPIO-%d: chip request fail, %d\n",
629 chip->base + gpio, status);
630 /* and it's not available to anyone else ...
631 * gpio_request() is the fully clean solution.
637 status = chip->direction_output(chip, gpio, value);
639 set_bit(FLAG_IS_OUT, &desc->flags);
643 spin_unlock_irqrestore(&gpio_lock, flags);
645 pr_debug("%s: gpio-%d status %d\n",
646 __func__, gpio, status);
649 EXPORT_SYMBOL_GPL(gpio_direction_output);
652 * gpio_set_debounce - sets @debounce time for a @gpio
653 * @gpio: the gpio to set debounce time
654 * @debounce: debounce time is microseconds
656 int gpio_set_debounce(unsigned gpio, unsigned debounce)
659 struct gpio_chip *chip;
660 struct gpio_desc *desc = &gpio_desc[gpio];
661 int status = -EINVAL;
663 spin_lock_irqsave(&gpio_lock, flags);
665 if (!gpio_is_valid(gpio))
668 if (!chip || !chip->set || !chip->set_debounce)
671 if (gpio >= chip->ngpio)
673 status = gpio_ensure_requested(desc, gpio);
677 /* now we know the gpio is valid and chip won't vanish */
679 spin_unlock_irqrestore(&gpio_lock, flags);
681 might_sleep_if(chip->can_sleep);
683 return chip->set_debounce(chip, gpio, debounce);
686 spin_unlock_irqrestore(&gpio_lock, flags);
688 pr_debug("%s: gpio-%d status %d\n",
689 __func__, gpio, status);
693 EXPORT_SYMBOL_GPL(gpio_set_debounce);
695 /* I/O calls are only valid after configuration completed; the relevant
696 * "is this a valid GPIO" error checks should already have been done.
698 * "Get" operations are often inlinable as reading a pin value register,
699 * and masking the relevant bit in that register.
701 * When "set" operations are inlinable, they involve writing that mask to
702 * one register to set a low value, or a different register to set it high.
703 * Otherwise locking is needed, so there may be little value to inlining.
705 *------------------------------------------------------------------------
707 * IMPORTANT!!! The hot paths -- get/set value -- assume that callers
708 * have requested the GPIO. That can include implicit requesting by
709 * a direction setting call. Marking a gpio as requested locks its chip
710 * in memory, guaranteeing that these table lookups need no more locking
711 * and that gpiochip_remove() will fail.
713 * REVISIT when debugging, consider adding some instrumentation to ensure
714 * that the GPIO was actually requested.
718 * __gpio_get_value() - return a gpio's value
719 * @gpio: gpio whose value will be returned
722 * This is used directly or indirectly to implement gpio_get_value().
723 * It returns the zero or nonzero value provided by the associated
724 * gpio_chip.get() method; or zero if no such method is provided.
726 int __gpio_get_value(unsigned gpio)
728 struct gpio_chip *chip;
731 chip = gpio_to_chip(gpio);
732 /* Should be using gpio_get_value_cansleep() */
733 WARN_ON(chip->can_sleep);
734 value = chip->get ? chip->get(chip, gpio - chip->base) : 0;
737 EXPORT_SYMBOL_GPL(__gpio_get_value);
740 * _gpio_set_open_drain_value() - Set the open drain gpio's value.
741 * @gpio: Gpio whose state need to be set.
743 * @value: Non-zero for setting it HIGH otherise it will set to LOW.
745 static void _gpio_set_open_drain_value(unsigned gpio,
746 struct gpio_chip *chip, int value)
750 err = chip->direction_input(chip, gpio - chip->base);
752 clear_bit(FLAG_IS_OUT, &gpio_desc[gpio].flags);
754 err = chip->direction_output(chip, gpio - chip->base, 0);
756 set_bit(FLAG_IS_OUT, &gpio_desc[gpio].flags);
759 pr_err("%s: Error in set_value for open drain gpio%d err %d\n",
760 __func__, gpio, err);
764 * _gpio_set_open_source() - Set the open source gpio's value.
765 * @gpio: Gpio whose state need to be set.
767 * @value: Non-zero for setting it HIGH otherise it will set to LOW.
769 static void _gpio_set_open_source_value(unsigned gpio,
770 struct gpio_chip *chip, int value)
774 err = chip->direction_output(chip, gpio - chip->base, 1);
776 set_bit(FLAG_IS_OUT, &gpio_desc[gpio].flags);
778 err = chip->direction_input(chip, gpio - chip->base);
780 clear_bit(FLAG_IS_OUT, &gpio_desc[gpio].flags);
783 pr_err("%s: Error in set_value for open source gpio%d err %d\n",
784 __func__, gpio, err);
789 * __gpio_set_value() - assign a gpio's value
790 * @gpio: gpio whose value will be assigned
791 * @value: value to assign
794 * This is used directly or indirectly to implement gpio_set_value().
795 * It invokes the associated gpio_chip.set() method.
797 void __gpio_set_value(unsigned gpio, int value)
799 struct gpio_chip *chip;
801 chip = gpio_to_chip(gpio);
802 /* Should be using gpio_set_value_cansleep() */
803 WARN_ON(chip->can_sleep);
804 if (test_bit(FLAG_OPEN_DRAIN, &gpio_desc[gpio].flags))
805 _gpio_set_open_drain_value(gpio, chip, value);
806 else if (test_bit(FLAG_OPEN_SOURCE, &gpio_desc[gpio].flags))
807 _gpio_set_open_source_value(gpio, chip, value);
809 chip->set(chip, gpio - chip->base, value);
811 EXPORT_SYMBOL_GPL(__gpio_set_value);
814 * __gpio_cansleep() - report whether gpio value access will sleep
815 * @gpio: gpio in question
818 * This is used directly or indirectly to implement gpio_cansleep(). It
819 * returns nonzero if access reading or writing the GPIO value can sleep.
821 int __gpio_cansleep(unsigned gpio)
823 struct gpio_chip *chip;
825 /* only call this on GPIOs that are valid! */
826 chip = gpio_to_chip(gpio);
828 return chip->can_sleep;
830 EXPORT_SYMBOL_GPL(__gpio_cansleep);
833 * __gpio_to_irq() - return the IRQ corresponding to a GPIO
834 * @gpio: gpio whose IRQ will be returned (already requested)
837 * This is used directly or indirectly to implement gpio_to_irq().
838 * It returns the number of the IRQ signaled by this (input) GPIO,
839 * or a negative errno.
841 int __gpio_to_irq(unsigned gpio)
843 struct gpio_chip *chip;
845 chip = gpio_to_chip(gpio);
846 return chip->to_irq ? chip->to_irq(chip, gpio - chip->base) : -ENXIO;
848 EXPORT_SYMBOL_GPL(__gpio_to_irq);
852 /* There's no value in making it easy to inline GPIO calls that may sleep.
853 * Common examples include ones connected to I2C or SPI chips.
856 int gpio_get_value_cansleep(unsigned gpio)
858 struct gpio_chip *chip;
861 might_sleep_if(extra_checks);
862 chip = gpio_to_chip(gpio);
863 value = chip->get ? chip->get(chip, gpio - chip->base) : 0;
864 trace_gpio_value(gpio, 1, value);
867 EXPORT_SYMBOL_GPL(gpio_get_value_cansleep);
869 void gpio_set_value_cansleep(unsigned gpio, int value)
871 struct gpio_chip *chip;
873 might_sleep_if(extra_checks);
874 chip = gpio_to_chip(gpio);
875 trace_gpio_value(gpio, 0, value);
876 if (test_bit(FLAG_OPEN_DRAIN, &gpio_desc[gpio].flags))
877 _gpio_set_open_drain_value(gpio, chip, value);
878 else if (test_bit(FLAG_OPEN_SOURCE, &gpio_desc[gpio].flags))
879 _gpio_set_open_source_value(gpio, chip, value);
881 chip->set(chip, gpio - chip->base, value);
883 EXPORT_SYMBOL_GPL(gpio_set_value_cansleep);