drivers/nubus/bus.c

Source file repositories/reference/linux-study-clean/drivers/nubus/bus.c

File Facts

System
Linux kernel
Corpus path
drivers/nubus/bus.c
Extension
.c
Size
2421 bytes
Lines
98
Domain
Driver Families
Bucket
drivers/nubus
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 const struct bus_type nubus_bus_type = {
	.name		= "nubus",
	.probe		= nubus_device_probe,
	.remove		= nubus_device_remove,
};

int nubus_driver_register(struct nubus_driver *ndrv)
{
	ndrv->driver.bus = &nubus_bus_type;
	return driver_register(&ndrv->driver);
}
EXPORT_SYMBOL(nubus_driver_register);

void nubus_driver_unregister(struct nubus_driver *ndrv)
{
	driver_unregister(&ndrv->driver);
}
EXPORT_SYMBOL(nubus_driver_unregister);

static int __init nubus_bus_register(void)
{
	return bus_register(&nubus_bus_type);
}
postcore_initcall(nubus_bus_register);

static void nubus_device_release(struct device *dev)
{
	struct nubus_board *board = to_nubus_board(dev);
	struct nubus_rsrc *fres, *tmp;

	list_for_each_entry_safe(fres, tmp, &nubus_func_rsrcs, list)
		if (fres->board == board) {
			list_del(&fres->list);
			kfree(fres);
		}
	kfree(board);
}

int nubus_device_register(struct device *parent, struct nubus_board *board)
{
	board->dev.parent = parent;
	board->dev.release = nubus_device_release;
	board->dev.bus = &nubus_bus_type;
	dev_set_name(&board->dev, "slot.%X", board->slot);
	board->dev.dma_mask = &board->dev.coherent_dma_mask;
	dma_set_mask(&board->dev, DMA_BIT_MASK(32));
	return device_register(&board->dev);
}

static int nubus_print_device_name_fn(struct device *dev, void *data)
{
	struct nubus_board *board = to_nubus_board(dev);
	struct seq_file *m = data;

	seq_printf(m, "Slot %X: %s\n", board->slot, board->name);
	return 0;
}

int nubus_proc_show(struct seq_file *m, void *data)
{
	return bus_for_each_dev(&nubus_bus_type, NULL, m,
				nubus_print_device_name_fn);
}

Annotation

Implementation Notes