|
|
Do not write a driver that relies on particular configuration parameters such as the interrupt vector. Avoiding such ``hardcoded'' assumptions helps prevent collisions with other drivers, and insulates the driver from system configuration changes.
The only drivers that need to know this information fall into one of two categories: drivers performing some form of physical I/O that use the major device number to determine the type of I/O, and block device drivers that need to know if the device they control is the root or the swap device.
The only drivers that need to know this information fall into one of two categories: drivers performing some form of physical I/O that use the major device number to determine the type of I/O, and block device drivers that need to know if the device they control is the root or the swap device.
b_dev
member of the transfer's buffer.
Drivers needing to know if they are the root device can
find out using code such as the following:
#include "sys/conf.h" #include "sys/cmn_err.h"extern struct bdevsw bdevsw[];
if ( bdevsw[major(rootdev)].d_open == xxopen ) { cmn_err(CE_CONT,"the xx driver is the root device\n"); . . . }