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@xxxxxxx> --- 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