]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[hw] Eliminate polling while waiting for window to open
authorMichael Brown <mcb30@ipxe.org>
Fri, 24 Jun 2011 15:51:31 +0000 (16:51 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 28 Jun 2011 13:45:11 +0000 (14:45 +0100)
Polling for the data-transfer window to become open is wasteful.  We
can eliminate the polling loop by using hw_step() as the handler for
an xfer_window_changed() event.

If the window is already open at the time of instantiation, then
xfer_window_changed() may never be called.  We can cover this case by
using hw_step() as the step() method of a one-shot process.  Since the
signature for an xfer_window_changed() method is identical to the
signature for a process step() method, the same function can be used
for both.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/hw.c

index e9c9ffc1d6aa793ae7e0bb8f649721ad6c70fd1c..91736a65294c181029d46546e88a3834e37f78df 100644 (file)
@@ -36,6 +36,7 @@ static void hw_step ( struct hw *hw ) {
 }
 
 static struct interface_operation hw_xfer_operations[] = {
+       INTF_OP ( xfer_window_changed, struct hw *, hw_step ),
        INTF_OP ( intf_close, struct hw *, hw_finished ),
 };
 
@@ -43,7 +44,7 @@ static struct interface_descriptor hw_xfer_desc =
        INTF_DESC ( struct hw, xfer, hw_xfer_operations );
 
 static struct process_descriptor hw_process_desc =
-       PROC_DESC ( struct hw, process, hw_step );
+       PROC_DESC_ONCE ( struct hw, process, hw_step );
 
 static int hw_open ( struct interface *xfer, struct uri *uri __unused ) {
        struct hw *hw;