Lines Matching full:ni

273  * @ni: A reference to the initialized instance descriptor
300 struct scmi_notify_instance *ni; member
372 scmi_get_active_handler(struct scmi_notify_instance *ni, u32 evt_key);
373 static void scmi_put_active_handler(struct scmi_notify_instance *ni,
375 static bool scmi_put_handler_unlocked(struct scmi_notify_instance *ni,
380 * @ni: A reference to the notification instance to use
386 scmi_lookup_and_call_event_chain(struct scmi_notify_instance *ni, in scmi_lookup_and_call_event_chain() argument
398 hndl = scmi_get_active_handler(ni, evt_key); in scmi_lookup_and_call_event_chain()
408 scmi_put_active_handler(ni, hndl); in scmi_lookup_and_call_event_chain()
437 dev_err(pd->ni->handle->dev, "corrupted EVT header. Flush.\n"); in scmi_process_event_header()
479 dev_err(pd->ni->handle->dev, "corrupted EVT Payload. Flush.\n"); in scmi_process_event_payload()
485 dev_warn(pd->ni->handle->dev, in scmi_process_event_payload()
495 dev_err(pd->ni->handle->dev, in scmi_process_event_payload()
503 scmi_lookup_and_call_event_chain(pd->ni, key, report); in scmi_process_event_payload()
507 scmi_lookup_and_call_event_chain(pd->ni, key, report); in scmi_process_event_payload()
584 struct scmi_notify_instance *ni; in scmi_notify() local
586 ni = scmi_notification_instance_data_get(handle); in scmi_notify()
587 if (!ni) in scmi_notify()
590 r_evt = SCMI_GET_REVT(ni, proto_id, evt_id); in scmi_notify()
644 * @ni: A reference to the notification instance to use
652 static int scmi_initialize_events_queue(struct scmi_notify_instance *ni, in scmi_initialize_events_queue() argument
662 ret = devm_add_action_or_reset(ni->handle->dev, scmi_kfifo_free, in scmi_initialize_events_queue()
668 equeue->wq = ni->notify_wq; in scmi_initialize_events_queue()
676 * @ni: A reference to the &struct scmi_notify_instance notification instance
692 scmi_allocate_registered_events_desc(struct scmi_notify_instance *ni, in scmi_allocate_registered_events_desc() argument
702 if (WARN_ON(ni->registered_protocols[proto_id])) in scmi_allocate_registered_events_desc()
705 pd = devm_kzalloc(ni->handle->dev, sizeof(*pd), GFP_KERNEL); in scmi_allocate_registered_events_desc()
710 pd->ni = ni; in scmi_allocate_registered_events_desc()
712 ret = scmi_initialize_events_queue(ni, &pd->equeue, queue_sz); in scmi_allocate_registered_events_desc()
716 pd->eh = devm_kzalloc(ni->handle->dev, eh_sz, GFP_KERNEL); in scmi_allocate_registered_events_desc()
721 pd->registered_events = devm_kcalloc(ni->handle->dev, num_events, in scmi_allocate_registered_events_desc()
757 struct scmi_notify_instance *ni; in scmi_register_protocol_events() local
764 ni = scmi_notification_instance_data_get(handle); in scmi_register_protocol_events()
765 if (!ni) in scmi_register_protocol_events()
784 pd = scmi_allocate_registered_events_desc(ni, proto_id, ee->queue_sz, in scmi_register_protocol_events()
795 r_evt = devm_kzalloc(ni->handle->dev, sizeof(*r_evt), in scmi_register_protocol_events()
802 r_evt->sources = devm_kcalloc(ni->handle->dev, num_sources, in scmi_register_protocol_events()
809 r_evt->report = devm_kzalloc(ni->handle->dev, in scmi_register_protocol_events()
827 ni->registered_protocols[proto_id] = pd; in scmi_register_protocol_events()
835 schedule_work(&ni->init_work); in scmi_register_protocol_events()
849 struct scmi_notify_instance *ni; in scmi_deregister_protocol_events() local
852 ni = scmi_notification_instance_data_get(handle); in scmi_deregister_protocol_events()
853 if (!ni) in scmi_deregister_protocol_events()
856 pd = ni->registered_protocols[proto_id]; in scmi_deregister_protocol_events()
860 ni->registered_protocols[proto_id] = NULL; in scmi_deregister_protocol_events()
869 * @ni: A reference to the notification instance to use
883 scmi_allocate_event_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_allocate_event_handler() argument
894 hash_add(ni->pending_events_handlers, &hndl->hash, hndl->key); in scmi_allocate_event_handler()
914 * @ni: A reference to the notification instance to use
924 static inline int scmi_bind_event_handler(struct scmi_notify_instance *ni, in scmi_bind_event_handler() argument
929 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(hndl->key), in scmi_bind_event_handler()
946 scmi_protocol_acquire(ni->handle, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_bind_event_handler()
959 * @ni: A reference to the notification instance to use
971 static inline int scmi_valid_pending_handler(struct scmi_notify_instance *ni, in scmi_valid_pending_handler() argument
979 pd = SCMI_GET_PROTO(ni, KEY_XTRACT_PROTO_ID(hndl->key)); in scmi_valid_pending_handler()
988 * @ni: A reference to the notification instance to use
1003 static int scmi_register_event_handler(struct scmi_notify_instance *ni, in scmi_register_event_handler() argument
1008 ret = scmi_bind_event_handler(ni, hndl); in scmi_register_event_handler()
1010 dev_dbg(ni->handle->dev, "registered NEW handler - key:%X\n", in scmi_register_event_handler()
1013 ret = scmi_valid_pending_handler(ni, hndl); in scmi_register_event_handler()
1015 dev_dbg(ni->handle->dev, in scmi_register_event_handler()
1025 * @ni: A reference to the notification instance to use
1054 __scmi_event_handler_get_ops(struct scmi_notify_instance *ni, in __scmi_event_handler_get_ops() argument
1060 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(evt_key), in __scmi_event_handler_get_ops()
1063 mutex_lock(&ni->pending_mtx); in __scmi_event_handler_get_ops()
1076 hndl = KEY_FIND(ni->pending_events_handlers, hndl, evt_key); in __scmi_event_handler_get_ops()
1083 hndl = scmi_allocate_event_handler(ni, evt_key); in __scmi_event_handler_get_ops()
1084 if (hndl && scmi_register_event_handler(ni, hndl)) { in __scmi_event_handler_get_ops()
1085 dev_dbg(ni->handle->dev, in __scmi_event_handler_get_ops()
1089 scmi_put_handler_unlocked(ni, hndl); in __scmi_event_handler_get_ops()
1093 mutex_unlock(&ni->pending_mtx); in __scmi_event_handler_get_ops()
1099 scmi_get_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_handler() argument
1101 return __scmi_event_handler_get_ops(ni, evt_key, false); in scmi_get_handler()
1105 scmi_get_or_create_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_or_create_handler() argument
1107 return __scmi_event_handler_get_ops(ni, evt_key, true); in scmi_get_or_create_handler()
1112 * @ni: A reference to the notification instance to use
1122 scmi_get_active_handler(struct scmi_notify_instance *ni, u32 evt_key) in scmi_get_active_handler() argument
1127 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(evt_key), in scmi_get_active_handler()
1238 * @ni: A reference to the notification instance to use
1250 static bool scmi_put_handler_unlocked(struct scmi_notify_instance *ni, in scmi_put_handler_unlocked() argument
1265 static void scmi_put_handler(struct scmi_notify_instance *ni, in scmi_put_handler() argument
1272 mutex_lock(&ni->pending_mtx); in scmi_put_handler()
1278 freed = scmi_put_handler_unlocked(ni, hndl); in scmi_put_handler()
1289 scmi_protocol_release(ni->handle, protocol_id); in scmi_put_handler()
1291 mutex_unlock(&ni->pending_mtx); in scmi_put_handler()
1294 static void scmi_put_active_handler(struct scmi_notify_instance *ni, in scmi_put_active_handler() argument
1302 freed = scmi_put_handler_unlocked(ni, hndl); in scmi_put_active_handler()
1305 scmi_protocol_release(ni->handle, protocol_id); in scmi_put_active_handler()
1364 struct scmi_notify_instance *ni; in scmi_notifier_register() local
1366 ni = scmi_notification_instance_data_get(handle); in scmi_notifier_register()
1367 if (!ni) in scmi_notifier_register()
1372 hndl = scmi_get_or_create_handler(ni, evt_key); in scmi_notifier_register()
1382 scmi_put_handler(ni, hndl); in scmi_notifier_register()
1410 struct scmi_notify_instance *ni; in scmi_notifier_unregister() local
1412 ni = scmi_notification_instance_data_get(handle); in scmi_notifier_unregister()
1413 if (!ni) in scmi_notifier_unregister()
1418 hndl = scmi_get_handler(ni, evt_key); in scmi_notifier_unregister()
1427 scmi_put_handler(ni, hndl); in scmi_notifier_unregister()
1440 scmi_put_handler(ni, hndl); in scmi_notifier_unregister()
1564 struct scmi_notify_instance *ni; in scmi_protocols_late_init() local
1567 ni = container_of(work, struct scmi_notify_instance, init_work); in scmi_protocols_late_init()
1572 mutex_lock(&ni->pending_mtx); in scmi_protocols_late_init()
1573 hash_for_each_safe(ni->pending_events_handlers, bkt, tmp, hndl, hash) { in scmi_protocols_late_init()
1576 ret = scmi_bind_event_handler(ni, hndl); in scmi_protocols_late_init()
1578 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1583 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1586 scmi_put_active_handler(ni, hndl); in scmi_protocols_late_init()
1589 ret = scmi_valid_pending_handler(ni, hndl); in scmi_protocols_late_init()
1591 dev_dbg(ni->handle->dev, in scmi_protocols_late_init()
1595 scmi_put_handler_unlocked(ni, hndl); in scmi_protocols_late_init()
1599 mutex_unlock(&ni->pending_mtx); in scmi_protocols_late_init()
1642 struct scmi_notify_instance *ni; in scmi_notification_init() local
1648 ni = devm_kzalloc(handle->dev, sizeof(*ni), GFP_KERNEL); in scmi_notification_init()
1649 if (!ni) in scmi_notification_init()
1652 ni->gid = gid; in scmi_notification_init()
1653 ni->handle = handle; in scmi_notification_init()
1655 ni->registered_protocols = devm_kcalloc(handle->dev, SCMI_MAX_PROTO, in scmi_notification_init()
1657 if (!ni->registered_protocols) in scmi_notification_init()
1660 ni->notify_wq = alloc_workqueue(dev_name(handle->dev), in scmi_notification_init()
1663 if (!ni->notify_wq) in scmi_notification_init()
1666 mutex_init(&ni->pending_mtx); in scmi_notification_init()
1667 hash_init(ni->pending_events_handlers); in scmi_notification_init()
1669 INIT_WORK(&ni->init_work, scmi_protocols_late_init); in scmi_notification_init()
1671 scmi_notification_instance_data_set(handle, ni); in scmi_notification_init()
1678 devres_close_group(handle->dev, ni->gid); in scmi_notification_init()
1694 struct scmi_notify_instance *ni; in scmi_notification_exit() local
1696 ni = scmi_notification_instance_data_get(handle); in scmi_notification_exit()
1697 if (!ni) in scmi_notification_exit()
1702 destroy_workqueue(ni->notify_wq); in scmi_notification_exit()
1704 devres_release_group(ni->handle->dev, ni->gid); in scmi_notification_exit()