Changeset 4286 for lm-sensors/trunk/prog/pwm/pwmconfig
- Timestamp:
- 01/07/07 23:10:02 (6 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/prog/pwm/pwmconfig (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/prog/pwm/pwmconfig
r4280 r4286 43 43 44 44 DIR=/proc/sys/dev/sensors 45 SDIR=/sys/bus/i2c/devices46 45 if [ ! -d $DIR ] 47 46 then 48 if [ ! -d $SDIR ] 49 then 47 if [ -d "/sys/class/hwmon" ] 48 then 49 SYSFS=2 50 DIR="/sys/class/hwmon" 51 elif [ -d "/sys/bus/i2c/devices" ] 52 then 53 SYSFS=1 54 DIR="/sys/bus/i2c/devices" 55 else 50 56 echo $0: 'No sensors found! (modprobe sensor modules?)' 51 57 exit 1 52 else53 SYSFS=154 DIR=$SDIR55 58 fi 56 59 fi 57 60 58 61 cd $DIR 59 DRIVERS=`echo *-*` 60 if [ "*-*" = "$DRIVERS" ] 62 if [ "$SYSFS" = "2" ] 63 then 64 PREFIX='hwmon*/device' 65 else 66 PREFIX='*-*' 67 fi 68 DEVICES=`echo $PREFIX` 69 if [ "$PREFIX" = "$DEVICES" ] 61 70 then 62 71 echo $0: 'No sensors found! (modprobe sensor modules?)' … … 64 73 fi 65 74 66 MATCH= '*/pwm[1-9]'75 MATCH=$PREFIX/'pwm[1-9]' 67 76 PWM=`echo $MATCH` 68 77 if [ "$SYSFS" = "1" -a "$MATCH" = "$PWM" ] 69 78 then 70 79 # Deprecated naming scheme (used in kernels 2.6.5 to 2.6.9) 71 MATCH= '*/fan[1-9]_pwm'80 MATCH=$PREFIX/'fan[1-9]_pwm' 72 81 PWM=`echo $MATCH` 73 82 fi … … 78 87 fi 79 88 80 if [ "$SYSFS" = "1" ]81 then 82 MATCH= '*/fan[1-9]_input'89 if [ -n "$SYSFS" ] 90 then 91 MATCH=$PREFIX/'fan[1-9]_input' 83 92 else 84 MATCH= '*/fan[1-9]'93 MATCH=$PREFIX/'fan[1-9]' 85 94 fi 86 95 FAN=`echo $MATCH` … … 90 99 exit 1 91 100 fi 101 102 # $1 = padding 103 # Only works with Linux 2.6 104 function print_devices() 105 { 106 for device in $DEVICES 107 do 108 echo "$1$device is `cat $device/name`" 109 done 110 } 92 111 93 112 # $1 = pwm file name 94 113 function pwmdisable() 95 114 { 96 if [ "$SYSFS" = "1" ] 97 then 115 if [ -n "$SYSFS" ] 116 then 117 ENABLE=${1}_enable 118 # No enable file? Just set to max 119 if [ ! -f $ENABLE ] 120 then 121 echo $MAX > $1 122 return 0 123 fi 124 125 # Try pwmN_enable=0 126 echo 0 > $ENABLE 2> /dev/null 127 if [ "`cat $ENABLE`" -eq 0 ] 128 then 129 # Success 130 return 0 131 fi 132 133 # It didn't work, try pwmN_enable=1 pwmN=255 134 echo 1 > $ENABLE 2> /dev/null 98 135 echo $MAX > $1 99 ENABLE=${1}_enable 100 if [ -w $ENABLE ] 101 then 102 echo 0 > $ENABLE 2> /dev/null 103 fi 136 if [ "`cat $ENABLE`" -eq 1 -a "`cat $1`" -ge 190 ] 137 then 138 # Success 139 return 0 140 fi 141 142 # Nothing worked 143 echo "$ENABLE stuck to `cat $ENABLE`" >&2 144 return 1 104 145 else 105 146 echo $MAX 0 > $1 … … 110 151 function pwmenable() 111 152 { 112 if [ "$SYSFS" = "1" ]153 if [ -n "$SYSFS" ] 113 154 then 114 155 ENABLE=${1}_enable … … 132 173 echo $2 > $1 133 174 } 175 176 if [ -n "$SYSFS" ] 177 then 178 echo 'Found the following devices:' 179 print_devices " " 180 echo 181 fi 134 182 135 183 echo 'Found the following PWM controls:' … … 140 188 then 141 189 pwmdisable $i 190 if [ $? -ne 0 ] 191 then 192 echo "Failed to set pwm$i to full speed" >&2 193 echo "Something's wrong, check your fans!" >&2 194 exit 1 195 fi 142 196 else 143 197 NOTROOT=1 … … 373 427 fi 374 428 375 if [ "$SYSFS" = "1" ]376 then 377 MATCH= '*/temp[1-9]_input'429 if [ -n "$SYSFS" ] 430 then 431 MATCH=$PREFIX/'temp[1-9]_input' 378 432 else 379 MATCH= '*/temp[1-9]'433 MATCH=$PREFIX/'temp[1-9]' 380 434 fi 381 435 TEMPS=`echo $MATCH` … … 423 477 MINSTART=`egrep '^MINSTART=.*$' $1 | sed -e 's/MINSTART=//g'` 424 478 MINSTOP=`egrep '^MINSTOP=.*$' $1 | sed -e 's/MINSTOP=//g'` 479 480 # Check for configuration change 481 local item 482 for item in $FCFANS 483 do 484 if [ ! -f "`echo $item | sed -e 's/=.*$//'`" ] 485 then 486 echo "Configuration appears to be outdated, discarded" 487 FCTEMPS="" 488 FCFANS="" 489 MINTEMP="" 490 MAXTEMP="" 491 MINSTART="" 492 MINSTOP="" 493 fi 494 done 425 495 } 426 496 … … 530 600 pwmsed=`echo ${pwms} | sed -e 's/\//\\\\\//g'` #escape / for sed 531 601 echo 602 if [ -n "$SYSFS" ] 603 then 604 echo 'Devices:' 605 print_devices "" 606 echo 607 fi 532 608 echo 'Current temperature readings are as follows:' 533 609 for j in $TEMPS … … 535 611 # this will return the first field if there's only one (sysfs) 536 612 S=`cat $j | cut -d' ' -f3` 537 if [ "$SYSFS" = "1" ]613 if [ -n "$SYSFS" ] 538 614 then 539 615 let S="$S / 1000"
