Lines Matching +full:forced +full:- +full:comms +full:- +full:default
5 * Copyright (C) 2005 Mike Wray, Hewlett-Packard
60 #include <xen/xen-ops.h>
68 static int xs_init_irq = -1;
77 (xen_store_interface->connection == XENSTORE_CONNECTED))
90 for (; *arr->devicetype != '\0'; arr++) { in match_device()
91 if (!strcmp(arr->devicetype, dev->devicetype)) in match_device()
101 if (!drv->ids) in xenbus_match()
104 return match_device(drv->ids, to_xenbus_device(_dev)) != NULL; in xenbus_match()
111 kfree(dev->otherend); in free_otherend_details()
112 dev->otherend = NULL; in free_otherend_details()
118 if (dev->otherend_watch.node) { in free_otherend_watch()
119 unregister_xenbus_watch(&dev->otherend_watch); in free_otherend_watch()
120 kfree(dev->otherend_watch.node); in free_otherend_watch()
121 dev->otherend_watch.node = NULL; in free_otherend_watch()
128 struct xenbus_driver *drv = to_xenbus_driver(dev->dev.driver); in talk_to_otherend()
133 return drv->read_otherend_details(dev); in talk_to_otherend()
141 container_of(dev->dev.bus, struct xen_bus_type, bus); in watch_otherend()
143 return xenbus_watch_pathfmt(dev, &dev->otherend_watch, in watch_otherend()
144 bus->otherend_will_handle, in watch_otherend()
145 bus->otherend_changed, in watch_otherend()
146 "%s/%s", dev->otherend, "state"); in watch_otherend()
153 int err = xenbus_gather(XBT_NIL, xendev->nodename, in xenbus_read_otherend_details()
154 id_node, "%i", &xendev->otherend_id, in xenbus_read_otherend_details()
155 path_node, NULL, &xendev->otherend, in xenbus_read_otherend_details()
160 xendev->nodename); in xenbus_read_otherend_details()
163 if (strlen(xendev->otherend) == 0 || in xenbus_read_otherend_details()
164 !xenbus_exists(XBT_NIL, xendev->otherend, "")) { in xenbus_read_otherend_details()
165 xenbus_dev_fatal(xendev, -ENOENT, in xenbus_read_otherend_details()
168 xendev->nodename); in xenbus_read_otherend_details()
170 return -ENOENT; in xenbus_read_otherend_details()
183 struct xenbus_driver *drv = to_xenbus_driver(dev->dev.driver); in xenbus_otherend_changed()
188 if (!dev->otherend || in xenbus_otherend_changed()
189 strncmp(dev->otherend, path, strlen(dev->otherend))) { in xenbus_otherend_changed()
190 dev_dbg(&dev->dev, "Ignoring watch at %s\n", path); in xenbus_otherend_changed()
194 state = xenbus_read_driver_state(dev->otherend); in xenbus_otherend_changed()
196 dev_dbg(&dev->dev, "state is %d, (%s), %s, %s\n", in xenbus_otherend_changed()
197 state, xenbus_strstate(state), dev->otherend_watch.node, path); in xenbus_otherend_changed()
209 if (drv->otherend_changed) in xenbus_otherend_changed()
210 drv->otherend_changed(dev, state); in xenbus_otherend_changed()
221 return sprintf(buf, "%d\n", atomic_read(&dev->name)); \
236 return sprintf(buf, "%d\n", dev->spurious_threshold); in spurious_threshold_show()
251 dev->spurious_threshold = val; in spurious_threshold_store()
275 struct xenbus_driver *drv = to_xenbus_driver(_dev->driver); in xenbus_dev_probe()
279 DPRINTK("%s", dev->nodename); in xenbus_dev_probe()
281 if (!drv->probe) { in xenbus_dev_probe()
282 err = -ENODEV; in xenbus_dev_probe()
286 id = match_device(drv->ids, dev); in xenbus_dev_probe()
288 err = -ENODEV; in xenbus_dev_probe()
294 dev_warn(&dev->dev, "talk_to_otherend on %s failed.\n", in xenbus_dev_probe()
295 dev->nodename); in xenbus_dev_probe()
299 if (!try_module_get(drv->driver.owner)) { in xenbus_dev_probe()
300 dev_warn(&dev->dev, "failed to acquire module reference on '%s'\n", in xenbus_dev_probe()
301 drv->driver.name); in xenbus_dev_probe()
302 err = -ESRCH; in xenbus_dev_probe()
306 down(&dev->reclaim_sem); in xenbus_dev_probe()
307 err = drv->probe(dev, id); in xenbus_dev_probe()
308 up(&dev->reclaim_sem); in xenbus_dev_probe()
314 dev_warn(&dev->dev, "watch_otherend on %s failed.\n", in xenbus_dev_probe()
315 dev->nodename); in xenbus_dev_probe()
319 dev->spurious_threshold = 1; in xenbus_dev_probe()
320 if (sysfs_create_group(&dev->dev.kobj, &xenbus_group)) in xenbus_dev_probe()
321 dev_warn(&dev->dev, "sysfs_create_group on %s failed.\n", in xenbus_dev_probe()
322 dev->nodename); in xenbus_dev_probe()
326 if (drv->remove) { in xenbus_dev_probe()
327 down(&dev->reclaim_sem); in xenbus_dev_probe()
328 drv->remove(dev); in xenbus_dev_probe()
329 up(&dev->reclaim_sem); in xenbus_dev_probe()
332 module_put(drv->driver.owner); in xenbus_dev_probe()
334 xenbus_dev_error(dev, err, "xenbus_dev_probe on %s", dev->nodename); in xenbus_dev_probe()
342 struct xenbus_driver *drv = to_xenbus_driver(_dev->driver); in xenbus_dev_remove()
344 DPRINTK("%s", dev->nodename); in xenbus_dev_remove()
346 sysfs_remove_group(&dev->dev.kobj, &xenbus_group); in xenbus_dev_remove()
350 if (drv->remove) { in xenbus_dev_remove()
351 down(&dev->reclaim_sem); in xenbus_dev_remove()
352 drv->remove(dev); in xenbus_dev_remove()
353 up(&dev->reclaim_sem); in xenbus_dev_remove()
356 module_put(drv->driver.owner); in xenbus_dev_remove()
361 * If the toolstack has forced the device state to closing then set in xenbus_dev_remove()
363 * Similarly, if the driver does not support re-bind, set the in xenbus_dev_remove()
366 if (!drv->allow_rebind || in xenbus_dev_remove()
367 xenbus_read_driver_state(dev->nodename) == XenbusStateClosing) in xenbus_dev_remove()
376 drv->driver.name = drv->name ? drv->name : drv->ids[0].devicetype; in xenbus_register_driver_common()
377 drv->driver.bus = &bus->bus; in xenbus_register_driver_common()
378 drv->driver.owner = owner; in xenbus_register_driver_common()
379 drv->driver.mod_name = mod_name; in xenbus_register_driver_common()
381 return driver_register(&drv->driver); in xenbus_register_driver_common()
387 driver_unregister(&drv->driver); in xenbus_unregister_driver()
401 if (!strcmp(xendev->nodename, info->nodename)) { in cmp_dev()
402 info->dev = xendev; in cmp_dev()
422 int len = strlen(info->nodename); in cleanup_dev()
424 DPRINTK("%s", info->nodename); in cleanup_dev()
426 /* Match the info->nodename path, or any subdirectory of that path. */ in cleanup_dev()
427 if (strncmp(xendev->nodename, info->nodename, len)) in cleanup_dev()
431 if ((strlen(xendev->nodename) > len) && (xendev->nodename[len] != '/')) in cleanup_dev()
434 info->dev = xendev; in cleanup_dev()
447 device_unregister(&info.dev->dev); in xenbus_cleanup_devices()
448 put_device(&info.dev->dev); in xenbus_cleanup_devices()
462 return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename); in nodename_show()
469 return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype); in devtype_show()
476 return sprintf(buf, "%s:%s\n", dev->bus->name, in modalias_show()
477 to_xenbus_device(dev)->devicetype); in modalias_show()
485 xenbus_strstate(to_xenbus_device(dev)->state)); in state_show()
528 return -ENOMEM; in xenbus_probe_node()
530 xendev->state = XenbusStateInitialising; in xenbus_probe_node()
536 xendev->nodename = tmpstring; in xenbus_probe_node()
540 xendev->devicetype = tmpstring; in xenbus_probe_node()
541 init_completion(&xendev->down); in xenbus_probe_node()
543 xendev->dev.bus = &bus->bus; in xenbus_probe_node()
544 xendev->dev.release = xenbus_dev_release; in xenbus_probe_node()
546 err = bus->get_bus_id(devname, xendev->nodename); in xenbus_probe_node()
550 dev_set_name(&xendev->dev, "%s", devname); in xenbus_probe_node()
551 sema_init(&xendev->reclaim_sem, 1); in xenbus_probe_node()
554 err = device_register(&xendev->dev); in xenbus_probe_node()
556 put_device(&xendev->dev); in xenbus_probe_node()
575 dir = xenbus_directory(XBT_NIL, bus->root, type, &dir_n); in xenbus_probe_device_type()
580 err = bus->probe(bus, type, dir[i]); in xenbus_probe_device_type()
595 dir = xenbus_directory(XBT_NIL, bus->root, "", &dir_n); in xenbus_probe_devices()
628 len--; in strsep_len()
630 return (len == 0) ? i : -ERANGE; in strsep_len()
645 xenbus_cleanup_devices(node, &bus->bus); in xenbus_dev_changed()
652 type[XEN_BUS_ID_SIZE-1] = '\0'; in xenbus_dev_changed()
654 rootlen = strsep_len(node, '/', bus->levels); in xenbus_dev_changed()
661 dev = xenbus_device_find(root, &bus->bus); in xenbus_dev_changed()
665 put_device(&dev->dev); in xenbus_dev_changed()
678 DPRINTK("%s", xdev->nodename); in xenbus_dev_suspend()
680 if (dev->driver == NULL) in xenbus_dev_suspend()
682 drv = to_xenbus_driver(dev->driver); in xenbus_dev_suspend()
683 if (drv->suspend) in xenbus_dev_suspend()
684 err = drv->suspend(xdev); in xenbus_dev_suspend()
698 DPRINTK("%s", xdev->nodename); in xenbus_dev_resume()
700 if (dev->driver == NULL) in xenbus_dev_resume()
702 drv = to_xenbus_driver(dev->driver); in xenbus_dev_resume()
709 xdev->state = XenbusStateInitialising; in xenbus_dev_resume()
711 if (drv->resume) { in xenbus_dev_resume()
712 err = drv->resume(xdev); in xenbus_dev_resume()
746 ret = nb->notifier_call(nb, 0, NULL); in register_xenstore_notifier()
825 return -ENODEV; in xenbus_probe_initcall()
840 * thread which will wait for xenstored or a xenstore-stubdom to be in xenbus_probe_initcall()
885 int err = -ENOMEM; in xenstored_local_init()
902 if (err == -ENOSYS) in xenstored_local_init()
931 xen_store_evtchn = xen_start_info->store_evtchn; in xenbus_resume_cb()
962 return -ENODEV; in xenbus_init()
972 if (xen_pv_domain() && !xen_start_info->store_evtchn) in xenbus_init()
974 if (xen_pv_domain() && xen_start_info->store_evtchn) in xenbus_init()
985 xen_store_evtchn = xen_start_info->store_evtchn; in xenbus_init()
986 xen_store_gfn = xen_start_info->store_mfn; in xenbus_init()
1008 err = -ENOENT; in xenbus_init()
1014 /* Avoid truncation on 32-bit. */ in xenbus_init()
1019 err = -EINVAL; in xenbus_init()
1030 err = -EINVAL; in xenbus_init()
1033 if (xen_store_interface->connection != XENSTORE_CONNECTED) in xenbus_init()
1050 default: in xenbus_init()
1063 pr_warn("Error initializing xenstore comms: %i\n", err); in xenbus_init()