Keep the coding style consistent.
Signed-off-by: Weili Qian qianweili@huawei.com --- wd_dh.c | 71 ++++++++++++++++++++++++++++--------------------------- wd_ecc.c | 72 +++++++++++++++++++++++++++++--------------------------- wd_rsa.c | 71 ++++++++++++++++++++++++++++--------------------------- 3 files changed, 109 insertions(+), 105 deletions(-)
diff --git a/wd_dh.c b/wd_dh.c index 546fb90..df5d90e 100644 --- a/wd_dh.c +++ b/wd_dh.c @@ -235,45 +235,46 @@ int wd_dh_init2_(char *alg, __u32 sched_type, int task_type, struct wd_ctx_param goto out_clear_init; }
-res_retry: - memset(&wd_dh_setting.config, 0, sizeof(struct wd_ctx_config_internal)); - - /* Get alg driver and dev name */ - wd_dh_setting.driver = wd_alg_drv_bind(task_type, alg); - if (!wd_dh_setting.driver) { - WD_ERR("fail to bind a valid driver.\n"); - ret = -WD_EINVAL; - goto out_dlopen; - } + while (ret) { + memset(&wd_dh_setting.config, 0, sizeof(struct wd_ctx_config_internal)); + + /* Get alg driver and dev name */ + wd_dh_setting.driver = wd_alg_drv_bind(task_type, alg); + if (!wd_dh_setting.driver) { + WD_ERR("fail to bind a valid driver.\n"); + ret = -WD_EINVAL; + goto out_dlopen; + }
- dh_ctx_params.ctx_set_num = dh_ctx_num; - ret = wd_ctx_param_init(&dh_ctx_params, ctx_params, - wd_dh_setting.driver, WD_DH_TYPE, WD_DH_PHASE2); - if (ret) { - if (ret == -WD_EAGAIN) { - wd_disable_drv(wd_dh_setting.driver); - wd_alg_drv_unbind(wd_dh_setting.driver); - goto res_retry; + dh_ctx_params.ctx_set_num = dh_ctx_num; + ret = wd_ctx_param_init(&dh_ctx_params, ctx_params, + wd_dh_setting.driver, WD_DH_TYPE, WD_DH_PHASE2); + if (ret) { + if (ret == -WD_EAGAIN) { + wd_disable_drv(wd_dh_setting.driver); + wd_alg_drv_unbind(wd_dh_setting.driver); + continue; + } + goto out_driver; } - goto out_driver; - }
- wd_dh_init_attrs.alg = alg; - wd_dh_init_attrs.sched_type = sched_type; - wd_dh_init_attrs.driver = wd_dh_setting.driver; - wd_dh_init_attrs.ctx_params = &dh_ctx_params; - wd_dh_init_attrs.alg_init = wd_dh_common_init; - wd_dh_init_attrs.alg_poll_ctx = wd_dh_poll_ctx; - ret = wd_alg_attrs_init(&wd_dh_init_attrs); - if (ret) { - if (ret == -WD_ENODEV) { - wd_disable_drv(wd_dh_setting.driver); - wd_alg_drv_unbind(wd_dh_setting.driver); - wd_ctx_param_uninit(&dh_ctx_params); - goto res_retry; + wd_dh_init_attrs.alg = alg; + wd_dh_init_attrs.sched_type = sched_type; + wd_dh_init_attrs.driver = wd_dh_setting.driver; + wd_dh_init_attrs.ctx_params = &dh_ctx_params; + wd_dh_init_attrs.alg_init = wd_dh_common_init; + wd_dh_init_attrs.alg_poll_ctx = wd_dh_poll_ctx; + ret = wd_alg_attrs_init(&wd_dh_init_attrs); + if (ret) { + if (ret == -WD_ENODEV) { + wd_disable_drv(wd_dh_setting.driver); + wd_alg_drv_unbind(wd_dh_setting.driver); + wd_ctx_param_uninit(&dh_ctx_params); + continue; + } + WD_ERR("failed to init alg attrs!\n"); + goto out_params_uninit; } - WD_ERR("failed to init alg attrs!\n"); - goto out_params_uninit; }
wd_alg_set_init(&wd_dh_setting.status); diff --git a/wd_ecc.c b/wd_ecc.c index 0a9ebe0..e401a46 100644 --- a/wd_ecc.c +++ b/wd_ecc.c @@ -302,51 +302,53 @@ int wd_ecc_init2_(char *alg, __u32 sched_type, int task_type, struct wd_ctx_para goto out_clear_init; }
-res_retry: - memset(&wd_ecc_setting.config, 0, sizeof(struct wd_ctx_config_internal)); - - /* Get alg driver and dev name */ - wd_ecc_setting.driver = wd_alg_drv_bind(task_type, alg); - if (!wd_ecc_setting.driver) { - WD_ERR("failed to bind a valid driver!\n"); - ret = -WD_EINVAL; - goto out_dlopen; - } + while (ret) { + memset(&wd_ecc_setting.config, 0, sizeof(struct wd_ctx_config_internal)); + + /* Get alg driver and dev name */ + wd_ecc_setting.driver = wd_alg_drv_bind(task_type, alg); + if (!wd_ecc_setting.driver) { + WD_ERR("failed to bind a valid driver!\n"); + ret = -WD_EINVAL; + goto out_dlopen; + }
- ecc_ctx_params.ctx_set_num = ecc_ctx_num; - ret = wd_ctx_param_init(&ecc_ctx_params, ctx_params, - wd_ecc_setting.driver, WD_ECC_TYPE, WD_EC_OP_MAX); - if (ret) { - if (ret == -WD_EAGAIN) { - wd_disable_drv(wd_ecc_setting.driver); - wd_alg_drv_unbind(wd_ecc_setting.driver); - goto res_retry; + ecc_ctx_params.ctx_set_num = ecc_ctx_num; + ret = wd_ctx_param_init(&ecc_ctx_params, ctx_params, + wd_ecc_setting.driver, WD_ECC_TYPE, WD_EC_OP_MAX); + if (ret) { + if (ret == -WD_EAGAIN) { + wd_disable_drv(wd_ecc_setting.driver); + wd_alg_drv_unbind(wd_ecc_setting.driver); + continue; + } + goto out_driver; } - goto out_driver; - }
- wd_ecc_init_attrs.alg = alg; - wd_ecc_init_attrs.sched_type = sched_type; - wd_ecc_init_attrs.driver = wd_ecc_setting.driver; - wd_ecc_init_attrs.ctx_params = &ecc_ctx_params; - wd_ecc_init_attrs.alg_init = wd_ecc_common_init; - wd_ecc_init_attrs.alg_poll_ctx = wd_ecc_poll_ctx; - ret = wd_alg_attrs_init(&wd_ecc_init_attrs); - if (ret) { - if (ret == -WD_ENODEV) { - wd_disable_drv(wd_ecc_setting.driver); - wd_alg_drv_unbind(wd_ecc_setting.driver); - wd_ctx_param_uninit(&ecc_ctx_params); - goto res_retry; + wd_ecc_init_attrs.alg = alg; + wd_ecc_init_attrs.sched_type = sched_type; + wd_ecc_init_attrs.driver = wd_ecc_setting.driver; + wd_ecc_init_attrs.ctx_params = &ecc_ctx_params; + wd_ecc_init_attrs.alg_init = wd_ecc_common_init; + wd_ecc_init_attrs.alg_poll_ctx = wd_ecc_poll_ctx; + ret = wd_alg_attrs_init(&wd_ecc_init_attrs); + if (ret) { + if (ret == -WD_ENODEV) { + wd_disable_drv(wd_ecc_setting.driver); + wd_alg_drv_unbind(wd_ecc_setting.driver); + wd_ctx_param_uninit(&ecc_ctx_params); + continue; + } + WD_ERR("failed to init alg attrs!\n"); + goto out_params_uninit; } - WD_ERR("failed to init alg attrs!\n"); - goto out_params_uninit; }
wd_alg_set_init(&wd_ecc_setting.status); wd_ctx_param_uninit(&ecc_ctx_params);
return 0; + out_params_uninit: wd_ctx_param_uninit(&ecc_ctx_params); out_driver: diff --git a/wd_rsa.c b/wd_rsa.c index 382e831..ba2e088 100644 --- a/wd_rsa.c +++ b/wd_rsa.c @@ -276,45 +276,46 @@ int wd_rsa_init2_(char *alg, __u32 sched_type, int task_type, struct wd_ctx_para goto out_clear_init; }
-res_retry: - memset(&wd_rsa_setting.config, 0, sizeof(struct wd_ctx_config_internal)); - - /* Get alg driver and dev name */ - wd_rsa_setting.driver = wd_alg_drv_bind(task_type, alg); - if (!wd_rsa_setting.driver) { - WD_ERR("failed to bind a valid driver!\n"); - ret = -WD_EINVAL; - goto out_dlopen; - } + while (ret) { + memset(&wd_rsa_setting.config, 0, sizeof(struct wd_ctx_config_internal)); + + /* Get alg driver and dev name */ + wd_rsa_setting.driver = wd_alg_drv_bind(task_type, alg); + if (!wd_rsa_setting.driver) { + WD_ERR("failed to bind a valid driver!\n"); + ret = -WD_EINVAL; + goto out_dlopen; + }
- rsa_ctx_params.ctx_set_num = rsa_ctx_num; - ret = wd_ctx_param_init(&rsa_ctx_params, ctx_params, - wd_rsa_setting.driver, WD_RSA_TYPE, WD_RSA_GENKEY); - if (ret) { - if (ret == -WD_EAGAIN) { - wd_disable_drv(wd_rsa_setting.driver); - wd_alg_drv_unbind(wd_rsa_setting.driver); - goto res_retry; + rsa_ctx_params.ctx_set_num = rsa_ctx_num; + ret = wd_ctx_param_init(&rsa_ctx_params, ctx_params, + wd_rsa_setting.driver, WD_RSA_TYPE, WD_RSA_GENKEY); + if (ret) { + if (ret == -WD_EAGAIN) { + wd_disable_drv(wd_rsa_setting.driver); + wd_alg_drv_unbind(wd_rsa_setting.driver); + continue; + } + goto out_driver; } - goto out_driver; - }
- wd_rsa_init_attrs.alg = alg; - wd_rsa_init_attrs.sched_type = sched_type; - wd_rsa_init_attrs.driver = wd_rsa_setting.driver; - wd_rsa_init_attrs.ctx_params = &rsa_ctx_params; - wd_rsa_init_attrs.alg_init = wd_rsa_common_init; - wd_rsa_init_attrs.alg_poll_ctx = wd_rsa_poll_ctx; - ret = wd_alg_attrs_init(&wd_rsa_init_attrs); - if (ret) { - if (ret == -WD_ENODEV) { - wd_disable_drv(wd_rsa_setting.driver); - wd_alg_drv_unbind(wd_rsa_setting.driver); - wd_ctx_param_uninit(&rsa_ctx_params); - goto res_retry; + wd_rsa_init_attrs.alg = alg; + wd_rsa_init_attrs.sched_type = sched_type; + wd_rsa_init_attrs.driver = wd_rsa_setting.driver; + wd_rsa_init_attrs.ctx_params = &rsa_ctx_params; + wd_rsa_init_attrs.alg_init = wd_rsa_common_init; + wd_rsa_init_attrs.alg_poll_ctx = wd_rsa_poll_ctx; + ret = wd_alg_attrs_init(&wd_rsa_init_attrs); + if (ret) { + if (ret == -WD_ENODEV) { + wd_disable_drv(wd_rsa_setting.driver); + wd_alg_drv_unbind(wd_rsa_setting.driver); + wd_ctx_param_uninit(&rsa_ctx_params); + continue; + } + WD_ERR("failed to init alg attrs!\n"); + goto out_params_uninit; } - WD_ERR("failed to init alg attrs!\n"); - goto out_params_uninit; }
wd_alg_set_init(&wd_rsa_setting.status);