Lines Matching full:notifier
66 static bool match_i2c(struct v4l2_async_notifier *notifier, in match_i2c() argument
81 static struct device *notifier_dev(struct v4l2_async_notifier *notifier) in notifier_dev() argument
83 if (notifier->sd) in notifier_dev()
84 return notifier->sd->dev; in notifier_dev()
86 if (notifier->v4l2_dev) in notifier_dev()
87 return notifier->v4l2_dev->dev; in notifier_dev()
93 match_fwnode_one(struct v4l2_async_notifier *notifier, in match_fwnode_one() argument
100 dev_dbg(notifier_dev(notifier), in match_fwnode_one()
105 dev_dbg(notifier_dev(notifier), in match_fwnode_one()
111 dev_dbg(notifier_dev(notifier), in match_fwnode_one()
122 dev_dbg(notifier_dev(notifier), in match_fwnode_one()
129 static bool match_fwnode(struct v4l2_async_notifier *notifier, in match_fwnode() argument
133 dev_dbg(notifier_dev(notifier), in match_fwnode()
134 "v4l2-async: matching for notifier %pfw, sd fwnode %pfw\n", in match_fwnode()
135 dev_fwnode(notifier_dev(notifier)), sd->fwnode); in match_fwnode()
161 if (match_fwnode_one(notifier, sd, sd->fwnode, match)) in match_fwnode()
168 dev_dbg(notifier_dev(notifier), in match_fwnode()
171 return match_fwnode_one(notifier, sd, sd->fwnode->secondary, match); in match_fwnode()
179 v4l2_async_find_match(struct v4l2_async_notifier *notifier, in v4l2_async_find_match() argument
182 bool (*match)(struct v4l2_async_notifier *notifier, in v4l2_async_find_match()
187 list_for_each_entry(asc, ¬ifier->waiting_list, asc_entry) { in v4l2_async_find_match()
203 if (match(notifier, sd, &asc->match)) in v4l2_async_find_match()
230 /* Find the sub-device notifier registered by a sub-device driver. */
243 /* Get v4l2_device related to the notifier if one can be found. */
245 v4l2_async_nf_find_v4l2_dev(struct v4l2_async_notifier *notifier) in v4l2_async_nf_find_v4l2_dev() argument
247 while (notifier->parent) in v4l2_async_nf_find_v4l2_dev()
248 notifier = notifier->parent; in v4l2_async_nf_find_v4l2_dev()
250 return notifier->v4l2_dev; in v4l2_async_nf_find_v4l2_dev()
257 v4l2_async_nf_can_complete(struct v4l2_async_notifier *notifier) in v4l2_async_nf_can_complete() argument
261 if (!list_empty(¬ifier->waiting_list)) in v4l2_async_nf_can_complete()
264 list_for_each_entry(asc, ¬ifier->done_list, asc_entry) { in v4l2_async_nf_can_complete()
277 * Complete the master notifier if possible. This is done when all async
281 v4l2_async_nf_try_complete(struct v4l2_async_notifier *notifier) in v4l2_async_nf_try_complete() argument
283 struct v4l2_async_notifier *__notifier = notifier; in v4l2_async_nf_try_complete()
286 if (!list_empty(¬ifier->waiting_list)) in v4l2_async_nf_try_complete()
289 if (notifier->sd) in v4l2_async_nf_try_complete()
290 dev_dbg(notifier_dev(notifier), in v4l2_async_nf_try_complete()
293 /* Check the entire notifier tree; find the root notifier first. */ in v4l2_async_nf_try_complete()
294 while (notifier->parent) in v4l2_async_nf_try_complete()
295 notifier = notifier->parent; in v4l2_async_nf_try_complete()
298 if (!notifier->v4l2_dev) { in v4l2_async_nf_try_complete()
305 if (!v4l2_async_nf_can_complete(notifier)) in v4l2_async_nf_try_complete()
310 return v4l2_async_nf_call_complete(notifier); in v4l2_async_nf_try_complete()
314 v4l2_async_nf_try_all_subdevs(struct v4l2_async_notifier *notifier);
337 static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, in v4l2_async_match_notify() argument
353 ret = v4l2_async_nf_call_bound(notifier, sd, asc); in v4l2_async_match_notify()
356 dev_dbg(notifier_dev(notifier), in v4l2_async_match_notify()
369 ret = v4l2_async_create_ancillary_links(notifier, sd); in v4l2_async_match_notify()
372 dev_dbg(notifier_dev(notifier), in v4l2_async_match_notify()
382 /* Move from the waiting list to notifier's done */ in v4l2_async_match_notify()
383 list_move(&asc->asc_entry, ¬ifier->done_list); in v4l2_async_match_notify()
385 dev_dbg(notifier_dev(notifier), "v4l2-async: %s bound (ret %d)\n", in v4l2_async_match_notify()
389 * See if the sub-device has a notifier. If not, return here. in v4l2_async_match_notify()
396 * Proceed with checking for the sub-device notifier's async in v4l2_async_match_notify()
400 subdev_notifier->parent = notifier; in v4l2_async_match_notify()
405 v4l2_async_nf_call_unbind(notifier, sd, asc); in v4l2_async_match_notify()
415 /* Test all async sub-devices in a notifier for a match. */
417 v4l2_async_nf_try_all_subdevs(struct v4l2_async_notifier *notifier) in v4l2_async_nf_try_all_subdevs() argument
420 v4l2_async_nf_find_v4l2_dev(notifier); in v4l2_async_nf_try_all_subdevs()
426 dev_dbg(notifier_dev(notifier), "v4l2-async: trying all sub-devices\n"); in v4l2_async_nf_try_all_subdevs()
433 asc = v4l2_async_find_match(notifier, sd); in v4l2_async_nf_try_all_subdevs()
437 dev_dbg(notifier_dev(notifier), in v4l2_async_nf_try_all_subdevs()
440 ret = v4l2_async_match_notify(notifier, v4l2_dev, sd, asc); in v4l2_async_nf_try_all_subdevs()
446 * new notifier and thus changing the async subdevs in v4l2_async_nf_try_all_subdevs()
456 static void v4l2_async_unbind_subdev_one(struct v4l2_async_notifier *notifier, in v4l2_async_unbind_subdev_one() argument
459 list_move_tail(&asc->asc_entry, ¬ifier->waiting_list); in v4l2_async_unbind_subdev_one()
461 v4l2_async_nf_call_unbind(notifier, asc->sd, asc); in v4l2_async_unbind_subdev_one()
468 /* Unbind all sub-devices in the notifier tree. */
470 v4l2_async_nf_unbind_all_subdevs(struct v4l2_async_notifier *notifier) in v4l2_async_nf_unbind_all_subdevs() argument
474 list_for_each_entry_safe(asc, asc_tmp, ¬ifier->done_list, in v4l2_async_nf_unbind_all_subdevs()
482 v4l2_async_unbind_subdev_one(notifier, asc); in v4l2_async_nf_unbind_all_subdevs()
485 notifier->parent = NULL; in v4l2_async_nf_unbind_all_subdevs()
488 /* See if an async sub-device can be found in a notifier's lists. */
490 v4l2_async_nf_has_async_match_entry(struct v4l2_async_notifier *notifier, in v4l2_async_nf_has_async_match_entry() argument
495 list_for_each_entry(asc, ¬ifier->waiting_list, asc_entry) in v4l2_async_nf_has_async_match_entry()
499 list_for_each_entry(asc, ¬ifier->done_list, asc_entry) in v4l2_async_nf_has_async_match_entry()
508 * in a given notifier.
511 v4l2_async_nf_has_async_match(struct v4l2_async_notifier *notifier, in v4l2_async_nf_has_async_match() argument
515 ¬ifier->waiting_list, in v4l2_async_nf_has_async_match()
516 ¬ifier->done_list, in v4l2_async_nf_has_async_match()
535 list_for_each_entry(notifier, ¬ifier_list, notifier_entry) in v4l2_async_nf_has_async_match()
536 if (v4l2_async_nf_has_async_match_entry(notifier, match)) in v4l2_async_nf_has_async_match()
542 static int v4l2_async_nf_match_valid(struct v4l2_async_notifier *notifier, in v4l2_async_nf_match_valid() argument
545 struct device *dev = notifier_dev(notifier); in v4l2_async_nf_match_valid()
550 if (v4l2_async_nf_has_async_match(notifier, match)) { in v4l2_async_nf_match_valid()
551 dev_dbg(dev, "v4l2-async: match descriptor already listed in a notifier\n"); in v4l2_async_nf_match_valid()
564 void v4l2_async_nf_init(struct v4l2_async_notifier *notifier, in v4l2_async_nf_init() argument
567 INIT_LIST_HEAD(¬ifier->waiting_list); in v4l2_async_nf_init()
568 INIT_LIST_HEAD(¬ifier->done_list); in v4l2_async_nf_init()
569 INIT_LIST_HEAD(¬ifier->notifier_entry); in v4l2_async_nf_init()
570 notifier->v4l2_dev = v4l2_dev; in v4l2_async_nf_init()
574 void v4l2_async_subdev_nf_init(struct v4l2_async_notifier *notifier, in v4l2_async_subdev_nf_init() argument
577 INIT_LIST_HEAD(¬ifier->waiting_list); in v4l2_async_subdev_nf_init()
578 INIT_LIST_HEAD(¬ifier->done_list); in v4l2_async_subdev_nf_init()
579 INIT_LIST_HEAD(¬ifier->notifier_entry); in v4l2_async_subdev_nf_init()
580 notifier->sd = sd; in v4l2_async_subdev_nf_init()
584 static int __v4l2_async_nf_register(struct v4l2_async_notifier *notifier) in __v4l2_async_nf_register() argument
591 list_for_each_entry(asc, ¬ifier->waiting_list, asc_entry) { in __v4l2_async_nf_register()
592 ret = v4l2_async_nf_match_valid(notifier, &asc->match); in __v4l2_async_nf_register()
597 ret = v4l2_async_nf_try_all_subdevs(notifier); in __v4l2_async_nf_register()
601 ret = v4l2_async_nf_try_complete(notifier); in __v4l2_async_nf_register()
606 list_add(¬ifier->notifier_entry, ¬ifier_list); in __v4l2_async_nf_register()
614 * On failure, unbind all sub-devices registered through this notifier. in __v4l2_async_nf_register()
616 v4l2_async_nf_unbind_all_subdevs(notifier); in __v4l2_async_nf_register()
624 int v4l2_async_nf_register(struct v4l2_async_notifier *notifier) in v4l2_async_nf_register() argument
626 if (WARN_ON(!notifier->v4l2_dev == !notifier->sd)) in v4l2_async_nf_register()
629 return __v4l2_async_nf_register(notifier); in v4l2_async_nf_register()
634 __v4l2_async_nf_unregister(struct v4l2_async_notifier *notifier) in __v4l2_async_nf_unregister() argument
636 if (!notifier || (!notifier->v4l2_dev && !notifier->sd)) in __v4l2_async_nf_unregister()
639 v4l2_async_nf_unbind_all_subdevs(notifier); in __v4l2_async_nf_unregister()
641 list_del_init(¬ifier->notifier_entry); in __v4l2_async_nf_unregister()
644 void v4l2_async_nf_unregister(struct v4l2_async_notifier *notifier) in v4l2_async_nf_unregister() argument
648 __v4l2_async_nf_unregister(notifier); in v4l2_async_nf_unregister()
654 static void __v4l2_async_nf_cleanup(struct v4l2_async_notifier *notifier) in __v4l2_async_nf_cleanup() argument
658 if (!notifier || !notifier->waiting_list.next) in __v4l2_async_nf_cleanup()
661 WARN_ON(!list_empty(¬ifier->done_list)); in __v4l2_async_nf_cleanup()
663 list_for_each_entry_safe(asc, tmp, ¬ifier->waiting_list, asc_entry) { in __v4l2_async_nf_cleanup()
665 v4l2_async_nf_call_destroy(notifier, asc); in __v4l2_async_nf_cleanup()
673 notifier->sd = NULL; in __v4l2_async_nf_cleanup()
674 notifier->v4l2_dev = NULL; in __v4l2_async_nf_cleanup()
677 void v4l2_async_nf_cleanup(struct v4l2_async_notifier *notifier) in v4l2_async_nf_cleanup() argument
681 __v4l2_async_nf_cleanup(notifier); in v4l2_async_nf_cleanup()
687 static void __v4l2_async_nf_add_connection(struct v4l2_async_notifier *notifier, in __v4l2_async_nf_add_connection() argument
692 list_add_tail(&asc->asc_entry, ¬ifier->waiting_list); in __v4l2_async_nf_add_connection()
698 __v4l2_async_nf_add_fwnode(struct v4l2_async_notifier *notifier, in __v4l2_async_nf_add_fwnode() argument
708 asc->notifier = notifier; in __v4l2_async_nf_add_fwnode()
712 __v4l2_async_nf_add_connection(notifier, asc); in __v4l2_async_nf_add_fwnode()
741 __v4l2_async_nf_add_i2c(struct v4l2_async_notifier *notifier, int adapter_id, in __v4l2_async_nf_add_i2c() argument
750 asc->notifier = notifier; in __v4l2_async_nf_add_i2c()
755 __v4l2_async_nf_add_connection(notifier, asc); in __v4l2_async_nf_add_i2c()
792 struct v4l2_async_notifier *notifier; in v4l2_async_register_subdev() local
815 list_for_each_entry(notifier, ¬ifier_list, notifier_entry) { in v4l2_async_register_subdev()
817 v4l2_async_nf_find_v4l2_dev(notifier); in v4l2_async_register_subdev()
822 while ((asc = v4l2_async_find_match(notifier, sd))) { in v4l2_async_register_subdev()
823 ret = v4l2_async_match_notify(notifier, v4l2_dev, sd, in v4l2_async_register_subdev()
828 ret = v4l2_async_nf_try_complete(notifier); in v4l2_async_register_subdev()
851 v4l2_async_unbind_subdev_one(notifier, asc); in v4l2_async_register_subdev()
879 &asc->notifier->waiting_list); in v4l2_async_unregister_subdev()
881 v4l2_async_unbind_subdev_one(asc->notifier, asc); in v4l2_async_unregister_subdev()
918 v4l2_async_nf_name(struct v4l2_async_notifier *notifier) in v4l2_async_nf_name() argument
920 if (notifier->v4l2_dev) in v4l2_async_nf_name()
921 return notifier->v4l2_dev->name; in v4l2_async_nf_name()
922 else if (notifier->sd) in v4l2_async_nf_name()
923 return notifier->sd->name; in v4l2_async_nf_name()