All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert.Uytterhoeven@sonycom.com
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>,
	linuxppc-dev@ozlabs.org, linux-fbdev-devel@lists.sourceforge.net
Subject: [patch 1/4] ps3fb: thread updates
Date: Thu, 15 Feb 2007 16:23:02 +0100	[thread overview]
Message-ID: <20070215152432.264415000@sonycom.com> (raw)
In-Reply-To: 20070215152301.573853000@sonycom.com

[-- Attachment #1: ps3-wip/ps3fb-kthread.diff --]
[-- Type: text/plain, Size: 2603 bytes --]

ps3fb: Replace the kernel_thread by a proper kthread.

Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
---
 drivers/video/ps3fb.c |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

--- ps3-linux-2.6.20.orig/drivers/video/ps3fb.c
+++ ps3-linux-2.6.20/drivers/video/ps3fb.c
@@ -32,6 +32,8 @@
 #include <linux/ioctl.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
+#include <linux/freezer.h>
+#include <linux/kthread.h>
 
 #include <asm/uaccess.h>
 #include <linux/fb.h>
@@ -139,6 +141,7 @@ struct ps3fb_priv {
 	atomic_t ext_flip;	/* on/off flip with vsync */
 	atomic_t f_count;	/* fb_open count */
 	int is_blanked;
+	struct task_struct *task;
 };
 static struct ps3fb_priv ps3fb;
 
@@ -805,12 +808,14 @@ static int ps3fb_ioctl(struct fb_info *i
 
 static int ps3fbd(void *arg)
 {
-	daemonize("ps3fbd");
-	for (;;) {
-		down(&ps3fb.sem);
-		if (atomic_read(&ps3fb.ext_flip) == 0)
+	int error;
+
+	do {
+		try_to_freeze();
+		error = down_interruptible(&ps3fb.sem);
+		if (!error && !atomic_read(&ps3fb.ext_flip))
 			ps3fb_sync(0);	/* single buffer */
-	}
+	} while (!kthread_should_stop());
 	return 0;
 }
 
@@ -1050,9 +1055,17 @@ static int __init ps3fb_probe(struct pla
 	       "fb%d: PS3 frame buffer device, using %ld KiB of video memory\n",
 	       info->node, ps3fb_videomemory.size >> 10);
 
-	kernel_thread(ps3fbd, info, CLONE_KERNEL);
+	ps3fb.task = kthread_run(ps3fbd, info, "ps3fbd");
+	if (IS_ERR(ps3fb.task)) {
+		retval = PTR_ERR(ps3fb.task);
+		ps3fb.task = NULL;
+		goto err_unregister_framebuffer;
+	}
+
 	return 0;
 
+err_unregister_framebuffer:
+	unregister_framebuffer(info);
 err_fb_dealloc:
 	fb_dealloc_cmap(&info->cmap);
 err_framebuffer_release:
@@ -1083,6 +1096,10 @@ void ps3fb_cleanup(void)
 {
 	int status;
 
+	if (ps3fb.task) {
+		kthread_stop(ps3fb.task);
+		ps3fb.task = NULL;
+	}
 	if (ps3fb.irq_no) {
 		free_irq(ps3fb.irq_no, ps3fb.dev);
 		ps3_free_irq(ps3fb.irq_no);

--
Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- Sony Network and Software Technology Center Europe (NSCE)
Geert.Uytterhoeven@sonycom.com ------- The Corporate Village, Da Vincilaan 7-D1
Voice +32-2-7008453 Fax +32-2-7008622 ---------------- B-1935 Zaventem, Belgium


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

WARNING: multiple messages have this Message-ID (diff)
From: Geert.Uytterhoeven@sonycom.com
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>,
	linuxppc-dev@ozlabs.org, linux-fbdev-devel@lists.sourceforge.net
Subject: [patch 1/4] ps3fb: thread updates
Date: Thu, 15 Feb 2007 16:23:02 +0100	[thread overview]
Message-ID: <20070215152432.264415000@sonycom.com> (raw)
In-Reply-To: 20070215152301.573853000@sonycom.com

ps3fb: Replace the kernel_thread by a proper kthread.

Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
---
 drivers/video/ps3fb.c |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

--- ps3-linux-2.6.20.orig/drivers/video/ps3fb.c
+++ ps3-linux-2.6.20/drivers/video/ps3fb.c
@@ -32,6 +32,8 @@
 #include <linux/ioctl.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
+#include <linux/freezer.h>
+#include <linux/kthread.h>
 
 #include <asm/uaccess.h>
 #include <linux/fb.h>
@@ -139,6 +141,7 @@ struct ps3fb_priv {
 	atomic_t ext_flip;	/* on/off flip with vsync */
 	atomic_t f_count;	/* fb_open count */
 	int is_blanked;
+	struct task_struct *task;
 };
 static struct ps3fb_priv ps3fb;
 
@@ -805,12 +808,14 @@ static int ps3fb_ioctl(struct fb_info *i
 
 static int ps3fbd(void *arg)
 {
-	daemonize("ps3fbd");
-	for (;;) {
-		down(&ps3fb.sem);
-		if (atomic_read(&ps3fb.ext_flip) == 0)
+	int error;
+
+	do {
+		try_to_freeze();
+		error = down_interruptible(&ps3fb.sem);
+		if (!error && !atomic_read(&ps3fb.ext_flip))
 			ps3fb_sync(0);	/* single buffer */
-	}
+	} while (!kthread_should_stop());
 	return 0;
 }
 
@@ -1050,9 +1055,17 @@ static int __init ps3fb_probe(struct pla
 	       "fb%d: PS3 frame buffer device, using %ld KiB of video memory\n",
 	       info->node, ps3fb_videomemory.size >> 10);
 
-	kernel_thread(ps3fbd, info, CLONE_KERNEL);
+	ps3fb.task = kthread_run(ps3fbd, info, "ps3fbd");
+	if (IS_ERR(ps3fb.task)) {
+		retval = PTR_ERR(ps3fb.task);
+		ps3fb.task = NULL;
+		goto err_unregister_framebuffer;
+	}
+
 	return 0;
 
+err_unregister_framebuffer:
+	unregister_framebuffer(info);
 err_fb_dealloc:
 	fb_dealloc_cmap(&info->cmap);
 err_framebuffer_release:
@@ -1083,6 +1096,10 @@ void ps3fb_cleanup(void)
 {
 	int status;
 
+	if (ps3fb.task) {
+		kthread_stop(ps3fb.task);
+		ps3fb.task = NULL;
+	}
 	if (ps3fb.irq_no) {
 		free_irq(ps3fb.irq_no, ps3fb.dev);
 		ps3_free_irq(ps3fb.irq_no);

--
Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- Sony Network and Software Technology Center Europe (NSCE)
Geert.Uytterhoeven@sonycom.com ------- The Corporate Village, Da Vincilaan 7-D1
Voice +32-2-7008453 Fax +32-2-7008622 ---------------- B-1935 Zaventem, Belgium

  reply	other threads:[~2007-02-15 15:26 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-15 15:23 [patch 0/4] PS3 AV/FB updates Geert.Uytterhoeven
2007-02-15 15:23 ` Geert.Uytterhoeven
2007-02-15 15:23 ` Geert.Uytterhoeven [this message]
2007-02-15 15:23   ` [patch 1/4] ps3fb: thread updates Geert.Uytterhoeven
2007-02-15 17:50   ` Christoph Hellwig
2007-02-15 17:50     ` Christoph Hellwig
2007-02-15 21:43     ` Benjamin Herrenschmidt
2007-02-16  0:59       ` Andrew Morton
2007-02-16 15:58         ` Geert Uytterhoeven
2007-02-16 15:58           ` Geert Uytterhoeven
2007-02-16 16:00         ` [PATCH 1/4 (updated)] " Geert Uytterhoeven
2007-02-16 16:00           ` Geert Uytterhoeven
2007-02-16 16:38           ` Christoph Hellwig
2007-02-16 16:38             ` Christoph Hellwig
2007-02-16 17:33             ` Geert Uytterhoeven
2007-02-16 17:33               ` [Linux-fbdev-devel] " Geert Uytterhoeven
2007-02-19 14:07               ` Geert Uytterhoeven
2007-02-20 10:33                 ` Geert Uytterhoeven
2007-02-20 10:42                   ` [PATCH 1/4 (final?)] " Geert Uytterhoeven
2007-02-21 23:20                     ` Andrew Morton
2007-02-21 23:20                       ` Andrew Morton
2007-02-22  8:21                       ` Geert Uytterhoeven
2007-02-22  8:21                         ` Geert Uytterhoeven
2007-02-22 12:16                       ` Geert Uytterhoeven
2007-02-22 12:16                         ` Geert Uytterhoeven
2007-02-22 12:17                       ` [PATCH 1/4 (final)] " Geert Uytterhoeven
2007-02-22 12:17                         ` Geert Uytterhoeven
2007-02-16 16:03         ` [PATCH extra] ps3fb: atomic fixes Geert Uytterhoeven
2007-02-16 16:03           ` Geert Uytterhoeven
2007-02-16 16:36         ` [patch 1/4] ps3fb: thread updates Christoph Hellwig
2007-02-16 16:36           ` Christoph Hellwig
2007-02-15 15:23 ` [patch 2/4] ps3av: " Geert.Uytterhoeven
2007-02-15 15:23   ` Geert.Uytterhoeven
2007-02-15 15:23 ` [patch 3/4] ps3fb: kill superfluous zero initializations Geert.Uytterhoeven
2007-02-15 15:23   ` Geert.Uytterhoeven
2007-02-15 15:23 ` [patch 4/4] ps3av: misc updates Geert.Uytterhoeven
2007-02-15 15:23   ` Geert.Uytterhoeven
2007-02-15 15:48 ` [patch 0/4] PS3 AV/FB updates James Simmons
2007-02-15 15:48   ` [Linux-fbdev-devel] " James Simmons

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=20070215152432.264415000@sonycom.com \
    --to=geert.uytterhoeven@sonycom.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    --cc=linuxppc-dev@ozlabs.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.