On 2022/7/11 17:12, Yang Shen wrote:
Since two function will be used for mutil files, move them to header file.
Signed-off-by: Yang Shen shenyang39@huawei.com
include/wd.h | 15 +++++++++++++++ wd.c | 35 +++++++++++++++++------------------ 2 files changed, 32 insertions(+), 18 deletions(-)
diff --git a/include/wd.h b/include/wd.h index a78ee38..4f3a32f 100644 --- a/include/wd.h +++ b/include/wd.h @@ -508,6 +508,21 @@ void wd_mempool_stats(handle_t mempool, struct wd_mempool_stats *stats); */ void wd_blockpool_stats(handle_t blkpool, struct wd_blockpool_stats *stats);
+/**
- wd_clone_dev() - clone a new uacce device.
- @dev: The source device.
- Return a pointer value if succeed, and NULL if fail.
- */
+struct uacce_dev *wd_clone_dev(struct uacce_dev *dev);
+/**
- wd_add_to_list() - add a node to end of list.
- @head: The list head.
- @node: The node need to be add.
- */
+void wd_add_to_list(struct uacce_dev_list *head, struct uacce_dev_list *node);
It is recommended to change the function name to wd_add_dev_to_list. Thanks Longfang
/**
- wd_ctx_get_dev_name() - Get the device name about task.
- @h_ctx: The handle of context.
diff --git a/wd.c b/wd.c index b0c3dec..66a6df3 100644 --- a/wd.c +++ b/wd.c @@ -365,7 +365,13 @@ out: return strndup(name, len); }
-static struct uacce_dev *clone_uacce_dev(struct uacce_dev *dev) +static void wd_ctx_init_qfrs_offs(struct wd_ctx_h *ctx) +{
- memcpy(&ctx->qfrs_offs, &ctx->dev->qfrs_offs,
sizeof(ctx->qfrs_offs));
+}
+struct uacce_dev *wd_clone_dev(struct uacce_dev *dev) { struct uacce_dev *new;
@@ -378,10 +384,14 @@ static struct uacce_dev *clone_uacce_dev(struct uacce_dev *dev) return new; }
-static void wd_ctx_init_qfrs_offs(struct wd_ctx_h *ctx) +void wd_add_to_list(struct uacce_dev_list *head, struct uacce_dev_list *node) {
- memcpy(&ctx->qfrs_offs, &ctx->dev->qfrs_offs,
sizeof(ctx->qfrs_offs));
- struct uacce_dev_list *tmp = head;
- while (tmp->next)
tmp = tmp->next;
- tmp->next = node;
}
handle_t wd_request_ctx(struct uacce_dev *dev) @@ -416,7 +426,7 @@ handle_t wd_request_ctx(struct uacce_dev *dev) if (!ctx->drv_name) goto free_dev_name;
- ctx->dev = clone_uacce_dev(dev);
- ctx->dev = wd_clone_dev(dev); if (!ctx->dev) goto free_drv_name;
@@ -656,17 +666,6 @@ static bool dev_has_alg(const char *dev_alg_name, const char *alg_name) return false; }
-static void add_uacce_dev_to_list(struct uacce_dev_list *head,
struct uacce_dev_list *node)
-{
- struct uacce_dev_list *tmp = head;
- while (tmp->next)
tmp = tmp->next;
- tmp->next = node;
-}
static int check_alg_name(const char *alg_name) { int i = 0; @@ -729,7 +728,7 @@ struct uacce_dev_list *wd_get_accel_list(const char *alg_name) if (!head) head = node; else
add_uacce_dev_to_list(head, node);
wd_add_to_list(head, node);
}
closedir(wd_class);
@@ -788,7 +787,7 @@ struct uacce_dev *wd_get_accel_dev(const char *alg_name) }
if (dev)
target = clone_uacce_dev(dev);
target = wd_clone_dev(dev);
wd_free_list_accels(head);