From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Kent Gibson <warthog618@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org, Chuang Zhu <git@chuang.cz>,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [libgpiod][PATCH v3 1/2] bindings: python: fix line request by name with multiple entries
Date: Wed, 10 Jul 2024 14:57:18 +0200 [thread overview]
Message-ID: <20240710125719.33655-2-brgl@bgdev.pl> (raw)
In-Reply-To: <20240710125719.33655-1-brgl@bgdev.pl>
From: Chuang Zhu <git@chuang.cz>
When multiple entries are requested using line names in
Chip.request_lines(), only the the last entry is added to
LineRequest._name_map, causing a ValueError when trying to use functions
like LineRequest.set_value() on any former entries.
Move the required variables to the correct scope.
Signed-off-by: Chuang Zhu <git@chuang.cz>
Co-developed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
[Bartosz: tweak the commit message]
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
bindings/python/gpiod/chip.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/bindings/python/gpiod/chip.py b/bindings/python/gpiod/chip.py
index 47bda11..7692ba4 100644
--- a/bindings/python/gpiod/chip.py
+++ b/bindings/python/gpiod/chip.py
@@ -279,11 +279,12 @@ class Chip:
else:
mapped_output_values = None
+ name_map = dict()
+ offset_map = dict()
+ global_output_values = list()
+
for lines, settings in config.items():
offsets = list()
- name_map = dict()
- offset_map = dict()
- global_output_values = list()
if isinstance(lines, int) or isinstance(lines, str):
lines = (lines,)
--
2.43.0
next prev parent reply other threads:[~2024-07-10 12:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-10 12:57 [libgpiod][PATCH v3 0/2] bindings: python: fix line request by name with multiple entries Bartosz Golaszewski
2024-07-10 12:57 ` Bartosz Golaszewski [this message]
2024-07-10 12:57 ` [libgpiod][PATCH v3 2/2] bindings: python: tests: add a new test case Bartosz Golaszewski
2024-07-10 13:34 ` [libgpiod][PATCH v3 0/2] bindings: python: fix line request by name with multiple entries Kent Gibson
2024-07-11 11:26 ` Bartosz Golaszewski
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=20240710125719.33655-2-brgl@bgdev.pl \
--to=brgl@bgdev.pl \
--cc=bartosz.golaszewski@linaro.org \
--cc=git@chuang.cz \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox