Chapter 2. Driver structure

Traditionally a lower level driver for the scsi subsystem has been at least two files in the drivers/scsi directory. For example, a driver called "xyz" has a header file "xyz.h" and a source file "xyz.c". [Actually there is no good reason why this couldn't all be in one file.] Some drivers that have been ported to several operating systems (e.g. aic7xxx which has separate files for generic and OS-specific code) have more than two files. Such drivers tend to have their own directory under the drivers/scsi directory.

scsi_module.c is normally included at the end of a lower level driver. For it to work a declaration like this is needed before it is included:

    static Scsi_Host_Template driver_template = DRIVER_TEMPLATE;
    /* DRIVER_TEMPLATE should contain pointers to supported interface
       functions. Scsi_Host_Template is defined hosts.h */
    #include "scsi_module.c"

The scsi_module.c assumes the name "driver_template" is appropriately defined. It contains 2 functions:

  1. init_this_scsi_driver() called during builtin and module driver initialization: invokes mid level's scsi_register_host()

  2. exit_this_scsi_driver() called during closedown: invokes mid level's scsi_unregister_host()

When a new, lower level driver is being added to Linux, the following files (all found in the drivers/scsi directory) will need some attention: Makefile, Config.help and Config.in . It is probably best to look at what an existing lower level driver does in this regard.