fastrpc: rpcd: give listener registration its own function

All operations part of registering the listener are together now. Split
them into their own function so the main() function isn't too big.
This commit is contained in:
Richard Acayan
2023-01-05 22:08:03 -05:00
parent b79db3f029
commit 49e21ebb4a

View File

@@ -130,9 +130,28 @@ static void remotectl_err(const char *err)
fprintf(stderr, "Could not remotectl: %s\n", err);
}
int main()
static int register_fastrpc_listener(int fd)
{
struct fastrpc_context *ctx;
int ret;
ret = remotectl_open(fd, "adsp_default_listener", &ctx, remotectl_err);
if (ret)
return 1;
ret = adsp_default_listener_register(ctx);
if (ret) {
fprintf(stderr, "Could not register ADSP default listener\n");
goto err;
}
err:
remotectl_close(ctx, remotectl_err);
return ret;
}
int main()
{
struct fastrpc_init_create_static create;
uint32_t rctx, handle, sc;
uint32_t inbufs_len;
@@ -162,18 +181,10 @@ int main()
goto err_close_dev;
}
ret = remotectl_open(fd, "adsp_default_listener", &ctx, remotectl_err);
ret = register_fastrpc_listener(fd);
if (ret)
goto err_close_dev;
ret = adsp_default_listener_register(ctx);
if (ret) {
fprintf(stderr, "Could not register ADSP default listener\n");
goto err_close_handle;
}
remotectl_close(ctx, remotectl_err);
ret = adsp_listener_init2(fd);
if (ret) {
fprintf(stderr, "Could not initialize the listener: %u\n", ret);
@@ -190,9 +201,6 @@ int main()
return 0;
err_close_handle:
remotectl_close(ctx, remotectl_err);
err_close_dev:
close(fd);
return 1;