Lines Matching defs:hndl

368 #define IS_HNDL_PENDING(hndl)	(!(hndl)->r_evt)
373 struct scmi_event_handler *hndl);
375 struct scmi_event_handler *hndl);
389 struct scmi_event_handler *hndl;
397 hndl = scmi_get_active_handler(ni, evt_key);
398 if (!hndl)
401 ret = blocking_notifier_call_chain(&hndl->chain,
407 scmi_put_active_handler(ni, hndl);
869 * associated to this handler descriptor (hndl->r_evt == NULL), so the handler
878 struct scmi_event_handler *hndl;
880 hndl = kzalloc(sizeof(*hndl), GFP_KERNEL);
881 if (!hndl)
883 hndl->key = evt_key;
884 BLOCKING_INIT_NOTIFIER_HEAD(&hndl->chain);
885 refcount_set(&hndl->users, 1);
887 hash_add(ni->pending_events_handlers, &hndl->hash, hndl->key);
889 return hndl;
894 * @hndl: The event handler structure to free
899 static void scmi_free_event_handler(struct scmi_event_handler *hndl)
901 hash_del(&hndl->hash);
902 kfree(hndl);
908 * @hndl: The event handler to bind
918 struct scmi_event_handler *hndl)
922 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(hndl->key),
923 KEY_XTRACT_EVT_ID(hndl->key));
931 hash_del(&hndl->hash);
939 scmi_protocol_acquire(ni->handle, KEY_XTRACT_PROTO_ID(hndl->key));
940 hndl->r_evt = r_evt;
944 &hndl->hash, hndl->key);
953 * @hndl: The event handler to check
965 struct scmi_event_handler *hndl)
969 if (!IS_HNDL_PENDING(hndl))
972 pd = SCMI_GET_PROTO(ni, KEY_XTRACT_PROTO_ID(hndl->key));
982 * @hndl: The event handler to register
997 struct scmi_event_handler *hndl)
1001 ret = scmi_bind_event_handler(ni, hndl);
1004 hndl->key);
1006 ret = scmi_valid_pending_handler(ni, hndl);
1010 hndl->key);
1051 struct scmi_event_handler *hndl = NULL;
1060 hndl = KEY_FIND(r_evt->proto->registered_events_handlers,
1061 hndl, evt_key);
1062 if (hndl)
1063 refcount_inc(&hndl->users);
1068 if (!hndl) {
1069 hndl = KEY_FIND(ni->pending_events_handlers, hndl, evt_key);
1070 if (hndl)
1071 refcount_inc(&hndl->users);
1075 if (!hndl && create) {
1076 hndl = scmi_allocate_event_handler(ni, evt_key);
1077 if (hndl && scmi_register_event_handler(ni, hndl)) {
1080 hndl->key);
1081 /* this hndl can be only a pending one */
1082 scmi_put_handler_unlocked(ni, hndl);
1083 hndl = NULL;
1088 return hndl;
1118 struct scmi_event_handler *hndl = NULL;
1124 hndl = KEY_FIND(r_evt->proto->registered_events_handlers,
1125 hndl, evt_key);
1126 if (hndl)
1127 refcount_inc(&hndl->users);
1131 return hndl;
1193 static int scmi_enable_events(struct scmi_event_handler *hndl)
1197 if (!hndl->enabled) {
1198 ret = __scmi_enable_evt(hndl->r_evt,
1199 KEY_XTRACT_SRC_ID(hndl->key), true);
1201 hndl->enabled = true;
1207 static int scmi_disable_events(struct scmi_event_handler *hndl)
1211 if (hndl->enabled) {
1212 ret = __scmi_enable_evt(hndl->r_evt,
1213 KEY_XTRACT_SRC_ID(hndl->key), false);
1215 hndl->enabled = false;
1224 * @hndl: The event handler to act upon
1227 * update the refcount and if @hndl is no more in use by anyone:
1236 struct scmi_event_handler *hndl)
1240 if (refcount_dec_and_test(&hndl->users)) {
1241 if (!IS_HNDL_PENDING(hndl))
1242 scmi_disable_events(hndl);
1243 scmi_free_event_handler(hndl);
1251 struct scmi_event_handler *hndl)
1255 struct scmi_registered_event *r_evt = hndl->r_evt;
1263 freed = scmi_put_handler_unlocked(ni, hndl);
1280 struct scmi_event_handler *hndl)
1283 struct scmi_registered_event *r_evt = hndl->r_evt;
1287 freed = scmi_put_handler_unlocked(ni, hndl);
1295 * @hndl: The Event handler to act upon
1299 static int scmi_event_handler_enable_events(struct scmi_event_handler *hndl)
1301 if (scmi_enable_events(hndl)) {
1302 pr_err("Failed to ENABLE events for key:%X !\n", hndl->key);
1348 struct scmi_event_handler *hndl;
1357 hndl = scmi_get_or_create_handler(ni, evt_key);
1358 if (!hndl)
1361 blocking_notifier_chain_register(&hndl->chain, nb);
1364 if (!IS_HNDL_PENDING(hndl)) {
1365 ret = scmi_event_handler_enable_events(hndl);
1367 scmi_put_handler(ni, hndl);
1394 struct scmi_event_handler *hndl;
1403 hndl = scmi_get_handler(ni, evt_key);
1404 if (!hndl)
1411 blocking_notifier_chain_unregister(&hndl->chain, nb);
1412 scmi_put_handler(ni, hndl);
1425 scmi_put_handler(ni, hndl);
1570 struct scmi_event_handler *hndl;
1580 hash_for_each_safe(ni->pending_events_handlers, bkt, tmp, hndl, hash) {
1583 ret = scmi_bind_event_handler(ni, hndl);
1587 hndl->key);
1588 ret = scmi_event_handler_enable_events(hndl);
1592 hndl->key);
1593 scmi_put_active_handler(ni, hndl);
1596 ret = scmi_valid_pending_handler(ni, hndl);
1600 hndl->key);
1601 /* this hndl can be only a pending one */
1602 scmi_put_handler_unlocked(ni, hndl);