From 972e5e2f0150ce7399be70cb48b1d1eb2c99584d Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 4 Dec 2007 09:27:49 +0000 Subject: [PATCH] Really hide errors on sysfs writes. Deal gracefully with read-only pwm_enable files. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5061 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 2 ++ prog/pwm/pwmconfig | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 7a88ebc0..b568570d 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,8 @@ lm-sensors CHANGES file SVN documentation: Update the application writing guidelines Makefile: No warnings about ld configuration for staged installations + pwmconfig: Really hide errors on sysfs writes + Deal gracefully with read-only pwm_enable files sensors-detect: Drop PCA9540 detection 3.0.0 (2007-11-24) diff --git a/prog/pwm/pwmconfig b/prog/pwm/pwmconfig index 2db7814d..98ffbc19 100755 --- a/prog/pwm/pwmconfig +++ b/prog/pwm/pwmconfig @@ -1,6 +1,6 @@ #!/bin/bash # -# pwmconfig v0.8 +# pwmconfig v0.9 # Tests the pwm outputs of sensors and configures fancontrol # # Warning!!! This program will stop your fans, one at a time, @@ -123,7 +123,7 @@ function pwmdisable() fi # Try pwmN_enable=0 - echo 0 > $ENABLE 2> /dev/null + echo 0 2>/dev/null > $ENABLE if [ "`cat $ENABLE`" -eq 0 ] then # Success @@ -131,7 +131,7 @@ function pwmdisable() fi # It didn't work, try pwmN_enable=1 pwmN=255 - echo 1 > $ENABLE 2> /dev/null + echo 1 2>/dev/null > $ENABLE if [ "`cat $ENABLE`" -ne 1 ] then echo "$ENABLE stuck to `cat $ENABLE`" >&2 @@ -161,7 +161,7 @@ function pwmenable() ENABLE=${1}_enable if [ -w $ENABLE ] then - echo 1 > $ENABLE 2> /dev/null + echo 1 2>/dev/null > $ENABLE if [ $? -ne 0 ] then return 1 @@ -195,15 +195,24 @@ do pwmdisable $i if [ $? -ne 0 ] then - echo "Failed to set $i to full speed" >&2 - echo "Something's wrong, check your fans!" >&2 - exit 1 + echo "Manual control mode not supported, skipping $i." + elif [ "$GOODPWM" = "" ] + then + GOODPWM=$i + else + GOODPWM="$GOODPWM $i" fi else NOTROOT=1 fi done +if [ "$GOODPWM" = "" ] +then + echo 'There are no usable PWM outputs.' + exit 1 +fi + echo echo "Giving the fans some time to reach full speed..." sleep $DELAY @@ -343,7 +352,7 @@ function pwmdetail() echo } -for i in $PWM +for i in $GOODPWM do echo Testing pwm control $i ... pwmenable $i