Lines Matching refs:ni

273  * @ni: A reference to the initialized instance descriptor
300 struct scmi_notify_instance *ni;
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,
398 hndl = scmi_get_active_handler(ni, evt_key);
408 scmi_put_active_handler(ni, hndl);
437 dev_err(pd->ni->handle->dev, "corrupted EVT header. Flush.\n");
479 dev_err(pd->ni->handle->dev, "corrupted EVT Payload. Flush.\n");
485 dev_warn(pd->ni->handle->dev,
495 dev_err(pd->ni->handle->dev,
503 scmi_lookup_and_call_event_chain(pd->ni, key, report);
507 scmi_lookup_and_call_event_chain(pd->ni, key, report);
584 struct scmi_notify_instance *ni;
586 ni = scmi_notification_instance_data_get(handle);
587 if (!ni)
590 r_evt = SCMI_GET_REVT(ni, proto_id, evt_id);
644 * @ni: A reference to the notification instance to use
652 static int scmi_initialize_events_queue(struct scmi_notify_instance *ni,
662 ret = devm_add_action_or_reset(ni->handle->dev, scmi_kfifo_free,
668 equeue->wq = ni->notify_wq;
676 * @ni: A reference to the &struct scmi_notify_instance notification instance
692 scmi_allocate_registered_events_desc(struct scmi_notify_instance *ni,
702 if (WARN_ON(ni->registered_protocols[proto_id]))
705 pd = devm_kzalloc(ni->handle->dev, sizeof(*pd), GFP_KERNEL);
710 pd->ni = ni;
712 ret = scmi_initialize_events_queue(ni, &pd->equeue, queue_sz);
716 pd->eh = devm_kzalloc(ni->handle->dev, eh_sz, GFP_KERNEL);
721 pd->registered_events = devm_kcalloc(ni->handle->dev, num_events,
757 struct scmi_notify_instance *ni;
764 ni = scmi_notification_instance_data_get(handle);
765 if (!ni)
784 pd = scmi_allocate_registered_events_desc(ni, proto_id, ee->queue_sz,
795 r_evt = devm_kzalloc(ni->handle->dev, sizeof(*r_evt),
802 r_evt->sources = devm_kcalloc(ni->handle->dev, num_sources,
809 r_evt->report = devm_kzalloc(ni->handle->dev,
827 ni->registered_protocols[proto_id] = pd;
835 schedule_work(&ni->init_work);
849 struct scmi_notify_instance *ni;
852 ni = scmi_notification_instance_data_get(handle);
853 if (!ni)
856 pd = ni->registered_protocols[proto_id];
860 ni->registered_protocols[proto_id] = NULL;
869 * @ni: A reference to the notification instance to use
883 scmi_allocate_event_handler(struct scmi_notify_instance *ni, u32 evt_key)
894 hash_add(ni->pending_events_handlers, &hndl->hash, hndl->key);
914 * @ni: A reference to the notification instance to use
924 static inline int scmi_bind_event_handler(struct scmi_notify_instance *ni,
929 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(hndl->key),
946 scmi_protocol_acquire(ni->handle, KEY_XTRACT_PROTO_ID(hndl->key));
959 * @ni: A reference to the notification instance to use
971 static inline int scmi_valid_pending_handler(struct scmi_notify_instance *ni,
979 pd = SCMI_GET_PROTO(ni, KEY_XTRACT_PROTO_ID(hndl->key));
988 * @ni: A reference to the notification instance to use
1003 static int scmi_register_event_handler(struct scmi_notify_instance *ni,
1008 ret = scmi_bind_event_handler(ni, hndl);
1010 dev_dbg(ni->handle->dev, "registered NEW handler - key:%X\n",
1013 ret = scmi_valid_pending_handler(ni, hndl);
1015 dev_dbg(ni->handle->dev,
1025 * @ni: A reference to the notification instance to use
1054 __scmi_event_handler_get_ops(struct scmi_notify_instance *ni,
1060 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(evt_key),
1063 mutex_lock(&ni->pending_mtx);
1076 hndl = KEY_FIND(ni->pending_events_handlers, hndl, evt_key);
1083 hndl = scmi_allocate_event_handler(ni, evt_key);
1084 if (hndl && scmi_register_event_handler(ni, hndl)) {
1085 dev_dbg(ni->handle->dev,
1089 scmi_put_handler_unlocked(ni, hndl);
1093 mutex_unlock(&ni->pending_mtx);
1099 scmi_get_handler(struct scmi_notify_instance *ni, u32 evt_key)
1101 return __scmi_event_handler_get_ops(ni, evt_key, false);
1105 scmi_get_or_create_handler(struct scmi_notify_instance *ni, u32 evt_key)
1107 return __scmi_event_handler_get_ops(ni, evt_key, true);
1112 * @ni: A reference to the notification instance to use
1122 scmi_get_active_handler(struct scmi_notify_instance *ni, u32 evt_key)
1127 r_evt = SCMI_GET_REVT(ni, KEY_XTRACT_PROTO_ID(evt_key),
1238 * @ni: A reference to the notification instance to use
1250 static bool scmi_put_handler_unlocked(struct scmi_notify_instance *ni,
1265 static void scmi_put_handler(struct scmi_notify_instance *ni,
1272 mutex_lock(&ni->pending_mtx);
1278 freed = scmi_put_handler_unlocked(ni, hndl);
1289 scmi_protocol_release(ni->handle, protocol_id);
1291 mutex_unlock(&ni->pending_mtx);
1294 static void scmi_put_active_handler(struct scmi_notify_instance *ni,
1302 freed = scmi_put_handler_unlocked(ni, hndl);
1305 scmi_protocol_release(ni->handle, protocol_id);
1364 struct scmi_notify_instance *ni;
1366 ni = scmi_notification_instance_data_get(handle);
1367 if (!ni)
1372 hndl = scmi_get_or_create_handler(ni, evt_key);
1382 scmi_put_handler(ni, hndl);
1410 struct scmi_notify_instance *ni;
1412 ni = scmi_notification_instance_data_get(handle);
1413 if (!ni)
1418 hndl = scmi_get_handler(ni, evt_key);
1427 scmi_put_handler(ni, hndl);
1440 scmi_put_handler(ni, hndl);
1586 struct scmi_notify_instance *ni;
1589 ni = container_of(work, struct scmi_notify_instance, init_work);
1594 mutex_lock(&ni->pending_mtx);
1595 hash_for_each_safe(ni->pending_events_handlers, bkt, tmp, hndl, hash) {
1598 ret = scmi_bind_event_handler(ni, hndl);
1600 dev_dbg(ni->handle->dev,
1605 dev_dbg(ni->handle->dev,
1608 scmi_put_active_handler(ni, hndl);
1611 ret = scmi_valid_pending_handler(ni, hndl);
1613 dev_dbg(ni->handle->dev,
1617 scmi_put_handler_unlocked(ni, hndl);
1621 mutex_unlock(&ni->pending_mtx);
1664 struct scmi_notify_instance *ni;
1670 ni = devm_kzalloc(handle->dev, sizeof(*ni), GFP_KERNEL);
1671 if (!ni)
1674 ni->gid = gid;
1675 ni->handle = handle;
1677 ni->registered_protocols = devm_kcalloc(handle->dev, SCMI_MAX_PROTO,
1679 if (!ni->registered_protocols)
1682 ni->notify_wq = alloc_workqueue(dev_name(handle->dev),
1685 if (!ni->notify_wq)
1688 mutex_init(&ni->pending_mtx);
1689 hash_init(ni->pending_events_handlers);
1691 INIT_WORK(&ni->init_work, scmi_protocols_late_init);
1693 scmi_notification_instance_data_set(handle, ni);
1700 devres_close_group(handle->dev, ni->gid);
1716 struct scmi_notify_instance *ni;
1718 ni = scmi_notification_instance_data_get(handle);
1719 if (!ni)
1724 destroy_workqueue(ni->notify_wq);
1726 devres_release_group(ni->handle->dev, ni->gid);