Lines Matching full:ni

180 	r->proto->ops->set_notify_enabled(r->proto->ni->handle,	\
193 r->proto->ops->fill_custom_report(r->proto->ni->handle, \
271 * @ni: A reference to the initialized instance descriptor
297 struct scmi_notify_instance *ni; member
368 scmi_get_active_handler(struct scmi_notify_instance *ni, u32 evt_key);
369 static void scmi_put_active_handler(struct scmi_notify_instance *ni,
371 static void scmi_put_handler_unlocked(struct scmi_notify_instance *ni,
376 * @ni: A reference to the notification instance to use
382 scmi_lookup_and_call_event_chain(struct scmi_notify_instance *ni, in scmi_lookup_and_call_event_chain() argument
394 hndl = scmi_get_active_handler(ni, evt_key); in scmi_lookup_and_call_event_chain()
404 scmi_put_active_handler(ni, hndl); in scmi_lookup_and_call_event_chain()
433 dev_err(pd->ni->handle->dev, "corrupted EVT header. Flush.\n"); in scmi_process_event_header()
475 dev_err(pd->ni->handle->dev, "corrupted EVT Payload. Flush.\n"); in scmi_process_event_payload()
481 dev_warn(pd->ni->handle->dev, in scmi_process_event_payload()
491 dev_err(pd->ni->handle->dev, in scmi_process_event_payload()
499 scmi_lookup_and_call_event_chain(pd->ni, key, report); in scmi_process_event_payload()
503 scmi_lookup_and_call_event_chain(pd->ni, key, report); in scmi_process_event_payload()
580 struct scmi_notify_instance *ni; in scmi_notify() local
586 ni = handle->notify_priv; in scmi_notify()
588 r_evt = SCMI_GET_REVT(ni, proto_id, evt_id); in scmi_notify()
642 * @ni: A reference to the notification instance to use
650 static int scmi_initialize_events_queue(struct scmi_notify_instance *ni, in scmi_initialize_events_queue() argument
660 ret = devm_add_action_or_reset(ni->handle->dev, scmi_kfifo_free, in scmi_initialize_events_queue()
666 equeue->wq = ni->notify_wq; in scmi_initialize_events_queue()
674 * @ni: A reference to the &struct scmi_notify_instance notification instance
690 scmi_allocate_registered_events_desc(struct scmi_notify_instance *ni, in scmi_allocate_registered_events_desc() argument
700 if (WARN_ON(ni->registered_protocols[proto_id])) in scmi_allocate_registered_events_desc()
703 pd = devm_kzalloc(ni->handle->dev, sizeof(*pd), GFP_KERNEL); in scmi_allocate_registered_events_desc()
708 pd->ni = ni; in scmi_allocate_registered_events_desc()
710 ret = scmi_initialize_events_queue(ni, &pd->equeue, queue_sz); in scmi_allocate_registered_events_desc()
714 pd->eh = devm_kzalloc(ni->handle->dev, eh_sz, GFP_KERNEL); in scmi_allocate_registered_events_desc()
719 pd->registered_events = devm_kcalloc(ni->handle->dev, num_events, in scmi_allocate_registered_events_desc()
760 struct scmi_notify_instance *ni; in scmi_register_protocol_events() local
769 ni = handle->notify_priv; in scmi_register_protocol_events()
772 if (!devres_open_group(ni->handle->dev, ni->gid, GFP_KERNEL)) in scmi_register_protocol_events()
779 pd = scmi_allocate_registered_events_desc(ni, proto_id, queue_sz, in scmi_register_protocol_events()
787 r_evt = devm_kzalloc(ni->handle->dev, sizeof(*r_evt), in scmi_register_protocol_events()
794 r_evt->sources = devm_kcalloc(ni->handle->dev, num_sources, in scmi_register_protocol_events()
801 r_evt->report = devm_kzalloc(ni->handle->dev, in scmi_register_protocol_events()
814 ni->registered_protocols[proto_id] = pd; in scmi_register_protocol_events()
818 devres_close_group(ni->handle->dev, ni->gid); in scmi_register_protocol_events()
824 schedule_work(&ni->init_work); in scmi_register_protocol_events()
831 devres_close_group(ni->handle->dev, ni->gid); in scmi_register_protocol_events()
838 * @ni: A reference to the notification instance to use
852 scmi_allocate_event_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_allocate_event_handler() argument
863 hash_add(ni->pending_events_handlers, &hndl->hash, hndl->key); in scmi_allocate_event_handler()
883 * @ni: A reference to the notification instance to use
893 static inline int scmi_bind_event_handler(struct scmi_notify_instance *ni, in scmi_bind_event_handler() argument
898 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(hndl->key), in scmi_bind_event_handler()
916 * @ni: A reference to the notification instance to use
928 static inline int scmi_valid_pending_handler(struct scmi_notify_instance *ni, in scmi_valid_pending_handler() argument
936 pd = SCMI_GET_PROTO(ni, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_valid_pending_handler()
945 * @ni: A reference to the notification instance to use
960 static int scmi_register_event_handler(struct scmi_notify_instance *ni, in scmi_register_event_handler() argument
965 ret = scmi_bind_event_handler(ni, hndl); in scmi_register_event_handler()
967 dev_dbg(ni->handle->dev, "registered NEW handler - key:%X\n", in scmi_register_event_handler()
970 ret = scmi_valid_pending_handler(ni, hndl); in scmi_register_event_handler()
972 dev_dbg(ni->handle->dev, in scmi_register_event_handler()
982 * @ni: A reference to the notification instance to use
1011 __scmi_event_handler_get_ops(struct scmi_notify_instance *ni, in __scmi_event_handler_get_ops() argument
1017 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(evt_key), in __scmi_event_handler_get_ops()
1020 mutex_lock(&ni->pending_mtx); in __scmi_event_handler_get_ops()
1033 hndl = KEY_FIND(ni->pending_events_handlers, hndl, evt_key); in __scmi_event_handler_get_ops()
1040 hndl = scmi_allocate_event_handler(ni, evt_key); in __scmi_event_handler_get_ops()
1041 if (hndl && scmi_register_event_handler(ni, hndl)) { in __scmi_event_handler_get_ops()
1042 dev_dbg(ni->handle->dev, in __scmi_event_handler_get_ops()
1046 scmi_put_handler_unlocked(ni, hndl); in __scmi_event_handler_get_ops()
1050 mutex_unlock(&ni->pending_mtx); in __scmi_event_handler_get_ops()
1056 scmi_get_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_handler() argument
1058 return __scmi_event_handler_get_ops(ni, evt_key, false); in scmi_get_handler()
1062 scmi_get_or_create_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_or_create_handler() argument
1064 return __scmi_event_handler_get_ops(ni, evt_key, true); in scmi_get_or_create_handler()
1069 * @ni: A reference to the notification instance to use
1079 scmi_get_active_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_active_handler() argument
1084 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(evt_key), in scmi_get_active_handler()
1187 * @ni: A reference to the notification instance to use
1197 static void scmi_put_handler_unlocked(struct scmi_notify_instance *ni, in scmi_put_handler_unlocked() argument
1207 static void scmi_put_handler(struct scmi_notify_instance *ni, in scmi_put_handler() argument
1212 mutex_lock(&ni->pending_mtx); in scmi_put_handler()
1216 scmi_put_handler_unlocked(ni, hndl); in scmi_put_handler()
1220 mutex_unlock(&ni->pending_mtx); in scmi_put_handler()
1223 static void scmi_put_active_handler(struct scmi_notify_instance *ni, in scmi_put_active_handler() argument
1229 scmi_put_handler_unlocked(ni, hndl); in scmi_put_active_handler()
1289 struct scmi_notify_instance *ni; in scmi_register_notifier() local
1295 ni = handle->notify_priv; in scmi_register_notifier()
1299 hndl = scmi_get_or_create_handler(ni, evt_key); in scmi_register_notifier()
1309 scmi_put_handler(ni, hndl); in scmi_register_notifier()
1337 struct scmi_notify_instance *ni; in scmi_unregister_notifier() local
1343 ni = handle->notify_priv; in scmi_unregister_notifier()
1347 hndl = scmi_get_handler(ni, evt_key); in scmi_unregister_notifier()
1356 scmi_put_handler(ni, hndl); in scmi_unregister_notifier()
1369 scmi_put_handler(ni, hndl); in scmi_unregister_notifier()
1388 struct scmi_notify_instance *ni; in scmi_protocols_late_init() local
1391 ni = container_of(work, struct scmi_notify_instance, init_work); in scmi_protocols_late_init()
1396 mutex_lock(&ni->pending_mtx); in scmi_protocols_late_init()
1397 hash_for_each_safe(ni->pending_events_handlers, bkt, tmp, hndl, hash) { in scmi_protocols_late_init()
1400 ret = scmi_bind_event_handler(ni, hndl); in scmi_protocols_late_init()
1402 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1407 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1410 scmi_put_active_handler(ni, hndl); in scmi_protocols_late_init()
1413 ret = scmi_valid_pending_handler(ni, hndl); in scmi_protocols_late_init()
1415 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1419 scmi_put_handler_unlocked(ni, hndl); in scmi_protocols_late_init()
1423 mutex_unlock(&ni->pending_mtx); in scmi_protocols_late_init()
1464 struct scmi_notify_instance *ni; in scmi_notification_init() local
1470 ni = devm_kzalloc(handle->dev, sizeof(*ni), GFP_KERNEL); in scmi_notification_init()
1471 if (!ni) in scmi_notification_init()
1474 ni->gid = gid; in scmi_notification_init()
1475 ni->handle = handle; in scmi_notification_init()
1477 ni->notify_wq = alloc_workqueue(dev_name(handle->dev), in scmi_notification_init()
1480 if (!ni->notify_wq) in scmi_notification_init()
1483 ni->registered_protocols = devm_kcalloc(handle->dev, SCMI_MAX_PROTO, in scmi_notification_init()
1485 if (!ni->registered_protocols) in scmi_notification_init()
1488 mutex_init(&ni->pending_mtx); in scmi_notification_init()
1489 hash_init(ni->pending_events_handlers); in scmi_notification_init()
1491 INIT_WORK(&ni->init_work, scmi_protocols_late_init); in scmi_notification_init()
1494 handle->notify_priv = ni; in scmi_notification_init()
1500 devres_close_group(handle->dev, ni->gid); in scmi_notification_init()
1516 struct scmi_notify_instance *ni; in scmi_notification_exit() local
1522 ni = handle->notify_priv; in scmi_notification_exit()
1529 destroy_workqueue(ni->notify_wq); in scmi_notification_exit()
1531 devres_release_group(ni->handle->dev, ni->gid); in scmi_notification_exit()