Browse Source

[interface] Add intf_poke() helper

Reduce the cost of implementing object methods which convey no
information beyond the fact that the method has been called.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
81c80c8ba9
2 changed files with 30 additions and 0 deletions
  1. 25
    0
      src/core/interface.c
  2. 5
    0
      src/include/ipxe/interface.h

+ 25
- 0
src/core/interface.c View File

311
 	 */
311
 	 */
312
 	intf->desc = desc;
312
 	intf->desc = desc;
313
 }
313
 }
314
+
315
+/**
316
+ * Poke an object interface
317
+ *
318
+ * @v intf		Object interface
319
+ * @v type		Operation type
320
+ *
321
+ * This is a helper function to implement methods which take no
322
+ * parameters and return nothing.
323
+ */
324
+void intf_poke ( struct interface *intf,
325
+		 void ( type ) ( struct interface *intf ) ) {
326
+	struct interface *dest;
327
+	intf_poke_TYPE ( void * ) *op =
328
+		intf_get_dest_op_untyped ( intf, type, &dest );
329
+	void *object = intf_object ( dest );
330
+
331
+	if ( op ) {
332
+		op ( object );
333
+	} else {
334
+		/* Default is to do nothing */
335
+	}
336
+
337
+	intf_put ( dest );
338
+}

+ 5
- 0
src/include/ipxe/interface.h View File

145
 extern void intf_shutdown ( struct interface *intf, int rc );
145
 extern void intf_shutdown ( struct interface *intf, int rc );
146
 extern void intf_restart ( struct interface *intf, int rc );
146
 extern void intf_restart ( struct interface *intf, int rc );
147
 
147
 
148
+extern void intf_poke ( struct interface *intf,
149
+			void ( type ) ( struct interface *intf ) );
150
+#define intf_poke_TYPE( object_type ) \
151
+	typeof ( void ( object_type ) )
152
+
148
 extern struct interface_descriptor null_intf_desc;
153
 extern struct interface_descriptor null_intf_desc;
149
 extern struct interface null_intf;
154
 extern struct interface null_intf;
150
 
155
 

Loading…
Cancel
Save