Lines Matching +full:bus +full:- +full:err
5 * Copyright (C) 2005 Mike Wray, Hewlett-Packard
41 #include <linux/err.h>
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()
140 struct xen_bus_type *bus = in watch_otherend() local
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() local
154 id_node, "%i", &xendev->otherend_id, in xenbus_read_otherend_details()
155 path_node, NULL, &xendev->otherend, in xenbus_read_otherend_details()
157 if (err) { in xenbus_read_otherend_details()
158 xenbus_dev_fatal(xendev, err, in xenbus_read_otherend_details()
160 xendev->nodename); in xenbus_read_otherend_details()
161 return err; 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()
277 int err; in xenbus_dev_probe() local
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()
292 err = talk_to_otherend(dev); in xenbus_dev_probe()
293 if (err) { 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()
296 return err; 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()
309 if (err) in xenbus_dev_probe()
312 err = watch_otherend(dev); in xenbus_dev_probe()
313 if (err) { 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()
316 return err; 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 module_put(drv->driver.owner); in xenbus_dev_probe()
328 xenbus_dev_error(dev, err, "xenbus_dev_probe on %s", dev->nodename); in xenbus_dev_probe()
329 return err; in xenbus_dev_probe()
336 struct xenbus_driver *drv = to_xenbus_driver(_dev->driver); in xenbus_dev_remove()
338 DPRINTK("%s", dev->nodename); in xenbus_dev_remove()
340 sysfs_remove_group(&dev->dev.kobj, &xenbus_group); in xenbus_dev_remove()
344 if (drv->remove) { in xenbus_dev_remove()
345 down(&dev->reclaim_sem); in xenbus_dev_remove()
346 drv->remove(dev); in xenbus_dev_remove()
347 up(&dev->reclaim_sem); in xenbus_dev_remove()
350 module_put(drv->driver.owner); in xenbus_dev_remove()
357 * Similarly, if the driver does not support re-bind, set the in xenbus_dev_remove()
360 if (!drv->allow_rebind || in xenbus_dev_remove()
361 xenbus_read_driver_state(dev->nodename) == XenbusStateClosing) in xenbus_dev_remove()
367 struct xen_bus_type *bus, in xenbus_register_driver_common() argument
370 drv->driver.name = drv->name ? drv->name : drv->ids[0].devicetype; in xenbus_register_driver_common()
371 drv->driver.bus = &bus->bus; in xenbus_register_driver_common()
372 drv->driver.owner = owner; in xenbus_register_driver_common()
373 drv->driver.mod_name = mod_name; in xenbus_register_driver_common()
375 return driver_register(&drv->driver); in xenbus_register_driver_common()
381 driver_unregister(&drv->driver); in xenbus_unregister_driver()
395 if (!strcmp(xendev->nodename, info->nodename)) { in cmp_dev()
396 info->dev = xendev; in cmp_dev()
404 struct bus_type *bus) in xenbus_device_find() argument
408 bus_for_each_dev(bus, NULL, &info, cmp_dev); in xenbus_device_find()
416 int len = strlen(info->nodename); in cleanup_dev()
418 DPRINTK("%s", info->nodename); in cleanup_dev()
420 /* Match the info->nodename path, or any subdirectory of that path. */ in cleanup_dev()
421 if (strncmp(xendev->nodename, info->nodename, len)) in cleanup_dev()
425 if ((strlen(xendev->nodename) > len) && (xendev->nodename[len] != '/')) in cleanup_dev()
428 info->dev = xendev; in cleanup_dev()
433 static void xenbus_cleanup_devices(const char *path, struct bus_type *bus) in xenbus_cleanup_devices() argument
439 bus_for_each_dev(bus, NULL, &info, cleanup_dev); in xenbus_cleanup_devices()
441 device_unregister(&info.dev->dev); in xenbus_cleanup_devices()
442 put_device(&info.dev->dev); in xenbus_cleanup_devices()
456 return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename); in nodename_show()
463 return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype); in devtype_show()
470 return sprintf(buf, "%s:%s\n", dev->bus->name, in modalias_show()
471 to_xenbus_device(dev)->devicetype); in modalias_show()
479 xenbus_strstate(to_xenbus_device(dev)->state)); in state_show()
501 int xenbus_probe_node(struct xen_bus_type *bus, in xenbus_probe_node() argument
506 int err; in xenbus_probe_node() local
522 return -ENOMEM; in xenbus_probe_node()
524 xendev->state = XenbusStateInitialising; in xenbus_probe_node()
530 xendev->nodename = tmpstring; in xenbus_probe_node()
534 xendev->devicetype = tmpstring; in xenbus_probe_node()
535 init_completion(&xendev->down); in xenbus_probe_node()
537 xendev->dev.bus = &bus->bus; in xenbus_probe_node()
538 xendev->dev.release = xenbus_dev_release; in xenbus_probe_node()
540 err = bus->get_bus_id(devname, xendev->nodename); in xenbus_probe_node()
541 if (err) in xenbus_probe_node()
544 dev_set_name(&xendev->dev, "%s", devname); in xenbus_probe_node()
545 sema_init(&xendev->reclaim_sem, 1); in xenbus_probe_node()
548 err = device_register(&xendev->dev); in xenbus_probe_node()
549 if (err) { in xenbus_probe_node()
550 put_device(&xendev->dev); in xenbus_probe_node()
558 return err; in xenbus_probe_node()
562 static int xenbus_probe_device_type(struct xen_bus_type *bus, const char *type) in xenbus_probe_device_type() argument
564 int err = 0; in xenbus_probe_device_type() local
569 dir = xenbus_directory(XBT_NIL, bus->root, type, &dir_n); in xenbus_probe_device_type()
574 err = bus->probe(bus, type, dir[i]); in xenbus_probe_device_type()
575 if (err) in xenbus_probe_device_type()
580 return err; in xenbus_probe_device_type()
583 int xenbus_probe_devices(struct xen_bus_type *bus) in xenbus_probe_devices() argument
585 int err = 0; in xenbus_probe_devices() local
589 dir = xenbus_directory(XBT_NIL, bus->root, "", &dir_n); in xenbus_probe_devices()
594 err = xenbus_probe_device_type(bus, dir[i]); in xenbus_probe_devices()
595 if (err) in xenbus_probe_devices()
600 return err; in xenbus_probe_devices()
622 len--; in strsep_len()
624 return (len == 0) ? i : -ERANGE; in strsep_len()
627 void xenbus_dev_changed(const char *node, struct xen_bus_type *bus) in xenbus_dev_changed() argument
639 xenbus_cleanup_devices(node, &bus->bus); in xenbus_dev_changed()
646 type[XEN_BUS_ID_SIZE-1] = '\0'; in xenbus_dev_changed()
648 rootlen = strsep_len(node, '/', bus->levels); in xenbus_dev_changed()
655 dev = xenbus_device_find(root, &bus->bus); in xenbus_dev_changed()
657 xenbus_probe_node(bus, type, root); in xenbus_dev_changed()
659 put_device(&dev->dev); in xenbus_dev_changed()
667 int err = 0; in xenbus_dev_suspend() local
672 DPRINTK("%s", xdev->nodename); in xenbus_dev_suspend()
674 if (dev->driver == NULL) in xenbus_dev_suspend()
676 drv = to_xenbus_driver(dev->driver); in xenbus_dev_suspend()
677 if (drv->suspend) in xenbus_dev_suspend()
678 err = drv->suspend(xdev); in xenbus_dev_suspend()
679 if (err) in xenbus_dev_suspend()
680 dev_warn(dev, "suspend failed: %i\n", err); in xenbus_dev_suspend()
687 int err; in xenbus_dev_resume() local
692 DPRINTK("%s", xdev->nodename); in xenbus_dev_resume()
694 if (dev->driver == NULL) in xenbus_dev_resume()
696 drv = to_xenbus_driver(dev->driver); in xenbus_dev_resume()
697 err = talk_to_otherend(xdev); in xenbus_dev_resume()
698 if (err) { in xenbus_dev_resume()
699 dev_warn(dev, "resume (talk_to_otherend) failed: %i\n", err); in xenbus_dev_resume()
700 return err; in xenbus_dev_resume()
703 xdev->state = XenbusStateInitialising; in xenbus_dev_resume()
705 if (drv->resume) { in xenbus_dev_resume()
706 err = drv->resume(xdev); in xenbus_dev_resume()
707 if (err) { in xenbus_dev_resume()
708 dev_warn(dev, "resume failed: %i\n", err); in xenbus_dev_resume()
709 return err; in xenbus_dev_resume()
713 err = watch_otherend(xdev); in xenbus_dev_resume()
714 if (err) { in xenbus_dev_resume()
715 dev_warn(dev, "resume (watch_otherend) failed: %d\n", err); in xenbus_dev_resume()
716 return err; in xenbus_dev_resume()
740 ret = nb->notifier_call(nb, 0, NULL); in register_xenstore_notifier()
819 return -ENODEV; in xenbus_probe_initcall()
834 * thread which will wait for xenstored or a xenstore-stubdom to be in xenbus_probe_initcall()
879 int err = -ENOMEM; in xenstored_local_init() local
894 err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, in xenstored_local_init()
896 if (err == -ENOSYS) in xenstored_local_init()
899 BUG_ON(err); in xenstored_local_init()
907 return err; in xenstored_local_init()
913 int err = 0; in xenbus_resume_cb() local
918 err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); in xenbus_resume_cb()
919 if (!err && v) in xenbus_resume_cb()
923 err); in xenbus_resume_cb()
925 xen_store_evtchn = xen_start_info->store_evtchn; in xenbus_resume_cb()
927 return err; in xenbus_resume_cb()
936 int err; in xenbus_late_init() local
939 err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v); in xenbus_late_init()
940 if (err || !v || !~v) in xenbus_late_init()
950 int err; in xenbus_init() local
956 return -ENODEV; in xenbus_init()
966 if (xen_pv_domain() && !xen_start_info->store_evtchn) in xenbus_init()
968 if (xen_pv_domain() && xen_start_info->store_evtchn) in xenbus_init()
973 err = xenstored_local_init(); in xenbus_init()
974 if (err) in xenbus_init()
979 xen_store_evtchn = xen_start_info->store_evtchn; in xenbus_init()
980 xen_store_gfn = xen_start_info->store_mfn; in xenbus_init()
984 err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); in xenbus_init()
985 if (err) in xenbus_init()
988 err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v); in xenbus_init()
989 if (err) in xenbus_init()
1002 err = -ENOENT; in xenbus_init()
1008 /* Avoid truncation on 32-bit. */ in xenbus_init()
1013 err = -EINVAL; in xenbus_init()
1024 err = -EINVAL; in xenbus_init()
1027 if (xen_store_interface->connection != XENSTORE_CONNECTED) in xenbus_init()
1031 err = bind_evtchn_to_irqhandler(xen_store_evtchn, in xenbus_init()
1035 if (err < 0) { in xenbus_init()
1036 pr_err("xenstore_late_init couldn't bind irq err=%d\n", in xenbus_init()
1037 err); in xenbus_init()
1041 xs_init_irq = err; in xenbus_init()
1055 err = xs_init(); in xenbus_init()
1056 if (err) { in xenbus_init()
1057 pr_warn("Error initializing xenstore comms: %i\n", err); in xenbus_init()
1077 return err; in xenbus_init()