Lines Matching defs:hndl

365 #define IS_HNDL_PENDING(hndl)	(!(hndl)->r_evt)
370 struct scmi_event_handler *hndl);
372 struct scmi_event_handler *hndl);
386 struct scmi_event_handler *hndl;
394 hndl = scmi_get_active_handler(ni, evt_key);
395 if (!hndl)
398 ret = blocking_notifier_call_chain(&hndl->chain,
404 scmi_put_active_handler(ni, hndl);
845 * associated to this handler descriptor (hndl->r_evt == NULL), so the handler
854 struct scmi_event_handler *hndl;
856 hndl = kzalloc(sizeof(*hndl), GFP_KERNEL);
857 if (!hndl)
859 hndl->key = evt_key;
860 BLOCKING_INIT_NOTIFIER_HEAD(&hndl->chain);
861 refcount_set(&hndl->users, 1);
863 hash_add(ni->pending_events_handlers, &hndl->hash, hndl->key);
865 return hndl;
870 * @hndl: The event handler structure to free
875 static void scmi_free_event_handler(struct scmi_event_handler *hndl)
877 hash_del(&hndl->hash);
878 kfree(hndl);
884 * @hndl: The event handler to bind
894 struct scmi_event_handler *hndl)
898 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(hndl->key),
899 KEY_XTRACT_EVT_ID(hndl->key));
904 hash_del(&hndl->hash);
905 hndl->r_evt = r_evt;
908 &hndl->hash, hndl->key);
917 * @hndl: The event handler to check
929 struct scmi_event_handler *hndl)
933 if (!IS_HNDL_PENDING(hndl))
936 pd = SCMI_GET_PROTO(ni, KEY_XTRACT_PROTO_ID(hndl->key));
946 * @hndl: The event handler to register
961 struct scmi_event_handler *hndl)
965 ret = scmi_bind_event_handler(ni, hndl);
968 hndl->key);
970 ret = scmi_valid_pending_handler(ni, hndl);
974 hndl->key);
1015 struct scmi_event_handler *hndl = NULL;
1024 hndl = KEY_FIND(r_evt->proto->registered_events_handlers,
1025 hndl, evt_key);
1026 if (hndl)
1027 refcount_inc(&hndl->users);
1032 if (!hndl) {
1033 hndl = KEY_FIND(ni->pending_events_handlers, hndl, evt_key);
1034 if (hndl)
1035 refcount_inc(&hndl->users);
1039 if (!hndl && create) {
1040 hndl = scmi_allocate_event_handler(ni, evt_key);
1041 if (hndl && scmi_register_event_handler(ni, hndl)) {
1044 hndl->key);
1045 /* this hndl can be only a pending one */
1046 scmi_put_handler_unlocked(ni, hndl);
1047 hndl = NULL;
1052 return hndl;
1082 struct scmi_event_handler *hndl = NULL;
1088 hndl = KEY_FIND(r_evt->proto->registered_events_handlers,
1089 hndl, evt_key);
1090 if (hndl)
1091 refcount_inc(&hndl->users);
1095 return hndl;
1157 static int scmi_enable_events(struct scmi_event_handler *hndl)
1161 if (!hndl->enabled) {
1162 ret = __scmi_enable_evt(hndl->r_evt,
1163 KEY_XTRACT_SRC_ID(hndl->key), true);
1165 hndl->enabled = true;
1171 static int scmi_disable_events(struct scmi_event_handler *hndl)
1175 if (hndl->enabled) {
1176 ret = __scmi_enable_evt(hndl->r_evt,
1177 KEY_XTRACT_SRC_ID(hndl->key), false);
1179 hndl->enabled = false;
1188 * @hndl: The event handler to act upon
1191 * update the refcount and if @hndl is no more in use by anyone:
1198 struct scmi_event_handler *hndl)
1200 if (refcount_dec_and_test(&hndl->users)) {
1201 if (!IS_HNDL_PENDING(hndl))
1202 scmi_disable_events(hndl);
1203 scmi_free_event_handler(hndl);
1208 struct scmi_event_handler *hndl)
1210 struct scmi_registered_event *r_evt = hndl->r_evt;
1216 scmi_put_handler_unlocked(ni, hndl);
1224 struct scmi_event_handler *hndl)
1226 struct scmi_registered_event *r_evt = hndl->r_evt;
1229 scmi_put_handler_unlocked(ni, hndl);
1235 * @hndl: The Event handler to act upon
1239 static int scmi_event_handler_enable_events(struct scmi_event_handler *hndl)
1241 if (scmi_enable_events(hndl)) {
1242 pr_err("Failed to ENABLE events for key:%X !\n", hndl->key);
1288 struct scmi_event_handler *hndl;
1299 hndl = scmi_get_or_create_handler(ni, evt_key);
1300 if (!hndl)
1303 blocking_notifier_chain_register(&hndl->chain, nb);
1306 if (!IS_HNDL_PENDING(hndl)) {
1307 ret = scmi_event_handler_enable_events(hndl);
1309 scmi_put_handler(ni, hndl);
1336 struct scmi_event_handler *hndl;
1347 hndl = scmi_get_handler(ni, evt_key);
1348 if (!hndl)
1355 blocking_notifier_chain_unregister(&hndl->chain, nb);
1356 scmi_put_handler(ni, hndl);
1369 scmi_put_handler(ni, hndl);
1387 struct scmi_event_handler *hndl;
1397 hash_for_each_safe(ni->pending_events_handlers, bkt, tmp, hndl, hash) {
1400 ret = scmi_bind_event_handler(ni, hndl);
1404 hndl->key);
1405 ret = scmi_event_handler_enable_events(hndl);
1409 hndl->key);
1410 scmi_put_active_handler(ni, hndl);
1413 ret = scmi_valid_pending_handler(ni, hndl);
1417 hndl->key);
1418 /* this hndl can be only a pending one */
1419 scmi_put_handler_unlocked(ni, hndl);