Skip to content

devicetree/memory.h probably should not exist as-is #38886

@mbolivar-nordic

Description

@mbolivar-nordic

Describe the bug

Originally introduced in #35460. I have no idea how I missed all of this in review, but it showed up while I was working on release notes.

Marking high because it affects a stable API (devicetree.h) and these concerns ought to be fixed before we include the new API in the v2.7 LTS release with known mistakes from an API perspective.

  1. we should not be adding any include/devicetree/foo.h headers for manual inclusion; they should be included at the bottom of devicetree.h. So either devicetree/memory.h is in the wrong place or it needs to be included from devicetree.h.
  2. At least some of the contents are in the wrong place. Specifically #define DT_RESERVED_MEM_GET_PTR(node_id) _DT_RESERVED_START(node_id) refers to _DT_RESERVED_START, which is defined in include/linker/devicetree_reserved.h. This is a layering violation as devicetree.h macros should not depend on contents of higher layer headers.
  3. No documentation was added to doc/reference/devicetree/api.rst for the macros in devicetree/memory.h
  4. No explicit test coverage under tests/lib/devicetree exists; we require all macros to have API tests and docs.

Given the above, my suspicion is that these macros should probably all go to linker/devicetree_reserved.h. This is not an officially documented API (in the sense of https://docs.zephyrproject.org/latest/reference/api/overview.html) and can therefore basically do whatever it wants without getting into as much trouble from an API stability perspective.

Environment (please complete the following information):

  • Commit SHA or Version used: v2.7.0-rc3

Metadata

Metadata

Assignees

Labels

bugThe issue is a bug, or the PR is fixing a bugpriority: highHigh impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions