Skip to content

Conversation

@tbursztyka
Copy link
Contributor

DO NOT REVIEW YET (I just need to see first what CI will find out, my potato PC cannot run the whole test suites)

This is a fix for #76937 after discussing on the RFC #73836

I applied most comments made during these discussion.

  • Keeping current macros unchanged and able to live with the new ones
  • Adding new macros: both for device and service (not init, SYS_INIT() will be deprecated as well anyway). Taking the opportunity to reduce the number of macros. Basically merging DT/non-DT based macros, so removing manually introduced device name. This is a legacy thing that needs to disappear. Explicit device name is coming from the time DTS was not used, and during the process of switching to DTS we had to keep it. Now it's not true anymore. The new macros still can instantiate a non-DT device, but it will take the unique token as a name and that's it.
  • Declaring the explicit dependency resolution file to cmake via cmake functions and not by looking up on pre-determined places (only on the application side, I could not use such cmake function, so there it has to be a specific file, unless I misunderstood something with the build process)
  • The new service API is extremely minimal as it is meant to just replace SYS_INIT where relevant (like, say: net_init, and not all the places where SYS_INIT should not have been used). BUT: it will grow, there are plenty of rooms for improvements. We could start/stop/pause a service if needed, etc etc...

Added to this I (tried to) switch most device macro calls to new ones. Which make this PR a huge one in files touched and modified lines. There are few corner cases which prevent changes: PTP and ethernet's DSA. These needs to switch to DTS.

Last but not least: brace for impact /o\

Switching to DEVICE_INSTANCE and DEVICE_INSTANCE_FROM_DT_INST, thus
merging former DEVICE_DEFINE and DEVICE_DT_DEFINE into one, so removing
the name parameter from the earier and finally removing the prio
parameter on all.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to DEVICE_INSTANCE and DEVICE_INSTANCE_FROM_DT_INST, thus
merging former DEVICE_DEFINE and DEVICE_DT_DEFINE into one, so removing
the name parameter from the earier and finally removing the prio
parameter on all.

Signed-off-by: Tomasz Bursztyka <[email protected]>
In order to get rid of the manually inserted initialization priority,
device object generation need new macros.

Again removing the prio parameter.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to SENSOR_DEVICE_INSTANCE and
SENSOR_DEVICE_INSTANCE_FROM_DT_INST, thus removing the prio parameter
on all.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio parameter.

Managing the ident as a DT node-id or dev_id helps to reduce the number
from 12 to 7 macros.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to NET_DEVICE_INSTANCE, NET_DEVICE_INSTANCE_FROM_DT_INST,
NET_DEVICE_INSTANCE_MULTI, NET_DEVICE_INSTANCE_MULT_FROM_DT_INST,
NET_DEVICE_OFFLOAD_INSTANCE and
NET_DEVICE_OFFLOAD_INSTANCE_FROM_DT_INST.

Thus removing prio and name parameters on all.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio and name parameters.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to ETH_NET_DEVICE_INSTANCE,
ETH_NET_DEVICE_INSTANCE_FROM_DT_INST and ETH_NET_DEVICE_INSTANCE_MULTI.

Thus removing prio and name parameters on all.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to NET_DEVICE_INSTANCE, NET_DEVICE_INSTANCE_FROM_DT_INST,
NET_DEVICE_INSTANCE_MULTI, NET_DEVICE_INSTANCE_MULT_FROM_DT_INST,
NET_DEVICE_OFFLOAD_INSTANCE and
NET_DEVICE_OFFLOAD_INSTANCE_FROM_DT_INST.

Thus removing prio and name parameters on all.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio parameter.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to CAN_DEVICE_INSTANCE and CAN_DEVICE_INSTANCE_FROM_DT_INST
relevantly.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio parameter.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to SMBUS_DEVICE_INSTANCE and
SMBUS_DEVICE_INSTANCE_FROM_DT_INST relevantly.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Lone files that define their own wrapper macro on top of formely
DEVICE_DT_DEFINE macros.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio parameter.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to I2C_DEVICE_INSTANCE and I2C_DEVICE_INSTANCE_FROM_DT_INST
relevantly.

Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio parameter.

However, original macro does not seem to be used anywhere...

Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio parameter.

And switching the unique macro call in drivers.

Signed-off-by: Tomasz Bursztyka <[email protected]>
A few test and samples require explicit dependency resolution as the
devices they introduce do not have any DTS counter-part.

Signed-off-by: Tomasz Bursztyka <[email protected]>
A few device drivers need to get the dependency properly set up.
This is only true for non-DT based devices.

One of the changes being the device "unike token" which was made of
capital letter for some reason on crypto side etc...

Basically, legcay things that should disappear and be fully managed at
DTS level.

Signed-off-by: Tomasz Bursztyka <[email protected]>
It's clearly a bug: an input device is not meant to listen to itself.
This creates a dependency loop, and it is actually surprising this did
not get detected by DTS (which does call add_edge on graph on the same
node).

Binding description of the node says 'input' property can be left empty
so removing the line entirely.

Signed-off-by: Tomasz Bursztyka <[email protected]>
linker-defs.h does a weird trick around DT_NODE_HAS_STATUS. The issue is
that intrications of includes might anyway end up including
linker-defs.h and devicetree.h (as it requires other macros in that last
header).

Signed-off-by: Tomasz Bursztyka <[email protected]>
Now that init ordering got back to a unique number (automatically
computed or provided manually with legacy macros) the priorities need to
be sorted relevantly so the erroneous ordering still matches the
expectations.

When legacy macros will be removed after a deprecation period, such test
and most probably check_init_priorities.py tool as well won't make sense
anymore.

Signed-off-by: Tomasz Bursztyka <[email protected]>
@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Device Management area: Device Model DNM This PR should not be merged (Do Not Merge) Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants