tpm: remove unused TPMBackendCmd

There is only handling of request so far in both backends.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This commit is contained in:
Marc-André Lureau 2017-10-10 00:55:52 +02:00 committed by Stefan Berger
parent 76ae76bfea
commit 905e78ba25
4 changed files with 26 additions and 55 deletions

View File

@ -25,13 +25,12 @@ static void tpm_backend_worker_thread(gpointer data, gpointer user_data)
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s); TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
assert(k->handle_request != NULL); assert(k->handle_request != NULL);
k->handle_request(s, (TPMBackendCmd)data); k->handle_request(s);
} }
static void tpm_backend_thread_end(TPMBackend *s) static void tpm_backend_thread_end(TPMBackend *s)
{ {
if (s->thread_pool) { if (s->thread_pool) {
g_thread_pool_push(s->thread_pool, (gpointer)TPM_BACKEND_CMD_END, NULL);
g_thread_pool_free(s->thread_pool, FALSE, TRUE); g_thread_pool_free(s->thread_pool, FALSE, TRUE);
s->thread_pool = NULL; s->thread_pool = NULL;
} }
@ -64,7 +63,6 @@ int tpm_backend_startup_tpm(TPMBackend *s)
s->thread_pool = g_thread_pool_new(tpm_backend_worker_thread, s, 1, TRUE, s->thread_pool = g_thread_pool_new(tpm_backend_worker_thread, s, 1, TRUE,
NULL); NULL);
g_thread_pool_push(s->thread_pool, (gpointer)TPM_BACKEND_CMD_INIT, NULL);
res = k->startup_tpm ? k->startup_tpm(s) : 0; res = k->startup_tpm ? k->startup_tpm(s) : 0;
@ -80,8 +78,7 @@ bool tpm_backend_had_startup_error(TPMBackend *s)
void tpm_backend_deliver_request(TPMBackend *s) void tpm_backend_deliver_request(TPMBackend *s)
{ {
g_thread_pool_push(s->thread_pool, (gpointer)TPM_BACKEND_CMD_PROCESS_CMD, g_thread_pool_push(s->thread_pool, NULL, NULL);
NULL);
} }
void tpm_backend_reset(TPMBackend *s) void tpm_backend_reset(TPMBackend *s)

View File

@ -172,39 +172,29 @@ static int tpm_emulator_set_locality(TPMEmulator *tpm_emu, uint8_t locty_number)
return 0; return 0;
} }
static void tpm_emulator_handle_request(TPMBackend *tb, TPMBackendCmd cmd) static void tpm_emulator_handle_request(TPMBackend *tb)
{ {
TPMEmulator *tpm_emu = TPM_EMULATOR(tb); TPMEmulator *tpm_emu = TPM_EMULATOR(tb);
TPMLocality *locty = NULL; TPMLocality *locty = NULL;
bool selftest_done = false; bool selftest_done = false;
Error *err = NULL; Error *err = NULL;
DPRINTF("processing command type %d", cmd); DPRINTF("processing TPM command");
switch (cmd) { locty = tb->tpm_state->locty_data;
case TPM_BACKEND_CMD_PROCESS_CMD: if (tpm_emulator_set_locality(tpm_emu,
locty = tb->tpm_state->locty_data; tb->tpm_state->locty_number) < 0 ||
if (tpm_emulator_set_locality(tpm_emu, tpm_emulator_unix_tx_bufs(tpm_emu, locty->w_buffer.buffer,
tb->tpm_state->locty_number) < 0 || locty->w_offset, locty->r_buffer.buffer,
tpm_emulator_unix_tx_bufs(tpm_emu, locty->w_buffer.buffer, locty->r_buffer.size, &selftest_done,
locty->w_offset, locty->r_buffer.buffer, &err) < 0) {
locty->r_buffer.size, &selftest_done, tpm_util_write_fatal_error_response(locty->r_buffer.buffer,
&err) < 0) { locty->r_buffer.size);
tpm_util_write_fatal_error_response(locty->r_buffer.buffer, error_report_err(err);
locty->r_buffer.size);
error_report_err(err);
}
tb->recv_data_callback(tb->tpm_state, tb->tpm_state->locty_number,
selftest_done);
break;
case TPM_BACKEND_CMD_INIT:
case TPM_BACKEND_CMD_END:
case TPM_BACKEND_CMD_TPM_RESET:
/* nothing to do */
break;
} }
tb->recv_data_callback(tb->tpm_state, tb->tpm_state->locty_number,
selftest_done);
} }
static int tpm_emulator_probe_caps(TPMEmulator *tpm_emu) static int tpm_emulator_probe_caps(TPMEmulator *tpm_emu)

View File

@ -149,29 +149,20 @@ static int tpm_passthrough_unix_transfer(TPMPassthruState *tpm_pt,
selftest_done); selftest_done);
} }
static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd cmd) static void tpm_passthrough_handle_request(TPMBackend *tb)
{ {
TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
bool selftest_done = false; bool selftest_done = false;
DPRINTF("tpm_passthrough: processing command type %d\n", cmd); DPRINTF("tpm_passthrough: processing command\n");
switch (cmd) { tpm_passthrough_unix_transfer(tpm_pt,
case TPM_BACKEND_CMD_PROCESS_CMD: tb->tpm_state->locty_data,
tpm_passthrough_unix_transfer(tpm_pt, &selftest_done);
tb->tpm_state->locty_data,
&selftest_done);
tb->recv_data_callback(tb->tpm_state, tb->recv_data_callback(tb->tpm_state,
tb->tpm_state->locty_number, tb->tpm_state->locty_number,
selftest_done); selftest_done);
break;
case TPM_BACKEND_CMD_INIT:
case TPM_BACKEND_CMD_END:
case TPM_BACKEND_CMD_TPM_RESET:
/* nothing to do */
break;
}
} }
static void tpm_passthrough_reset(TPMBackend *tb) static void tpm_passthrough_reset(TPMBackend *tb)

View File

@ -32,13 +32,6 @@ typedef struct TPMBackend TPMBackend;
typedef void (TPMRecvDataCB)(TPMState *, uint8_t locty, bool selftest_done); typedef void (TPMRecvDataCB)(TPMState *, uint8_t locty, bool selftest_done);
typedef enum TPMBackendCmd {
TPM_BACKEND_CMD_INIT = 1,
TPM_BACKEND_CMD_PROCESS_CMD,
TPM_BACKEND_CMD_END,
TPM_BACKEND_CMD_TPM_RESET,
} TPMBackendCmd;
struct TPMBackend { struct TPMBackend {
Object parent; Object parent;
@ -83,7 +76,7 @@ struct TPMBackendClass {
void (*opened)(TPMBackend *s, Error **errp); void (*opened)(TPMBackend *s, Error **errp);
void (*handle_request)(TPMBackend *s, TPMBackendCmd cmd); void (*handle_request)(TPMBackend *s);
}; };
/** /**