From 55e8649c0d2a426201073e272c0975244fdec754 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 5 Jan 2007 16:34:32 +0000 Subject: [PATCH] pwmconfig, fancontrol: Gracefully handle errors when writing to sysfs files, as bash 3.1 otherwise displays them and this tends to frighten the user. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4280 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + prog/pwm/fancontrol | 9 +++++++-- prog/pwm/pwmconfig | 14 ++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 956b0836..b5d4a672 100644 --- a/CHANGES +++ b/CHANGES @@ -25,6 +25,7 @@ SVN HEAD Program i2cdetect: Make the output clearer Program py-smbus: New! Python i2c-dev bindings (prog/py-smbus) Programs dump/*: More robust handling of user inputs + Programs pwmconfig, fancontrol: Handle write errors for bash 3.1 Program sensord: Add pc87247 support (fans only) Add vt1211 support (#2150) Add w83627dhg support (David Holl, #2157) diff --git a/prog/pwm/fancontrol b/prog/pwm/fancontrol index d2c098ac..15076b49 100755 --- a/prog/pwm/fancontrol +++ b/prog/pwm/fancontrol @@ -124,7 +124,7 @@ function pwmdisable() ENABLE=${1}_enable if [ -f $ENABLE ] then - echo 0 > $ENABLE + echo 0 > $ENABLE 2> /dev/null fi else echo $MAX 0 > $1 @@ -139,8 +139,13 @@ function pwmenable() ENABLE=${1}_enable if [ -f $ENABLE ] then - echo 1 > $ENABLE + echo 1 > $ENABLE 2> /dev/null + if [ $? -ne 0 ] + then + return 1 + fi fi + echo $MAX > $1 else echo $MAX 1 > $1 fi diff --git a/prog/pwm/pwmconfig b/prog/pwm/pwmconfig index 4a0cfd0a..94f2c6de 100755 --- a/prog/pwm/pwmconfig +++ b/prog/pwm/pwmconfig @@ -99,7 +99,7 @@ function pwmdisable() ENABLE=${1}_enable if [ -w $ENABLE ] then - echo 0 > $ENABLE + echo 0 > $ENABLE 2> /dev/null fi else echo $MAX 0 > $1 @@ -114,8 +114,13 @@ function pwmenable() ENABLE=${1}_enable if [ -w $ENABLE ] then - echo 1 > $ENABLE + echo 1 > $ENABLE 2> /dev/null + if [ $? -ne 0 ] + then + return 1 + fi fi + echo $MAX > $1 else echo $MAX 1 > $1 fi @@ -271,6 +276,11 @@ for i in $PWM do echo Testing pwm control $i ... pwmenable $i + if [ $? -ne 0 ] + then + echo "Manual control mode not supported, skipping." + continue + fi pwmset $i 0 sleep $DELAY if [ $? -ne 0 ]