Skip to content

Commit 0de6f6c

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 edcef3b commit 0de6f6c

File tree

2 files changed

+25
-47
lines changed

2 files changed

+25
-47
lines changed

Diff for: dt-rust.yaml

+25-43
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,68 +19,53 @@
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
# Flash controllers don't have any particular property to identify them, so we need a list of
3931
# compatible values that should match.
4032
- name: flash-controller
4133
rules:
42-
- type: compatible
43-
value:
34+
- !Compatible
4435
names:
45-
- "nordic,nrf52-flash-controller"
46-
- "nordic,nrf51-flash-controller"
47-
- "raspberrypi,pico-flash-controller"
48-
- "zephyr,sim-flash"
36+
- "nordic,nrf52-flash-controller"
37+
- "nordic,nrf51-flash-controller"
38+
- "raspberrypi,pico-flash-controller"
39+
- "zephyr,sim-flash"
4940
level: 0
5041
actions:
51-
- type: instance
52-
value:
53-
raw:
54-
type: myself
42+
- !Instance
43+
raw: !Myself
5544
device: crate::device::flash::FlashController
5645

5746
# Flash partitions exist as children of a node compatible with "soc-nv-flash" that itself is a child
5847
# of the controller itself.
5948
# TODO: Get the write and erase property from the DT if present.
6049
- name: flash-partition
6150
rules:
62-
- type: compatible
63-
value:
51+
- !Compatible
6452
names:
65-
- "fixed-partitions"
53+
- "fixed-partitions"
6654
level: 1
67-
- type: compatible
68-
value:
55+
- !Compatible
6956
names:
70-
- "soc-nv-flash"
57+
- "soc-nv-flash"
7158
level: 2
7259
actions:
73-
- type: instance
74-
value:
75-
raw:
76-
type: parent
77-
value:
78-
level: 3
79-
args:
80-
- type: reg
60+
- !Instance
61+
raw: !Parent
62+
level: 3
63+
args:
64+
- !Reg
8165
device: "crate::device::flash::FlashPartition"
8266

8367
# Generate a pseudo node that matches all of the labels across the tree with their nodes.
8468
- name: labels
85-
rules:
86-
- type: root
69+
rules: !Root
8770
actions:
88-
- type: labels
89-
71+
- !Labels

Diff for: zephyr-build/src/devicetree/augment.rs

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

7676
/// A matching rule.
7777
#[derive(Debug, Serialize, Deserialize)]
78-
#[serde(tag = "type", rename_all = "snake_case", content = "value")]
7978
pub enum Rule {
8079
/// A set of "or" matches.
8180
Or(Vec<Rule>),
@@ -121,7 +120,6 @@ fn parent_compatible(node: &Node, names: &[String], level: usize) -> bool {
121120

122121
/// An action to perform
123122
#[derive(Debug, Serialize, Deserialize)]
124-
#[serde(tag = "type", rename_all = "snake_case", content = "value")]
125123
pub enum Action {
126124
/// Generate an "instance" with a specific device name.
127125
Instance {
@@ -171,7 +169,6 @@ impl Action {
171169
}
172170

173171
#[derive(Debug, Serialize, Deserialize)]
174-
#[serde(tag = "type", rename_all = "snake_case", content = "value")]
175172
pub enum RawInfo {
176173
/// Get the raw device directly from this node.
177174
Myself,
@@ -270,7 +267,6 @@ impl RawInfo {
270267
///
271268
/// At this point, we assume these all come from the current node.
272269
#[derive(Debug, Serialize, Deserialize)]
273-
#[serde(tag = "type", rename_all = "snake_case", content = "value")]
274270
pub enum ArgInfo {
275271
/// The arguments come from a 'reg' property.
276272
Reg,

0 commit comments

Comments
 (0)