From: Jean Delvare <jdelvare@suse.de>
To: Linux I2C <linux-i2c@vger.kernel.org>
Subject: [PATCH] i2cdetect: Sort the bus list by number
Date: Thu, 27 May 2021 10:07:03 +0200 [thread overview]
Message-ID: <20210527100703.71519bbe@endymion> (raw)
The bus list (option -l) will be easier to read once sorted, as
typically this will group the buses by driver.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
Why did I not do that earlier... I don't know.
tools/i2cbusses.c | 11 +++++++++++
1 file changed, 11 insertions(+)
--- i2c-tools.orig/tools/i2cbusses.c 2020-09-17 14:29:28.275299253 +0200
+++ i2c-tools/tools/i2cbusses.c 2021-05-27 10:00:04.864407042 +0200
@@ -129,6 +129,14 @@ static struct i2c_adap *more_adapters(st
return new_adapters;
}
+static int sort_i2c_busses(const void *a, const void *b)
+{
+ const struct i2c_adap *adap1 = a;
+ const struct i2c_adap *adap2 = b;
+
+ return adap1->nr - adap2->nr;
+}
+
struct i2c_adap *gather_i2c_busses(void)
{
char s[120];
@@ -314,6 +322,9 @@ struct i2c_adap *gather_i2c_busses(void)
closedir(dir);
done:
+ /* Sort by bus number for convenience */
+ qsort(adapters, count, sizeof(struct i2c_adap), sort_i2c_busses);
+
return adapters;
}
--
Jean Delvare
SUSE L3 Support
next reply other threads:[~2021-05-27 8:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-27 8:07 Jean Delvare [this message]
2021-05-28 19:13 ` [PATCH] i2cdetect: Sort the bus list by number Wolfram Sang
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=20210527100703.71519bbe@endymion \
--to=jdelvare@suse.de \
--cc=linux-i2c@vger.kernel.org \
/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).