Lines Matching defs:context

136 static void watch_existing_subdirs(struct usb_host_context *context,
142 wds[0] = inotify_add_watch(context->fd, USB_FS_DIR, IN_CREATE | IN_DELETE);
149 ret = inotify_add_watch(context->fd, path, IN_CREATE | IN_DELETE);
157 struct usb_host_context *context = calloc(1, sizeof(struct usb_host_context));
158 if (!context) {
162 context->fd = inotify_init();
163 if (context->fd < 0) {
165 free(context);
168 return context;
171 void usb_host_cleanup(struct usb_host_context *context)
173 close(context->fd);
174 free(context);
177 int usb_host_get_fd(struct usb_host_context *context)
179 return context->fd;
182 int usb_host_load(struct usb_host_context *context,
191 context->cb_added = added_cb;
192 context->cb_removed = removed_cb;
193 context->data = client_data;
199 context->wds[i] = -1;
202 context->wdd = inotify_add_watch(context->fd, DEV_DIR, IN_CREATE | IN_DELETE);
203 if (context->wdd < 0) {
210 watch_existing_subdirs(context, context->wds, MAX_USBFS_WD_COUNT);
220 int usb_host_read_event(struct usb_host_context *context)
229 ret = read(context->fd, event_buf, sizeof(event_buf));
235 if (wd == context->wdd) {
237 watch_existing_subdirs(context, context->wds, MAX_USBFS_WD_COUNT);
238 done = find_existing_devices(context->cb_added, context->data);
241 if (context->wds[i] >= 0) {
242 inotify_rm_watch(context->fd, context->wds[i]);
243 context->wds[i] = -1;
247 } else if (wd == context->wds[0]) {
254 ret = inotify_add_watch(context->fd, path,
257 context->wds[i] = ret;
258 done = find_existing_devices_bus(path, context->cb_added,
259 context->data);
261 inotify_rm_watch(context->fd, context->wds[i]);
262 context->wds[i] = -1;
267 if (wd == context->wds[i]) {
271 done = context->cb_added(path, context->data);
274 done = context->cb_removed(path, context->data);
287 void usb_host_run(struct usb_host_context *context,
295 done = usb_host_load(context, added_cb, removed_cb, discovery_done_cb, client_data);
299 done = usb_host_read_event(context);