init: drop device union from struct init_entry
Such union is rather redundant, considering a simple const cast can be done when initializing the init entry. Note that the init_entry does not need to be touched now that struct device stores the init call. It is merely an init entry sorted by linker scripts, so we can intertwine devices and SYS_INIT. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
ed3377ae78
commit
3f6add69da
@ -1156,18 +1156,14 @@ device_get_dt_nodelabels(const struct device *dev)
|
||||
static const Z_DECL_ALIGN(struct init_entry) __used __noasan Z_INIT_ENTRY_SECTION( \
|
||||
level, prio, Z_DEVICE_INIT_SUB_PRIO(node_id)) \
|
||||
Z_INIT_ENTRY_NAME(DEVICE_NAME_GET(dev_id)) = { \
|
||||
COND_CODE_1(Z_DEVICE_IS_MUTABLE(node_id), \
|
||||
(.dev = { .dev_rw = &DEVICE_NAME_GET(dev_id)}), \
|
||||
(.dev = { .dev = &DEVICE_NAME_GET(dev_id)})) \
|
||||
.dev = (const struct device *)&DEVICE_NAME_GET(dev_id) \
|
||||
}
|
||||
|
||||
#define Z_DEFER_DEVICE_INIT_ENTRY_DEFINE(node_id, dev_id) \
|
||||
static const Z_DECL_ALIGN(struct init_entry) __used __noasan \
|
||||
__attribute__((__section__(".z_deferred_init"))) \
|
||||
Z_INIT_ENTRY_NAME(DEVICE_NAME_GET(dev_id)) = { \
|
||||
COND_CODE_1(Z_DEVICE_IS_MUTABLE(node_id), \
|
||||
(.dev = { .dev_rw = &DEVICE_NAME_GET(dev_id)}), \
|
||||
(.dev = { .dev = &DEVICE_NAME_GET(dev_id)})) \
|
||||
.dev = (const struct device *)&DEVICE_NAME_GET(dev_id) \
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -73,12 +73,7 @@ struct init_entry {
|
||||
* If the init entry belongs to a device, this fields stores a
|
||||
* reference to it, otherwise it is set to NULL.
|
||||
*/
|
||||
union {
|
||||
const struct device *dev;
|
||||
#ifdef CONFIG_DEVICE_MUTABLE
|
||||
struct device *dev_rw;
|
||||
#endif
|
||||
} dev;
|
||||
const struct device *dev;
|
||||
};
|
||||
|
||||
/** @cond INTERNAL_HIDDEN */
|
||||
|
||||
@ -360,7 +360,7 @@ static void z_sys_init_run_level(enum init_level level)
|
||||
const struct init_entry *entry;
|
||||
|
||||
for (entry = levels[level]; entry < levels[level+1]; entry++) {
|
||||
const struct device *dev = entry->dev.dev;
|
||||
const struct device *dev = entry->dev;
|
||||
int result;
|
||||
|
||||
sys_trace_sys_init_enter(entry, level);
|
||||
@ -381,7 +381,7 @@ int z_impl_device_init(const struct device *dev)
|
||||
}
|
||||
|
||||
STRUCT_SECTION_FOREACH_ALTERNATE(_deferred_init, init_entry, entry) {
|
||||
if (entry->dev.dev == dev) {
|
||||
if (entry->dev == dev) {
|
||||
return do_device_init(dev);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,25 +64,25 @@ DEVICE_DT_DEFINE(TEST_NOLABEL, dev_init, NULL,
|
||||
ZTEST(devicetree_devices, test_init_get)
|
||||
{
|
||||
/* Check device pointers */
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_GPIO)->dev.dev,
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_GPIO)->dev,
|
||||
DEVICE_DT_GET(TEST_GPIO), NULL);
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_I2C)->dev.dev,
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_I2C)->dev,
|
||||
DEVICE_DT_GET(TEST_I2C), NULL);
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_DEVA)->dev.dev,
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_DEVA)->dev,
|
||||
DEVICE_DT_GET(TEST_DEVA), NULL);
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_DEVB)->dev.dev,
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_DEVB)->dev,
|
||||
DEVICE_DT_GET(TEST_DEVB), NULL);
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_GPIOX)->dev.dev,
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_GPIOX)->dev,
|
||||
DEVICE_DT_GET(TEST_GPIOX), NULL);
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_DEVC)->dev.dev,
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_DEVC)->dev,
|
||||
DEVICE_DT_GET(TEST_DEVC), NULL);
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_PARTITION)->dev.dev,
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_PARTITION)->dev,
|
||||
DEVICE_DT_GET(TEST_PARTITION), NULL);
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_GPIO_INJECTED)->dev.dev,
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_GPIO_INJECTED)->dev,
|
||||
DEVICE_DT_GET(TEST_GPIO_INJECTED), NULL);
|
||||
zassert_equal(DEVICE_INIT_GET(manual_dev)->dev.dev,
|
||||
zassert_equal(DEVICE_INIT_GET(manual_dev)->dev,
|
||||
DEVICE_GET(manual_dev), NULL);
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_NOLABEL)->dev.dev,
|
||||
zassert_equal(DEVICE_INIT_DT_GET(TEST_NOLABEL)->dev,
|
||||
DEVICE_DT_GET(TEST_NOLABEL), NULL);
|
||||
|
||||
/* Check init functions */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user