Device Unregistration
To unregister a device, the kernel and the associated device driver need to undo all the operations that were executed during its registration, and more:
Disable the device with
dev_close, described in the section "Enabling and Disabling a Network Device."Release all the allocated resources (IRQ, I/O memory, I/O port, etc.)
Remove the
net_devicestructure from the global listdev_baseand the two hash tables introduced in the section "Organization of net_device Structures."Once all the references to the structure have been released, free the
net_devicedata structure, the driver's private data structure, and any other memory block linked to it (see Figure 8-2). Thenet_devicestructure is freed withfree_netdev. When the kernel is compiled with support for sysfs,free_netdevlets it take care of freeing the structure.Remove any file that may have been added to the /proc and /sys filesystems.
Note that whenever there is a dependency between devices, unregistering one of them may force the unregistration of all (or part) of the others. See the section "Virtual Devices" for an example.
Three function pointers in net_device (represented
by a variable named dev) come into the picture when
unregistering a device:
-
dev->stop This function pointer is initialized by the device driver to one of its local routines. It is invoked by
dev_stopwhen disabling a device (see the section "Enabling and Disabling a Network Device"). Common tasks handled here include stopping the egress ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access