Device Extensions
Introduction
~~~~~~~~~~~~
Device extensions are internal extensions to a device, bus, or class
driver. Extensions may or may not have an external interface
associated with them and typically apply to every of a particular driver.
An example of an extension is the procfs or driverfs interface for PCI
devices. Each PCI device gets a procfs file and two driverfs files.
These extensions may or may not be present based on configuration
options; or they may be included in a module. Instead of hard coding
calls to add the devices to these interfaces, the extensions can be
registered with the driver and each device added implicitly.
Programming Interface
~~~~~~~~~~~~~~~~~~~~~
struct device_extension {
char* name;
rwlock_tlock;
struct list_headnode;
dev_add_tadd_device;
dev_remove_tremove_device;
};
extern int dev_ext_register(struct device_extension *);
extern void dev_ext_unregister(struct device_extension *);
extern int bus_ext_register(struct bus_type *, struct device_extension *);
extern void bus_ext_unregister(struct bus_type *, struct device_extension *);
extern int class_ext_register(struct device_class *, struct device_extension *);
extern void class_ext_unregister(struct device_class *, struct device_extension *);
Extensions are specific to a particular driver, but the structure is
common for each type of extension. So, a pointer to the entity that
the extension belongs to must be passed to the registration function.
Devices
~~~~~~~
As devices are added to the various drivers, it is added to each
extension of that driver. Extensions don't have to be applied to each
device, but it is up to the extension to determine that.