Skip to content

Commit

Permalink
[netdevice] Allow devices to indicate that interrupts are not supported
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jan 25, 2011
1 parent 7bf3714 commit 66caec3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/include/ipxe/netdevice.h
Expand Up @@ -236,6 +236,9 @@ struct net_device_operations {
*
* @v netdev Network device
* @v enable Interrupts should be enabled
*
* This method may be NULL to indicate that interrupts are not
* supported.
*/
void ( * irq ) ( struct net_device *netdev, int enable );
};
Expand Down Expand Up @@ -515,6 +518,17 @@ netdev_is_open ( struct net_device *netdev ) {
return ( netdev->state & NETDEV_OPEN );
}

/**
* Check whether or not network device supports interrupts
*
* @v netdev Network device
* @ret irq_supported Network device supports interrupts
*/
static inline __attribute__ (( always_inline )) int
netdev_irq_supported ( struct net_device *netdev ) {
return ( netdev->op->irq != NULL );
}

/**
* Check whether or not network device interrupts are currently enabled
*
Expand Down
4 changes: 4 additions & 0 deletions src/net/netdevice.c
Expand Up @@ -542,6 +542,10 @@ void unregister_netdev ( struct net_device *netdev ) {
*/
void netdev_irq ( struct net_device *netdev, int enable ) {

/* Do nothing if device does not support interrupts */
if ( ! netdev_irq_supported ( netdev ) )
return;

/* Enable or disable device interrupts */
netdev->op->irq ( netdev, enable );

Expand Down

0 comments on commit 66caec3

Please sign in to comment.