2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-09-04 16:25:18 +00:00

Support upcoming sysfs path to i2c adapters.

git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5758 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2009-07-22 12:20:58 +00:00
parent 9153ce2240
commit 09d912a45f
2 changed files with 23 additions and 9 deletions

View File

@@ -2150,11 +2150,17 @@ sub device_driver_autoloads
sub initialize_i2c_adapters_list
{
my $entry;
my ($entry, $base_dir, $have_i2c_adapter_class);
local $_;
my $class_dir = "${sysfs_root}/class/i2c-adapter";
opendir(local *ADAPTERS, $class_dir) or return;
if (-d "${sysfs_root}/class/i2c-adapter") {
$base_dir = "${sysfs_root}/class/i2c-adapter";
$have_i2c_adapter_class = 1;
} else {
$base_dir = "${sysfs_root}/bus/i2c/devices";
$have_i2c_adapter_class = 0;
}
opendir(local *ADAPTERS, $base_dir) or return;
while (defined($_ = readdir(ADAPTERS))) {
next unless m/^i2c-(\d+)$/;
@@ -2162,13 +2168,20 @@ sub initialize_i2c_adapters_list
$entry = {}; # New entry
# The layout in sysfs has changed over the years
my $link = readlink("${class_dir}/i2c-$nr/device");
if ($link =~ m/^(.*)\/i2c-$nr$/) {
$entry->{path} = "${class_dir}/i2c-$nr/device";
$entry->{parent} = "${class_dir}/i2c-$nr/$1";
if ($have_i2c_adapter_class) {
my $link = readlink("${base_dir}/i2c-$nr/device");
if ($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 {
$entry->{path} = "${class_dir}/i2c-$nr";
$entry->{parent} = "$entry->{path}/device";
my $link = readlink("${base_dir}/i2c-$nr");
$link =~ s/\/i2c-$nr$//;
$entry->{path} = "${base_dir}/i2c-$nr";
$entry->{parent} = "${base_dir}/$link";
}
$entry->{name} = sysfs_device_attribute($entry->{path}, "name");