Skip to content

Commit 2598bcd

Browse files
committed
Restrict device_has
1 parent 37a3e20 commit 2598bcd

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tools/targets/lint.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,21 @@ def check_inherits(dict):
6161
if ("inherits" in dict and len(dict["inherits"]) > 1):
6262
yield "multiple inheritance is forbidden"
6363

64+
DEVICE_HAS_ALLOWED = ["AACI", "ANALOGIN", "ANALOGOUT", "CAN", "CLCD",
65+
"ERROR_PATTERN", "ETHERNET", "EMAC", "FLASH", "I2C",
66+
"I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER",
67+
"PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "TRNG",
68+
"TSC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP",
69+
"SPI", "SPI_ASYNCH", "SPISLAVE", "STDIO_MESSAGES",
70+
"STORAGE", "SEMIHOST", "LOCALFILESYSTEM"]
71+
def check_device_has(dict):
72+
for name in dict.get("device_has", []):
73+
if name not in DEVICE_HAS_ALLOWED:
74+
yield "%s is not allowed in device_has" % name
75+
6476
MCU_REQUIRED_KEYS = ["release_versions", "supported_toolchains",
6577
"default_lib", "public", "inherits", "device_has"]
66-
MCU_ALLOWED_KEYS = ["device_has", "device_has_add", "device_has_remove", "core",
78+
MCU_ALLOWED_KEYS = ["device_has_add", "device_has_remove", "core",
6779
"extra_labels", "features", "features_add",
6880
"features_remove", "bootloader_supported", "device_name",
6981
"post_binary_hook", "default_toolchain", "config",
@@ -81,6 +93,7 @@ def check_mcu(mcu_json, strict=False):
8193
errors.extend(check_extra_labels(mcu_json))
8294
errors.extend(check_release_version(mcu_json))
8395
errors.extend(check_inherits(mcu_json))
96+
errors.extend(check_device_has(mcu_json))
8497
if 'public' in mcu_json and mcu_json['public']:
8598
errors.append("public must be false")
8699
return errors

0 commit comments

Comments
 (0)