drivers/rapidio/rio-driver.c

Source file repositories/reference/linux-study-clean/drivers/rapidio/rio-driver.c

File Facts

System
Linux kernel
Corpus path
drivers/rapidio/rio-driver.c
Extension
.c
Size
6828 bytes
Lines
267
Domain
Driver Families
Bucket
drivers/rapidio
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.

Dependency Surface

Detected Declarations

Annotated Snippet

static int rio_match_bus(struct device *dev, const struct device_driver *drv)
{
	struct rio_dev *rdev = to_rio_dev(dev);
	const struct rio_driver *rdrv = to_rio_driver(drv);
	const struct rio_device_id *id = rdrv->id_table;
	const struct rio_device_id *found_id;

	if (!id)
		goto out;

	found_id = rio_match_device(id, rdev);

	if (found_id)
		return 1;

      out:return 0;
}

static int rio_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
	const struct rio_dev *rdev;

	if (!dev)
		return -ENODEV;

	rdev = to_rio_dev(dev);
	if (!rdev)
		return -ENODEV;

	if (add_uevent_var(env, "MODALIAS=rapidio:v%04Xd%04Xav%04Xad%04X",
			   rdev->vid, rdev->did, rdev->asm_vid, rdev->asm_did))
		return -ENOMEM;
	return 0;
}

struct class rio_mport_class = {
	.name		= "rapidio_port",
	.dev_groups	= rio_mport_groups,
};
EXPORT_SYMBOL_GPL(rio_mport_class);

const struct bus_type rio_bus_type = {
	.name = "rapidio",
	.match = rio_match_bus,
	.dev_groups = rio_dev_groups,
	.bus_groups = rio_bus_groups,
	.probe = rio_device_probe,
	.remove = rio_device_remove,
	.shutdown = rio_device_shutdown,
	.uevent	= rio_uevent,
};

/**
 *  rio_bus_init - Register the RapidIO bus with the device model
 *
 *  Registers the RIO mport device class and RIO bus type with the Linux
 *  device model.
 */
static int __init rio_bus_init(void)
{
	int ret;

	ret = class_register(&rio_mport_class);
	if (!ret) {
		ret = bus_register(&rio_bus_type);
		if (ret)
			class_unregister(&rio_mport_class);
	}
	return ret;
}

postcore_initcall(rio_bus_init);

EXPORT_SYMBOL_GPL(rio_register_driver);
EXPORT_SYMBOL_GPL(rio_unregister_driver);
EXPORT_SYMBOL_GPL(rio_bus_type);
EXPORT_SYMBOL_GPL(rio_dev_get);
EXPORT_SYMBOL_GPL(rio_dev_put);

Annotation

Implementation Notes