Lines Matching refs:ivars

82 xenbusb_free_child_ivars(struct xenbus_device_ivars *ivars)  in xenbusb_free_child_ivars()  argument
84 if (ivars->xd_otherend_watch.node != NULL) { in xenbusb_free_child_ivars()
85 xs_unregister_watch(&ivars->xd_otherend_watch); in xenbusb_free_child_ivars()
86 free(ivars->xd_otherend_watch.node, M_XENBUS); in xenbusb_free_child_ivars()
87 ivars->xd_otherend_watch.node = NULL; in xenbusb_free_child_ivars()
90 if (ivars->xd_local_watch.node != NULL) { in xenbusb_free_child_ivars()
91 xs_unregister_watch(&ivars->xd_local_watch); in xenbusb_free_child_ivars()
92 ivars->xd_local_watch.node = NULL; in xenbusb_free_child_ivars()
95 if (ivars->xd_node != NULL) { in xenbusb_free_child_ivars()
96 free(ivars->xd_node, M_XENBUS); in xenbusb_free_child_ivars()
97 ivars->xd_node = NULL; in xenbusb_free_child_ivars()
99 ivars->xd_node_len = 0; in xenbusb_free_child_ivars()
101 if (ivars->xd_type != NULL) { in xenbusb_free_child_ivars()
102 free(ivars->xd_type, M_XENBUS); in xenbusb_free_child_ivars()
103 ivars->xd_type = NULL; in xenbusb_free_child_ivars()
106 if (ivars->xd_otherend_path != NULL) { in xenbusb_free_child_ivars()
107 free(ivars->xd_otherend_path, M_XENBUS); in xenbusb_free_child_ivars()
108 ivars->xd_otherend_path = NULL; in xenbusb_free_child_ivars()
110 ivars->xd_otherend_path_len = 0; in xenbusb_free_child_ivars()
112 free(ivars, M_XENBUS); in xenbusb_free_child_ivars()
133 struct xenbus_device_ivars *ivars; in xenbusb_otherend_watch_cb() local
139 ivars = (struct xenbus_device_ivars *)watch->callback_data; in xenbusb_otherend_watch_cb()
140 child = ivars->xd_dev; in xenbusb_otherend_watch_cb()
144 if (ivars->xd_otherend_path == NULL in xenbusb_otherend_watch_cb()
145 || strncmp(ivars->xd_otherend_path, path, ivars->xd_otherend_path_len)) in xenbusb_otherend_watch_cb()
148 newstate = xenbus_read_driver_state(ivars->xd_otherend_path); in xenbusb_otherend_watch_cb()
171 struct xenbus_device_ivars *ivars; in xenbusb_local_watch_cb() local
176 ivars = (struct xenbus_device_ivars *)watch->callback_data; in xenbusb_local_watch_cb()
177 child = ivars->xd_dev; in xenbusb_local_watch_cb()
181 if (ivars->xd_node == NULL in xenbusb_local_watch_cb()
182 || strncmp(ivars->xd_node, path, ivars->xd_node_len)) in xenbusb_local_watch_cb()
185 XENBUSB_LOCALEND_CHANGED(bus, child, &path[ivars->xd_node_len]); in xenbusb_local_watch_cb()
206 struct xenbus_device_ivars *ivars; in xenbusb_device_exists() local
214 ivars = device_get_ivars(kids[i]); in xenbusb_device_exists()
215 if (!strcmp(ivars->xd_node, node)) { in xenbusb_device_exists()
228 struct xenbus_device_ivars *ivars; in xenbusb_delete_child() local
230 ivars = device_get_ivars(child); in xenbusb_delete_child()
238 if (ivars->xd_otherend_watch.node != NULL) in xenbusb_delete_child()
239 xs_unregister_watch(&ivars->xd_otherend_watch); in xenbusb_delete_child()
240 if (ivars->xd_local_watch.node != NULL) in xenbusb_delete_child()
241 xs_unregister_watch(&ivars->xd_local_watch); in xenbusb_delete_child()
244 xenbusb_free_child_ivars(ivars); in xenbusb_delete_child()
440 struct xenbus_device_ivars *ivars; in xenbusb_probe_children() local
509 ivars = device_get_ivars(kids[i]); in xenbusb_probe_children()
510 xs_register_watch(&ivars->xd_otherend_watch); in xenbusb_probe_children()
511 xs_register_watch(&ivars->xd_local_watch); in xenbusb_probe_children()
639 struct xenbus_device_ivars *ivars; in xenbusb_add_device() local
648 ivars = malloc(sizeof(*ivars), M_XENBUS, M_ZERO|M_WAITOK); in xenbusb_add_device()
678 sx_init(&ivars->xd_lock, "xdlock"); in xenbusb_add_device()
679 ivars->xd_flags = XDF_CONNECTING; in xenbusb_add_device()
680 ivars->xd_node = strdup(devpath, M_XENBUS); in xenbusb_add_device()
681 ivars->xd_node_len = strlen(devpath); in xenbusb_add_device()
682 ivars->xd_type = strdup(type, M_XENBUS); in xenbusb_add_device()
683 ivars->xd_state = XenbusStateInitialising; in xenbusb_add_device()
685 error = XENBUSB_GET_OTHEREND_NODE(dev, ivars); in xenbusb_add_device()
692 statepath = malloc(ivars->xd_otherend_path_len in xenbusb_add_device()
694 sprintf(statepath, "%s/state", ivars->xd_otherend_path); in xenbusb_add_device()
695 ivars->xd_otherend_watch.node = statepath; in xenbusb_add_device()
696 ivars->xd_otherend_watch.callback = xenbusb_otherend_watch_cb; in xenbusb_add_device()
697 ivars->xd_otherend_watch.callback_data = (uintptr_t)ivars; in xenbusb_add_device()
703 ivars->xd_otherend_watch.max_pending = 1; in xenbusb_add_device()
705 ivars->xd_local_watch.node = ivars->xd_node; in xenbusb_add_device()
706 ivars->xd_local_watch.callback = xenbusb_local_watch_cb; in xenbusb_add_device()
707 ivars->xd_local_watch.callback_data = (uintptr_t)ivars; in xenbusb_add_device()
712 ivars->xd_local_watch.max_pending = 0; in xenbusb_add_device()
719 ivars->xd_dev = child; in xenbusb_add_device()
720 device_set_ivars(child, ivars); in xenbusb_add_device()
726 xenbusb_free_child_ivars(ivars); in xenbusb_add_device()
791 struct xenbus_device_ivars *ivars; in xenbusb_resume() local
809 ivars = device_get_ivars(kids[i]); in xenbusb_resume()
811 xs_unregister_watch(&ivars->xd_otherend_watch); in xenbusb_resume()
818 error = XENBUSB_GET_OTHEREND_NODE(dev, ivars); in xenbusb_resume()
822 statepath = malloc(ivars->xd_otherend_path_len in xenbusb_resume()
824 sprintf(statepath, "%s/state", ivars->xd_otherend_path); in xenbusb_resume()
826 free(ivars->xd_otherend_watch.node, M_XENBUS); in xenbusb_resume()
827 ivars->xd_otherend_watch.node = statepath; in xenbusb_resume()
831 xs_register_watch(&ivars->xd_otherend_watch); in xenbusb_resume()
839 sx_xlock(&ivars->xd_lock); in xenbusb_resume()
840 while (ivars->xd_state != XenbusStateClosed in xenbusb_resume()
841 && ivars->xd_state != XenbusStateConnected) in xenbusb_resume()
842 sx_sleep(&ivars->xd_state, &ivars->xd_lock, in xenbusb_resume()
844 sx_xunlock(&ivars->xd_lock); in xenbusb_resume()
856 struct xenbus_device_ivars *ivars = device_get_ivars(child); in xenbusb_print_child() local
860 retval += printf(" at %s", ivars->xd_node); in xenbusb_print_child()
869 struct xenbus_device_ivars *ivars = device_get_ivars(child); in xenbusb_read_ivar() local
873 *result = (uintptr_t) ivars->xd_node; in xenbusb_read_ivar()
877 *result = (uintptr_t) ivars->xd_type; in xenbusb_read_ivar()
881 *result = (uintptr_t) ivars->xd_state; in xenbusb_read_ivar()
885 *result = (uintptr_t) ivars->xd_otherend_id; in xenbusb_read_ivar()
889 *result = (uintptr_t) ivars->xd_otherend_path; in xenbusb_read_ivar()
899 struct xenbus_device_ivars *ivars = device_get_ivars(child); in xenbusb_write_ivar() local
910 sx_xlock(&ivars->xd_lock); in xenbusb_write_ivar()
911 if (ivars->xd_state == newstate) { in xenbusb_write_ivar()
922 error = xs_scanf(xst, ivars->xd_node, "state", in xenbusb_write_ivar()
929 error = xs_printf(xst, ivars->xd_node, "state", in xenbusb_write_ivar()
944 ivars->xd_state = newstate; in xenbusb_write_ivar()
946 if ((ivars->xd_flags & XDF_CONNECTING) != 0 && in xenbusb_write_ivar()
951 ivars->xd_flags &= ~XDF_CONNECTING; in xenbusb_write_ivar()
956 wakeup(&ivars->xd_state); in xenbusb_write_ivar()
960 sx_xunlock(&ivars->xd_lock); in xenbusb_write_ivar()
996 struct xenbus_device_ivars *ivars; in xenbusb_localend_changed() local
998 ivars = device_get_ivars(child); in xenbusb_localend_changed()
999 sx_xlock(&ivars->xd_lock); in xenbusb_localend_changed()
1000 ivars->xd_state = xenbus_read_driver_state(ivars->xd_node); in xenbusb_localend_changed()
1001 sx_xunlock(&ivars->xd_lock); in xenbusb_localend_changed()