All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Kent Gibson <warthog618@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-gpio@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [libgpiod][PATCH v2 4/8] gpioset: use gpiod_line_config_set_output_values()
Date: Fri, 20 Jan 2023 10:45:11 +0100	[thread overview]
Message-ID: <20230120094515.40464-5-brgl@bgdev.pl> (raw)
In-Reply-To: <20230120094515.40464-1-brgl@bgdev.pl>

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Use the new line config function to shrink the gpioset code and drop one
for loop.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 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


  parent reply	other threads:[~2023-01-20  9:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20  9:45 [libgpiod][PATCH v2 0/8] treewide: continue beating libgpiod v2 into shape for an upcoming release Bartosz Golaszewski
2023-01-20  9:45 ` [libgpiod][PATCH v2 1/8] README: update for libgpiod v2 Bartosz Golaszewski
2023-01-20  9:45 ` [libgpiod][PATCH v2 2/8] treewide: unify gpiod_line_config/request_get_offsets() functions Bartosz Golaszewski
2023-01-20  9:45 ` [libgpiod][PATCH v2 3/8] core: provide gpiod_line_config_set_output_values() Bartosz Golaszewski
2023-01-20  9:45 ` Bartosz Golaszewski [this message]
2023-01-20  9:45 ` [libgpiod][PATCH v2 5/8] bindings: cxx: add line_config.set_output_values() Bartosz Golaszewski
2023-01-20  9:45 ` [libgpiod][PATCH v2 6/8] bindings: python: add the output_values argument to Chip.request_lines() Bartosz Golaszewski
2023-01-20  9:45 ` [libgpiod][PATCH v2 7/8] bindings: rust: make mutators return &mut self Bartosz Golaszewski
2023-01-25  9:25   ` Viresh Kumar
2023-01-20  9:45 ` [libgpiod][PATCH v2 8/8] bindings: rust: provide line_config.set_output_values() Bartosz Golaszewski
2023-01-25  9:25   ` Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230120094515.40464-5-brgl@bgdev.pl \
    --to=brgl@bgdev.pl \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=viresh.kumar@linaro.org \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.