From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> Use the new line config function to shrink the gpioset code and drop one for loop. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> --- tools/gpioset.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/gpioset.c b/tools/gpioset.c index a871a16..1429d65 100644 --- a/tools/gpioset.c +++ b/tools/gpioset.c @@ -870,9 +870,9 @@ int main(int argc, char **argv) struct gpiod_line_config *line_cfg; struct line_resolver *resolver; enum gpiod_line_value *values; - int i, j, num_lines, ret; struct gpiod_chip *chip; unsigned int *offsets; + int i, num_lines, ret; struct config cfg; char **lines; @@ -933,15 +933,16 @@ int main(int argc, char **argv) values); gpiod_line_config_reset(line_cfg); - for (j = 0; j < num_lines; j++) { - gpiod_line_settings_set_output_value(settings, - values[j]); - - ret = gpiod_line_config_add_line_settings( - line_cfg, &offsets[j], 1, settings); - if (ret) - die_perror("unable to add line settings"); - } + + ret = gpiod_line_config_add_line_settings(line_cfg, offsets, + num_lines, settings); + if (ret) + die_perror("unable to add line settings"); + + ret = gpiod_line_config_set_output_values(line_cfg, + values, num_lines); + if (ret) + die_perror("unable to set output values"); chip = gpiod_chip_open(resolver->chips[i].path); if (!chip) -- 2.37.2