Skip to content

Commit 0f75e9e

Browse files
committed
zephyr-build: Simplify dt-yaml syntax
The Serde "tag" rules was being used for enums, which results in enums being generated in a somewhat awkward format. Remove this, and change the syntax of the dt-rust.yaml file to match. This typically results in changes like: - type: instance value: raw: type: myself to be simplified to just: - !Instance raw: !Myself Signed-off-by: David Brown <[email protected]>
1 parent f26a507 commit 0f75e9e

File tree

2 files changed

+38
-67
lines changed

2 files changed

+38
-67
lines changed

dt-rust.yaml

+38-63
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@
77
# few instances were we can actually just match on a property.
88
- name: gpio-controller
99
rules:
10-
- type: has_prop
11-
value: gpio-controller
10+
- !HasProp gpio-controller
1211
actions:
13-
- type: instance
14-
value:
15-
raw:
16-
type: myself
12+
- !Instance
13+
raw: !Myself
1714
device: crate::device::gpio::Gpio
1815
static_type: crate::device::gpio::GpioStatic
1916

@@ -22,101 +19,79 @@
2219
# with each gpio.
2320
- name: gpio-leds
2421
rules:
25-
- type: compatible
26-
value:
27-
names:
28-
- gpio-leds
22+
- !Compatible
23+
names: [gpio-leds]
2924
level: 1
3025
actions:
31-
- type: instance
32-
value:
33-
raw:
34-
type: phandle
35-
value: gpios
26+
- !Instance
27+
raw: !Phandle gpios
3628
device: crate::device::gpio::GpioPin
3729

3830
# Hook up the gpio-keys as gpio pins as well
3931
- name: gpio-keys
4032
rules:
41-
- type: compatible
42-
value:
33+
- !Compatible
4334
names:
44-
- gpio-keys
35+
- gpio-keys
4536
level: 1
4637
actions:
47-
- type: instance
48-
value:
49-
raw:
50-
type: phandle
51-
value: gpios
38+
- !Instance
39+
raw: !Phandle gpios
5240
device: crate::device::gpio::GpioPin
5341

5442
# Flash controllers don't have any particular property to identify them, so we need a list of
5543
# compatible values that should match.
5644
- name: flash-controller
5745
rules:
58-
- type: compatible
59-
value:
46+
- !Compatible
6047
names:
61-
- "nordic,nrf52-flash-controller"
62-
- "nordic,nrf51-flash-controller"
63-
- "raspberrypi,pico-flash-controller"
64-
- "st,stm32g4-flash-controller"
65-
- "st,stm32l5-flash-controller"
66-
- "zephyr,sim-flash"
48+
- "nordic,nrf52-flash-controller"
49+
- "nordic,nrf51-flash-controller"
50+
- "raspberrypi,pico-flash-controller"
51+
- "st,stm32g4-flash-controller"
52+
- "st,stm32l5-flash-controller"
53+
- "zephyr,sim-flash"
6754
level: 0
6855
actions:
69-
- type: instance
70-
value:
71-
raw:
72-
type: myself
56+
- !Instance
57+
raw: !Myself
7358
device: crate::device::flash::FlashController
7459

7560
# Flash partitions exist as children of a node compatible with "soc-nv-flash" that itself is a child
7661
# of the controller itself.
7762
# TODO: Get the write and erase property from the DT if present.
7863
- name: flash-partition
7964
rules:
80-
- type: compatible
81-
value:
65+
- !Compatible
8266
names:
83-
- "fixed-partitions"
67+
- "fixed-partitions"
8468
level: 1
85-
- type: compatible
86-
value:
69+
- !Compatible
8770
names:
88-
- "soc-nv-flash"
71+
- "soc-nv-flash"
8972
level: 2
9073
actions:
91-
- type: instance
92-
value:
93-
raw:
94-
type: parent
95-
value:
96-
level: 3
97-
args:
98-
- type: reg
74+
- !Instance
75+
raw: !Parent
76+
level: 3
77+
args:
78+
- !Reg
9979
device: "crate::device::flash::FlashPartition"
10080

10181
# I2C.
10282
- name: i2c
10383
rules:
104-
- type: compatible
105-
value:
106-
names:
107-
- "snps,designware-i2c"
108-
level: 0
84+
- !Compatible
85+
names:
86+
- "snps,designware-i2c"
87+
level: 0
10988
actions:
110-
- type: instance
111-
value:
112-
raw:
113-
type: myself
114-
device: crate::device::i2c::I2C
89+
- !Instance
90+
raw: !Myself
91+
device: crate::device::i2c::I2C
11592

11693
# Generate a pseudo node that matches all of the labels across the tree with their nodes.
11794
- name: labels
118-
rules:
119-
- type: root
95+
rules: !Root
12096
actions:
121-
- type: labels
122-
97+
- !Labels

zephyr-build/src/devicetree/augment.rs

-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ impl Augment for Augmentation {
8181

8282
/// A matching rule.
8383
#[derive(Debug, Serialize, Deserialize)]
84-
#[serde(tag = "type", rename_all = "snake_case", content = "value")]
8584
pub enum Rule {
8685
/// A set of "or" matches.
8786
Or(Vec<Rule>),
@@ -127,7 +126,6 @@ fn parent_compatible(node: &Node, names: &[String], level: usize) -> bool {
127126

128127
/// An action to perform
129128
#[derive(Debug, Serialize, Deserialize)]
130-
#[serde(tag = "type", rename_all = "snake_case", content = "value")]
131129
pub enum Action {
132130
/// Generate an "instance" with a specific device name.
133131
Instance {
@@ -177,7 +175,6 @@ impl Action {
177175
}
178176

179177
#[derive(Debug, Serialize, Deserialize)]
180-
#[serde(tag = "type", rename_all = "snake_case", content = "value")]
181178
pub enum RawInfo {
182179
/// Get the raw device directly from this node.
183180
Myself,
@@ -276,7 +273,6 @@ impl RawInfo {
276273
///
277274
/// At this point, we assume these all come from the current node.
278275
#[derive(Debug, Serialize, Deserialize)]
279-
#[serde(tag = "type", rename_all = "snake_case", content = "value")]
280276
pub enum ArgInfo {
281277
/// The arguments come from a 'reg' property.
282278
Reg,

0 commit comments

Comments
 (0)