drivers/xen/xenbus/xenbus_probe.c
Source file repositories/reference/linux-study-clean/drivers/xen/xenbus/xenbus_probe.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/xen/xenbus/xenbus_probe.c- Extension
.c- Size
- 27732 bytes
- Lines
- 1128
- Domain
- Driver Families
- Bucket
- drivers/xen
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/err.hlinux/string.hlinux/ctype.hlinux/fcntl.hlinux/mm.hlinux/proc_fs.hlinux/notifier.hlinux/kthread.hlinux/mutex.hlinux/io.hlinux/slab.hlinux/module.hasm/page.hasm/xen/hypervisor.hxen/xen.hxen/xenbus.hxen/events.hxen/xen-ops.hxen/page.hxen/hvm.hxenbus.h
Detected Declarations
struct xb_find_infofunction match_devicefunction xenbus_matchfunction free_otherend_detailsfunction free_otherend_watchfunction talk_to_otherendfunction watch_otherendfunction xenbus_read_otherend_detailsfunction xenbus_otherend_changedfunction strncmpfunction spurious_threshold_showfunction spurious_threshold_storefunction xenbus_dev_probefunction xenbus_dev_removefunction xenbus_register_driver_commonfunction xenbus_unregister_driverfunction cmp_devfunction cleanup_devfunction xenbus_cleanup_devicesfunction xenbus_dev_releasefunction nodename_showfunction devtype_showfunction modalias_showfunction state_showfunction xenbus_probe_nodefunction xenbus_probe_device_typefunction xenbus_probe_devicesfunction char_countfunction strsep_lenfunction xenbus_dev_changedfunction xenbus_dev_freezefunction xenbus_dev_restorefunction xenbus_dev_thawfunction register_xenstore_notifierfunction unregister_xenstore_notifierfunction xenbus_probefunction xs_hvm_defer_init_for_callbackfunction xenbus_probe_threadfunction xenbus_probe_initcallfunction xen_set_callback_viafunction xenstored_local_initfunction xenbus_resume_cbfunction xenbus_late_initfunction xenbus_initfunction xs_initmodule init xenbus_probe_initcallexport xen_store_evtchnexport xen_store_interface
Annotated Snippet
int xenbus_match(struct device *_dev, const struct device_driver *_drv)
{
const struct xenbus_driver *drv = to_xenbus_driver(_drv);
if (!drv->ids)
return 0;
return match_device(drv->ids, to_xenbus_device(_dev)) != NULL;
}
EXPORT_SYMBOL_GPL(xenbus_match);
static void free_otherend_details(struct xenbus_device *dev)
{
kfree(dev->otherend);
dev->otherend = NULL;
}
static void free_otherend_watch(struct xenbus_device *dev)
{
if (dev->otherend_watch.node) {
unregister_xenbus_watch(&dev->otherend_watch);
kfree(dev->otherend_watch.node);
dev->otherend_watch.node = NULL;
}
}
static int talk_to_otherend(struct xenbus_device *dev)
{
struct xenbus_driver *drv = to_xenbus_driver(dev->dev.driver);
free_otherend_watch(dev);
free_otherend_details(dev);
return drv->read_otherend_details(dev);
}
static int watch_otherend(struct xenbus_device *dev)
{
struct xen_bus_type *bus =
container_of(dev->dev.bus, struct xen_bus_type, bus);
return xenbus_watch_pathfmt(dev, &dev->otherend_watch,
bus->otherend_will_handle,
bus->otherend_changed,
"%s/%s", dev->otherend, "state");
}
int xenbus_read_otherend_details(struct xenbus_device *xendev,
char *id_node, char *path_node)
{
int err = xenbus_gather(XBT_NIL, xendev->nodename,
id_node, "%i", &xendev->otherend_id,
path_node, NULL, &xendev->otherend,
NULL);
if (err) {
xenbus_dev_fatal(xendev, err,
"reading other end details from %s",
xendev->nodename);
return err;
}
if (strlen(xendev->otherend) == 0 ||
!xenbus_exists(XBT_NIL, xendev->otherend, "")) {
xenbus_dev_fatal(xendev, -ENOENT,
"unable to read other end from %s. "
"missing or inaccessible.",
xendev->nodename);
free_otherend_details(xendev);
return -ENOENT;
}
return 0;
}
EXPORT_SYMBOL_GPL(xenbus_read_otherend_details);
void xenbus_otherend_changed(struct xenbus_watch *watch,
const char *path, const char *token,
int ignore_on_shutdown)
{
struct xenbus_device *dev =
container_of(watch, struct xenbus_device, otherend_watch);
struct xenbus_driver *drv = to_xenbus_driver(dev->dev.driver);
enum xenbus_state state;
/* Protect us against watches firing on old details when the otherend
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/err.h`, `linux/string.h`, `linux/ctype.h`, `linux/fcntl.h`, `linux/mm.h`, `linux/proc_fs.h`, `linux/notifier.h`.
- Detected declarations: `struct xb_find_info`, `function match_device`, `function xenbus_match`, `function free_otherend_details`, `function free_otherend_watch`, `function talk_to_otherend`, `function watch_otherend`, `function xenbus_read_otherend_details`, `function xenbus_otherend_changed`, `function strncmp`.
- Atlas domain: Driver Families / drivers/xen.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.