From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Vincent Fazio <vfazio@xes-inc.com>,
Kent Gibson <warthog618@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Erik Schilling <erik.schilling@linaro.org>,
Phil Howard <phil@gadgetoid.com>,
Viresh Kumar <viresh.kumar@linaro.org>,
Koichiro Den <koichiro.den@canonical.com>
Cc: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
linux-gpio@vger.kernel.org
Subject: [PATCH libgpiod 2/3] bindings: python: tests: disable device before releasing the bank
Date: Mon, 03 Feb 2025 14:25:04 +0100 [thread overview]
Message-ID: <20250203-fix-gpiosim-in-bindings-v1-2-d2c9e0f3a29d@linaro.org> (raw)
In-Reply-To: <20250203-fix-gpiosim-in-bindings-v1-0-d2c9e0f3a29d@linaro.org>
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Linux kernel commit 8bd76b3d3f3a ("gpio: sim: lock up configfs that an
instantiated device depends on") uncovered an issue in Python bindings
tests where the GPIO simulator device is not disabled before removing its
configfs entries. Reorder the operations in chip_finalize() in order to
disable the device first (if needed) before releasing any other
resources.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
bindings/python/tests/gpiosim/ext.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/bindings/python/tests/gpiosim/ext.c b/bindings/python/tests/gpiosim/ext.c
index 272e6f7..cb5611a 100644
--- a/bindings/python/tests/gpiosim/ext.c
+++ b/bindings/python/tests/gpiosim/ext.c
@@ -96,15 +96,16 @@ static int chip_init(chip_object *self,
static void chip_finalize(chip_object *self)
{
- if (self->bank)
- gpiosim_bank_unref(self->bank);
-
if (self->dev) {
if (gpiosim_dev_is_live(self->dev))
gpiosim_dev_disable(self->dev);
-
- gpiosim_dev_unref(self->dev);
}
+
+ if (self->bank)
+ gpiosim_bank_unref(self->bank);
+
+ if (self->dev)
+ gpiosim_dev_unref(self->dev);
}
static void chip_dealloc(PyObject *self)
--
2.45.2
next prev parent reply other threads:[~2025-02-03 13:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-03 13:25 [PATCH libgpiod 0/3] bindings: fix ordering of releasing of gpiosim resources Bartosz Golaszewski
2025-02-03 13:25 ` [PATCH libgpiod 1/3] bindings: cxx: tests: disable GPIO simulator before releasing it Bartosz Golaszewski
2025-02-03 13:25 ` Bartosz Golaszewski [this message]
2025-02-03 13:25 ` [PATCH libgpiod 3/3] bindings: rust: tests: disable device before dropping the resources Bartosz Golaszewski
2025-02-04 4:18 ` Viresh Kumar
2025-02-04 8:29 ` Bartosz Golaszewski
2025-02-05 13:35 ` [PATCH libgpiod 0/3] bindings: fix ordering of releasing of gpiosim resources 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=20250203-fix-gpiosim-in-bindings-v1-2-d2c9e0f3a29d@linaro.org \
--to=brgl@bgdev.pl \
--cc=bartosz.golaszewski@linaro.org \
--cc=erik.schilling@linaro.org \
--cc=koichiro.den@canonical.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=phil@gadgetoid.com \
--cc=vfazio@xes-inc.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).