Lines Matching refs:nmh
741 static int o2net_handler_cmp(struct o2net_msg_handler *nmh, u32 msg_type, in o2net_handler_cmp() argument
744 int ret = memcmp(&nmh->nh_key, &key, sizeof(key)); in o2net_handler_cmp()
747 ret = memcmp(&nmh->nh_msg_type, &msg_type, sizeof(msg_type)); in o2net_handler_cmp()
758 struct o2net_msg_handler *nmh, *ret = NULL; in o2net_handler_tree_lookup() local
763 nmh = rb_entry(parent, struct o2net_msg_handler, nh_node); in o2net_handler_tree_lookup()
764 cmp = o2net_handler_cmp(nmh, msg_type, key); in o2net_handler_tree_lookup()
771 ret = nmh; in o2net_handler_tree_lookup()
786 struct o2net_msg_handler *nmh; in o2net_handler_kref_release() local
787 nmh = container_of(kref, struct o2net_msg_handler, nh_kref); in o2net_handler_kref_release()
789 kfree(nmh); in o2net_handler_kref_release()
792 static void o2net_handler_put(struct o2net_msg_handler *nmh) in o2net_handler_put() argument
794 kref_put(&nmh->nh_kref, o2net_handler_kref_release); in o2net_handler_put()
804 struct o2net_msg_handler *nmh = NULL; in o2net_register_handler() local
828 nmh = kzalloc(sizeof(struct o2net_msg_handler), GFP_NOFS); in o2net_register_handler()
829 if (nmh == NULL) { in o2net_register_handler()
834 nmh->nh_func = func; in o2net_register_handler()
835 nmh->nh_func_data = data; in o2net_register_handler()
836 nmh->nh_post_func = post_func; in o2net_register_handler()
837 nmh->nh_msg_type = msg_type; in o2net_register_handler()
838 nmh->nh_max_len = max_len; in o2net_register_handler()
839 nmh->nh_key = key; in o2net_register_handler()
842 kref_init(&nmh->nh_kref); in o2net_register_handler()
843 INIT_LIST_HEAD(&nmh->nh_unregister_item); in o2net_register_handler()
849 rb_link_node(&nmh->nh_node, parent, p); in o2net_register_handler()
850 rb_insert_color(&nmh->nh_node, &o2net_handler_tree); in o2net_register_handler()
851 list_add_tail(&nmh->nh_unregister_item, unreg_list); in o2net_register_handler()
865 kfree(nmh); in o2net_register_handler()
873 struct o2net_msg_handler *nmh, *n; in o2net_unregister_handler_list() local
876 list_for_each_entry_safe(nmh, n, list, nh_unregister_item) { in o2net_unregister_handler_list()
878 nmh->nh_func, nmh->nh_msg_type, nmh->nh_key); in o2net_unregister_handler_list()
879 rb_erase(&nmh->nh_node, &o2net_handler_tree); in o2net_unregister_handler_list()
880 list_del_init(&nmh->nh_unregister_item); in o2net_unregister_handler_list()
881 kref_put(&nmh->nh_kref, o2net_handler_kref_release); in o2net_unregister_handler_list()
889 struct o2net_msg_handler *nmh; in o2net_handler_get() local
892 nmh = o2net_handler_tree_lookup(msg_type, key, NULL, NULL); in o2net_handler_get()
893 if (nmh) in o2net_handler_get()
894 kref_get(&nmh->nh_kref); in o2net_handler_get()
897 return nmh; in o2net_handler_get()
1176 struct o2net_msg_handler *nmh = NULL; in o2net_process_message() local
1207 nmh = o2net_handler_get(be16_to_cpu(hdr->msg_type), in o2net_process_message()
1209 if (!nmh) { in o2net_process_message()
1218 if (be16_to_cpu(hdr->data_len) > nmh->nh_max_len) in o2net_process_message()
1227 handler_status = (nmh->nh_func)(hdr, sizeof(struct o2net_msg) + in o2net_process_message()
1229 nmh->nh_func_data, &ret_data); in o2net_process_message()
1244 if (nmh) { in o2net_process_message()
1245 BUG_ON(ret_data != NULL && nmh->nh_post_func == NULL); in o2net_process_message()
1246 if (nmh->nh_post_func) in o2net_process_message()
1247 (nmh->nh_post_func)(handler_status, nmh->nh_func_data, in o2net_process_message()
1252 if (nmh) in o2net_process_message()
1253 o2net_handler_put(nmh); in o2net_process_message()