Lines Matching +full:free +full:- +full:flowing
1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2020-2021 ARM Ltd.
36 * All users provided callbacks and allocated notification-chains are stored in
44 * hash-keys.
54 * pushes the event-data itself on a protocol-dedicated kfifo queue for further
59 * queued items into the proper notification-chain: notifications processing can
65 * conveyed, converted into a custom per-event report struct, as the void *data
73 #define dev_fmt(fmt) "SCMI Notifications - " fmt
74 #define pr_fmt(fmt) "SCMI Notifications - " fmt
102 #define NOTIF_UNSUPP -1
116 * Assumes that the stored obj includes its own hash-key in a field named 'key':
132 if (obj_->key == k_) \
153 __pd = READ_ONCE(ni_->registered_protocols[(__pid)]); \
163 if (pd_ && eid_ < pd_->num_events) \
164 __revt = READ_ONCE(pd_->registered_events[eid_]); \
182 r->proto->ops->set_notify_enabled(r->proto->ph, \
195 r->proto->ops->fill_custom_report(r->proto->ph, \
205 * struct scmi_notify_instance - Represents an instance of the notification
213 * all the registered protocol-level specific information
233 * struct events_queue - Describes a queue and its associated worker
249 * struct scmi_event_header - A utility header
269 * struct scmi_registered_events_desc - Protocol Specific information
271 * @ops: Protocol specific and event-related operations
272 * @equeue: The embedded per-protocol events_queue
274 * @eh: A reference to pre-allocated buffer to be used as a scratch area by the
276 * @eh_sz: Size of the pre-allocated buffer @eh
280 * events' descriptors, whose fixed-size is determined at
287 * All protocols that register at least one event have their protocol-specific
294 * we safely grab a NON-NULL reference from the array we can keep it and use it.
313 * struct scmi_registered_event - Event Specific Information
317 * @report: A pre-allocated buffer used by the deferred worker to fill a
333 * safely grab a NON-NULL reference from the table we can keep it and use it.
347 * struct scmi_event_handler - Event handler information
361 * These descriptors are stored in a per-protocol @registered_events_handlers
373 #define IS_HNDL_PENDING(hndl) (!(hndl)->r_evt)
383 * scmi_lookup_and_call_event_chain() - Lookup the proper chain and call it
386 * @report: The customized event-specific report to pass down to the callbacks
406 ret = blocking_notifier_call_chain(&hndl->chain, in scmi_lookup_and_call_event_chain()
416 * scmi_process_event_header() - Dequeue and process an event header
426 * * ERR_PTR(-EINVAL) when NO registered event could be found
436 outs = kfifo_out(&eq->kfifo, pd->eh, in scmi_process_event_header()
441 dev_err(pd->ni->handle->dev, "corrupted EVT header. Flush.\n"); in scmi_process_event_header()
442 kfifo_reset_out(&eq->kfifo); in scmi_process_event_header()
446 r_evt = SCMI_GET_REVT_FROM_PD(pd, pd->eh->evt_id); in scmi_process_event_header()
448 r_evt = ERR_PTR(-EINVAL); in scmi_process_event_header()
454 * scmi_process_event_payload() - Dequeue and process an event payload
475 outs = kfifo_out(&eq->kfifo, pd->eh->payld, pd->eh->payld_sz); in scmi_process_event_payload()
479 /* Any in-flight event has now been officially processed */ in scmi_process_event_payload()
480 pd->in_flight = NULL; in scmi_process_event_payload()
482 if (outs != pd->eh->payld_sz) { in scmi_process_event_payload()
483 dev_err(pd->ni->handle->dev, "corrupted EVT Payload. Flush.\n"); in scmi_process_event_payload()
484 kfifo_reset_out(&eq->kfifo); in scmi_process_event_payload()
489 dev_warn(pd->ni->handle->dev, in scmi_process_event_payload()
490 "SKIP UNKNOWN EVT - proto:%X evt:%d\n", in scmi_process_event_payload()
491 pd->id, pd->eh->evt_id); in scmi_process_event_payload()
495 report = REVT_FILL_REPORT(r_evt, pd->eh->evt_id, pd->eh->timestamp, in scmi_process_event_payload()
496 pd->eh->payld, pd->eh->payld_sz, in scmi_process_event_payload()
497 r_evt->report, &src_id); in scmi_process_event_payload()
499 dev_err(pd->ni->handle->dev, in scmi_process_event_payload()
500 "report not available - proto:%X evt:%d\n", in scmi_process_event_payload()
501 pd->id, pd->eh->evt_id); in scmi_process_event_payload()
506 key = MAKE_ALL_SRCS_KEY(pd->id, pd->eh->evt_id); in scmi_process_event_payload()
507 scmi_lookup_and_call_event_chain(pd->ni, key, report); in scmi_process_event_payload()
510 key = MAKE_HASH_KEY(pd->id, pd->eh->evt_id, src_id); in scmi_process_event_payload()
511 scmi_lookup_and_call_event_chain(pd->ni, key, report); in scmi_process_event_payload()
517 * scmi_events_dispatcher() - Common worker logic for all work items.
524 * - > call the related notification chain passing in the report
526 * - > call the related notification chain passing in the report
529 * * a dedicated per-protocol kfifo queue is used: in this way an anomalous
531 * * each per-protocol queue is associated to a distinct work_item, which
537 * reader/writer on the associated kfifo, so that we can use it lock-less
550 * In order to keep the queue lock-less and the number of memcopies in scmi_events_dispatcher()
552 * possibility of per-protocol in-flight events: i.e. an event whose in scmi_events_dispatcher()
557 if (!pd->in_flight) { in scmi_events_dispatcher()
561 pd->in_flight = r_evt; in scmi_events_dispatcher()
563 r_evt = pd->in_flight; in scmi_events_dispatcher()
569 * scmi_notify() - Queues a notification for further deferred processing
596 return -EINVAL; in scmi_notify()
598 if (len > r_evt->evt->max_payld_sz) { in scmi_notify()
599 dev_err(handle->dev, "discard badly sized message\n"); in scmi_notify()
600 return -EINVAL; in scmi_notify()
602 if (kfifo_avail(&r_evt->proto->equeue.kfifo) < sizeof(eh) + len) { in scmi_notify()
603 dev_warn(handle->dev, in scmi_notify()
606 return -ENOMEM; in scmi_notify()
615 * with in-flight events tracking. in scmi_notify()
617 kfifo_in(&r_evt->proto->equeue.kfifo, &eh, sizeof(eh)); in scmi_notify()
618 kfifo_in(&r_evt->proto->equeue.kfifo, buf, len); in scmi_notify()
623 * - if work was already queued it will simply fail to queue a new one in scmi_notify()
625 * - if work was not queued already it will be now, even in case work in scmi_notify()
631 queue_work(r_evt->proto->equeue.wq, in scmi_notify()
632 &r_evt->proto->equeue.notify_work); in scmi_notify()
638 * scmi_kfifo_free() - Devres action helper to free the kfifo
639 * @kfifo: The kfifo to free
647 * scmi_initialize_events_queue() - Allocate/Initialize a kfifo buffer
661 if (kfifo_alloc(&equeue->kfifo, sz, GFP_KERNEL)) in scmi_initialize_events_queue()
662 return -ENOMEM; in scmi_initialize_events_queue()
663 /* Size could have been roundup to power-of-two */ in scmi_initialize_events_queue()
664 equeue->sz = kfifo_size(&equeue->kfifo); in scmi_initialize_events_queue()
666 ret = devm_add_action_or_reset(ni->handle->dev, scmi_kfifo_free, in scmi_initialize_events_queue()
667 &equeue->kfifo); in scmi_initialize_events_queue()
671 INIT_WORK(&equeue->notify_work, scmi_events_dispatcher); in scmi_initialize_events_queue()
672 equeue->wq = ni->notify_wq; in scmi_initialize_events_queue()
678 * scmi_allocate_registered_events_desc() - Allocate a registered events'
684 * @eh_sz: Size of the event header scratch area to pre-allocate
706 if (WARN_ON(ni->registered_protocols[proto_id])) in scmi_allocate_registered_events_desc()
707 return ERR_PTR(-EINVAL); in scmi_allocate_registered_events_desc()
709 pd = devm_kzalloc(ni->handle->dev, sizeof(*pd), GFP_KERNEL); in scmi_allocate_registered_events_desc()
711 return ERR_PTR(-ENOMEM); in scmi_allocate_registered_events_desc()
712 pd->id = proto_id; in scmi_allocate_registered_events_desc()
713 pd->ops = ops; in scmi_allocate_registered_events_desc()
714 pd->ni = ni; in scmi_allocate_registered_events_desc()
716 ret = scmi_initialize_events_queue(ni, &pd->equeue, queue_sz); in scmi_allocate_registered_events_desc()
720 pd->eh = devm_kzalloc(ni->handle->dev, eh_sz, GFP_KERNEL); in scmi_allocate_registered_events_desc()
721 if (!pd->eh) in scmi_allocate_registered_events_desc()
722 return ERR_PTR(-ENOMEM); in scmi_allocate_registered_events_desc()
723 pd->eh_sz = eh_sz; in scmi_allocate_registered_events_desc()
725 pd->registered_events = devm_kcalloc(ni->handle->dev, num_events, in scmi_allocate_registered_events_desc()
727 if (!pd->registered_events) in scmi_allocate_registered_events_desc()
728 return ERR_PTR(-ENOMEM); in scmi_allocate_registered_events_desc()
729 pd->num_events = num_events; in scmi_allocate_registered_events_desc()
732 mutex_init(&pd->registered_mtx); in scmi_allocate_registered_events_desc()
733 hash_init(pd->registered_events_handlers); in scmi_allocate_registered_events_desc()
739 * scmi_register_protocol_events() - Register Protocol Events with the core
748 * pre-allocate and store all needed descriptors, scratch buffers and event
764 if (!ee || !ee->ops || !ee->evts || !ph || in scmi_register_protocol_events()
765 (!ee->num_sources && !ee->ops->get_num_sources)) in scmi_register_protocol_events()
766 return -EINVAL; in scmi_register_protocol_events()
770 return -ENOMEM; in scmi_register_protocol_events()
773 if (ee->num_sources) { in scmi_register_protocol_events()
774 num_sources = ee->num_sources; in scmi_register_protocol_events()
776 int nsrc = ee->ops->get_num_sources(ph); in scmi_register_protocol_events()
779 return -EINVAL; in scmi_register_protocol_events()
783 evt = ee->evts; in scmi_register_protocol_events()
784 for (i = 0; i < ee->num_events; i++) in scmi_register_protocol_events()
788 pd = scmi_allocate_registered_events_desc(ni, proto_id, ee->queue_sz, in scmi_register_protocol_events()
789 payld_sz, ee->num_events, in scmi_register_protocol_events()
790 ee->ops); in scmi_register_protocol_events()
794 pd->ph = ph; in scmi_register_protocol_events()
795 for (i = 0; i < ee->num_events; i++, evt++) { in scmi_register_protocol_events()
799 r_evt = devm_kzalloc(ni->handle->dev, sizeof(*r_evt), in scmi_register_protocol_events()
802 return -ENOMEM; in scmi_register_protocol_events()
803 r_evt->proto = pd; in scmi_register_protocol_events()
804 r_evt->evt = evt; in scmi_register_protocol_events()
806 r_evt->sources = devm_kcalloc(ni->handle->dev, num_sources, in scmi_register_protocol_events()
808 if (!r_evt->sources) in scmi_register_protocol_events()
809 return -ENOMEM; in scmi_register_protocol_events()
810 r_evt->num_sources = num_sources; in scmi_register_protocol_events()
811 mutex_init(&r_evt->sources_mtx); in scmi_register_protocol_events()
813 r_evt->report = devm_kzalloc(ni->handle->dev, in scmi_register_protocol_events()
814 evt->max_report_sz, GFP_KERNEL); in scmi_register_protocol_events()
815 if (!r_evt->report) in scmi_register_protocol_events()
816 return -ENOMEM; in scmi_register_protocol_events()
818 if (ee->ops->is_notify_supported) { in scmi_register_protocol_events()
821 for (id = 0; id < r_evt->num_sources; id++) { in scmi_register_protocol_events()
822 if (!ee->ops->is_notify_supported(ph, r_evt->evt->id, id)) in scmi_register_protocol_events()
823 refcount_set(&r_evt->sources[id], NOTIF_UNSUPP); in scmi_register_protocol_events()
829 r_evt->not_supported_by_platform = !supported; in scmi_register_protocol_events()
832 pd->registered_events[i] = r_evt; in scmi_register_protocol_events()
835 dev_dbg(handle->dev, "registered event - %lX\n", in scmi_register_protocol_events()
836 MAKE_ALL_SRCS_KEY(r_evt->proto->id, r_evt->evt->id)); in scmi_register_protocol_events()
840 ni->registered_protocols[proto_id] = pd; in scmi_register_protocol_events()
848 schedule_work(&ni->init_work); in scmi_register_protocol_events()
854 * scmi_deregister_protocol_events - Deregister protocol events with the core
869 pd = ni->registered_protocols[proto_id]; in scmi_deregister_protocol_events()
873 ni->registered_protocols[proto_id] = NULL; in scmi_deregister_protocol_events()
877 cancel_work_sync(&pd->equeue.notify_work); in scmi_deregister_protocol_events()
881 * scmi_allocate_event_handler() - Allocate Event handler
889 * associated to this handler descriptor (hndl->r_evt == NULL), so the handler
903 hndl->key = evt_key; in scmi_allocate_event_handler()
904 BLOCKING_INIT_NOTIFIER_HEAD(&hndl->chain); in scmi_allocate_event_handler()
905 refcount_set(&hndl->users, 1); in scmi_allocate_event_handler()
907 hash_add(ni->pending_events_handlers, &hndl->hash, hndl->key); in scmi_allocate_event_handler()
913 * scmi_free_event_handler() - Free the provided Event handler
914 * @hndl: The event handler structure to free
921 hash_del(&hndl->hash); in scmi_free_event_handler()
926 * scmi_bind_event_handler() - Helper to attempt binding an handler to an event
942 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(hndl->key), in scmi_bind_event_handler()
943 KEY_XTRACT_EVT_ID(hndl->key)); in scmi_bind_event_handler()
945 return -EINVAL; in scmi_bind_event_handler()
951 hash_del(&hndl->hash); in scmi_bind_event_handler()
954 if (r_evt->not_supported_by_platform) in scmi_bind_event_handler()
955 return -EOPNOTSUPP; in scmi_bind_event_handler()
964 scmi_protocol_acquire(ni->handle, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_bind_event_handler()
965 hndl->r_evt = r_evt; in scmi_bind_event_handler()
967 mutex_lock(&r_evt->proto->registered_mtx); in scmi_bind_event_handler()
968 hash_add(r_evt->proto->registered_events_handlers, in scmi_bind_event_handler()
969 &hndl->hash, hndl->key); in scmi_bind_event_handler()
970 mutex_unlock(&r_evt->proto->registered_mtx); in scmi_bind_event_handler()
976 * scmi_valid_pending_handler() - Helper to check pending status of handlers
995 return -EINVAL; in scmi_valid_pending_handler()
997 pd = SCMI_GET_PROTO(ni, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_valid_pending_handler()
999 return -EINVAL; in scmi_valid_pending_handler()
1005 * scmi_register_event_handler() - Register whenever possible an Event handler
1028 dev_dbg(ni->handle->dev, "registered NEW handler - key:%X\n", in scmi_register_event_handler()
1029 hndl->key); in scmi_register_event_handler()
1033 dev_dbg(ni->handle->dev, in scmi_register_event_handler()
1034 "registered PENDING handler - key:%X\n", in scmi_register_event_handler()
1035 hndl->key); in scmi_register_event_handler()
1042 * __scmi_event_handler_get_ops() - Utility to get or create an event handler
1048 * Search for the desired handler matching the key in both the per-protocol
1067 * events really start flowing.
1081 if (r_evt && r_evt->not_supported_by_platform) in __scmi_event_handler_get_ops()
1082 return ERR_PTR(-EOPNOTSUPP); in __scmi_event_handler_get_ops()
1084 mutex_lock(&ni->pending_mtx); in __scmi_event_handler_get_ops()
1087 mutex_lock(&r_evt->proto->registered_mtx); in __scmi_event_handler_get_ops()
1088 hndl = KEY_FIND(r_evt->proto->registered_events_handlers, in __scmi_event_handler_get_ops()
1091 refcount_inc(&hndl->users); in __scmi_event_handler_get_ops()
1092 mutex_unlock(&r_evt->proto->registered_mtx); in __scmi_event_handler_get_ops()
1097 hndl = KEY_FIND(ni->pending_events_handlers, hndl, evt_key); in __scmi_event_handler_get_ops()
1099 refcount_inc(&hndl->users); in __scmi_event_handler_get_ops()
1106 dev_dbg(ni->handle->dev, in __scmi_event_handler_get_ops()
1107 "purging UNKNOWN handler - key:%X\n", in __scmi_event_handler_get_ops()
1108 hndl->key); in __scmi_event_handler_get_ops()
1111 hndl = ERR_PTR(-EINVAL); in __scmi_event_handler_get_ops()
1114 mutex_unlock(&ni->pending_mtx); in __scmi_event_handler_get_ops()
1132 * scmi_get_active_handler() - Helper to get active handlers only
1136 * Search for the desired handler matching the key only in the per-protocol
1151 mutex_lock(&r_evt->proto->registered_mtx); in scmi_get_active_handler()
1152 hndl = KEY_FIND(r_evt->proto->registered_events_handlers, in scmi_get_active_handler()
1155 refcount_inc(&hndl->users); in scmi_get_active_handler()
1156 mutex_unlock(&r_evt->proto->registered_mtx); in scmi_get_active_handler()
1163 * __scmi_enable_evt() - Enable/disable events generation
1166 * @enable: The action to perform: true->Enable, false->Disable
1184 num_sources = r_evt->num_sources; in __scmi_enable_evt()
1185 } else if (src_id < r_evt->num_sources) { in __scmi_enable_evt()
1188 return -EINVAL; in __scmi_enable_evt()
1191 mutex_lock(&r_evt->sources_mtx); in __scmi_enable_evt()
1193 for (; num_sources; src_id++, num_sources--) { in __scmi_enable_evt()
1196 sid = &r_evt->sources[src_id]; in __scmi_enable_evt()
1198 dev_dbg(r_evt->proto->ph->dev, in __scmi_enable_evt()
1199 "Notification NOT supported - proto_id:%d evt_id:%d src_id:%d", in __scmi_enable_evt()
1200 r_evt->proto->id, r_evt->evt->id, in __scmi_enable_evt()
1202 ret = -EOPNOTSUPP; in __scmi_enable_evt()
1204 ret = REVT_NOTIFY_ENABLE(r_evt, r_evt->evt->id, in __scmi_enable_evt()
1214 for (; num_sources; src_id++, num_sources--) { in __scmi_enable_evt()
1215 sid = &r_evt->sources[src_id]; in __scmi_enable_evt()
1220 r_evt->evt->id, src_id); in __scmi_enable_evt()
1224 mutex_unlock(&r_evt->sources_mtx); in __scmi_enable_evt()
1226 return retvals ? 0 : -EINVAL; in __scmi_enable_evt()
1233 if (!hndl->enabled) { in scmi_enable_events()
1234 ret = __scmi_enable_evt(hndl->r_evt, in scmi_enable_events()
1235 KEY_XTRACT_SRC_ID(hndl->key), true); in scmi_enable_events()
1237 hndl->enabled = true; in scmi_enable_events()
1247 if (hndl->enabled) { in scmi_disable_events()
1248 ret = __scmi_enable_evt(hndl->r_evt, in scmi_disable_events()
1249 KEY_XTRACT_SRC_ID(hndl->key), false); in scmi_disable_events()
1251 hndl->enabled = false; in scmi_disable_events()
1258 * scmi_put_handler_unlocked() - Put an event handler
1265 * * unregister and free the handler itself
1276 if (refcount_dec_and_test(&hndl->users)) { in scmi_put_handler_unlocked()
1291 struct scmi_registered_event *r_evt = hndl->r_evt; in scmi_put_handler()
1293 mutex_lock(&ni->pending_mtx); in scmi_put_handler()
1295 protocol_id = r_evt->proto->id; in scmi_put_handler()
1296 mutex_lock(&r_evt->proto->registered_mtx); in scmi_put_handler()
1302 mutex_unlock(&r_evt->proto->registered_mtx); in scmi_put_handler()
1306 * releasing a protocol can trigger its de-initialization in scmi_put_handler()
1310 scmi_protocol_release(ni->handle, protocol_id); in scmi_put_handler()
1312 mutex_unlock(&ni->pending_mtx); in scmi_put_handler()
1319 struct scmi_registered_event *r_evt = hndl->r_evt; in scmi_put_active_handler()
1320 u8 protocol_id = r_evt->proto->id; in scmi_put_active_handler()
1322 mutex_lock(&r_evt->proto->registered_mtx); in scmi_put_active_handler()
1324 mutex_unlock(&r_evt->proto->registered_mtx); in scmi_put_active_handler()
1326 scmi_protocol_release(ni->handle, protocol_id); in scmi_put_active_handler()
1330 * scmi_event_handler_enable_events() - Enable events associated to an handler
1338 pr_err("Failed to ENABLE events for key:%X !\n", hndl->key); in scmi_event_handler_enable_events()
1339 return -EINVAL; in scmi_event_handler_enable_events()
1346 * scmi_notifier_register() - Register a notifier_block for an event
1361 * (proto_X, evt_Y, src_Z) --> chain_X_Y_Z
1389 return -ENODEV; in scmi_notifier_register()
1397 blocking_notifier_chain_register(&hndl->chain, nb); in scmi_notifier_register()
1410 * scmi_notifier_unregister() - Unregister a notifier_block for an event
1435 return -ENODEV; in scmi_notifier_unregister()
1447 blocking_notifier_chain_unregister(&hndl->chain, nb); in scmi_notifier_unregister()
1459 * path which will finally free this unused handler. in scmi_notifier_unregister()
1479 scmi_notifier_unregister(dres->handle, dres->proto_id, dres->evt_id, in scmi_devm_release_notifier()
1480 dres->src_id, dres->nb); in scmi_devm_release_notifier()
1484 * scmi_devm_notifier_register() - Managed registration of a notifier_block
1510 return -ENOMEM; in scmi_devm_notifier_register()
1512 ret = scmi_notifier_register(sdev->handle, proto_id, in scmi_devm_notifier_register()
1519 dres->handle = sdev->handle; in scmi_devm_notifier_register()
1520 dres->proto_id = proto_id; in scmi_devm_notifier_register()
1521 dres->evt_id = evt_id; in scmi_devm_notifier_register()
1522 dres->nb = nb; in scmi_devm_notifier_register()
1524 dres->__src_id = *src_id; in scmi_devm_notifier_register()
1525 dres->src_id = &dres->__src_id; in scmi_devm_notifier_register()
1527 dres->src_id = NULL; in scmi_devm_notifier_register()
1529 devres_add(&sdev->dev, dres); in scmi_devm_notifier_register()
1542 return dres->nb == nb; in scmi_devm_notifier_match()
1546 * scmi_devm_notifier_unregister() - Managed un-registration of a
1552 * Generic devres managed helper to explicitly un-register a notifier_block
1563 ret = devres_release(&sdev->dev, scmi_devm_release_notifier, in scmi_devm_notifier_unregister()
1572 * scmi_protocols_late_init() - Worker for late initialization
1593 mutex_lock(&ni->pending_mtx); in scmi_protocols_late_init()
1594 hash_for_each_safe(ni->pending_events_handlers, bkt, tmp, hndl, hash) { in scmi_protocols_late_init()
1599 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1600 "finalized PENDING handler - key:%X\n", in scmi_protocols_late_init()
1601 hndl->key); in scmi_protocols_late_init()
1604 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1605 "purging INVALID handler - key:%X\n", in scmi_protocols_late_init()
1606 hndl->key); in scmi_protocols_late_init()
1612 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1613 "purging PENDING handler - key:%X\n", in scmi_protocols_late_init()
1614 hndl->key); in scmi_protocols_late_init()
1620 mutex_unlock(&ni->pending_mtx); in scmi_protocols_late_init()
1635 * scmi_notification_init() - Initializes Notification Core Support
1650 * further per-protocol allocations
1665 gid = devres_open_group(handle->dev, NULL, GFP_KERNEL); in scmi_notification_init()
1667 return -ENOMEM; in scmi_notification_init()
1669 ni = devm_kzalloc(handle->dev, sizeof(*ni), GFP_KERNEL); in scmi_notification_init()
1673 ni->gid = gid; in scmi_notification_init()
1674 ni->handle = handle; in scmi_notification_init()
1676 ni->registered_protocols = devm_kcalloc(handle->dev, SCMI_MAX_PROTO, in scmi_notification_init()
1678 if (!ni->registered_protocols) in scmi_notification_init()
1681 ni->notify_wq = alloc_workqueue(dev_name(handle->dev), in scmi_notification_init()
1684 if (!ni->notify_wq) in scmi_notification_init()
1687 mutex_init(&ni->pending_mtx); in scmi_notification_init()
1688 hash_init(ni->pending_events_handlers); in scmi_notification_init()
1690 INIT_WORK(&ni->init_work, scmi_protocols_late_init); in scmi_notification_init()
1693 handle->notify_ops = ¬ify_ops; in scmi_notification_init()
1697 dev_info(handle->dev, "Core Enabled.\n"); in scmi_notification_init()
1699 devres_close_group(handle->dev, ni->gid); in scmi_notification_init()
1704 dev_warn(handle->dev, "Initialization Failed.\n"); in scmi_notification_init()
1705 devres_release_group(handle->dev, gid); in scmi_notification_init()
1706 return -ENOMEM; in scmi_notification_init()
1710 * scmi_notification_exit() - Shutdown and clean Notification core
1723 destroy_workqueue(ni->notify_wq); in scmi_notification_exit()
1725 devres_release_group(ni->handle->dev, ni->gid); in scmi_notification_exit()