Let's take a look at another example. Here, we're looking at the hardware interrupt handler of the Intel IXGB ethernet adapter's device driver, which we mentioned earlier:
// drivers/net/ethernet/intel/ixgb/ixgb_main.c
static irqreturn_t
ixgb_intr(int irq, void *data)
{
struct net_device *netdev = data;
struct ixgb_adapter *adapter = netdev_priv(netdev);
struct ixgb_hw *hw = &adapter-hw;
u32 icr = IXGB_READ_REG(hw, ICR);
if (unlikely(!icr))
return IRQ_NONE; /* Not our interrupt */
[...]
if (napi_schedule_prep(&adapter-napi)) {
[...]
IXGB_WRITE_REG(&adapter-hw, IMC, ~0);
__napi_schedule(&adapter-napi);
}
return IRQ_HANDLED;
}
In the preceding code snippet, notice how the driver gains access to its private (or context) metadata structure (struct ixgb_adapter) from the net_device structure (the specialized structure for...