summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2025-11-20 12:39:38 +0000
committerMark Brown <broonie@kernel.org>2025-11-20 12:39:38 +0000
commitbe2b723d94f2fa3f8ca028a55d313ba0b3007d44 (patch)
treecff5cffc26b0902dccbd1507ecb70578ce3e772f /lib
parentbdf96e9135a0cf53a853a19c30fa11131a744062 (diff)
parent7a0a87712120329c034b0aae88bdaa05bd046f10 (diff)
gpio: improve support for shared GPIOs
Merge series from Bartosz Golaszewski <brgl@bgdev.pl>: Problem statement: GPIOs are implemented as a strictly exclusive resource in the kernel but there are lots of platforms on which single pin is shared by multiple devices which don't communicate so need some way of properly sharing access to a GPIO. What we have now is the GPIOD_FLAGS_BIT_NONEXCLUSIVE flag which was introduced as a hack and doesn't do any locking or arbitration of access - it literally just hand the same GPIO descriptor to all interested users. The proposed solution is composed of three major parts: the high-level, shared GPIO proxy driver that arbitrates access to the shared pin and exposes a regular GPIO chip interface to consumers, a low-level shared GPIOLIB module that scans firmware nodes and creates auxiliary devices that attach to the proxy driver and finally a set of core GPIOLIB changes that plug the former into the GPIO lookup path. The changes are implemented in a way that allows to seamlessly compile out any code related to sharing GPIOs for systems that don't need it. The practical use-case for this are the powerdown GPIOs shared by speakers on Qualcomm db845c platform, however I have also extensively tested it using gpio-virtuser on arm64 qemu with various DT configurations.
Diffstat (limited to 'lib')
-rw-r--r--lib/tests/string_kunit.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/tests/string_kunit.c b/lib/tests/string_kunit.c
index 0ed7448a26d3..f9a8e557ba77 100644
--- a/lib/tests/string_kunit.c
+++ b/lib/tests/string_kunit.c
@@ -602,6 +602,18 @@ static void string_test_memtostr(struct kunit *test)
KUNIT_EXPECT_EQ(test, dest[7], '\0');
}
+static void string_test_strends(struct kunit *test)
+{
+ KUNIT_EXPECT_TRUE(test, strends("foo-bar", "bar"));
+ KUNIT_EXPECT_TRUE(test, strends("foo-bar", "-bar"));
+ KUNIT_EXPECT_TRUE(test, strends("foobar", "foobar"));
+ KUNIT_EXPECT_TRUE(test, strends("foobar", ""));
+ KUNIT_EXPECT_FALSE(test, strends("bar", "foobar"));
+ KUNIT_EXPECT_FALSE(test, strends("", "foo"));
+ KUNIT_EXPECT_FALSE(test, strends("foobar", "ba"));
+ KUNIT_EXPECT_TRUE(test, strends("", ""));
+}
+
static struct kunit_case string_test_cases[] = {
KUNIT_CASE(string_test_memset16),
KUNIT_CASE(string_test_memset32),
@@ -623,6 +635,7 @@ static struct kunit_case string_test_cases[] = {
KUNIT_CASE(string_test_strlcat),
KUNIT_CASE(string_test_strtomem),
KUNIT_CASE(string_test_memtostr),
+ KUNIT_CASE(string_test_strends),
{}
};