summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/host/trxcon/l1ctl_link.c36
-rw-r--r--src/host/trxcon/l1ctl_link.h2
-rw-r--r--src/host/trxcon/trxcon.c4
3 files changed, 20 insertions, 22 deletions
diff --git a/src/host/trxcon/l1ctl_link.c b/src/host/trxcon/l1ctl_link.c
index 1350c3c1..b7ea262a 100644
--- a/src/host/trxcon/l1ctl_link.c
+++ b/src/host/trxcon/l1ctl_link.c
@@ -229,59 +229,57 @@ int l1ctl_link_close_conn(struct l1ctl_link *l1l)
return 0;
}
-int l1ctl_link_init(struct l1ctl_link **l1l, const char *sock_path)
+struct l1ctl_link *l1ctl_link_init(void *tall_ctx, const char *sock_path)
{
- struct l1ctl_link *l1l_new;
+ struct l1ctl_link *l1l;
struct osmo_fd *bfd;
int rc;
LOGP(DL1C, LOGL_NOTICE, "Init L1CTL link (%s)\n", sock_path);
- l1l_new = talloc_zero(tall_trx_ctx, struct l1ctl_link);
- if (!l1l_new) {
+ l1l = talloc_zero(tall_ctx, struct l1ctl_link);
+ if (!l1l) {
LOGP(DL1C, LOGL_ERROR, "Failed to allocate memory\n");
- return -ENOMEM;
+ return NULL;
}
/* Allocate a new dedicated state machine */
- l1l_new->fsm = osmo_fsm_inst_alloc(&l1ctl_fsm, l1l_new,
+ l1l->fsm = osmo_fsm_inst_alloc(&l1ctl_fsm, l1l,
NULL, LOGL_DEBUG, "l1ctl_link");
- if (l1l_new->fsm == NULL) {
+ if (l1l->fsm == NULL) {
LOGP(DTRX, LOGL_ERROR, "Failed to allocate an instance "
"of FSM '%s'\n", l1ctl_fsm.name);
- talloc_free(l1l_new);
- return -ENOMEM;
+ talloc_free(l1l);
+ return NULL;
}
/* Create a socket and bind handlers */
- bfd = &l1l_new->listen_bfd;
+ bfd = &l1l->listen_bfd;
rc = osmo_sock_unix_init_ofd(bfd, SOCK_STREAM, 0, sock_path,
OSMO_SOCK_F_BIND);
if (rc < 0) {
LOGP(DL1C, LOGL_ERROR, "Could not create UNIX socket: %s\n",
strerror(errno));
- osmo_fsm_inst_free(l1l_new->fsm);
- talloc_free(l1l_new);
- return rc;
+ osmo_fsm_inst_free(l1l->fsm);
+ talloc_free(l1l);
+ return NULL;
}
/* Bind shutdown handler */
- l1l_new->shutdown_cb = l1ctl_shutdown_cb;
+ l1l->shutdown_cb = l1ctl_shutdown_cb;
/* Bind connection handler */
bfd->cb = l1ctl_link_accept;
bfd->when = BSC_FD_READ;
- bfd->data = l1l_new;
+ bfd->data = l1l;
/**
* To be able to accept first connection and
* drop others, it should be set to -1
*/
- l1l_new->wq.bfd.fd = -1;
+ l1l->wq.bfd.fd = -1;
- *l1l = l1l_new;
-
- return 0;
+ return l1l;
}
void l1ctl_link_shutdown(struct l1ctl_link *l1l)
diff --git a/src/host/trxcon/l1ctl_link.h b/src/host/trxcon/l1ctl_link.h
index 01103dcc..da64419a 100644
--- a/src/host/trxcon/l1ctl_link.h
+++ b/src/host/trxcon/l1ctl_link.h
@@ -41,7 +41,7 @@ struct l1ctl_link {
void (*shutdown_cb)(struct l1ctl_link *l1l);
};
-int l1ctl_link_init(struct l1ctl_link **l1l, const char *sock_path);
+struct l1ctl_link *l1ctl_link_init(void *tall_ctx, const char *sock_path);
void l1ctl_link_shutdown(struct l1ctl_link *l1l);
int l1ctl_link_send(struct l1ctl_link *l1l, struct msgb *msg);
diff --git a/src/host/trxcon/trxcon.c b/src/host/trxcon/trxcon.c
index 501d0c72..777138f6 100644
--- a/src/host/trxcon/trxcon.c
+++ b/src/host/trxcon/trxcon.c
@@ -279,8 +279,8 @@ int main(int argc, char **argv)
NULL, LOGL_DEBUG, "main");
/* Init L1CTL server */
- rc = l1ctl_link_init(&app_data.l1l, app_data.bind_socket);
- if (rc)
+ app_data.l1l = l1ctl_link_init(tall_trx_ctx, app_data.bind_socket);
+ if (app_data.l1l == NULL)
goto exit;
/* Init transceiver interface */