8.2. When a Device Is Unregistered
Two main conditions trigger the unregistration of a device:
Unloading an NIC device driver
This can be done only for drivers loaded as modules, of course, not for those built into the kernel. When the administrator unloads an NIC's device driver, all the associated NICs must be unregistered.
For example, we saw in Chapter 6 how unloading a PCI device driver leads to the execution of the pci_driver->remove routine provided by the driver, often called something like xxx_remove_one, which will take care of device unregistration. This routine is invoked by the PCI layer once for each device registered against the driver being unloaded. In this chapter, we will look at how those routines are implemented.
Removing a hot-pluggable network device
When a user removes a hot-pluggable NIC from a system whose running kernel has support for hot-pluggable devices, the network device is unregistered.