Lines Matching full:ni
273 * @ni: A reference to the initialized instance descriptor
300 struct scmi_notify_instance *ni; member
376 scmi_get_active_handler(struct scmi_notify_instance *ni, u32 evt_key);
377 static void scmi_put_active_handler(struct scmi_notify_instance *ni,
379 static bool scmi_put_handler_unlocked(struct scmi_notify_instance *ni,
384 * @ni: A reference to the notification instance to use
390 scmi_lookup_and_call_event_chain(struct scmi_notify_instance *ni, in scmi_lookup_and_call_event_chain() argument
402 hndl = scmi_get_active_handler(ni, evt_key); in scmi_lookup_and_call_event_chain()
412 scmi_put_active_handler(ni, hndl); in scmi_lookup_and_call_event_chain()
441 dev_err(pd->ni->handle->dev, "corrupted EVT header. Flush.\n"); in scmi_process_event_header()
483 dev_err(pd->ni->handle->dev, "corrupted EVT Payload. Flush.\n"); in scmi_process_event_payload()
489 dev_warn(pd->ni->handle->dev, in scmi_process_event_payload()
499 dev_err(pd->ni->handle->dev, in scmi_process_event_payload()
507 scmi_lookup_and_call_event_chain(pd->ni, key, report); in scmi_process_event_payload()
511 scmi_lookup_and_call_event_chain(pd->ni, key, report); in scmi_process_event_payload()
588 struct scmi_notify_instance *ni; in scmi_notify() local
590 ni = scmi_notification_instance_data_get(handle); in scmi_notify()
591 if (!ni) in scmi_notify()
594 r_evt = SCMI_GET_REVT(ni, proto_id, evt_id); in scmi_notify()
648 * @ni: A reference to the notification instance to use
656 static int scmi_initialize_events_queue(struct scmi_notify_instance *ni, in scmi_initialize_events_queue() argument
666 ret = devm_add_action_or_reset(ni->handle->dev, scmi_kfifo_free, in scmi_initialize_events_queue()
672 equeue->wq = ni->notify_wq; in scmi_initialize_events_queue()
680 * @ni: A reference to the &struct scmi_notify_instance notification instance
696 scmi_allocate_registered_events_desc(struct scmi_notify_instance *ni, in scmi_allocate_registered_events_desc() argument
706 if (WARN_ON(ni->registered_protocols[proto_id])) in scmi_allocate_registered_events_desc()
709 pd = devm_kzalloc(ni->handle->dev, sizeof(*pd), GFP_KERNEL); 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()
725 pd->registered_events = devm_kcalloc(ni->handle->dev, num_events, in scmi_allocate_registered_events_desc()
761 struct scmi_notify_instance *ni; in scmi_register_protocol_events() local
768 ni = scmi_notification_instance_data_get(handle); in scmi_register_protocol_events()
769 if (!ni) in scmi_register_protocol_events()
788 pd = scmi_allocate_registered_events_desc(ni, proto_id, ee->queue_sz, in scmi_register_protocol_events()
799 r_evt = devm_kzalloc(ni->handle->dev, sizeof(*r_evt), in scmi_register_protocol_events()
806 r_evt->sources = devm_kcalloc(ni->handle->dev, num_sources, in scmi_register_protocol_events()
813 r_evt->report = devm_kzalloc(ni->handle->dev, 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()
862 struct scmi_notify_instance *ni; in scmi_deregister_protocol_events() local
865 ni = scmi_notification_instance_data_get(handle); in scmi_deregister_protocol_events()
866 if (!ni) in scmi_deregister_protocol_events()
869 pd = ni->registered_protocols[proto_id]; in scmi_deregister_protocol_events()
873 ni->registered_protocols[proto_id] = NULL; in scmi_deregister_protocol_events()
882 * @ni: A reference to the notification instance to use
896 scmi_allocate_event_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_allocate_event_handler() argument
907 hash_add(ni->pending_events_handlers, &hndl->hash, hndl->key); in scmi_allocate_event_handler()
927 * @ni: A reference to the notification instance to use
937 static inline int scmi_bind_event_handler(struct scmi_notify_instance *ni, in scmi_bind_event_handler() argument
942 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(hndl->key), in scmi_bind_event_handler()
964 scmi_protocol_acquire(ni->handle, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_bind_event_handler()
977 * @ni: A reference to the notification instance to use
989 static inline int scmi_valid_pending_handler(struct scmi_notify_instance *ni, in scmi_valid_pending_handler() argument
997 pd = SCMI_GET_PROTO(ni, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_valid_pending_handler()
1006 * @ni: A reference to the notification instance to use
1021 static int scmi_register_event_handler(struct scmi_notify_instance *ni, in scmi_register_event_handler() argument
1026 ret = scmi_bind_event_handler(ni, hndl); in scmi_register_event_handler()
1028 dev_dbg(ni->handle->dev, "registered NEW handler - key:%X\n", in scmi_register_event_handler()
1031 ret = scmi_valid_pending_handler(ni, hndl); in scmi_register_event_handler()
1033 dev_dbg(ni->handle->dev, in scmi_register_event_handler()
1043 * @ni: A reference to the notification instance to use
1072 __scmi_event_handler_get_ops(struct scmi_notify_instance *ni, in __scmi_event_handler_get_ops() argument
1078 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(evt_key), in __scmi_event_handler_get_ops()
1084 mutex_lock(&ni->pending_mtx); in __scmi_event_handler_get_ops()
1097 hndl = KEY_FIND(ni->pending_events_handlers, hndl, evt_key); in __scmi_event_handler_get_ops()
1104 hndl = scmi_allocate_event_handler(ni, evt_key); in __scmi_event_handler_get_ops()
1105 if (hndl && scmi_register_event_handler(ni, hndl)) { in __scmi_event_handler_get_ops()
1106 dev_dbg(ni->handle->dev, in __scmi_event_handler_get_ops()
1110 scmi_put_handler_unlocked(ni, hndl); in __scmi_event_handler_get_ops()
1114 mutex_unlock(&ni->pending_mtx); in __scmi_event_handler_get_ops()
1120 scmi_get_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_handler() argument
1122 return __scmi_event_handler_get_ops(ni, evt_key, false); in scmi_get_handler()
1126 scmi_get_or_create_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_or_create_handler() argument
1128 return __scmi_event_handler_get_ops(ni, evt_key, true); in scmi_get_or_create_handler()
1133 * @ni: A reference to the notification instance to use
1143 scmi_get_active_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_active_handler() argument
1148 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(evt_key), in scmi_get_active_handler()
1259 * @ni: A reference to the notification instance to use
1271 static bool scmi_put_handler_unlocked(struct scmi_notify_instance *ni, in scmi_put_handler_unlocked() argument
1286 static void scmi_put_handler(struct scmi_notify_instance *ni, in scmi_put_handler() argument
1293 mutex_lock(&ni->pending_mtx); in scmi_put_handler()
1299 freed = scmi_put_handler_unlocked(ni, hndl); 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()
1315 static void scmi_put_active_handler(struct scmi_notify_instance *ni, in scmi_put_active_handler() argument
1323 freed = scmi_put_handler_unlocked(ni, hndl); in scmi_put_active_handler()
1326 scmi_protocol_release(ni->handle, protocol_id); in scmi_put_active_handler()
1385 struct scmi_notify_instance *ni; in scmi_notifier_register() local
1387 ni = scmi_notification_instance_data_get(handle); in scmi_notifier_register()
1388 if (!ni) in scmi_notifier_register()
1393 hndl = scmi_get_or_create_handler(ni, evt_key); in scmi_notifier_register()
1403 scmi_put_handler(ni, hndl); in scmi_notifier_register()
1431 struct scmi_notify_instance *ni; in scmi_notifier_unregister() local
1433 ni = scmi_notification_instance_data_get(handle); in scmi_notifier_unregister()
1434 if (!ni) in scmi_notifier_unregister()
1439 hndl = scmi_get_handler(ni, evt_key); in scmi_notifier_unregister()
1448 scmi_put_handler(ni, hndl); in scmi_notifier_unregister()
1461 scmi_put_handler(ni, hndl); in scmi_notifier_unregister()
1585 struct scmi_notify_instance *ni; in scmi_protocols_late_init() local
1588 ni = container_of(work, struct scmi_notify_instance, init_work); in scmi_protocols_late_init()
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()
1597 ret = scmi_bind_event_handler(ni, hndl); in scmi_protocols_late_init()
1599 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1604 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1607 scmi_put_active_handler(ni, hndl); in scmi_protocols_late_init()
1610 ret = scmi_valid_pending_handler(ni, hndl); in scmi_protocols_late_init()
1612 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1616 scmi_put_handler_unlocked(ni, hndl); in scmi_protocols_late_init()
1620 mutex_unlock(&ni->pending_mtx); in scmi_protocols_late_init()
1663 struct scmi_notify_instance *ni; in scmi_notification_init() local
1669 ni = devm_kzalloc(handle->dev, sizeof(*ni), GFP_KERNEL); in scmi_notification_init()
1670 if (!ni) 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()
1692 scmi_notification_instance_data_set(handle, ni); in scmi_notification_init()
1699 devres_close_group(handle->dev, ni->gid); in scmi_notification_init()
1715 struct scmi_notify_instance *ni; in scmi_notification_exit() local
1717 ni = scmi_notification_instance_data_get(handle); in scmi_notification_exit()
1718 if (!ni) in scmi_notification_exit()
1723 destroy_workqueue(ni->notify_wq); in scmi_notification_exit()
1725 devres_release_group(ni->handle->dev, ni->gid); in scmi_notification_exit()