public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Aristeu Sergio Rozanski Filho <aris@valeta•org>
To: linuxppc-dev@ozlabs•org
Subject: [PATCH] powermac: defer work in backlight key press
Date: Mon, 3 Jul 2006 22:39:23 -0300	[thread overview]
Message-ID: <20060704013923.GG27596@cathedrallabs.org> (raw)

powermac: defer work in backlight key press

pmac_backlight_key() is called under interrupt context, can't use mutexes or
semaphores, so defer the backlight level for later, as it's not critical

Signed-off-by: Aristeu S. Rozanski F. <aris@valeta•org>

Index: ppc-2.6/arch/powerpc/platforms/powermac/backlight.c
===================================================================
--- ppc-2.6.orig/arch/powerpc/platforms/powermac/backlight.c	2006-07-03 21:00:44.000000000 -0300
+++ ppc-2.6/arch/powerpc/platforms/powermac/backlight.c	2006-07-03 21:38:12.000000000 -0300
@@ -15,6 +15,10 @@
 
 #define OLD_BACKLIGHT_MAX 15
 
+static void pmac_backlight_key_worker(void *data);
+static DECLARE_WORK(pmac_backlight_key_work, pmac_backlight_key_worker, NULL);
+static int pmac_backlight_key_queued;
+
 /* Protect the pmac_backlight variable */
 DEFINE_MUTEX(pmac_backlight_mutex);
 
@@ -71,7 +75,7 @@
 	return level;
 }
 
-static void pmac_backlight_key(int direction)
+static void pmac_backlight_key_worker(void *data)
 {
 	mutex_lock(&pmac_backlight_mutex);
 	if (pmac_backlight) {
@@ -82,7 +86,8 @@
 		props = pmac_backlight->props;
 
 		brightness = props->brightness +
-			((direction?-1:1) * (props->max_brightness / 15));
+			((pmac_backlight_key_queued?-1:1) *
+			 (props->max_brightness / 15));
 
 		if (brightness < 0)
 			brightness = 0;
@@ -97,6 +102,14 @@
 	mutex_unlock(&pmac_backlight_mutex);
 }
 
+static void pmac_backlight_key(int direction)
+{
+	/* we can receive multiple interrupts here, but the scheduled work
+	 * will run only once, with the last value */
+	pmac_backlight_key_queued = direction;
+	schedule_work(&pmac_backlight_key_work);
+}
+
 void pmac_backlight_key_up()
 {
 	pmac_backlight_key(0);

             reply	other threads:[~2006-07-04  2:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-04  1:39 Aristeu Sergio Rozanski Filho [this message]
2006-07-04  8:06 ` [PATCH] powermac: defer work in backlight key press Johannes Berg
2006-07-04 11:03   ` Aristeu Sergio Rozanski Filho
2006-07-04 11:16     ` Johannes Berg
2006-07-08 14:35 ` Michael Hanselmann
2006-07-08 15:58 ` [PATCH] powermac: defer work in backlight key press (and export fixes) Michael Hanselmann

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=20060704013923.GG27596@cathedrallabs.org \
    --to=aris@valeta$(echo .)org \
    --cc=linuxppc-dev@ozlabs$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox