zephyr/subsys/bluetooth/host
Gerard Marull-Paretas a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
..
a2dp_internal.h
a2dp.c Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log 2022-11-25 17:08:36 +01:00
addr_internal.h BluetootH: Host: add helper functions for resolved addresses 2023-01-12 13:31:12 +01:00
addr.c BluetootH: Host: add helper functions for resolved addresses 2023-01-12 13:31:12 +01:00
adv.c bluetooth: Fix linking issues with armclang 2023-04-05 19:32:34 +02:00
adv.h
aes_ccm.c Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log 2022-11-25 17:08:36 +01:00
at.c bluetooth: fix armclang compiler warnings with is*() functions 2023-03-31 09:19:16 +02:00
at.h
att_internal.h
att.c Bluetooth: host: downgrade select log messages 2023-03-16 12:56:48 +01:00
avdtp_internal.h
avdtp.c Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log 2022-11-25 17:08:36 +01:00
br.c bluetooth: host: Check for NULL discovery callbacks 2023-02-28 12:48:47 +01:00
br.h
buf.c Bluetooth: Fix clearing sent_cmd pointer when allocating event buffer 2023-04-11 16:57:37 +02:00
CMakeLists.txt Bluetooth: Move bt_data_parse to dedicated source file 2023-03-16 11:46:36 +01:00
conn_internal.h bluetooth: host: Add common helper for checking LTK presence 2023-03-28 16:15:58 +00:00
conn.c bluetooth: host: Fix checking if LTK is present 2023-03-29 15:54:47 +00:00
crypto.c Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log 2022-11-25 17:08:36 +01:00
crypto.h
data.c Bluetooth: Host: Move new bt_data functions to data.c 2023-03-21 18:17:52 +00:00
direction_internal.h
direction.c Bluetooth: host: df: Add missing bt_conn_unref in error cases 2023-03-23 08:56:07 +00:00
ecc.c tests: bluetooth: host: Add UT for bt_pub_key_gen() 2023-03-22 09:33:42 +01:00
ecc.h
gatt_internal.h
gatt.c bluetooth: host: Add common helper for checking LTK presence 2023-03-28 16:15:58 +00:00
hci_common.c
hci_core.c Bluetooth: Host: Remove unnecessary guarding 2023-03-31 14:01:33 +02:00
hci_core.h
hci_ecc.c Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log 2022-11-25 17:08:36 +01:00
hci_ecc.h
hci_raw_internal.h
hci_raw.c Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log 2022-11-25 17:08:36 +01:00
hfp_hf.c Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log 2022-11-25 17:08:36 +01:00
hfp_internal.h
id.c Bluetooth: host: adv: set the address in bt_le_adv_resume 2022-12-19 09:37:25 +00:00
id.h
iso_internal.h Bluetooth: audio: Fix declaring conn type object in header file 2023-03-28 15:07:09 +02:00
iso.c Bluetooth: iso: Add bt_iso_server_unregister function 2023-03-28 15:07:09 +02:00
Kconfig Bluetooth: Logging: Remove BT_DEBUG 2023-03-30 10:40:01 +00:00
Kconfig.gatt Bluetooth: Logging: Move all logging symbols together 2023-03-28 10:33:24 +02:00
Kconfig.l2cap Bluetooth: Logging: Move all logging symbols together 2023-03-28 10:33:24 +02:00
keys_br.c all: Fix "#if IS_ENABLED(CONFIG_FOO)" occurrences 2022-12-21 10:09:23 +01:00
keys.c tests: bluetooth: host: Add UT for bt_keys_update_usage() 2023-01-17 13:13:02 +01:00
keys.h
l2cap_br.c Bluetooth: L2CAP: Fix use of 'br_chan' 2023-02-20 09:53:26 +01:00
l2cap_internal.h Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log 2022-11-25 17:08:36 +01:00
l2cap.c sys: util: migrate all files to DIV_ROUND_UP 2023-04-11 12:00:37 +02:00
long_wq.c init: remove the need for a dummy device pointer in SYS_INIT functions 2023-04-12 14:28:07 +00:00
long_wq.h
monitor.c init: remove the need for a dummy device pointer in SYS_INIT functions 2023-04-12 14:28:07 +00:00
monitor.h
rfcomm_internal.h
rfcomm.c Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log 2022-11-25 17:08:36 +01:00
scan.c Bluetooth: Host: Fix handling of incomplete data status adv reports 2023-03-24 17:36:32 +00:00
scan.h
sdp_internal.h
sdp.c Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log 2022-11-25 17:08:36 +01:00
settings.c Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log 2022-11-25 17:08:36 +01:00
settings.h
smp_null.c Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log 2022-11-25 17:08:36 +01:00
smp.c Bluetooth: Host: Fix legacy OOB pairing as central 2023-04-07 13:36:41 +02:00
smp.h Bluetooth: Host: SMP Keypress Notification 2023-03-13 14:04:25 +01:00
ssp.c Bluetooth: Use Zephyr standard log system instead of bluetooth/common/log 2022-11-25 17:08:36 +01:00
ssp.h
testing.c Bluetooth: Mesh: Add Model Receive testing callback 2023-03-06 13:52:15 +01:00
testing.h Bluetooth: Mesh: Add Model Receive testing callback 2023-03-06 13:52:15 +01:00
uuid.c