[interface] Convert all job-control interfaces to generic interfaces

Remove job-control as an interface type, and replace job-control
interfaces with generic interfaces supporting the close() method.
(Both done() and kill() are absorbed into the function of close();
kill() is merely close(-ECANCELED).)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2008-06-12 21:47:19 +01:00
parent e71b83b22b
commit a03dd97e6b
8 changed files with 88 additions and 293 deletions

View File

@@ -28,70 +28,27 @@ FILE_LICENCE ( GPL2_OR_LATER );
*
*/
void job_done ( struct job_interface *job, int rc ) {
struct job_interface *dest = job_get_dest ( job );
job_unplug ( job );
dest->op->done ( dest, rc );
job_put ( dest );
}
void job_kill ( struct job_interface *job ) {
struct job_interface *dest = job_get_dest ( job );
job_unplug ( job );
dest->op->kill ( dest );
job_put ( dest );
}
void job_progress ( struct job_interface *job,
struct job_progress *progress ) {
struct job_interface *dest = job_get_dest ( job );
dest->op->progress ( dest, progress );
job_put ( dest );
}
/****************************************************************************
*
* Helper methods
*
* These functions are designed to be used as methods in the
* job_interface_operations table.
*
*/
void ignore_job_done ( struct job_interface *job __unused, int rc __unused ) {
/* Nothing to do */
}
void ignore_job_kill ( struct job_interface *job __unused ) {
/* Nothing to do */
}
void ignore_job_progress ( struct job_interface *job __unused,
struct job_progress *progress ) {
memset ( progress, 0, sizeof ( *progress ) );
}
/** Null job control interface operations */
struct job_interface_operations null_job_ops = {
.done = ignore_job_done,
.kill = ignore_job_kill,
.progress = ignore_job_progress,
};
/**
* Null job control interface
* Get job progress
*
* This is the interface to which job control interfaces are connected
* when unplugged. It will never generate messages, and will silently
* absorb all received messages.
* @v intf Object interface
* @v progress Progress data to fill in
*/
struct job_interface null_job = {
.intf = {
.dest = &null_job.intf,
.refcnt = NULL,
},
.op = &null_job_ops,
};
void job_progress ( struct interface *intf, struct job_progress *progress ) {
struct interface *dest;
job_progress_TYPE ( void * ) *op =
intf_get_dest_op ( intf, job_progress, &dest );
void *object = intf_object ( dest );
DBGC ( INTF_COL ( intf ), "INTF " INTF_INTF_FMT " job_progress\n",
INTF_INTF_DBG ( intf, dest ) );
if ( op ) {
op ( object, progress );
} else {
/* Default is to mark progress as zero */
memset ( progress, 0, sizeof ( *progress ) );
}
intf_put ( dest );
}