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_get_notification_instance_data(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_get_notification_instance_data(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()
847 struct scmi_notify_instance *ni; in scmi_deregister_protocol_events() local
850 ni = scmi_get_notification_instance_data(handle); in scmi_deregister_protocol_events()
851 if (!ni) in scmi_deregister_protocol_events()
854 pd = ni->registered_protocols[proto_id]; in scmi_deregister_protocol_events()
858 ni->registered_protocols[proto_id] = NULL; in scmi_deregister_protocol_events()
867 * @ni: A reference to the notification instance to use
881 scmi_allocate_event_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_allocate_event_handler() argument
892 hash_add(ni->pending_events_handlers, &hndl->hash, hndl->key); in scmi_allocate_event_handler()
912 * @ni: A reference to the notification instance to use
922 static inline int scmi_bind_event_handler(struct scmi_notify_instance *ni, in scmi_bind_event_handler() argument
927 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(hndl->key), in scmi_bind_event_handler()
944 scmi_acquire_protocol(ni->handle, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_bind_event_handler()
957 * @ni: A reference to the notification instance to use
969 static inline int scmi_valid_pending_handler(struct scmi_notify_instance *ni, in scmi_valid_pending_handler() argument
977 pd = SCMI_GET_PROTO(ni, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_valid_pending_handler()
986 * @ni: A reference to the notification instance to use
1001 static int scmi_register_event_handler(struct scmi_notify_instance *ni, in scmi_register_event_handler() argument
1006 ret = scmi_bind_event_handler(ni, hndl); in scmi_register_event_handler()
1008 dev_dbg(ni->handle->dev, "registered NEW handler - key:%X\n", in scmi_register_event_handler()
1011 ret = scmi_valid_pending_handler(ni, hndl); in scmi_register_event_handler()
1013 dev_dbg(ni->handle->dev, in scmi_register_event_handler()
1023 * @ni: A reference to the notification instance to use
1052 __scmi_event_handler_get_ops(struct scmi_notify_instance *ni, in __scmi_event_handler_get_ops() argument
1058 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(evt_key), in __scmi_event_handler_get_ops()
1061 mutex_lock(&ni->pending_mtx); in __scmi_event_handler_get_ops()
1074 hndl = KEY_FIND(ni->pending_events_handlers, hndl, evt_key); in __scmi_event_handler_get_ops()
1081 hndl = scmi_allocate_event_handler(ni, evt_key); in __scmi_event_handler_get_ops()
1082 if (hndl && scmi_register_event_handler(ni, hndl)) { in __scmi_event_handler_get_ops()
1083 dev_dbg(ni->handle->dev, in __scmi_event_handler_get_ops()
1087 scmi_put_handler_unlocked(ni, hndl); in __scmi_event_handler_get_ops()
1091 mutex_unlock(&ni->pending_mtx); in __scmi_event_handler_get_ops()
1097 scmi_get_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_handler() argument
1099 return __scmi_event_handler_get_ops(ni, evt_key, false); in scmi_get_handler()
1103 scmi_get_or_create_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_or_create_handler() argument
1105 return __scmi_event_handler_get_ops(ni, evt_key, true); in scmi_get_or_create_handler()
1110 * @ni: A reference to the notification instance to use
1120 scmi_get_active_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_active_handler() argument
1125 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(evt_key), in scmi_get_active_handler()
1228 * @ni: A reference to the notification instance to use
1240 static bool scmi_put_handler_unlocked(struct scmi_notify_instance *ni, in scmi_put_handler_unlocked() argument
1255 static void scmi_put_handler(struct scmi_notify_instance *ni, in scmi_put_handler() argument
1262 mutex_lock(&ni->pending_mtx); in scmi_put_handler()
1268 freed = scmi_put_handler_unlocked(ni, hndl); in scmi_put_handler()
1279 scmi_release_protocol(ni->handle, protocol_id); in scmi_put_handler()
1281 mutex_unlock(&ni->pending_mtx); in scmi_put_handler()
1284 static void scmi_put_active_handler(struct scmi_notify_instance *ni, in scmi_put_active_handler() argument
1292 freed = scmi_put_handler_unlocked(ni, hndl); in scmi_put_active_handler()
1295 scmi_release_protocol(ni->handle, protocol_id); in scmi_put_active_handler()
1354 struct scmi_notify_instance *ni; in scmi_register_notifier() local
1356 ni = scmi_get_notification_instance_data(handle); in scmi_register_notifier()
1357 if (!ni) in scmi_register_notifier()
1362 hndl = scmi_get_or_create_handler(ni, evt_key); in scmi_register_notifier()
1372 scmi_put_handler(ni, hndl); in scmi_register_notifier()
1400 struct scmi_notify_instance *ni; in scmi_unregister_notifier() local
1402 ni = scmi_get_notification_instance_data(handle); in scmi_unregister_notifier()
1403 if (!ni) in scmi_unregister_notifier()
1408 hndl = scmi_get_handler(ni, evt_key); in scmi_unregister_notifier()
1417 scmi_put_handler(ni, hndl); in scmi_unregister_notifier()
1430 scmi_put_handler(ni, hndl); in scmi_unregister_notifier()
1570 struct scmi_notify_instance *ni; in scmi_protocols_late_init() local
1573 ni = container_of(work, struct scmi_notify_instance, init_work); in scmi_protocols_late_init()
1578 mutex_lock(&ni->pending_mtx); in scmi_protocols_late_init()
1579 hash_for_each_safe(ni->pending_events_handlers, bkt, tmp, hndl, hash) { in scmi_protocols_late_init()
1582 ret = scmi_bind_event_handler(ni, hndl); in scmi_protocols_late_init()
1584 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1589 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1592 scmi_put_active_handler(ni, hndl); in scmi_protocols_late_init()
1595 ret = scmi_valid_pending_handler(ni, hndl); in scmi_protocols_late_init()
1597 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1601 scmi_put_handler_unlocked(ni, hndl); in scmi_protocols_late_init()
1605 mutex_unlock(&ni->pending_mtx); in scmi_protocols_late_init()
1648 struct scmi_notify_instance *ni; in scmi_notification_init() local
1654 ni = devm_kzalloc(handle->dev, sizeof(*ni), GFP_KERNEL); in scmi_notification_init()
1655 if (!ni) in scmi_notification_init()
1658 ni->gid = gid; in scmi_notification_init()
1659 ni->handle = handle; in scmi_notification_init()
1661 ni->registered_protocols = devm_kcalloc(handle->dev, SCMI_MAX_PROTO, in scmi_notification_init()
1663 if (!ni->registered_protocols) in scmi_notification_init()
1666 ni->notify_wq = alloc_workqueue(dev_name(handle->dev), in scmi_notification_init()
1669 if (!ni->notify_wq) in scmi_notification_init()
1672 mutex_init(&ni->pending_mtx); in scmi_notification_init()
1673 hash_init(ni->pending_events_handlers); in scmi_notification_init()
1675 INIT_WORK(&ni->init_work, scmi_protocols_late_init); in scmi_notification_init()
1677 scmi_set_notification_instance_data(handle, ni); in scmi_notification_init()
1684 devres_close_group(handle->dev, ni->gid); in scmi_notification_init()
1700 struct scmi_notify_instance *ni; in scmi_notification_exit() local
1702 ni = scmi_get_notification_instance_data(handle); in scmi_notification_exit()
1703 if (!ni) in scmi_notification_exit()
1708 destroy_workqueue(ni->notify_wq); in scmi_notification_exit()
1710 devres_release_group(ni->handle->dev, ni->gid); in scmi_notification_exit()