Lines Matching refs:hndl

368 #define IS_HNDL_PENDING(hndl)	(!(hndl)->r_evt)  argument
373 struct scmi_event_handler *hndl);
375 struct scmi_event_handler *hndl);
389 struct scmi_event_handler *hndl; in scmi_lookup_and_call_event_chain() local
397 hndl = scmi_get_active_handler(ni, evt_key); in scmi_lookup_and_call_event_chain()
398 if (!hndl) in scmi_lookup_and_call_event_chain()
401 ret = blocking_notifier_call_chain(&hndl->chain, in scmi_lookup_and_call_event_chain()
407 scmi_put_active_handler(ni, hndl); in scmi_lookup_and_call_event_chain()
878 struct scmi_event_handler *hndl; in scmi_allocate_event_handler() local
880 hndl = kzalloc(sizeof(*hndl), GFP_KERNEL); in scmi_allocate_event_handler()
881 if (!hndl) in scmi_allocate_event_handler()
883 hndl->key = evt_key; in scmi_allocate_event_handler()
884 BLOCKING_INIT_NOTIFIER_HEAD(&hndl->chain); in scmi_allocate_event_handler()
885 refcount_set(&hndl->users, 1); in scmi_allocate_event_handler()
887 hash_add(ni->pending_events_handlers, &hndl->hash, hndl->key); in scmi_allocate_event_handler()
889 return hndl; in scmi_allocate_event_handler()
899 static void scmi_free_event_handler(struct scmi_event_handler *hndl) in scmi_free_event_handler() argument
901 hash_del(&hndl->hash); in scmi_free_event_handler()
902 kfree(hndl); in scmi_free_event_handler()
918 struct scmi_event_handler *hndl) in scmi_bind_event_handler() argument
922 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(hndl->key), in scmi_bind_event_handler()
923 KEY_XTRACT_EVT_ID(hndl->key)); in scmi_bind_event_handler()
931 hash_del(&hndl->hash); in scmi_bind_event_handler()
939 scmi_protocol_acquire(ni->handle, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_bind_event_handler()
940 hndl->r_evt = r_evt; in scmi_bind_event_handler()
944 &hndl->hash, hndl->key); in scmi_bind_event_handler()
965 struct scmi_event_handler *hndl) in scmi_valid_pending_handler() argument
969 if (!IS_HNDL_PENDING(hndl)) in scmi_valid_pending_handler()
972 pd = SCMI_GET_PROTO(ni, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_valid_pending_handler()
997 struct scmi_event_handler *hndl) in scmi_register_event_handler() argument
1001 ret = scmi_bind_event_handler(ni, hndl); in scmi_register_event_handler()
1004 hndl->key); in scmi_register_event_handler()
1006 ret = scmi_valid_pending_handler(ni, hndl); in scmi_register_event_handler()
1010 hndl->key); in scmi_register_event_handler()
1051 struct scmi_event_handler *hndl = NULL; in __scmi_event_handler_get_ops() local
1060 hndl = KEY_FIND(r_evt->proto->registered_events_handlers, in __scmi_event_handler_get_ops()
1061 hndl, evt_key); in __scmi_event_handler_get_ops()
1062 if (hndl) in __scmi_event_handler_get_ops()
1063 refcount_inc(&hndl->users); in __scmi_event_handler_get_ops()
1068 if (!hndl) { in __scmi_event_handler_get_ops()
1069 hndl = KEY_FIND(ni->pending_events_handlers, hndl, evt_key); in __scmi_event_handler_get_ops()
1070 if (hndl) in __scmi_event_handler_get_ops()
1071 refcount_inc(&hndl->users); in __scmi_event_handler_get_ops()
1075 if (!hndl && create) { in __scmi_event_handler_get_ops()
1076 hndl = scmi_allocate_event_handler(ni, evt_key); in __scmi_event_handler_get_ops()
1077 if (hndl && scmi_register_event_handler(ni, hndl)) { in __scmi_event_handler_get_ops()
1080 hndl->key); in __scmi_event_handler_get_ops()
1082 scmi_put_handler_unlocked(ni, hndl); in __scmi_event_handler_get_ops()
1083 hndl = NULL; in __scmi_event_handler_get_ops()
1088 return hndl; in __scmi_event_handler_get_ops()
1118 struct scmi_event_handler *hndl = NULL; in scmi_get_active_handler() local
1124 hndl = KEY_FIND(r_evt->proto->registered_events_handlers, in scmi_get_active_handler()
1125 hndl, evt_key); in scmi_get_active_handler()
1126 if (hndl) in scmi_get_active_handler()
1127 refcount_inc(&hndl->users); in scmi_get_active_handler()
1131 return hndl; in scmi_get_active_handler()
1193 static int scmi_enable_events(struct scmi_event_handler *hndl) in scmi_enable_events() argument
1197 if (!hndl->enabled) { in scmi_enable_events()
1198 ret = __scmi_enable_evt(hndl->r_evt, in scmi_enable_events()
1199 KEY_XTRACT_SRC_ID(hndl->key), true); in scmi_enable_events()
1201 hndl->enabled = true; in scmi_enable_events()
1207 static int scmi_disable_events(struct scmi_event_handler *hndl) in scmi_disable_events() argument
1211 if (hndl->enabled) { in scmi_disable_events()
1212 ret = __scmi_enable_evt(hndl->r_evt, in scmi_disable_events()
1213 KEY_XTRACT_SRC_ID(hndl->key), false); in scmi_disable_events()
1215 hndl->enabled = false; in scmi_disable_events()
1236 struct scmi_event_handler *hndl) in scmi_put_handler_unlocked() argument
1240 if (refcount_dec_and_test(&hndl->users)) { in scmi_put_handler_unlocked()
1241 if (!IS_HNDL_PENDING(hndl)) in scmi_put_handler_unlocked()
1242 scmi_disable_events(hndl); in scmi_put_handler_unlocked()
1243 scmi_free_event_handler(hndl); in scmi_put_handler_unlocked()
1251 struct scmi_event_handler *hndl) in scmi_put_handler() argument
1255 struct scmi_registered_event *r_evt = hndl->r_evt; in scmi_put_handler()
1263 freed = scmi_put_handler_unlocked(ni, hndl); in scmi_put_handler()
1280 struct scmi_event_handler *hndl) in scmi_put_active_handler() argument
1283 struct scmi_registered_event *r_evt = hndl->r_evt; in scmi_put_active_handler()
1287 freed = scmi_put_handler_unlocked(ni, hndl); in scmi_put_active_handler()
1299 static int scmi_event_handler_enable_events(struct scmi_event_handler *hndl) in scmi_event_handler_enable_events() argument
1301 if (scmi_enable_events(hndl)) { in scmi_event_handler_enable_events()
1302 pr_err("Failed to ENABLE events for key:%X !\n", hndl->key); in scmi_event_handler_enable_events()
1348 struct scmi_event_handler *hndl; in scmi_notifier_register() local
1357 hndl = scmi_get_or_create_handler(ni, evt_key); in scmi_notifier_register()
1358 if (!hndl) in scmi_notifier_register()
1361 blocking_notifier_chain_register(&hndl->chain, nb); in scmi_notifier_register()
1364 if (!IS_HNDL_PENDING(hndl)) { in scmi_notifier_register()
1365 ret = scmi_event_handler_enable_events(hndl); in scmi_notifier_register()
1367 scmi_put_handler(ni, hndl); in scmi_notifier_register()
1394 struct scmi_event_handler *hndl; in scmi_notifier_unregister() local
1403 hndl = scmi_get_handler(ni, evt_key); in scmi_notifier_unregister()
1404 if (!hndl) in scmi_notifier_unregister()
1411 blocking_notifier_chain_unregister(&hndl->chain, nb); in scmi_notifier_unregister()
1412 scmi_put_handler(ni, hndl); in scmi_notifier_unregister()
1425 scmi_put_handler(ni, hndl); in scmi_notifier_unregister()
1570 struct scmi_event_handler *hndl; in scmi_protocols_late_init() local
1580 hash_for_each_safe(ni->pending_events_handlers, bkt, tmp, hndl, hash) { in scmi_protocols_late_init()
1583 ret = scmi_bind_event_handler(ni, hndl); in scmi_protocols_late_init()
1587 hndl->key); in scmi_protocols_late_init()
1588 ret = scmi_event_handler_enable_events(hndl); in scmi_protocols_late_init()
1592 hndl->key); in scmi_protocols_late_init()
1593 scmi_put_active_handler(ni, hndl); in scmi_protocols_late_init()
1596 ret = scmi_valid_pending_handler(ni, hndl); in scmi_protocols_late_init()
1600 hndl->key); in scmi_protocols_late_init()
1602 scmi_put_handler_unlocked(ni, hndl); in scmi_protocols_late_init()