Skip to content

Commit abcf427

Browse files
authored
Merge pull request #50 from superna9999/local-gpio-yaml-fix
local_gpio: simplify yaml description
2 parents 494b048 + e08d14a commit abcf427

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

README

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,21 @@ devices:
6666
console: /dev/serial/by-id/usb-1234-if00-port0
6767
name: GPIO controller board
6868
local_gpio:
69-
- power:
70-
chip: gpiochip0
71-
line: 7
72-
active_low: true
73-
- fastboot_key:
74-
chip: gpiochip0
75-
line: 8
76-
active_low: true
77-
- power_key:
78-
chip: gpiochip0
79-
line: 14
80-
active_low: true
81-
- usb_disconnect:
82-
chip: gpiochip1
83-
line: 4
69+
power:
70+
chip: gpiochip0
71+
line: 7
72+
active_low: true
73+
fastboot_key:
74+
chip: gpiochip0
75+
line: 8
76+
active_low: true
77+
power_key:
78+
chip: gpiochip0
79+
line: 14
80+
active_low: true
81+
usb_disconnect:
82+
chip: gpiochip1
83+
line: 4
8484
fastboot: cacafada
8585
fastboot_set_active: true
8686
fastboot_key_timeout: 2

local-gpio.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,14 @@ void *local_gpio_parse_options(struct device_parser *dp)
5454
char value[TOKEN_LENGTH];
5555
char key[TOKEN_LENGTH];
5656

57-
device_parser_expect(dp, YAML_SEQUENCE_START_EVENT, NULL, 0);
57+
device_parser_expect(dp, YAML_MAPPING_START_EVENT, NULL, 0);
5858

5959
options = calloc(1, sizeof(*options));
6060

6161
/* Loop over sub-properties */
62-
while (device_parser_accept(dp, YAML_MAPPING_START_EVENT, NULL, 0)) {
62+
while (device_parser_accept(dp, YAML_SCALAR_EVENT, key, TOKEN_LENGTH)) {
6363
int gpio_id;
6464

65-
device_parser_accept(dp, YAML_SCALAR_EVENT, key, TOKEN_LENGTH);
66-
6765
if (!strcmp(key, "power")) {
6866
gpio_id = GPIO_POWER;
6967
} else if (!strcmp(key, "fastboot_key")) {
@@ -98,11 +96,9 @@ void *local_gpio_parse_options(struct device_parser *dp)
9896
device_parser_expect(dp, YAML_MAPPING_END_EVENT, NULL, 0);
9997

10098
options->gpios[gpio_id].present = true;
101-
102-
device_parser_expect(dp, YAML_MAPPING_END_EVENT, NULL, 0);
10399
}
104100

105-
device_parser_expect(dp, YAML_SEQUENCE_END_EVENT, NULL, 0);
101+
device_parser_expect(dp, YAML_MAPPING_END_EVENT, NULL, 0);
106102

107103
return options;
108104
}

0 commit comments

Comments
 (0)