devicetree: add CONFIG_LEGACY_DEVICETREE_MACROS

This default-y option allows continued use of the legacy devicetree
macros.

There are no functional changes yet, but when this is default n,
old-style DT code won't build. At that point, adding any of these will
be a fix to keep old-style code working:

- "CONFIG_LEGACY_DEVICETREE_MACROS=y" to prj.conf
- "-- -DCONFIG_LEGACY_DEVICETREE_MACROS=y" to the west build command
- "-DCONFIG_LEGACY_DEVICETREE_MACROS=y" to the cmake command

This option can be changed to default n in time for the Zephyr 2.3
release. That will provide users of Zephyr 2.2 with a smooth migration
path to the new devicetree.h API after 2.3 is released, which
nonetheless will alert them immediately that something is wrong due to
build errors.

Unfortunately, __DEPRECATED_MACRO is not sufficient in all cases as a
warning to users. This is because, at least in GCC, macros defined
using __DEPRECATED_MACRO cannot be used in preprocessor lines like
"#if DT_SOME_LEGACY_MACRO".

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2020-04-15 14:11:05 -07:00 committed by Kumar Gala
commit 270dfffc8d
3 changed files with 26 additions and 0 deletions

View file

@ -16,8 +16,20 @@
#ifndef DEVICETREE_H
#define DEVICETREE_H
#ifdef _LINKER
/*
* Linker scripts include this file too, and autoconf.h isn't
* automatically included for those files the way it is for C source
* files. Make sure we pull it in before using
* CONFIG_LEGACY_DEVICETREE_MACROS in that case.
*/
#include <autoconf.h>
#endif
#include <devicetree_unfixed.h>
#ifdef CONFIG_LEGACY_DEVICETREE_MACROS
#include <devicetree_legacy_unfixed.h>
#endif
#include <devicetree_fixups.h>
#include <sys/util.h>