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] tools: replace alphasort() with versionsort()
Date: Mon, 3 Apr 2023 16:28:15 +0200 [thread overview]
Message-ID: <20230403142815.183891-1-brgl@bgdev.pl> (raw)
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
With a high enough number of chips, gpiodetect currently sorts them
like this:
gpiochip0
gpiochip1
gpiochip10
gpiochip11
gpiochip12
gpiochip13
gpiochip14
gpiochip15
gpiochip16
gpiochip17
gpiochip18
gpiochip19
gpiochip2
gpiochip20
gpiochip21
gpiochip22
gpiochip23
gpiochip24
gpiochip25
gpiochip26
gpiochip3
gpiochip4
gpiochip5
gpiochip6
gpiochip7
gpiochip8
gpiochip9
Switching to using versionsort() instead of alphasort() makes it look
better and the order is more logical:
gpiochip0
gpiochip1
gpiochip2
gpiochip3
gpiochip4
gpiochip5
gpiochip6
gpiochip7
gpiochip8
gpiochip9
gpiochip10
gpiochip11
gpiochip12
gpiochip13
gpiochip14
gpiochip15
gpiochip16
gpiochip17
gpiochip18
gpiochip19
gpiochip20
gpiochip21
gpiochip22
gpiochip23
gpiochip24
gpiochip25
gpiochip26
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
configure.ac | 2 +-
tools/tools-common.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 7d72c24..c1005a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,7 +119,7 @@ AS_IF([test "x$with_tools" = xtrue],
AC_CHECK_FUNC([daemon], [], [FUNC_NOT_FOUND_TOOLS([daemon])])
AC_CHECK_FUNC([asprintf], [], [FUNC_NOT_FOUND_LIB([asprintf])])
AC_CHECK_FUNC([scandir], [], [FUNC_NOT_FOUND_LIB([scandir])])
- AC_CHECK_FUNC([alphasort], [], [FUNC_NOT_FOUND_LIB([alphasort])])
+ AC_CHECK_FUNC([versionsort], [], [FUNC_NOT_FOUND_LIB([versionsort])])
AS_IF([test "x$with_gpioset_interactive" = xtrue],
[PKG_CHECK_MODULES([LIBEDIT], [libedit >= 3.1])])
])
diff --git a/tools/tools-common.c b/tools/tools-common.c
index e5f6fc1..64592d3 100644
--- a/tools/tools-common.c
+++ b/tools/tools-common.c
@@ -469,7 +469,7 @@ int all_chip_paths(char ***paths_ptr)
struct dirent **entries;
char **paths;
- num_chips = scandir("/dev/", &entries, chip_dir_filter, alphasort);
+ num_chips = scandir("/dev/", &entries, chip_dir_filter, versionsort);
if (num_chips < 0)
die_perror("unable to scan /dev");
--
2.37.2
next reply other threads:[~2023-04-03 14:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-03 14:28 Bartosz Golaszewski [this message]
2023-04-04 0:41 ` [libgpiod][PATCH] tools: replace alphasort() with versionsort() Kent Gibson
2023-04-04 7:23 ` Linus Walleij
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=20230403142815.183891-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox