]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[netdevice] Allow devices to indicate that interrupts are not supported
authorMichael Brown <mcb30@ipxe.org>
Tue, 25 Jan 2011 14:16:11 +0000 (14:16 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 25 Jan 2011 14:16:11 +0000 (14:16 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/netdevice.h
src/net/netdevice.c

index a7852a810fe00bf7216704da5ef5ce7ec886f1e3..ac7cec521795fe92d3f690e93545e7a949e1e179 100644 (file)
@@ -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 );
 };
@@ -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
  *
index c7e907ad6596954791a394ca2622bc3b6d405cbc..8138237608ad0b4228ace14518ee18d3ed69a74f 100644 (file)
@@ -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 );