From ea854deb032de02a0faea44403aed59956b781c1 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 29 Jan 2009 08:28:17 +0000 Subject: [PATCH] Drop support for kernels 2.4 and earlier. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5630 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 2 + prog/pwm/fancontrol | 113 +++++++++++----------------- prog/pwm/pwmconfig | 175 +++++++++++++++++--------------------------- 3 files changed, 112 insertions(+), 178 deletions(-) diff --git a/CHANGES b/CHANGES index 95d1c108..84a1abd7 100644 --- a/CHANGES +++ b/CHANGES @@ -10,7 +10,9 @@ SVN-HEAD Drop support for kernels 2.4 and earlier lm_sensors.init.suse: Delete (actual SuSE script is much different) Makefile: Install sensors.conf.default instead of sensors.conf.eg (#2333) + pwmconfig: Drop support for kernels 2.4 and earlier fancontrol: Don't round temperature values + Drop support for kernels 2.4 and earlier maxilife scripts: Delete (driver never ported to Linux 2.6) sensord: Accept negative temperatures in RRD database Don't bail out on transient errors (#2330) diff --git a/prog/pwm/fancontrol b/prog/pwm/fancontrol index 6aad3c17..f52da908 100755 --- a/prog/pwm/fancontrol +++ b/prog/pwm/fancontrol @@ -1,6 +1,7 @@ #!/bin/bash # # Simple script implementing a temperature dependent fan speed control +# Supported Linux kernel versions: 2.6.5 and later # # Version 0.68 # @@ -159,84 +160,67 @@ else LoadConfig /etc/fancontrol fi -DIR=/proc/sys/dev/sensors +# Detect if config file uses the hwmon class or not yet +if echo "${AFCPWM[0]}" | egrep -q '^hwmon[0-9]' +then + DIR=/sys/class/hwmon +else + DIR=/sys/bus/i2c/devices +fi + if [ ! -d $DIR ] then - # For Linux 2.6, detect if config file uses the hwmon class or not yet - if echo "${AFCPWM[0]}" | egrep -q '^hwmon[0-9]' - then - SDIR=/sys/class/hwmon - else - SDIR=/sys/bus/i2c/devices - fi - - if [ ! -d $SDIR ] - then - echo $0: 'No sensors found! (did you load the necessary modules?)' - exit 1 - else - SYSFS=1 - DIR=$SDIR - fi + echo $0: 'No sensors found! (did you load the necessary modules?)' + exit 1 fi cd $DIR # $1 = pwm file name function pwmdisable() { - if [ -n "$SYSFS" ] + ENABLE=${1}_enable + # No enable file? Just set to max + if [ ! -f $ENABLE ] then - ENABLE=${1}_enable - # No enable file? Just set to max - if [ ! -f $ENABLE ] - then - echo $MAX > $1 - return 0 - fi - - # Try pwmN_enable=0 - echo 0 > $ENABLE 2> /dev/null - if [ `cat $ENABLE` -eq 0 ] - then - # Success - return 0 - fi - - # It didn't work, try pwmN_enable=1 pwmN=255 - echo 1 > $ENABLE 2> /dev/null echo $MAX > $1 - if [ `cat $ENABLE` -eq 1 -a `cat $1` -ge 190 ] - then - # Success - return 0 - fi - - # Nothing worked - echo "$ENABLE stuck to" `cat $ENABLE` >&2 - return 1 - else - echo $MAX 0 > $1 + return 0 fi + + # Try pwmN_enable=0 + echo 0 > $ENABLE 2> /dev/null + if [ `cat $ENABLE` -eq 0 ] + then + # Success + return 0 + fi + + # It didn't work, try pwmN_enable=1 pwmN=255 + echo 1 > $ENABLE 2> /dev/null + echo $MAX > $1 + if [ `cat $ENABLE` -eq 1 -a `cat $1` -ge 190 ] + then + # Success + return 0 + fi + + # Nothing worked + echo "$ENABLE stuck to" `cat $ENABLE` >&2 + return 1 } # $1 = pwm file name function pwmenable() { - if [ "$SYSFS" = "1" ] + ENABLE=${1}_enable + if [ -f $ENABLE ] then - ENABLE=${1}_enable - if [ -f $ENABLE ] + echo 1 > $ENABLE 2> /dev/null + if [ $? -ne 0 ] then - echo 1 > $ENABLE 2> /dev/null - if [ $? -ne 0 ] - then - return 1 - fi + return 1 fi - echo $MAX > $1 - else - echo $MAX 1 > $1 fi + echo $MAX > $1 } function restorefans() @@ -280,11 +264,6 @@ function UpdateFanSpeeds { echo "Error reading temperature from $DIR/$tsens" restorefans 1 fi - if [ "$SYSFS" != "1" ] - then - tval=`echo ${tval} | cut -d' ' -f3 | cut -d'.' -f1` - let tval="${tval}*1000" - fi read pwmpval < ${pwmo} if [ $? -ne 0 ] @@ -292,10 +271,6 @@ function UpdateFanSpeeds { echo "Error reading PWM value from $DIR/$pwmo" restorefans 1 fi - if [ "$SYSFS" != "1" ] - then - pwmpval=`echo ${pwmpval} | cut -d' ' -f1` - fi # If fanspeed-sensor output shall be used, do it if [[ -n ${fan} ]] @@ -306,10 +281,6 @@ function UpdateFanSpeeds { echo "Error reading Fan value from $DIR/$fan" restorefans 1 fi - if [ "$SYSFS" != "1" ] - then - fanval=`echo ${fanval} | cut -d' ' -f2` - fi else fanval=1 # set it to a non zero value, so the rest of the script still works fi diff --git a/prog/pwm/pwmconfig b/prog/pwm/pwmconfig index c705f3e8..fe448ad2 100755 --- a/prog/pwm/pwmconfig +++ b/prog/pwm/pwmconfig @@ -2,6 +2,7 @@ # # pwmconfig # Tests the pwm outputs of sensors and configures fancontrol +# Supported Linux kernel versions: 2.6.5 and later # # Warning!!! This program will stop your fans, one at a time, # for approximately 5 seconds each!!! @@ -9,7 +10,7 @@ # Verify that all fans are running at normal speed after this # program has exited!!! # -# Copyright (C) 2007-2008 Jean Delvare +# Copyright (C) 2007-2009 Jean Delvare # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -57,30 +58,22 @@ echo DELAY=5 # 3 seconds delay is too short for large fans, thus I increased it to 5 MAX=255 -DIR=/proc/sys/dev/sensors -if [ ! -d $DIR ] +if [ -d "/sys/class/hwmon" ] then - if [ -d "/sys/class/hwmon" ] - then - SYSFS=2 - DIR="/sys/class/hwmon" - elif [ -d "/sys/bus/i2c/devices" ] - then - SYSFS=1 - DIR="/sys/bus/i2c/devices" - else - echo $0: 'No sensors found! (modprobe sensor modules?)' - exit 1 - fi + SYSFS=2 + DIR="/sys/class/hwmon" + PREFIX='hwmon*' +elif [ -d "/sys/bus/i2c/devices" ] +then + SYSFS=1 + DIR="/sys/bus/i2c/devices" + PREFIX='*-*' +else + echo $0: 'No sensors found! (modprobe sensor modules?)' + exit 1 fi cd $DIR -if [ "$SYSFS" = "2" ] -then - PREFIX='hwmon*' -else - PREFIX='*-*' -fi DEVICES=`echo $PREFIX` if [ "$PREFIX" = "$DEVICES" ] then @@ -88,7 +81,7 @@ then exit 1 fi -# For sysfs, we may need to adjust the device path +# We may need to adjust the device path if [ "$SYSFS" = "2" ] then OLD_DEVICES="$DEVICES" @@ -123,12 +116,7 @@ do fi # Find available fan monitoring inputs - if [ -n "$SYSFS" ] - then - MATCH=$device/'fan[1-9]_input' - else - MATCH=$device/'fan[1-9]' - fi + MATCH=$device/'fan[1-9]_input' device_fan=`echo $MATCH` if [ "$MATCH" != "$device_fan" ] then @@ -148,7 +136,6 @@ then fi # $1 = padding -# Only works with Linux 2.6 function print_devices() { local name @@ -164,15 +151,12 @@ function print_devices() # $1 = pwm file name function is_pwm_auto() { - if [ -n "$SYSFS" ] + ENABLE=${1}_enable + if [ -f $ENABLE ] then - ENABLE=${1}_enable - if [ -f $ENABLE ] + if [ "`cat $ENABLE`" -gt 1 ] then - if [ "`cat $ENABLE`" -gt 1 ] - then - return 0 - fi + return 0 fi fi @@ -182,65 +166,55 @@ function is_pwm_auto() # $1 = pwm file name function pwmdisable() { - if [ -n "$SYSFS" ] + ENABLE=${1}_enable + # No enable file? Just set to max + if [ ! -f $ENABLE ] then - ENABLE=${1}_enable - # No enable file? Just set to max - if [ ! -f $ENABLE ] - then - echo $MAX > $1 - return 0 - fi - - # Try pwmN_enable=0 - echo 0 2>/dev/null > $ENABLE - if [ "`cat $ENABLE`" -eq 0 ] - then - # Success - return 0 - fi - - # It didn't work, try pwmN_enable=1 pwmN=255 - echo 1 2>/dev/null > $ENABLE - if [ "`cat $ENABLE`" -ne 1 ] - then - echo "$ENABLE stuck to `cat $ENABLE`" >&2 - return 1 - fi - echo $MAX > $1 - if [ "`cat $1`" -ge 190 ] - then - # Success - return 0 - fi - - # Nothing worked - echo "$1 stuck to `cat $1`" >&2 - return 1 - else - echo $MAX 0 > $1 + return 0 fi + + # Try pwmN_enable=0 + echo 0 2>/dev/null > $ENABLE + if [ "`cat $ENABLE`" -eq 0 ] + then + # Success + return 0 + fi + + # It didn't work, try pwmN_enable=1 pwmN=255 + echo 1 2>/dev/null > $ENABLE + if [ "`cat $ENABLE`" -ne 1 ] + then + echo "$ENABLE stuck to `cat $ENABLE`" >&2 + return 1 + fi + + echo $MAX > $1 + if [ "`cat $1`" -ge 190 ] + then + # Success + return 0 + fi + + # Nothing worked + echo "$1 stuck to `cat $1`" >&2 + return 1 } # $1 = pwm file name function pwmenable() { - if [ -n "$SYSFS" ] + ENABLE=${1}_enable + if [ -w $ENABLE ] then - ENABLE=${1}_enable - if [ -w $ENABLE ] + echo 1 2>/dev/null > $ENABLE + if [ $? -ne 0 ] then - echo 1 2>/dev/null > $ENABLE - if [ $? -ne 0 ] - then - return 1 - fi + return 1 fi - echo $MAX > $1 - else - echo $MAX 1 > $1 fi + echo $MAX > $1 } # $1 = pwm file name; $2 = pwm value 0-255 @@ -249,12 +223,9 @@ function pwmset() echo $2 > $1 } -if [ -n "$SYSFS" ] -then - echo 'Found the following devices:' - print_devices " " - echo -fi +echo 'Found the following devices:' +print_devices " " +echo echo 'Found the following PWM controls:' for i in $PWM @@ -555,12 +526,7 @@ fi 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 + MATCH=$device/'temp[1-9]_input' device_temp=`echo $MATCH` if [ "$MATCH" != "$device_temp" ] then @@ -785,21 +751,16 @@ select pwms in $pwmactive "Change INTERVAL" "Just quit" "Save and quit" "Show co "`echo ${pwmactive} |sed -e 's/ /\n/g' | egrep "${pwms}"`" ) pwmsed=`echo ${pwms} | sed -e 's/\//\\\\\//g'` #escape / for sed echo - if [ -n "$SYSFS" ] - then - echo 'Devices:' - print_devices "" - echo - fi + + echo 'Devices:' + print_devices "" + echo + echo 'Current temperature readings are as follows:' for j in $TEMPS do - # this will return the first field if there's only one (sysfs) - S=`cat $j | cut -d' ' -f3` - if [ -n "$SYSFS" ] - then - let S="$S / 1000" - fi + S=`cat $j` + let S="$S / 1000" echo "$j $S" done FAN=`echo $fanactive|cut -d' ' -f$REPLY`