All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maximilian Seesslen <mes@seesslen.net>
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] [PATCH] fix fancontrol to survive a system suspend
Date: Fri, 12 Jul 2013 17:12:51 +0000	[thread overview]
Message-ID: <201307121912.51382.mes@seesslen.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 273 bytes --]

Hello,

find attached a patch that fixes fancontrol to survive a system suspend. 

If the daemon can not set the pwm values but it did it already in the past 
successfully, it tries to reenable the pwm output instead of quitting.


Regards,
   Max


--
Maximilian Seesslen

[-- Attachment #2: fix-fancontrol-to-survive-a-system-suspend-hibernate.diff --]
[-- Type: text/x-patch, Size: 829 bytes --]

Index: prog/pwm/fancontrol
===================================================================
--- prog/pwm/fancontrol	(Revision 6189)
+++ prog/pwm/fancontrol	(Arbeitskopie)
@@ -42,6 +42,7 @@
 
 #DEBUG=1
 MAX=255
+DID_FIRSTRUN=0
 
 function LoadConfig
 {
@@ -490,7 +491,12 @@
 		if [ $? -ne 0 ]
 		then
 			echo "Error writing PWM value to $DIR/$pwmo" >&2
-			restorefans 1
+			[ "$DID_FIRSTRUN" == "0" ] && restorefans 1
+			# Ignoring write error. System probably was syspended and has to reanable pwm.
+			echo "Ignoring, i try reanabling PWM."
+			pwmenable $pwmo
+			# Write values again to keep failure short
+			echo $pwmval > $pwmo # write new value to pwm output
 		fi
 		if [ "$DEBUG" != "" ]
 		then
@@ -498,6 +504,8 @@
 		fi
 		let fcvcount=$fcvcount+1
 	done
+	
+	DID_FIRSTRUN=1
 }
 
 echo 'Enabling PWM on fans...'

[-- Attachment #3: 0001-fix-fancontrol-to-survive-a-system-suspend-hibernate.patch --]
[-- Type: text/x-patch, Size: 1254 bytes --]

From 46940390c8f9fcc4325710867c95b2e28aebaf81 Mon Sep 17 00:00:00 2001
From: Maximilian Seesslen <mes@seesslen.net>
Date: Fri, 12 Jul 2013 18:59:49 +0200
Subject: [PATCH] fix fancontrol to survive a system suspend/hibernate

---
 prog/pwm/fancontrol |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/prog/pwm/fancontrol b/prog/pwm/fancontrol
index 2771139..3e57901 100755
--- a/prog/pwm/fancontrol
+++ b/prog/pwm/fancontrol
@@ -42,6 +42,7 @@ PIDFILE="/var/run/fancontrol.pid"
 
 #DEBUG=1
 MAX=255
+DID_FIRSTRUN=0
 
 function LoadConfig
 {
@@ -490,7 +491,12 @@ function UpdateFanSpeeds
 		if [ $? -ne 0 ]
 		then
 			echo "Error writing PWM value to $DIR/$pwmo" >&2
-			restorefans 1
+			[ "$DID_FIRSTRUN" == "0" ] && restorefans 1
+			# Ignoring write error. System probably was syspended and has to reanable pwm.
+			echo "Ignoring, i try reanabling PWM."
+			pwmenable $pwmo
+			# Write values again to keep failure short
+			echo $pwmval > $pwmo # write new value to pwm output
 		fi
 		if [ "$DEBUG" != "" ]
 		then
@@ -498,6 +504,8 @@ function UpdateFanSpeeds
 		fi
 		let fcvcount=$fcvcount+1
 	done
+	
+	DID_FIRSTRUN=1
 }
 
 echo 'Enabling PWM on fans...'
-- 
1.7.10.4


[-- Attachment #4: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

                 reply	other threads:[~2013-07-12 17:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201307121912.51382.mes@seesslen.net \
    --to=mes@seesslen.net \
    --cc=lm-sensors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.