/** * __mcb_register_driver() - Register a @mcb_driver at the system * @drv: The @mcb_driver * @owner: The @mcb_driver's module * @mod_name: The name of the @mcb_driver's module * * Register a @mcb_driver at the system. Perform some sanity checks, if * the .probe and .remove methods are provided by the driver.
*/ int __mcb_register_driver(struct mcb_driver *drv, struct module *owner, constchar *mod_name)
{ if (!drv->probe || !drv->remove) return -EINVAL;
/** * mcb_unregister_driver() - Unregister a @mcb_driver from the system * @drv: The @mcb_driver * * Unregister a @mcb_driver from the system.
*/ void mcb_unregister_driver(struct mcb_driver *drv)
{
driver_unregister(&drv->driver);
}
EXPORT_SYMBOL_NS_GPL(mcb_unregister_driver, "MCB");
/** * mcb_device_register() - Register a mcb_device * @bus: The @mcb_bus of the device * @dev: The @mcb_device * * Register a specific @mcb_device at a @mcb_bus and the system itself.
*/ int mcb_device_register(struct mcb_bus *bus, struct mcb_device *dev)
{ int ret; int device_id;
/** * mcb_alloc_bus() - Allocate a new @mcb_bus * @carrier: generic &struct device for the carrier device * * Allocate a new @mcb_bus.
*/ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
{ struct mcb_bus *bus; int bus_nr; int rc;
bus = kzalloc(sizeof(struct mcb_bus), GFP_KERNEL); if (!bus) return ERR_PTR(-ENOMEM);
/** * mcb_bus_put() - Decrement refcnt * @bus: The @mcb_bus * * Release a @mcb_bus' ref
*/ void mcb_bus_put(struct mcb_bus *bus)
{ if (bus)
put_device(&bus->dev);
}
EXPORT_SYMBOL_NS_GPL(mcb_bus_put, "MCB");
/** * mcb_alloc_dev() - Allocate a device * @bus: The @mcb_bus the device is part of * * Allocate a @mcb_device and add bus.
*/ struct mcb_device *mcb_alloc_dev(struct mcb_bus *bus)
{ struct mcb_device *dev;
dev = kzalloc(sizeof(struct mcb_device), GFP_KERNEL); if (!dev) return NULL;
/** * mcb_bus_add_devices() - Add devices in the bus' internal device list * @bus: The @mcb_bus we add the devices * * Add devices in the bus' internal device list to the system.
*/ void mcb_bus_add_devices(conststruct mcb_bus *bus)
{
bus_for_each_dev(bus->dev.bus, NULL, NULL, __mcb_bus_add_devices);
}
EXPORT_SYMBOL_NS_GPL(mcb_bus_add_devices, "MCB");
/** * mcb_get_resource() - get a resource for a mcb device * @dev: the mcb device * @type: the type of resource
*/ struct resource *mcb_get_resource(struct mcb_device *dev, unsignedint type)
{ if (type == IORESOURCE_MEM) return &dev->mem; elseif (type == IORESOURCE_IRQ) return &dev->irq; else return NULL;
}
EXPORT_SYMBOL_NS_GPL(mcb_get_resource, "MCB");
/** * mcb_request_mem() - Request memory * @dev: The @mcb_device the memory is for * @name: The name for the memory reference. * * Request memory for a @mcb_device. If @name is NULL the driver name will * be used.
*/ struct resource *mcb_request_mem(struct mcb_device *dev, constchar *name)
{ struct resource *mem;
u32 size;
if (!name)
name = dev->dev.driver->name;
size = resource_size(&dev->mem);
mem = request_mem_region(dev->mem.start, size, name); if (!mem) return ERR_PTR(-EBUSY);
/** * mcb_release_mem() - Release memory requested by device * @mem: The memory resource to be released * * Release memory that was prior requested via @mcb_request_mem().
*/ void mcb_release_mem(struct resource *mem)
{
u32 size;
/** * mcb_get_irq() - Get device's IRQ number * @dev: The @mcb_device the IRQ is for * * Get the IRQ number of a given @mcb_device.
*/ int mcb_get_irq(struct mcb_device *dev)
{ struct mcb_bus *bus = dev->bus;
/* mcb must be initialized after PCI but before the chameleon drivers. * That means we must use some initcall between subsys_initcall and * device_initcall.
*/
fs_initcall(mcb_init);
module_exit(mcb_exit);
MODULE_DESCRIPTION("MEN Chameleon Bus Driver");
MODULE_AUTHOR("Johannes Thumshirn ");
MODULE_LICENSE("GPL v2");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.