From 2b880d6474d15f58d58dfc62616d29f72e62776a Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Fri, 21 Apr 2023 11:07:10 +0200 Subject: [PATCH] e1_input: add new driver callback function: line_create When a line is created using e1inp_line_create, then the line data structures are initialized and the line is registered in the line list. struct e1inp_line also contains driver specific sub structs that, depending on the driver, might also need some initialization. At the moment is no way. Let's add a line_create callback that, when populated by the driver, is executed on line creation. Related: OS#5983 Change-Id: I404fa23e9b8a952be84e9716889c0dbbbc665d22 --- TODO-RELEASE | 1 + include/osmocom/abis/e1_input.h | 3 +++ src/e1_input.c | 10 +++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/TODO-RELEASE b/TODO-RELEASE index 5f2f654..99d9735 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -9,3 +9,4 @@ #library what description / commit summary line libosmo-abis struct e1inp_driver Field added at the end (ABI break) libosmocodec >1.8.0 osmo_{fr,efr}_sid_classify() new functions +libosmo-abis struct e1inp_driver Field added (line_create callback) at the end (ABI break) diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index a66f8eb..b40382e 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -190,6 +190,9 @@ struct e1inp_driver { /* Set Sa bits to transmit in TS0 (MSB to LSB): Sa8 Sa7 Sa5 Sa4 Sa64 Sa63 Sa62 Sa61/Sa6 */ int (*set_sa_bits)(struct e1inp_line *line, uint8_t sa_bits); + + /* Optional callback to perform driver specific initialization when the line is created. */ + int (*line_create)(struct e1inp_line *line); }; struct e1inp_line_ops { diff --git a/src/e1_input.c b/src/e1_input.c index e3ac67e..6fca307 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -639,8 +639,16 @@ e1inp_line_create(uint8_t e1_nr, const char *driver_name) line->use_count.talloc_object = line; line->use_count.use_cb = e1inp_line_use_cb; - e1inp_line_get2(line, "ctor"); + if (driver->line_create) { + if (driver->line_create(line) < 0) { + LOGPIL(line, DLINP, LOGL_ERROR, "Cannot initialize line driver\n"); + talloc_free(line); + return NULL; + } + } + + e1inp_line_get2(line, "ctor"); llist_add_tail(&line->list, &e1inp_line_list); return line;