From: Weili Qian qianweili@huawei.com
Before calling WD_DEBUG, check whether debug logs need to be recorded to prevent the syslog syscall from affecting the performance.
Signed-off-by: Weili Qian qianweili@huawei.com Signed-off-by: JiangShui Yang yangjiangshui@h-partners.com --- wd_ecc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/wd_ecc.c b/wd_ecc.c index 24f167f..d36a697 100644 --- a/wd_ecc.c +++ b/wd_ecc.c @@ -1020,20 +1020,19 @@ static int fill_user_curve_cfg(struct wd_ecc_curve *param, struct wd_ecc_sess_setup *setup) { struct wd_ecc_curve *src_param = setup->cv.cfg.pparam; - __u32 curve_id; + bool need_debug = wd_need_debug(); + __u32 curve_id = 0; int ret = 0;
if (setup->cv.type == WD_CV_CFG_ID) { curve_id = setup->cv.cfg.id; ret = fill_param_by_id(param, setup->key_bits, curve_id); - WD_DEBUG("set curve id %u!\n", curve_id); } else if (setup->cv.type == WD_CV_CFG_PARAM) { ret = set_key_cv(param, src_param); if (ret) { WD_ERR("failed to set key cv!\n"); return ret; } - WD_DEBUG("set curve by user param!\n"); } else { WD_ERR("invalid: fill curve cfg type %u is error!\n", setup->cv.type); return -WD_EINVAL; @@ -1045,6 +1044,9 @@ static int fill_user_curve_cfg(struct wd_ecc_curve *param, return -WD_EINVAL; }
+ if (need_debug) + WD_DEBUG("curve cfg type is %u, curve_id is %u!\n", setup->cv.type, curve_id); + return ret; }