sensors-detect: Fix parent device discovery
PATCH 2/2 sensors-detect: Fix parent device discovery
Take multiplexers into account when looking up the parent device of each I2C adapter. We don't bother with old kernels as they didn't have support for multiplexers anyway.
--- prog/detect/sensors-detect | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
prog/detect/sensors-detect +7 -6
@@ -2,7 +2,7 @@ # # sensors-detect - Detect hardware monitoring chips # Copyright (C) 1998 - 2002 Frodo Looijaard <[email protected]> -# Copyright (C) 2004 - 2011 Jean Delvare <[email protected]> +# Copyright (C) 2004 - 2012 Jean Delvare <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by
@@ -2696,14 +2696,15 @@ sub initialize_i2c_adapters_list } elsif ($link =~ m/^(.*)\/i2c-$nr$/) { $entry->{path} = "${base_dir}/i2c-$nr/device"; $entry->{parent} = "${base_dir}/i2c-$nr/$1"; - } else { - $entry->{path} = "${base_dir}/i2c-$nr"; - $entry->{parent} = "$entry->{path}/device"; } - } else { + } + + # This works for all recent kernels (with or without + # CONFIG_I2C_COMPAT) + if (!defined $entry->{path}) { my $link = readlink("${base_dir}/i2c-$nr"); - $link =~ s/\/i2c-$nr$//; $entry->{path} = "${base_dir}/i2c-$nr"; + $link =~ s/(\/i2c-[0-9]+)+$//; # Handle multiplexers too $entry->{parent} = "${base_dir}/$link"; }
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 28 lines · Jean Delvare
Take multiplexers into account when looking up the parent device of each I2C adapter. We don't bother with old kernels as they didn't have support for multiplexers anyway.
--- prog/detect/sensors-detect | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)prog/detect/sensors-detect +2
-5@@ -2,7 +2,7 @@ # # sensors-detect - Detect hardware monitoring chips # Copyright (C) 1998 - 2002 Frodo Looijaard <[email protected]> -# Copyright (C) 2004 - 2011 Jean Delvare <[email protected]> +# Copyright (C) 2004 - 2012 Jean Delvare <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by@@ -2696,14 +2696,15 @@ sub initialize_i2c_adapters_list } elsif ($link =~ m/^(.*)\/i2c-$nr$/) { $entry->{path} = "${base_dir}/i2c-$nr/device"; $entry->{parent} = "${base_dir}/i2c-$nr/$1"; - } else { - $entry->{path} = "${base_dir}/i2c-$nr"; - $entry->{parent} = "$entry->{path}/device"; } - } else { + }
prog/detect/sensors-detect sub initialize_i2c_adapters_list · line 2709
Quoted 10 lines
prog/detect/sensors-detect +5
-1+ + # This works for all recent kernels (with or without + # CONFIG_I2C_COMPAT) + if (!defined $entry->{path}) { my $link = readlink("${base_dir}/i2c-$nr"); - $link =~ s/\/i2c-$nr$//; $entry->{path} = "${base_dir}/i2c-$nr"; + $link =~ s/(\/i2c-[0-9]+)+$//; # Handle multiplexers too $entry->{parent} = "${base_dir}/$link"; }
Acked-by Guenter Roeck <[email protected]>
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors