Просмотр исходного кода

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 лет назад
Родитель
Сommit
66caec3f00
2 измененных файлов: 18 добавлений и 0 удалений
  1. 14
    0
      src/include/ipxe/netdevice.h
  2. 4
    0
      src/net/netdevice.c

+ 14
- 0
src/include/ipxe/netdevice.h Просмотреть файл

@@ -236,6 +236,9 @@ struct net_device_operations {
236 236
 	 *
237 237
 	 * @v netdev	Network device
238 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 243
 	void ( * irq ) ( struct net_device *netdev, int enable );
241 244
 };
@@ -515,6 +518,17 @@ netdev_is_open ( struct net_device *netdev ) {
515 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 533
  * Check whether or not network device interrupts are currently enabled
520 534
  *

+ 4
- 0
src/net/netdevice.c Просмотреть файл

@@ -542,6 +542,10 @@ void unregister_netdev ( struct net_device *netdev ) {
542 542
  */
543 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 549
 	/* Enable or disable device interrupts */
546 550
 	netdev->op->irq ( netdev, enable );
547 551
 

Загрузка…
Отмена
Сохранить