Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 6: Device Drivers


The meanings of the elements are as follows:

❑ namepoints to a text string to uniquely identify the driver.
❑ buspoints to an object that represents the bus and provides bus-specific operations (see closer
look at this below).
❑ klist_devicesis the head of a standard list that includes thedeviceinstances of all
devices controlled by the driver. The individual devices are interlinked by means of
devices->knode_devices.
❑ knode_busis used to link all devices on a common bus.
❑ probeis a function to check whether a device that can be handled by the device driver is present
in the system.
❑ removeis invoked to remove a device from the system.
❑ shutdown,suspend,andresumeare used for power management.

Drivers are registered with the system using thedriver_registerstandard function of the kernel dis-
cussed below.

Representationof Buses


The generic driver model represents not only devices but also buses using a further data structure that is
defined as follows:

<device.h>
struct bus_type {
const char * name;
...
struct kset subsys;
struct kset drivers;
struct kset devices;
struct klist klist_devices;
struct klist klist_drivers;
...
int (*match)(struct device * dev, struct device_driver * drv);
int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
int (*probe)(struct device * dev);
int (*remove)(struct device * dev);
void (*shutdown)(struct device * dev);
int (*suspend)(struct device * dev, pm_message_t state);
...
int (*resume)(struct device * dev);
...
};

❑ nameis a text name for the bus. It is especially usedto identify the bus in the sysfs filesystem.
❑ All devices and drivers associated with the bus are managed as sets using thedriversand
devicesentries. The kernel also generates two lists (klist_devicesandklist_drivers)tohold
Free download pdf