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
This commit is contained in:
Philipp Maier 2023-04-21 11:07:10 +02:00
parent a7e7621690
commit 2b880d6474
3 changed files with 13 additions and 1 deletions

View File

@ -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)

View File

@ -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 {

View File

@ -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;