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