public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@mvista.com>
To: linux-omap-open-source@linux.omap.com
Subject: [PATCH] ARM: OMAP: fix suspend for twl4030
Date: Tue, 24 Jul 2007 16:47:16 -0700	[thread overview]
Message-ID: <20070724234716.488413681@mvista.com> (raw)

Use competions instead of manually setting scheduler state.
daemonize kernel thread and set PF_NOFREEZE.

Signed-off-by: Kevin Hilman <khilman@mvista.com>

---
 drivers/i2c/chips/twl4030_core.c |   25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

Index: linux-2.6.21/drivers/i2c/chips/twl4030_core.c
===================================================================
--- linux-2.6.21.orig/drivers/i2c/chips/twl4030_core.c
+++ linux-2.6.21/drivers/i2c/chips/twl4030_core.c
@@ -146,6 +146,7 @@ static void twl_init_irq(void);
 /**** Data Structures */
 /* To have info on T2 IRQ substem activated or not */
 static unsigned char twl_irq_used = FREE;
+static struct completion irq_event;
 
 /* Structure to define on TWL4030 Slave ID */
 struct twl4030_client {
@@ -459,11 +460,16 @@ static int twl4030_irq_thread(void *data
 	static unsigned i2c_errors;
 	const static unsigned max_i2c_errors = 100;
 
+	daemonize("twl4030-irq");
+	current->flags |= PF_NOFREEZE;
+
 	while (!kthread_should_stop()) {
 		int ret;
 		int module_irq;
 		u8 pih_isr;
 
+		wait_for_completion_interruptible(&irq_event);
+
 		ret = twl4030_i2c_read_u8(TWL4030_MODULE_PIH, &pih_isr,
 					  REG_PIH_ISR_P1);
 		if (ret) {
@@ -491,16 +497,9 @@ static int twl4030_irq_thread(void *data
 			}
 		}
 
-		local_irq_disable();
-
-		set_current_state(TASK_INTERRUPTIBLE);
 		desc->chip->unmask(irq);
-
-		local_irq_enable();
-
-		schedule();
 	}
-	set_current_state(TASK_RUNNING);
+
 	return 0;
 }
 
@@ -516,7 +515,7 @@ static int twl4030_irq_thread(void *data
 static void do_twl4030_irq(unsigned int irq, irq_desc_t *desc)
 {
 	const unsigned int cpu = smp_processor_id();
-	struct task_struct *thread = get_irq_data(irq);
+
 	/*
 	 * Earlier this was desc->triggered = 1;
 	 */
@@ -530,8 +529,7 @@ static void do_twl4030_irq(unsigned int 
 	if (!desc->depth) {
 		kstat_cpu(cpu).irqs[irq]++;
 
-		if (thread && thread->state != TASK_RUNNING)
-			wake_up_process(thread);
+		complete(&irq_event);
 	}
 }
 
@@ -637,8 +635,9 @@ struct task_struct *start_twl4030_irq_th
 {
 	struct task_struct *thread;
 
-	thread = kthread_create(twl4030_irq_thread, (void *)irq,
-				"twl4030 irq %d", irq);
+	init_completion(&irq_event);
+	thread = kthread_run(twl4030_irq_thread, (void *)irq,
+			     "twl4030 irq %d", irq);
 	if (!thread)
 		pr_err("%s: could not create twl4030 irq %d thread!\n",
 		       __FUNCTION__,irq);
--

             reply	other threads:[~2007-07-24 23:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-24 23:47 Kevin Hilman [this message]
2007-08-10  9:25 ` [PATCH] ARM: OMAP: fix suspend for twl4030 Tony Lindgren

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=20070724234716.488413681@mvista.com \
    --to=khilman@mvista.com \
    --cc=linux-omap-open-source@linux.omap.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox