From f7ccb96a7c3268c66d5b02833b4ca31d5602569e Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 27 Sep 2008 15:35:47 +0000 Subject: [PATCH] Add support for drivers that place the hwmon attributes in the hwmon class device directory rather than directly in the device directory. This is what virtual devices have. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5343 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + prog/pwm/pwmconfig | 91 +++++++++++++++++++++++++++++++++------------- 2 files changed, 67 insertions(+), 25 deletions(-) diff --git a/CHANGES b/CHANGES index 3707be9c..33bb0afb 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,7 @@ SVN-HEAD Determine MINSTOP automatically Skip MINSTOP and MINSTART tests if fan can't stop Change default for MINTEMP from 0 to 20 degrees C + Add support for attributes in the hwmon class device (#2260) sensors-detect: Add Intel SCH (bus) support Add SMSC EMC6D103 support Improve MAX6657, MAX6658, MAX6659 detection diff --git a/prog/pwm/pwmconfig b/prog/pwm/pwmconfig index 3c69e868..57cc98ee 100755 --- a/prog/pwm/pwmconfig +++ b/prog/pwm/pwmconfig @@ -77,7 +77,7 @@ fi cd $DIR if [ "$SYSFS" = "2" ] then - PREFIX='hwmon*/device' + PREFIX='hwmon*' else PREFIX='*-*' fi @@ -88,28 +88,60 @@ then exit 1 fi -MATCH=$PREFIX/'pwm[1-9]' -PWM=`echo $MATCH` -if [ "$SYSFS" = "1" -a "$MATCH" = "$PWM" ] +# For sysfs, we may need to adjust the device path +if [ "$SYSFS" = "2" ] then - # Deprecated naming scheme (used in kernels 2.6.5 to 2.6.9) - MATCH=$PREFIX/'fan[1-9]_pwm' - PWM=`echo $MATCH` + OLD_DEVICES="$DEVICES" + DEVICES="" + + for device in $OLD_DEVICES + do + if [ ! -r "$device/name" ] + then + device="$device/device" + fi + + DEVICES="$DEVICES $device" + done fi -if [ "$MATCH" = "$PWM" ] + + +for device in $DEVICES +do + # Find available fan control outputs + MATCH=$device/'pwm[1-9]' + device_pwm=`echo $MATCH` + if [ "$SYSFS" = "1" -a "$MATCH" = "$device_pwm" ] + then + # Deprecated naming scheme (used in kernels 2.6.5 to 2.6.9) + MATCH=$device/'fan[1-9]_pwm' + device_pwm=`echo $MATCH` + fi + if [ "$MATCH" != "$device_pwm" ] + then + PWM="$PWM $device_pwm" + fi + + # Find available fan monitoring inputs + if [ -n "$SYSFS" ] + then + MATCH=$device/'fan[1-9]_input' + else + MATCH=$device/'fan[1-9]' + fi + device_fan=`echo $MATCH` + if [ "$MATCH" != "$device_fan" ] + then + FAN="$FAN $device_fan" + fi +done + +if [ -z "$PWM" ] then echo $0: 'There are no pwm-capable sensor modules installed' exit 1 fi - -if [ -n "$SYSFS" ] -then - MATCH=$PREFIX/'fan[1-9]_input' -else - MATCH=$PREFIX/'fan[1-9]' -fi -FAN=`echo $MATCH` -if [ "$MATCH" = "$FAN" ] +if [ -z "$FAN" ] then echo $0: 'There are no fan-capable sensor modules installed' exit 1 @@ -516,14 +548,23 @@ then exit fi -if [ -n "$SYSFS" ] -then - MATCH=$PREFIX/'temp[1-9]_input' -else - MATCH=$PREFIX/'temp[1-9]' -fi -TEMPS=`echo $MATCH` -if [ "$MATCH" = "$TEMPS" ] +for device in $DEVICES +do + # Find available temperature monitoring inputs + if [ -n "$SYSFS" ] + then + MATCH=$device/'temp[1-9]_input' + else + MATCH=$device/'temp[1-9]' + fi + device_temp=`echo $MATCH` + if [ "$MATCH" != "$device_temp" ] + then + TEMPS="$TEMPS $device_temp" + fi +done + +if [ -z "$TEMPS" ] then echo $0: 'There are no temperature-capable sensor modules installed' exit 1