zephyr/subsys/net/ip
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
..
6lo_private.h
6lo.c net: ip: 6lo: Fix corner case with packet format after IPHC 2023-02-19 20:33:36 -05:00
6lo.h
canbus_socket.c
canbus_socket.h
CMakeLists.txt
connection.c net: conn: Fix issues with SMP in connection code 2022-11-24 15:23:11 +01:00
connection.h
dhcpv4.c sys: util: migrate all files to DIV_ROUND_UP 2023-04-11 12:00:37 +02:00
dhcpv4.h
icmpv4.c
icmpv4.h
icmpv6.c net: icmpv6: fix if need calc tx checksum 2022-11-28 10:47:20 +01:00
icmpv6.h net: icmpv6: Implement IPv6 RA Recursive DNS Server option 2023-02-21 10:59:18 +01:00
igmp.c net: ipv4: Added mechanism to add 224.0.0.1 address to a multicast filter 2023-01-13 09:44:10 +01:00
ipv4_autoconf_internal.h
ipv4_autoconf.c net: ipv4: Fix subnet mask setting when autoconf is used 2023-02-06 10:10:54 +01:00
ipv4_fragment.c
ipv4.c
ipv4.h
ipv6_fragment.c
ipv6_mld.c net: ipv6: mld: Don't attempt to send a MLD query if iface is down 2023-02-08 11:26:42 +01:00
ipv6_nbr.c net: icmpv6: Initialize dns sockaddr in RA RDNSS 2023-02-22 14:26:39 +01:00
ipv6.c
ipv6.h
Kconfig net: ip: Kconfig for TCP packet allocation timeout 2023-04-12 10:22:12 +02:00
Kconfig.debug
Kconfig.ipv4 net: ipv4: Added mechanism to add 224.0.0.1 address to a multicast filter 2023-01-13 09:44:10 +01:00
Kconfig.ipv6 net: ipv6: Fix Kconfig dependencies when native IPv6 is disabled 2023-03-21 18:11:06 +00:00
Kconfig.mgmt net: ip: net_mgmt: Increase default queue size 2023-02-21 10:58:10 +01:00
Kconfig.stack
Kconfig.stats
nbr.c
nbr.h
net_context.c net: tcp: Fix TCP connection ref counting 2023-01-26 12:34:04 +00:00
net_core.c init: remove the need for a dummy device pointer in SYS_INIT functions 2023-04-12 14:28:07 +00:00
net_if.c net: dummy L2 for offloaded ifaces 2023-03-20 09:53:25 +01:00
net_mgmt.c net: ip: net_mgmt: Prevent loss of event 2023-02-21 10:58:10 +01:00
net_pkt.c net: pkt: Allow zero payload for non-IPv4/v6 frames 2023-02-06 10:04:03 +01:00
net_private.h net: ipv4: Added mechanism to add 224.0.0.1 address to a multicast filter 2023-01-13 09:44:10 +01:00
net_shell.c net: shell: Fix shell freeze 2023-03-25 07:49:18 -04:00
net_shell.h
net_stats.c
net_stats.h
net_tc_mapping.h
net_tc.c all: Fix "#if IS_ENABLED(CONFIG_FOO)" occurrences 2022-12-21 10:09:23 +01:00
net_timeout.c
packet_socket.c all: Fix "#if IS_ENABLED(CONFIG_FOO)" occurrences 2022-12-21 10:09:23 +01:00
packet_socket.h
promiscuous.c
route.c
route.h
tcp_internal.h net: tcp: Remove net_tcp_unref() 2023-01-26 12:34:04 +00:00
tcp_private.h net: ip: Kconfig for TCP packet allocation timeout 2023-04-12 10:22:12 +02:00
tcp.c net: tcp: Rework TCP SO_RCVBUF/SO_SNDBUF option handling 2023-03-20 16:54:41 +01:00
tcp.h net: tcp: Remove net_tcp_unref() 2023-01-26 12:34:04 +00:00
tp_priv.h
tp.c
tp.h all: Fix "#if IS_ENABLED(CONFIG_FOO)" occurrences 2022-12-21 10:09:23 +01:00
trickle.c
udp_internal.h
udp.c
utils.c