mirror of
https://github.com/linux-msm/cdba.git
synced 2026-02-25 13:11:56 -08:00
local_gpio: simplify yaml description
Instead of:
local_gpio:
- power:
chip: gpiochip0
line: 7
active_low: true
- fastboot_key:
chip: gpiochip0
line: 8
active_low: true
- power_key:
chip: gpiochip0
line: 14
active_low: true
- usb_disconnect:
chip: gpiochip1
line: 4
Accept the following:
local_gpio:
power:
chip: gpiochip0
line: 7
active_low: true
fastboot_key:
chip: gpiochip0
line: 8
active_low: true
power_key:
chip: gpiochip0
line: 14
active_low: true
usb_disconnect:
chip: gpiochip1
line: 4
It's simpler and clearer.
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
This commit is contained in:
30
README
30
README
@@ -66,21 +66,21 @@ devices:
|
||||
console: /dev/serial/by-id/usb-1234-if00-port0
|
||||
name: GPIO controller board
|
||||
local_gpio:
|
||||
- power:
|
||||
chip: gpiochip0
|
||||
line: 7
|
||||
active_low: true
|
||||
- fastboot_key:
|
||||
chip: gpiochip0
|
||||
line: 8
|
||||
active_low: true
|
||||
- power_key:
|
||||
chip: gpiochip0
|
||||
line: 14
|
||||
active_low: true
|
||||
- usb_disconnect:
|
||||
chip: gpiochip1
|
||||
line: 4
|
||||
power:
|
||||
chip: gpiochip0
|
||||
line: 7
|
||||
active_low: true
|
||||
fastboot_key:
|
||||
chip: gpiochip0
|
||||
line: 8
|
||||
active_low: true
|
||||
power_key:
|
||||
chip: gpiochip0
|
||||
line: 14
|
||||
active_low: true
|
||||
usb_disconnect:
|
||||
chip: gpiochip1
|
||||
line: 4
|
||||
fastboot: cacafada
|
||||
fastboot_set_active: true
|
||||
fastboot_key_timeout: 2
|
||||
|
||||
10
local-gpio.c
10
local-gpio.c
@@ -54,16 +54,14 @@ void *local_gpio_parse_options(struct device_parser *dp)
|
||||
char value[TOKEN_LENGTH];
|
||||
char key[TOKEN_LENGTH];
|
||||
|
||||
device_parser_expect(dp, YAML_SEQUENCE_START_EVENT, NULL, 0);
|
||||
device_parser_expect(dp, YAML_MAPPING_START_EVENT, NULL, 0);
|
||||
|
||||
options = calloc(1, sizeof(*options));
|
||||
|
||||
/* Loop over sub-properties */
|
||||
while (device_parser_accept(dp, YAML_MAPPING_START_EVENT, NULL, 0)) {
|
||||
while (device_parser_accept(dp, YAML_SCALAR_EVENT, key, TOKEN_LENGTH)) {
|
||||
int gpio_id;
|
||||
|
||||
device_parser_accept(dp, YAML_SCALAR_EVENT, key, TOKEN_LENGTH);
|
||||
|
||||
if (!strcmp(key, "power")) {
|
||||
gpio_id = GPIO_POWER;
|
||||
} else if (!strcmp(key, "fastboot_key")) {
|
||||
@@ -98,11 +96,9 @@ void *local_gpio_parse_options(struct device_parser *dp)
|
||||
device_parser_expect(dp, YAML_MAPPING_END_EVENT, NULL, 0);
|
||||
|
||||
options->gpios[gpio_id].present = true;
|
||||
|
||||
device_parser_expect(dp, YAML_MAPPING_END_EVENT, NULL, 0);
|
||||
}
|
||||
|
||||
device_parser_expect(dp, YAML_SEQUENCE_END_EVENT, NULL, 0);
|
||||
device_parser_expect(dp, YAML_MAPPING_END_EVENT, NULL, 0);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user