Lines Matching full:ni

272  * @ni: A reference to the initialized instance descriptor
299 struct scmi_notify_instance *ni; member
371 scmi_get_active_handler(struct scmi_notify_instance *ni, u32 evt_key);
372 static void scmi_put_active_handler(struct scmi_notify_instance *ni,
374 static bool scmi_put_handler_unlocked(struct scmi_notify_instance *ni,
379 * @ni: A reference to the notification instance to use
385 scmi_lookup_and_call_event_chain(struct scmi_notify_instance *ni, in scmi_lookup_and_call_event_chain() argument
397 hndl = scmi_get_active_handler(ni, evt_key); in scmi_lookup_and_call_event_chain()
407 scmi_put_active_handler(ni, hndl); in scmi_lookup_and_call_event_chain()
436 dev_err(pd->ni->handle->dev, "corrupted EVT header. Flush.\n"); in scmi_process_event_header()
478 dev_err(pd->ni->handle->dev, "corrupted EVT Payload. Flush.\n"); in scmi_process_event_payload()
484 dev_warn(pd->ni->handle->dev, in scmi_process_event_payload()
494 dev_err(pd->ni->handle->dev, in scmi_process_event_payload()
502 scmi_lookup_and_call_event_chain(pd->ni, key, report); in scmi_process_event_payload()
506 scmi_lookup_and_call_event_chain(pd->ni, key, report); in scmi_process_event_payload()
583 struct scmi_notify_instance *ni; in scmi_notify() local
585 ni = scmi_notification_instance_data_get(handle); in scmi_notify()
586 if (!ni) in scmi_notify()
589 r_evt = SCMI_GET_REVT(ni, proto_id, evt_id); in scmi_notify()
643 * @ni: A reference to the notification instance to use
651 static int scmi_initialize_events_queue(struct scmi_notify_instance *ni, in scmi_initialize_events_queue() argument
661 ret = devm_add_action_or_reset(ni->handle->dev, scmi_kfifo_free, in scmi_initialize_events_queue()
667 equeue->wq = ni->notify_wq; in scmi_initialize_events_queue()
675 * @ni: A reference to the &struct scmi_notify_instance notification instance
691 scmi_allocate_registered_events_desc(struct scmi_notify_instance *ni, in scmi_allocate_registered_events_desc() argument
701 if (WARN_ON(ni->registered_protocols[proto_id])) in scmi_allocate_registered_events_desc()
704 pd = devm_kzalloc(ni->handle->dev, sizeof(*pd), GFP_KERNEL); in scmi_allocate_registered_events_desc()
709 pd->ni = ni; in scmi_allocate_registered_events_desc()
711 ret = scmi_initialize_events_queue(ni, &pd->equeue, queue_sz); in scmi_allocate_registered_events_desc()
715 pd->eh = devm_kzalloc(ni->handle->dev, eh_sz, GFP_KERNEL); in scmi_allocate_registered_events_desc()
720 pd->registered_events = devm_kcalloc(ni->handle->dev, num_events, in scmi_allocate_registered_events_desc()
756 struct scmi_notify_instance *ni; in scmi_register_protocol_events() local
763 ni = scmi_notification_instance_data_get(handle); in scmi_register_protocol_events()
764 if (!ni) in scmi_register_protocol_events()
783 pd = scmi_allocate_registered_events_desc(ni, proto_id, ee->queue_sz, in scmi_register_protocol_events()
793 r_evt = devm_kzalloc(ni->handle->dev, sizeof(*r_evt), in scmi_register_protocol_events()
800 r_evt->sources = devm_kcalloc(ni->handle->dev, num_sources, in scmi_register_protocol_events()
807 r_evt->report = devm_kzalloc(ni->handle->dev, in scmi_register_protocol_events()
820 ni->registered_protocols[proto_id] = pd; in scmi_register_protocol_events()
828 schedule_work(&ni->init_work); in scmi_register_protocol_events()
842 struct scmi_notify_instance *ni; in scmi_deregister_protocol_events() local
845 ni = scmi_notification_instance_data_get(handle); in scmi_deregister_protocol_events()
846 if (!ni) in scmi_deregister_protocol_events()
849 pd = ni->registered_protocols[proto_id]; in scmi_deregister_protocol_events()
853 ni->registered_protocols[proto_id] = NULL; in scmi_deregister_protocol_events()
862 * @ni: A reference to the notification instance to use
876 scmi_allocate_event_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_allocate_event_handler() argument
887 hash_add(ni->pending_events_handlers, &hndl->hash, hndl->key); in scmi_allocate_event_handler()
907 * @ni: A reference to the notification instance to use
917 static inline int scmi_bind_event_handler(struct scmi_notify_instance *ni, in scmi_bind_event_handler() argument
922 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(hndl->key), in scmi_bind_event_handler()
939 scmi_protocol_acquire(ni->handle, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_bind_event_handler()
952 * @ni: A reference to the notification instance to use
964 static inline int scmi_valid_pending_handler(struct scmi_notify_instance *ni, in scmi_valid_pending_handler() argument
972 pd = SCMI_GET_PROTO(ni, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_valid_pending_handler()
981 * @ni: A reference to the notification instance to use
996 static int scmi_register_event_handler(struct scmi_notify_instance *ni, in scmi_register_event_handler() argument
1001 ret = scmi_bind_event_handler(ni, hndl); in scmi_register_event_handler()
1003 dev_dbg(ni->handle->dev, "registered NEW handler - key:%X\n", in scmi_register_event_handler()
1006 ret = scmi_valid_pending_handler(ni, hndl); in scmi_register_event_handler()
1008 dev_dbg(ni->handle->dev, in scmi_register_event_handler()
1018 * @ni: A reference to the notification instance to use
1047 __scmi_event_handler_get_ops(struct scmi_notify_instance *ni, in __scmi_event_handler_get_ops() argument
1053 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(evt_key), in __scmi_event_handler_get_ops()
1056 mutex_lock(&ni->pending_mtx); in __scmi_event_handler_get_ops()
1069 hndl = KEY_FIND(ni->pending_events_handlers, hndl, evt_key); in __scmi_event_handler_get_ops()
1076 hndl = scmi_allocate_event_handler(ni, evt_key); in __scmi_event_handler_get_ops()
1077 if (hndl && scmi_register_event_handler(ni, hndl)) { in __scmi_event_handler_get_ops()
1078 dev_dbg(ni->handle->dev, in __scmi_event_handler_get_ops()
1082 scmi_put_handler_unlocked(ni, hndl); in __scmi_event_handler_get_ops()
1086 mutex_unlock(&ni->pending_mtx); in __scmi_event_handler_get_ops()
1092 scmi_get_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_handler() argument
1094 return __scmi_event_handler_get_ops(ni, evt_key, false); in scmi_get_handler()
1098 scmi_get_or_create_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_or_create_handler() argument
1100 return __scmi_event_handler_get_ops(ni, evt_key, true); in scmi_get_or_create_handler()
1105 * @ni: A reference to the notification instance to use
1115 scmi_get_active_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_active_handler() argument
1120 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(evt_key), in scmi_get_active_handler()
1223 * @ni: A reference to the notification instance to use
1235 static bool scmi_put_handler_unlocked(struct scmi_notify_instance *ni, in scmi_put_handler_unlocked() argument
1250 static void scmi_put_handler(struct scmi_notify_instance *ni, in scmi_put_handler() argument
1257 mutex_lock(&ni->pending_mtx); in scmi_put_handler()
1263 freed = scmi_put_handler_unlocked(ni, hndl); in scmi_put_handler()
1274 scmi_protocol_release(ni->handle, protocol_id); in scmi_put_handler()
1276 mutex_unlock(&ni->pending_mtx); in scmi_put_handler()
1279 static void scmi_put_active_handler(struct scmi_notify_instance *ni, in scmi_put_active_handler() argument
1287 freed = scmi_put_handler_unlocked(ni, hndl); in scmi_put_active_handler()
1290 scmi_protocol_release(ni->handle, protocol_id); in scmi_put_active_handler()
1349 struct scmi_notify_instance *ni; in scmi_notifier_register() local
1351 ni = scmi_notification_instance_data_get(handle); in scmi_notifier_register()
1352 if (!ni) in scmi_notifier_register()
1357 hndl = scmi_get_or_create_handler(ni, evt_key); in scmi_notifier_register()
1367 scmi_put_handler(ni, hndl); in scmi_notifier_register()
1395 struct scmi_notify_instance *ni; in scmi_notifier_unregister() local
1397 ni = scmi_notification_instance_data_get(handle); in scmi_notifier_unregister()
1398 if (!ni) in scmi_notifier_unregister()
1403 hndl = scmi_get_handler(ni, evt_key); in scmi_notifier_unregister()
1412 scmi_put_handler(ni, hndl); in scmi_notifier_unregister()
1425 scmi_put_handler(ni, hndl); in scmi_notifier_unregister()
1571 struct scmi_notify_instance *ni; in scmi_protocols_late_init() local
1574 ni = container_of(work, struct scmi_notify_instance, init_work); in scmi_protocols_late_init()
1579 mutex_lock(&ni->pending_mtx); in scmi_protocols_late_init()
1580 hash_for_each_safe(ni->pending_events_handlers, bkt, tmp, hndl, hash) { in scmi_protocols_late_init()
1583 ret = scmi_bind_event_handler(ni, hndl); in scmi_protocols_late_init()
1585 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1590 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1593 scmi_put_active_handler(ni, hndl); in scmi_protocols_late_init()
1596 ret = scmi_valid_pending_handler(ni, hndl); in scmi_protocols_late_init()
1598 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1602 scmi_put_handler_unlocked(ni, hndl); in scmi_protocols_late_init()
1606 mutex_unlock(&ni->pending_mtx); in scmi_protocols_late_init()
1649 struct scmi_notify_instance *ni; in scmi_notification_init() local
1655 ni = devm_kzalloc(handle->dev, sizeof(*ni), GFP_KERNEL); in scmi_notification_init()
1656 if (!ni) in scmi_notification_init()
1659 ni->gid = gid; in scmi_notification_init()
1660 ni->handle = handle; in scmi_notification_init()
1662 ni->registered_protocols = devm_kcalloc(handle->dev, SCMI_MAX_PROTO, in scmi_notification_init()
1664 if (!ni->registered_protocols) in scmi_notification_init()
1667 ni->notify_wq = alloc_workqueue(dev_name(handle->dev), in scmi_notification_init()
1670 if (!ni->notify_wq) in scmi_notification_init()
1673 mutex_init(&ni->pending_mtx); in scmi_notification_init()
1674 hash_init(ni->pending_events_handlers); in scmi_notification_init()
1676 INIT_WORK(&ni->init_work, scmi_protocols_late_init); in scmi_notification_init()
1678 scmi_notification_instance_data_set(handle, ni); in scmi_notification_init()
1685 devres_close_group(handle->dev, ni->gid); in scmi_notification_init()
1701 struct scmi_notify_instance *ni; in scmi_notification_exit() local
1703 ni = scmi_notification_instance_data_get(handle); in scmi_notification_exit()
1704 if (!ni) in scmi_notification_exit()
1709 destroy_workqueue(ni->notify_wq); in scmi_notification_exit()
1711 devres_release_group(ni->handle->dev, ni->gid); in scmi_notification_exit()