Lines Matching refs:desc
19 struct gpio_desc *desc; member
60 struct gpio_desc *desc = data->desc; in direction_show() local
65 gpiod_get_direction(desc); in direction_show()
67 test_bit(FLAG_IS_OUT, &desc->flags) in direction_show()
79 struct gpio_desc *desc = data->desc; in direction_store() local
85 status = gpiod_direction_output_raw(desc, 1); in direction_store()
87 status = gpiod_direction_output_raw(desc, 0); in direction_store()
89 status = gpiod_direction_input(desc); in direction_store()
103 struct gpio_desc *desc = data->desc; in value_show() local
108 status = sprintf(buf, "%d\n", gpiod_get_value_cansleep(desc)); in value_show()
119 struct gpio_desc *desc = data->desc; in value_store() local
124 if (!test_bit(FLAG_IS_OUT, &desc->flags)) { in value_store()
131 gpiod_set_value_cansleep(desc, value); in value_store()
155 struct gpio_desc *desc = data->desc; in gpio_sysfs_request_irq() local
159 data->irq = gpiod_to_irq(desc); in gpio_sysfs_request_irq()
169 irq_flags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ? in gpio_sysfs_request_irq()
172 irq_flags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ? in gpio_sysfs_request_irq()
183 ret = gpiochip_lock_as_irq(desc->chip, gpio_chip_hwgpio(desc)); in gpio_sysfs_request_irq()
197 gpiochip_unlock_as_irq(desc->chip, gpio_chip_hwgpio(desc)); in gpio_sysfs_request_irq()
211 struct gpio_desc *desc = data->desc; in gpio_sysfs_free_irq() local
215 gpiochip_unlock_as_irq(desc->chip, gpio_chip_hwgpio(desc)); in gpio_sysfs_free_irq()
295 struct gpio_desc *desc = data->desc; in gpio_sysfs_set_active_low() local
299 if (!!test_bit(FLAG_ACTIVE_LOW, &desc->flags) == !!value) in gpio_sysfs_set_active_low()
303 set_bit(FLAG_ACTIVE_LOW, &desc->flags); in gpio_sysfs_set_active_low()
305 clear_bit(FLAG_ACTIVE_LOW, &desc->flags); in gpio_sysfs_set_active_low()
321 struct gpio_desc *desc = data->desc; in active_low_show() local
327 !!test_bit(FLAG_ACTIVE_LOW, &desc->flags)); in active_low_show()
358 struct gpio_desc *desc = data->desc; in gpio_is_visible() local
366 if (gpiod_to_irq(desc) < 0) in gpio_is_visible()
368 if (!show_direction && test_bit(FLAG_IS_OUT, &desc->flags)) in gpio_is_visible()
446 struct gpio_desc *desc; in export_store() local
453 desc = gpio_to_desc(gpio); in export_store()
455 if (!desc) { in export_store()
465 status = gpiod_request(desc, "sysfs"); in export_store()
471 status = gpiod_export(desc, true); in export_store()
473 gpiod_free(desc); in export_store()
475 set_bit(FLAG_SYSFS, &desc->flags); in export_store()
488 struct gpio_desc *desc; in unexport_store() local
495 desc = gpio_to_desc(gpio); in unexport_store()
497 if (!desc) { in unexport_store()
508 if (test_and_clear_bit(FLAG_SYSFS, &desc->flags)) { in unexport_store()
510 gpiod_free(desc); in unexport_store()
547 int gpiod_export(struct gpio_desc *desc, bool direction_may_change) in gpiod_export() argument
563 if (!desc) { in gpiod_export()
568 chip = desc->chip; in gpiod_export()
579 if (!test_bit(FLAG_REQUESTED, &desc->flags) || in gpiod_export()
580 test_bit(FLAG_EXPORT, &desc->flags)) { in gpiod_export()
582 gpiod_dbg(desc, "%s: unavailable (requested=%d, exported=%d)\n", in gpiod_export()
584 test_bit(FLAG_REQUESTED, &desc->flags), in gpiod_export()
585 test_bit(FLAG_EXPORT, &desc->flags)); in gpiod_export()
597 data->desc = desc; in gpiod_export()
604 offset = gpio_chip_hwgpio(desc); in gpiod_export()
611 desc_to_gpio(desc)); in gpiod_export()
617 set_bit(FLAG_EXPORT, &desc->flags); in gpiod_export()
625 gpiod_dbg(desc, "%s: status %d\n", __func__, status); in gpiod_export()
630 static int match_export(struct device *dev, const void *desc) in match_export() argument
634 return data->desc == desc; in match_export()
649 struct gpio_desc *desc) in gpiod_export_link() argument
654 if (!desc) { in gpiod_export_link()
659 cdev = class_find_device(&gpio_class, NULL, desc, match_export); in gpiod_export_link()
676 void gpiod_unexport(struct gpio_desc *desc) in gpiod_unexport() argument
681 if (!desc) { in gpiod_unexport()
688 if (!test_bit(FLAG_EXPORT, &desc->flags)) in gpiod_unexport()
691 dev = class_find_device(&gpio_class, NULL, desc, match_export); in gpiod_unexport()
697 clear_bit(FLAG_EXPORT, &desc->flags); in gpiod_unexport()
748 struct gpio_desc *desc; in gpiochip_sysfs_unregister() local
763 desc = &chip->desc[i]; in gpiochip_sysfs_unregister()
764 if (test_and_clear_bit(FLAG_SYSFS, &desc->flags)) in gpiochip_sysfs_unregister()
765 gpiod_free(desc); in gpiochip_sysfs_unregister()