Representation of Buses

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

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 (*remove)(struct device * dev);

void (*shutdown)(struct device * dev);

int (*suspend)(struct device * dev, pm_message_t state);

int (*resume)(struct device * dev);

□ name is a text name for the bus. It is especially used to identify the bus in the sysfs filesystem.

□ All devices and drivers associated with the bus are managed as sets using the drivers and devices entries. The kernel also generates two lists (klist_devices and klist_drivers) to hold the same data. The lists enable all resources (devices and drivers) to be scanned quickly, and the ksets ensure automatic integration into the sysfs filesystem. subsys provides a connection with the bus subsystem. Accordingly buses appear in /sys/bus/busname.

□ match points to a function that attempts to find a matching driver for a given device.

□ add is used to inform a bus that a new device has been added to the system.

□ probe is invoked when it is necessary to link a driver with a device. This function checks whether the device is actually present in the system.

□ remove removes the link between a driver and a device. This happens, for example, when a hot-pluggable device is removed from the system.

□ shutdown, suspend, and resume are power management functions.

Continue reading here: Registering Buses

Was this article helpful?

0 0