October 2017
Intermediate to advanced
586 pages
14h 8m
English
This is a cleaning function, which relies on two functions. Our driver release function should look like this:
static int my_netdev_remove(struct spi_device *spi)
{
struct priv_net_struct *priv = spi_get_drvdata(spi);
unregister_netdev(priv->netdev);
free_irq(spi->irq, priv);
free_netdev(priv->netdev);
return 0;
}
The unregister_netdev() function removes the interface from the system, and the kernel can no longer call its methods; free_netdev() frees the memory used by the struct net_device structure itself along with the memory allocated for private data, as well as any internally allocated memory related to the network device. Do note that you should never free netdev->priv by yourself.