Skip to content

Commit

Permalink
resource: ubridge: execute a scan phase only if a device is in suitab…
Browse files Browse the repository at this point in the history
…le ready state
  • Loading branch information
prajnoha committed Dec 13, 2023
1 parent e52b928 commit 511eee8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/resource/ubridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -4388,6 +4388,10 @@ static int _cmd_exec_scan_pre(sid_resource_t *cmd_res)
static int _cmd_exec_scan_current(sid_resource_t *cmd_res)
{
struct sid_ucmd_ctx *ucmd_ctx = sid_resource_get_data(cmd_res);
dev_ready_t ready = _do_sid_ucmd_dev_get_ready(NULL, sid_resource_get_data(cmd_res), 0);

if (!UTIL_IN_SET(ready, DEV_RDY_PRIVATE, DEV_RDY_FLAT, DEV_RDY_PUBLIC))
return 0;

_exec_block_mods(cmd_res);
return _exec_type_mod(cmd_res, ucmd_ctx->scan.type_mod_res_current);
Expand All @@ -4396,8 +4400,14 @@ static int _cmd_exec_scan_current(sid_resource_t *cmd_res)
static int _cmd_exec_scan_next(sid_resource_t *cmd_res)
{
struct sid_ucmd_ctx *ucmd_ctx = sid_resource_get_data(cmd_res);
dev_ready_t ready;
const char *next_mod_name;

ready = _do_sid_ucmd_dev_get_ready(NULL, ucmd_ctx, 0);

if (!UTIL_IN_SET(ready, DEV_RDY_PUBLIC))
return 0;

_exec_block_mods(cmd_res);

if ((next_mod_name = _do_sid_ucmd_get_kv(NULL,
Expand All @@ -4420,6 +4430,10 @@ static int _cmd_exec_scan_next(sid_resource_t *cmd_res)
static int _cmd_exec_scan_post_current(sid_resource_t *cmd_res)
{
struct sid_ucmd_ctx *ucmd_ctx = sid_resource_get_data(cmd_res);
dev_ready_t ready = _do_sid_ucmd_dev_get_ready(NULL, ucmd_ctx, 0);

if (!UTIL_IN_SET(ready, DEV_RDY_PRIVATE, DEV_RDY_FLAT, DEV_RDY_PUBLIC))
return 0;

_exec_block_mods(cmd_res);
return _exec_type_mod(cmd_res, ucmd_ctx->scan.type_mod_res_current);
Expand All @@ -4428,6 +4442,10 @@ static int _cmd_exec_scan_post_current(sid_resource_t *cmd_res)
static int _cmd_exec_scan_post_next(sid_resource_t *cmd_res)
{
struct sid_ucmd_ctx *ucmd_ctx = sid_resource_get_data(cmd_res);
dev_ready_t ready = _do_sid_ucmd_dev_get_ready(NULL, ucmd_ctx, 0);

if (!UTIL_IN_SET(ready, DEV_RDY_PUBLIC))
return 0;

_exec_block_mods(cmd_res);
return _exec_type_mod(cmd_res, ucmd_ctx->scan.type_mod_res_next);
Expand Down

0 comments on commit 511eee8

Please sign in to comment.