Lines Matching full:entry
71 struct gpio_shared_entry *entry; in gpio_shared_find_entry() local
73 list_for_each_entry(entry, &gpio_shared_list, list) { in gpio_shared_find_entry()
74 if (entry->fwnode == controller_node && entry->offset == offset) in gpio_shared_find_entry()
75 return entry; in gpio_shared_find_entry()
110 static int gpio_shared_setup_reset_proxy(struct gpio_shared_entry *entry, in gpio_shared_setup_reset_proxy() argument
115 list_for_each_entry(ref, &entry->refs, list) { in gpio_shared_setup_reset_proxy()
127 list_add_tail(&ref->list, &entry->refs); in gpio_shared_setup_reset_proxy()
130 entry->offset, fwnode_get_name(entry->fwnode)); in gpio_shared_setup_reset_proxy()
161 struct gpio_shared_entry *entry; in gpio_shared_of_traverse() local
228 entry = gpio_shared_find_entry(fwnode, offset); in gpio_shared_of_traverse()
229 if (!entry) { in gpio_shared_of_traverse()
230 entry = kzalloc_obj(*entry); in gpio_shared_of_traverse()
231 if (!entry) in gpio_shared_of_traverse()
234 entry->fwnode = fwnode_handle_get(fwnode); in gpio_shared_of_traverse()
235 entry->offset = offset; in gpio_shared_of_traverse()
236 entry->index = count; in gpio_shared_of_traverse()
237 INIT_LIST_HEAD(&entry->refs); in gpio_shared_of_traverse()
238 mutex_init(&entry->lock); in gpio_shared_of_traverse()
240 list_add_tail(&entry->list, &gpio_shared_list); in gpio_shared_of_traverse()
269 if (!list_empty(&entry->refs)) in gpio_shared_of_traverse()
271 entry->offset, fwnode_get_name(entry->fwnode)); in gpio_shared_of_traverse()
273 list_add_tail(&ref->list, &entry->refs); in gpio_shared_of_traverse()
276 ret = gpio_shared_setup_reset_proxy(entry, args.args[1]); in gpio_shared_of_traverse()
312 struct gpio_shared_entry *entry, in gpio_shared_make_adev() argument
325 adev->dev.platform_data = entry; in gpio_shared_make_adev()
357 struct gpio_shared_entry *entry, in gpio_shared_dev_is_reset_gpio() argument
375 * fwnode we stored in the entry structure. in gpio_shared_dev_is_reset_gpio()
377 if (!device_match_fwnode(parent, entry->fwnode)) in gpio_shared_dev_is_reset_gpio()
383 * of this entry and see if there's one, whose reset-gpios property's in gpio_shared_dev_is_reset_gpio()
386 list_for_each_entry(real_ref, &entry->refs, list) { in gpio_shared_dev_is_reset_gpio()
399 * that's referencing the entry's firmware node. in gpio_shared_dev_is_reset_gpio()
417 match = ((ref_args.fwnode == entry->fwnode) && in gpio_shared_dev_is_reset_gpio()
418 (aux_args.fwnode == entry->fwnode) && in gpio_shared_dev_is_reset_gpio()
439 struct gpio_shared_entry *entry, in gpio_shared_dev_is_reset_gpio() argument
451 struct gpio_shared_entry *entry; in gpio_shared_add_proxy_lookup() local
454 list_for_each_entry(entry, &gpio_shared_list, list) { in gpio_shared_add_proxy_lookup()
455 list_for_each_entry(ref, &entry->refs, list) { in gpio_shared_add_proxy_lookup()
459 if (!gpio_shared_dev_is_reset_gpio(consumer, entry, ref)) in gpio_shared_add_proxy_lookup()
484 …pr_debug("Adding machine lookup entry for a shared GPIO for consumer %s, with key '%s' and con_id … in gpio_shared_add_proxy_lookup()
512 struct gpio_shared_entry *entry; in gpiochip_setup_shared() local
517 list_for_each_entry(entry, &gpio_shared_list, list) { in gpiochip_setup_shared()
518 list_for_each_entry(ref, &entry->refs, list) { in gpiochip_setup_shared()
535 list_for_each_entry(entry, &gpio_shared_list, list) { in gpiochip_setup_shared()
536 if (!device_match_fwnode(&gdev->dev, entry->fwnode)) in gpiochip_setup_shared()
539 if (list_count_nodes(&entry->refs) <= 1) in gpiochip_setup_shared()
542 scoped_guard(mutex, &entry->lock) { in gpiochip_setup_shared()
544 if (is_of_node(entry->fwnode) && gc->of_xlate) { in gpiochip_setup_shared()
551 gpiospec.np = to_of_node(entry->fwnode); in gpiochip_setup_shared()
553 gpiospec.args[0] = entry->offset; in gpiochip_setup_shared()
559 entry->offset = ret; in gpiochip_setup_shared()
563 desc = &gdev->descs[entry->offset]; in gpiochip_setup_shared()
576 entry->offset, gpio_device_get_label(gdev)); in gpiochip_setup_shared()
579 list_for_each_entry(ref, &entry->refs, list) { in gpiochip_setup_shared()
580 pr_debug("Setting up a shared GPIO entry for %s (con_id: '%s')\n", in gpiochip_setup_shared()
584 ret = gpio_shared_make_adev(gdev, entry, ref); in gpiochip_setup_shared()
597 struct gpio_shared_entry *entry; in gpio_device_teardown_shared() local
600 list_for_each_entry(entry, &gpio_shared_list, list) { in gpio_device_teardown_shared()
601 guard(mutex)(&entry->lock); in gpio_device_teardown_shared()
603 if (!device_match_fwnode(&gdev->dev, entry->fwnode)) in gpio_device_teardown_shared()
606 gpiod_free_commit(&gdev->descs[entry->offset]); in gpio_device_teardown_shared()
608 list_for_each_entry(ref, &entry->refs, list) { in gpio_device_teardown_shared()
625 struct gpio_shared_entry *entry = in gpio_shared_release() local
629 guard(mutex)(&entry->lock); in gpio_shared_release()
631 shared_desc = entry->shared_desc; in gpio_shared_release()
636 entry->shared_desc = NULL; in gpio_shared_release()
641 struct gpio_shared_entry *entry = data; in gpiod_shared_put() local
643 kref_put(&entry->ref, gpio_shared_release); in gpiod_shared_put()
647 gpiod_shared_desc_create(struct gpio_shared_entry *entry) in gpiod_shared_desc_create() argument
652 lockdep_assert_held(&entry->lock); in gpiod_shared_desc_create()
658 gdev = gpio_device_find_by_fwnode(entry->fwnode); in gpiod_shared_desc_create()
664 shared_desc->desc = &gdev->descs[entry->offset]; in gpiod_shared_desc_create()
677 struct gpio_shared_entry *entry; in devm_gpiod_shared_get() local
680 entry = dev_get_platdata(dev); in devm_gpiod_shared_get()
681 if (WARN_ON(!entry)) in devm_gpiod_shared_get()
685 scoped_guard(mutex, &entry->lock) { in devm_gpiod_shared_get()
686 if (entry->shared_desc) { in devm_gpiod_shared_get()
687 kref_get(&entry->ref); in devm_gpiod_shared_get()
688 shared_desc = entry->shared_desc; in devm_gpiod_shared_get()
690 shared_desc = gpiod_shared_desc_create(entry); in devm_gpiod_shared_get()
694 kref_init(&entry->ref); in devm_gpiod_shared_get()
695 entry->shared_desc = shared_desc; in devm_gpiod_shared_get()
703 ret = devm_add_action_or_reset(dev, gpiod_shared_put, entry); in devm_gpiod_shared_get()
722 static void gpio_shared_drop_entry(struct gpio_shared_entry *entry) in gpio_shared_drop_entry() argument
724 list_del(&entry->list); in gpio_shared_drop_entry()
725 mutex_destroy(&entry->lock); in gpio_shared_drop_entry()
726 fwnode_handle_put(entry->fwnode); in gpio_shared_drop_entry()
727 kfree(entry); in gpio_shared_drop_entry()
736 struct gpio_shared_entry *entry, *epos; in gpio_shared_teardown() local
739 list_for_each_entry_safe(entry, epos, &gpio_shared_list, list) { in gpio_shared_teardown()
740 list_for_each_entry_safe(ref, rpos, &entry->refs, list) in gpio_shared_teardown()
743 gpio_shared_drop_entry(entry); in gpio_shared_teardown()
747 static bool gpio_shared_entry_is_really_shared(struct gpio_shared_entry *entry) in gpio_shared_entry_is_really_shared() argument
749 size_t num_nodes = list_count_nodes(&entry->refs); in gpio_shared_entry_is_really_shared()
759 list_for_each_entry(ref, &entry->refs, list) { in gpio_shared_entry_is_really_shared()
775 struct gpio_shared_entry *entry, *epos; in gpio_shared_free_exclusive() local
778 list_for_each_entry_safe(entry, epos, &gpio_shared_list, list) { in gpio_shared_free_exclusive()
779 if (gpio_shared_entry_is_really_shared(entry)) in gpio_shared_free_exclusive()
782 list_for_each_entry_safe(ref, rpos, &entry->refs, list) in gpio_shared_free_exclusive()
784 gpio_shared_drop_entry(entry); in gpio_shared_free_exclusive()