sock/net_framework: Adding a static inline function to get next framework.
This can remove these duplicated codes. Signed-off-by: yidong0635 <dongx.yi@intel.com> Change-Id: Ie6590fc10e72471dbc6f0c1ac9c14eb3edfa3599 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2769 Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
ea02571d0f
commit
7b77e06801
@ -46,6 +46,12 @@ static void *g_fini_cb_arg = NULL;
|
|||||||
|
|
||||||
struct spdk_net_framework *g_next_net_framework = NULL;
|
struct spdk_net_framework *g_next_net_framework = NULL;
|
||||||
|
|
||||||
|
static inline struct spdk_net_framework *
|
||||||
|
get_next_net_framework(struct spdk_net_framework *net)
|
||||||
|
{
|
||||||
|
return net ? STAILQ_NEXT(net, link) : STAILQ_FIRST(&g_net_frameworks);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spdk_net_framework_init_next(int rc)
|
spdk_net_framework_init_next(int rc)
|
||||||
{
|
{
|
||||||
@ -55,12 +61,7 @@ spdk_net_framework_init_next(int rc)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_next_net_framework == NULL) {
|
g_next_net_framework = get_next_net_framework(g_next_net_framework);
|
||||||
g_next_net_framework = STAILQ_FIRST(&g_net_frameworks);
|
|
||||||
} else {
|
|
||||||
g_next_net_framework = STAILQ_NEXT(g_next_net_framework, link);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_next_net_framework == NULL) {
|
if (g_next_net_framework == NULL) {
|
||||||
g_init_cb_fn(g_init_cb_arg, 0);
|
g_init_cb_fn(g_init_cb_arg, 0);
|
||||||
return;
|
return;
|
||||||
@ -81,12 +82,7 @@ spdk_net_framework_start(spdk_net_init_cb cb_fn, void *cb_arg)
|
|||||||
void
|
void
|
||||||
spdk_net_framework_fini_next(void)
|
spdk_net_framework_fini_next(void)
|
||||||
{
|
{
|
||||||
if (g_next_net_framework == NULL) {
|
g_next_net_framework = get_next_net_framework(g_next_net_framework);
|
||||||
g_next_net_framework = STAILQ_FIRST(&g_net_frameworks);
|
|
||||||
} else {
|
|
||||||
g_next_net_framework = STAILQ_NEXT(g_next_net_framework, link);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_next_net_framework == NULL) {
|
if (g_next_net_framework == NULL) {
|
||||||
g_fini_cb_fn(g_fini_cb_arg);
|
g_fini_cb_fn(g_fini_cb_arg);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user