Browse Source

[interface] Default to calling intf_restart() in response to intf_close()

If an object interface does not provide an intf_close() method, then
default to calling intf_restart().  This allows static objects to
safely ignore intf_close(), without needing to add code solely to
ensure that the interface gets unplugged.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
a3346e3587
1 changed files with 19 additions and 2 deletions
  1. 19
    2
      src/core/interface.c

+ 19
- 2
src/core/interface.c View File

@@ -34,8 +34,24 @@ FILE_LICENCE ( GPL2_OR_LATER );
34 34
  *
35 35
  */
36 36
 
37
+/**
38
+ * Close null interface
39
+ *
40
+ * @v intf		Null interface
41
+ * @v rc		Reason for close
42
+ */
43
+static void null_intf_close ( struct interface *intf __unused,
44
+			      int rc __unused ) {
45
+
46
+	/* Do nothing.  In particular, do not call intf_restart(),
47
+	 * since that would result in an infinite loop.
48
+	 */
49
+}
50
+
37 51
 /** Null interface operations */
38
-static struct interface_operation null_intf_op[] = {};
52
+static struct interface_operation null_intf_op[] = {
53
+	INTF_OP ( intf_close, struct interface *, null_intf_close ),
54
+};
39 55
 
40 56
 /** Null interface descriptor */
41 57
 struct interface_descriptor null_intf_desc =
@@ -233,7 +249,8 @@ void intf_close ( struct interface *intf, int rc ) {
233 249
 	if ( op ) {
234 250
 		op ( object, rc );
235 251
 	} else {
236
-		/* Default is to ignore intf_close() */
252
+		/* Default is to restart the interface */
253
+		intf_restart ( dest, rc );
237 254
 	}
238 255
 
239 256
 	intf_put ( dest );

Loading…
Cancel
Save