From 6138dbda5a4bfa6c724fd04b9225181d3a3c85a7 Mon Sep 17 00:00:00 2001 From: Gonglei Date: Thu, 22 Dec 2016 11:12:39 +0800 Subject: cryptodev: wrap the ready flag The ready flag should be set by the children of cryptodev backend interface. Warp the setter/getter functions for it. Signed-off-by: Gonglei Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- backends/cryptodev-builtin.c | 4 ++++ backends/cryptodev.c | 15 +++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 486b4a62bc..82a068e792 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -94,6 +94,8 @@ static void cryptodev_builtin_init( backend->conf.max_size = LONG_MAX - sizeof(CryptoDevBackendSymOpInfo); backend->conf.max_cipher_key_len = CRYPTODEV_BUITLIN_MAX_CIPHER_KEY_LEN; backend->conf.max_auth_key_len = CRYPTODEV_BUITLIN_MAX_AUTH_KEY_LEN; + + cryptodev_backend_set_ready(backend, true); } static int @@ -366,6 +368,8 @@ static void cryptodev_builtin_cleanup( backend->conf.peers.ccs[i] = NULL; } } + + cryptodev_backend_set_ready(backend, false); } static void diff --git a/backends/cryptodev.c b/backends/cryptodev.c index 6a66c27d68..832f056266 100644 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -73,8 +73,6 @@ void cryptodev_backend_cleanup( if (bc->cleanup) { bc->cleanup(backend, errp); } - - backend->ready = false; } int64_t cryptodev_backend_sym_create_session( @@ -189,11 +187,10 @@ cryptodev_backend_complete(UserCreatable *uc, Error **errp) goto out; } } - backend->ready = true; + return; out: - backend->ready = false; error_propagate(errp, local_err); } @@ -207,6 +204,16 @@ bool cryptodev_backend_is_used(CryptoDevBackend *backend) return backend->is_used; } +void cryptodev_backend_set_ready(CryptoDevBackend *backend, bool ready) +{ + backend->ready = ready; +} + +bool cryptodev_backend_is_ready(CryptoDevBackend *backend) +{ + return backend->ready; +} + static bool cryptodev_backend_can_be_deleted(UserCreatable *uc, Error **errp) { -- cgit v1.2.3