Browse Source

[netdevice] Allow devices to indicate that interrupts are not supported

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
66caec3f00
2 changed files with 18 additions and 0 deletions
  1. 14
    0
      src/include/ipxe/netdevice.h
  2. 4
    0
      src/net/netdevice.c

+ 14
- 0
src/include/ipxe/netdevice.h View File

236
 	 *
236
 	 *
237
 	 * @v netdev	Network device
237
 	 * @v netdev	Network device
238
 	 * @v enable	Interrupts should be enabled
238
 	 * @v enable	Interrupts should be enabled
239
+	 *
240
+	 * This method may be NULL to indicate that interrupts are not
241
+	 * supported.
239
 	 */
242
 	 */
240
 	void ( * irq ) ( struct net_device *netdev, int enable );
243
 	void ( * irq ) ( struct net_device *netdev, int enable );
241
 };
244
 };
515
 	return ( netdev->state & NETDEV_OPEN );
518
 	return ( netdev->state & NETDEV_OPEN );
516
 }
519
 }
517
 
520
 
521
+/**
522
+ * Check whether or not network device supports interrupts
523
+ *
524
+ * @v netdev		Network device
525
+ * @ret irq_supported	Network device supports interrupts
526
+ */
527
+static inline __attribute__ (( always_inline )) int
528
+netdev_irq_supported ( struct net_device *netdev ) {
529
+	return ( netdev->op->irq != NULL );
530
+}
531
+
518
 /**
532
 /**
519
  * Check whether or not network device interrupts are currently enabled
533
  * Check whether or not network device interrupts are currently enabled
520
  *
534
  *

+ 4
- 0
src/net/netdevice.c View File

542
  */
542
  */
543
 void netdev_irq ( struct net_device *netdev, int enable ) {
543
 void netdev_irq ( struct net_device *netdev, int enable ) {
544
 
544
 
545
+	/* Do nothing if device does not support interrupts */
546
+	if ( ! netdev_irq_supported ( netdev ) )
547
+		return;
548
+
545
 	/* Enable or disable device interrupts */
549
 	/* Enable or disable device interrupts */
546
 	netdev->op->irq ( netdev, enable );
550
 	netdev->op->irq ( netdev, enable );
547
 
551
 

Loading…
Cancel
Save