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()
883 struct scmi_event_handler *hndl; in scmi_allocate_event_handler() local
885 hndl = kzalloc(sizeof(*hndl), GFP_KERNEL); in scmi_allocate_event_handler()
886 if (!hndl) in scmi_allocate_event_handler()
888 hndl->key = evt_key; in scmi_allocate_event_handler()
889 BLOCKING_INIT_NOTIFIER_HEAD(&hndl->chain); in scmi_allocate_event_handler()
890 refcount_set(&hndl->users, 1); in scmi_allocate_event_handler()
892 hash_add(ni->pending_events_handlers, &hndl->hash, hndl->key); in scmi_allocate_event_handler()
894 return hndl; in scmi_allocate_event_handler()
904 static void scmi_free_event_handler(struct scmi_event_handler *hndl) in scmi_free_event_handler() argument
906 hash_del(&hndl->hash); in scmi_free_event_handler()
907 kfree(hndl); in scmi_free_event_handler()
923 struct scmi_event_handler *hndl) in scmi_bind_event_handler() argument
927 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(hndl->key), in scmi_bind_event_handler()
928 KEY_XTRACT_EVT_ID(hndl->key)); in scmi_bind_event_handler()
936 hash_del(&hndl->hash); in scmi_bind_event_handler()
944 scmi_acquire_protocol(ni->handle, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_bind_event_handler()
945 hndl->r_evt = r_evt; in scmi_bind_event_handler()
949 &hndl->hash, hndl->key); in scmi_bind_event_handler()
970 struct scmi_event_handler *hndl) in scmi_valid_pending_handler() argument
974 if (!IS_HNDL_PENDING(hndl)) in scmi_valid_pending_handler()
977 pd = SCMI_GET_PROTO(ni, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_valid_pending_handler()
1002 struct scmi_event_handler *hndl) in scmi_register_event_handler() argument
1006 ret = scmi_bind_event_handler(ni, hndl); in scmi_register_event_handler()
1009 hndl->key); in scmi_register_event_handler()
1011 ret = scmi_valid_pending_handler(ni, hndl); in scmi_register_event_handler()
1015 hndl->key); in scmi_register_event_handler()
1056 struct scmi_event_handler *hndl = NULL; in __scmi_event_handler_get_ops() local
1065 hndl = KEY_FIND(r_evt->proto->registered_events_handlers, in __scmi_event_handler_get_ops()
1066 hndl, evt_key); in __scmi_event_handler_get_ops()
1067 if (hndl) in __scmi_event_handler_get_ops()
1068 refcount_inc(&hndl->users); in __scmi_event_handler_get_ops()
1073 if (!hndl) { in __scmi_event_handler_get_ops()
1074 hndl = KEY_FIND(ni->pending_events_handlers, hndl, evt_key); in __scmi_event_handler_get_ops()
1075 if (hndl) in __scmi_event_handler_get_ops()
1076 refcount_inc(&hndl->users); in __scmi_event_handler_get_ops()
1080 if (!hndl && create) { in __scmi_event_handler_get_ops()
1081 hndl = scmi_allocate_event_handler(ni, evt_key); in __scmi_event_handler_get_ops()
1082 if (hndl && scmi_register_event_handler(ni, hndl)) { in __scmi_event_handler_get_ops()
1085 hndl->key); in __scmi_event_handler_get_ops()
1087 scmi_put_handler_unlocked(ni, hndl); in __scmi_event_handler_get_ops()
1088 hndl = NULL; in __scmi_event_handler_get_ops()
1093 return hndl; in __scmi_event_handler_get_ops()
1123 struct scmi_event_handler *hndl = NULL; in scmi_get_active_handler() local
1129 hndl = KEY_FIND(r_evt->proto->registered_events_handlers, in scmi_get_active_handler()
1130 hndl, evt_key); in scmi_get_active_handler()
1131 if (hndl) in scmi_get_active_handler()
1132 refcount_inc(&hndl->users); in scmi_get_active_handler()
1136 return hndl; in scmi_get_active_handler()
1198 static int scmi_enable_events(struct scmi_event_handler *hndl) in scmi_enable_events() argument
1202 if (!hndl->enabled) { in scmi_enable_events()
1203 ret = __scmi_enable_evt(hndl->r_evt, in scmi_enable_events()
1204 KEY_XTRACT_SRC_ID(hndl->key), true); in scmi_enable_events()
1206 hndl->enabled = true; in scmi_enable_events()
1212 static int scmi_disable_events(struct scmi_event_handler *hndl) in scmi_disable_events() argument
1216 if (hndl->enabled) { in scmi_disable_events()
1217 ret = __scmi_enable_evt(hndl->r_evt, in scmi_disable_events()
1218 KEY_XTRACT_SRC_ID(hndl->key), false); in scmi_disable_events()
1220 hndl->enabled = false; in scmi_disable_events()
1241 struct scmi_event_handler *hndl) in scmi_put_handler_unlocked() argument
1245 if (refcount_dec_and_test(&hndl->users)) { in scmi_put_handler_unlocked()
1246 if (!IS_HNDL_PENDING(hndl)) in scmi_put_handler_unlocked()
1247 scmi_disable_events(hndl); in scmi_put_handler_unlocked()
1248 scmi_free_event_handler(hndl); in scmi_put_handler_unlocked()
1256 struct scmi_event_handler *hndl) in scmi_put_handler() argument
1260 struct scmi_registered_event *r_evt = hndl->r_evt; in scmi_put_handler()
1268 freed = scmi_put_handler_unlocked(ni, hndl); in scmi_put_handler()
1285 struct scmi_event_handler *hndl) in scmi_put_active_handler() argument
1288 struct scmi_registered_event *r_evt = hndl->r_evt; in scmi_put_active_handler()
1292 freed = scmi_put_handler_unlocked(ni, hndl); in scmi_put_active_handler()
1304 static int scmi_event_handler_enable_events(struct scmi_event_handler *hndl) in scmi_event_handler_enable_events() argument
1306 if (scmi_enable_events(hndl)) { in scmi_event_handler_enable_events()
1307 pr_err("Failed to ENABLE events for key:%X !\n", hndl->key); in scmi_event_handler_enable_events()
1353 struct scmi_event_handler *hndl; in scmi_register_notifier() local
1362 hndl = scmi_get_or_create_handler(ni, evt_key); in scmi_register_notifier()
1363 if (!hndl) in scmi_register_notifier()
1366 blocking_notifier_chain_register(&hndl->chain, nb); in scmi_register_notifier()
1369 if (!IS_HNDL_PENDING(hndl)) { in scmi_register_notifier()
1370 ret = scmi_event_handler_enable_events(hndl); in scmi_register_notifier()
1372 scmi_put_handler(ni, hndl); in scmi_register_notifier()
1399 struct scmi_event_handler *hndl; in scmi_unregister_notifier() local
1408 hndl = scmi_get_handler(ni, evt_key); in scmi_unregister_notifier()
1409 if (!hndl) in scmi_unregister_notifier()
1416 blocking_notifier_chain_unregister(&hndl->chain, nb); in scmi_unregister_notifier()
1417 scmi_put_handler(ni, hndl); in scmi_unregister_notifier()
1430 scmi_put_handler(ni, hndl); in scmi_unregister_notifier()
1569 struct scmi_event_handler *hndl; in scmi_protocols_late_init() local
1579 hash_for_each_safe(ni->pending_events_handlers, bkt, tmp, hndl, hash) { in scmi_protocols_late_init()
1582 ret = scmi_bind_event_handler(ni, hndl); in scmi_protocols_late_init()
1586 hndl->key); in scmi_protocols_late_init()
1587 ret = scmi_event_handler_enable_events(hndl); in scmi_protocols_late_init()
1591 hndl->key); in scmi_protocols_late_init()
1592 scmi_put_active_handler(ni, hndl); in scmi_protocols_late_init()
1595 ret = scmi_valid_pending_handler(ni, hndl); in scmi_protocols_late_init()
1599 hndl->key); in scmi_protocols_late_init()
1601 scmi_put_handler_unlocked(ni, hndl); in scmi_protocols_late_init()