Skip to content

Commit

Permalink
res: ucmd-module: reduce API for dev alias queries to sid_ucmd_dev_al…
Browse files Browse the repository at this point in the history
…ias_get and sid_ucmd_dev_alias_get_foreign_dev
  • Loading branch information
prajnoha committed Jul 31, 2024
1 parent 3a40e32 commit 7563952
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 53 deletions.
20 changes: 6 additions & 14 deletions src/include/resource/ucmd-module.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,27 +292,19 @@ int sid_ucmd_dev_alias_rename(sid_res_t *mod_res,

int sid_ucmd_dev_alias_del(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_ctx, const char *alias_key, const char *alias);

const char **sid_ucmd_dev_alias_get(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_ctx, const char *alias_key, size_t *count);
const char **sid_ucmd_dev_alias_get(sid_res_t *mod_res,
struct sid_ucmd_ctx *ucmd_ctx,
const char *mod_name,
const char *alias_key,
size_t *count);

const char **sid_ucmd_dev_alias_get_foreign_dev(sid_res_t *mod_res,
struct sid_ucmd_ctx *ucmd_ctx,
const char *mod_name,
const char *foreign_dev_id,
const char *alias_key,
size_t *count);

const char **sid_ucmd_dev_alias_get_foreign_mod(sid_res_t *mod_res,
struct sid_ucmd_ctx *ucmd_ctx,
const char *foreign_mod_name,
const char *alias_key,
size_t *count);

const char **sid_ucmd_dev_alias_get_foreign_dev_mod(sid_res_t *mod_res,
struct sid_ucmd_ctx *ucmd_ctx,
const char *foreign_dev_id,
const char *foreign_mod_name,
const char *alias_key,
size_t *count);

int sid_ucmd_grp_create(sid_res_t *mod_res,
struct sid_ucmd_ctx *ucmd_ctx,
sid_ucmd_kv_namespace_t group_ns,
Expand Down
48 changes: 9 additions & 39 deletions src/resource/ubridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -3575,8 +3575,8 @@ int sid_ucmd_dev_alias_del(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_ctx, co

const char **_do_sid_ucmd_dev_alias_get(sid_res_t *mod_res,
struct sid_ucmd_ctx *ucmd_ctx,
const char *foreign_dev_id,
const char *mod_name,
const char *foreign_dev_id,
const char *alias_key,
size_t *count)
{
Expand Down Expand Up @@ -3617,7 +3617,11 @@ const char **_do_sid_ucmd_dev_alias_get(sid_res_t *mod_res,
return (const char **) key_strv;
}

const char **sid_ucmd_dev_alias_get(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_ctx, const char *alias_key, size_t *count)
const char **sid_ucmd_dev_alias_get(sid_res_t *mod_res,
struct sid_ucmd_ctx *ucmd_ctx,
const char *mod_name,
const char *alias_key,
size_t *count)
{
if (!mod_res || !ucmd_ctx ||
(!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
Expand All @@ -3627,11 +3631,12 @@ const char **sid_ucmd_dev_alias_get(sid_res_t *mod_res, struct sid_ucmd_ctx *ucm
return NULL;
}

return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, NULL, _owner_name(mod_res), alias_key, count);
return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, mod_name, NULL, alias_key, count);
}

const char **sid_ucmd_dev_alias_get_foreign_dev(sid_res_t *mod_res,
struct sid_ucmd_ctx *ucmd_ctx,
const char *mod_name,
const char *foreign_dev_id,
const char *alias_key,
size_t *count)
Expand All @@ -3644,42 +3649,7 @@ const char **sid_ucmd_dev_alias_get_foreign_dev(sid_res_t *mod_res,
return NULL;
}

return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, foreign_dev_id, _owner_name(mod_res), alias_key, count);
}

const char **sid_ucmd_dev_alias_get_foreign_mod(sid_res_t *mod_res,
struct sid_ucmd_ctx *ucmd_ctx,
const char *foreign_mod_name,
const char *alias_key,
size_t *count)
{
if (!mod_res || !ucmd_ctx ||
(!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))) {
if (count)
*count = 0;
return NULL;
}

return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, NULL, foreign_mod_name, alias_key, count);
}

const char **sid_ucmd_dev_alias_get_foreign_dev_mod(sid_res_t *mod_res,
struct sid_ucmd_ctx *ucmd_ctx,
const char *foreign_dev_id,
const char *foreign_mod_name,
const char *alias_key,
size_t *count)
{
if (!mod_res || !ucmd_ctx || UTIL_STR_EMPTY(foreign_dev_id) ||
(!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))) {
if (count)
*count = 0;
return NULL;
}

return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, foreign_dev_id, foreign_mod_name, alias_key, count);
return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, mod_name, foreign_dev_id, alias_key, count);
}

static int _kv_cb_write_new_only(struct sid_kvs_update_spec *spec)
Expand Down

0 comments on commit 7563952

Please sign in to comment.