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