i2cdetect: Sort the bus list by number
PATCH 1/1 i2cdetect: Sort the bus list by number
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 <[email protected]>
---
Why did I not do that earlier... I don't know.
tools/i2cbusses.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
tools/i2cbusses.c +11 -0
@@ -129,6 +129,14 @@ static struct i2c_adap *more_adapters(streturn 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; }
Signature · 2 lines
Jean Delvare SUSE L3 Support
Quoted 4 lines · Jean Delvare
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 <[email protected]>
I like it!
Reviewed-by Wolfram Sang <[email protected]>