From e962296d118fced22eda9d7ebb277ae0a6935e01 Mon Sep 17 00:00:00 2001 From: Lucas Russo Date: Fri, 25 Apr 2014 16:14:29 -0300 Subject: [PATCH] hdl/sm_io/*: add generic pointer to a specific handler SMIO modules often need some state information. Because of this, we store that in a new a generic field called smio_handler, inside the general sm_io structure. Specific realizations of the SMIO module need to set that pointer to the desired structure, initilize it correctly (inside bootstrap init function) and destroy it when donw (inside bootstrap shutdown function) --- hal/sm_io/sm_io.h | 3 +++ hal/sm_io/sm_io_bootstrap.c | 1 + 2 files changed, 4 insertions(+) diff --git a/hal/sm_io/sm_io.h b/hal/sm_io/sm_io.h index 639fd97..0d592d3 100644 --- a/hal/sm_io/sm_io.h +++ b/hal/sm_io/sm_io.h @@ -37,6 +37,9 @@ struct _smio_t { /* int verbose; */ /* Print activity to stdout */ mdp_worker_t *worker; /* zeroMQ Majordomo worker */ struct _devio_t *parent; /* Pointer back to parent dev_io */ + void *smio_handler; /* Generic pointer to a device handler. This + must be cast to a specific type by the + devices functions */ zctx_t *ctx; /* Our context */ void *pipe; /* Pipe back to parent to exchange messages */ diff --git a/hal/sm_io/sm_io_bootstrap.c b/hal/sm_io/sm_io_bootstrap.c index 1e6b2fd..9976214 100644 --- a/hal/sm_io/sm_io_bootstrap.c +++ b/hal/sm_io/sm_io_bootstrap.c @@ -165,6 +165,7 @@ static struct _smio_t *_smio_new (struct _devio_t *parent, struct _zctx_t *ctx, self->exp_ops_dtable = disp_table_new (); ASSERT_ALLOC(self->exp_ops_dtable, err_exp_ops_dtable_alloc); + self->smio_handler = NULL; /* This is set by the device functions */ self->ctx = ctx; self->pipe = pipe; -- 2.18.1