* [PATCH] kthread: convert pcmcia_cs from kernel_thread
@ 2006-06-14 12:06 Serge E. Hallyn
2006-06-14 12:45 ` Dominik Brodowski
0 siblings, 1 reply; 5+ messages in thread
From: Serge E. Hallyn @ 2006-06-14 12:06 UTC (permalink / raw)
To: linux-pcmcia, lkml
Convert pcmcia_cs to use kthread instead of the deprecated
kernel_thread.
Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
---
drivers/pcmcia/cs.c | 27 ++++++++++-----------------
include/pcmcia/ss.h | 1 -
2 files changed, 10 insertions(+), 18 deletions(-)
d711552935ab4b1734624e49d13b19675f24f29c
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 3162998..aa31b44 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -28,6 +28,7 @@
#include <linux/pm.h>
#include <linux/pci.h>
#include <linux/device.h>
+#include <linux/kthread.h>
#include <asm/system.h>
#include <asm/irq.h>
@@ -176,6 +177,7 @@ static int pccardd(void *__skt);
*/
int pcmcia_register_socket(struct pcmcia_socket *socket)
{
+ struct task_struct *tsk;
int ret;
if (!socket || !socket->ops || !socket->dev.dev || !socket->resource_ops)
@@ -234,20 +236,16 @@ int pcmcia_register_socket(struct pcmcia
INIT_LIST_HEAD(&socket->cis_cache);
init_completion(&socket->socket_released);
- init_completion(&socket->thread_done);
init_waitqueue_head(&socket->thread_wait);
mutex_init(&socket->skt_mutex);
spin_lock_init(&socket->thread_lock);
- ret = kernel_thread(pccardd, socket, CLONE_KERNEL);
- if (ret < 0)
+ tsk = kthread_run(pccardd, socket, "pccardd");
+ if (IS_ERR(tsk)) {
+ ret = PTR_ERR(tsk);
goto err;
-
- wait_for_completion(&socket->thread_done);
- if(!socket->thread) {
- printk(KERN_WARNING "PCMCIA: warning: socket thread for socket %p did not start\n", socket);
- return -EIO;
}
+
pcmcia_parse_events(socket, SS_DETECT);
return 0;
@@ -272,10 +270,8 @@ void pcmcia_unregister_socket(struct pcm
cs_dbg(socket, 0, "pcmcia_unregister_socket(0x%p)\n", socket->ops);
if (socket->thread) {
- init_completion(&socket->thread_done);
- socket->thread = NULL;
wake_up(&socket->thread_wait);
- wait_for_completion(&socket->thread_done);
+ kthread_stop(socket->thread);
}
release_cis_mem(socket);
@@ -630,8 +626,6 @@ static int pccardd(void *__skt)
DECLARE_WAITQUEUE(wait, current);
int ret;
- daemonize("pccardd");
-
skt->thread = current;
skt->socket = dead_socket;
skt->ops->init(skt);
@@ -643,11 +637,10 @@ static int pccardd(void *__skt)
printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n",
skt);
skt->thread = NULL;
- complete_and_exit(&skt->thread_done, 0);
+ return 0;
}
add_wait_queue(&skt->thread_wait, &wait);
- complete(&skt->thread_done);
for (;;) {
unsigned long flags;
@@ -674,7 +667,7 @@ static int pccardd(void *__skt)
continue;
}
- if (!skt->thread)
+ if (kthread_should_stop())
break;
schedule();
@@ -688,7 +681,7 @@ static int pccardd(void *__skt)
/* remove from the device core */
class_device_unregister(&skt->dev);
- complete_and_exit(&skt->thread_done, 0);
+ return 0;
}
/*
diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h
index 5e0a01a..e35d0bb 100644
--- a/include/pcmcia/ss.h
+++ b/include/pcmcia/ss.h
@@ -245,7 +245,6 @@ struct pcmcia_socket {
struct mutex skt_mutex; /* protects socket h/w state */
struct task_struct *thread;
- struct completion thread_done;
wait_queue_head_t thread_wait;
spinlock_t thread_lock; /* protects thread_events */
unsigned int thread_events;
--
1.1.6
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kthread: convert pcmcia_cs from kernel_thread
2006-06-14 12:06 [PATCH] kthread: convert pcmcia_cs from kernel_thread Serge E. Hallyn
@ 2006-06-14 12:45 ` Dominik Brodowski
2006-06-14 12:50 ` Serge E. Hallyn
0 siblings, 1 reply; 5+ messages in thread
From: Dominik Brodowski @ 2006-06-14 12:45 UTC (permalink / raw)
To: Serge E. Hallyn; +Cc: linux-pcmcia, lkml
On Wed, Jun 14, 2006 at 07:06:37AM -0500, Serge E. Hallyn wrote:
> Convert pcmcia_cs to use kthread instead of the deprecated
> kernel_thread.
Nack.
See
http://lists.infradead.org/pipermail/linux-pcmcia/2006-February/003259.html
or http://lkml.org/lkml/2006/2/14/395 for details.
Dominik
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kthread: convert pcmcia_cs from kernel_thread
2006-06-14 12:45 ` Dominik Brodowski
@ 2006-06-14 12:50 ` Serge E. Hallyn
2006-06-14 13:01 ` Serge E. Hallyn
0 siblings, 1 reply; 5+ messages in thread
From: Serge E. Hallyn @ 2006-06-14 12:50 UTC (permalink / raw)
To: Serge E. Hallyn, linux-pcmcia, lkml
Quoting Dominik Brodowski (linux@dominikbrodowski.net):
> On Wed, Jun 14, 2006 at 07:06:37AM -0500, Serge E. Hallyn wrote:
> > Convert pcmcia_cs to use kthread instead of the deprecated
> > kernel_thread.
>
> Nack.
>
> See
> http://lists.infradead.org/pipermail/linux-pcmcia/2006-February/003259.html
> or http://lkml.org/lkml/2006/2/14/395 for details.
Ok - so if we keep the thread_done completion in front of the main
loop in pccardd to check for that error, will that be sufficient?
thanks,
-serge
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kthread: convert pcmcia_cs from kernel_thread
2006-06-14 12:50 ` Serge E. Hallyn
@ 2006-06-14 13:01 ` Serge E. Hallyn
2006-06-30 18:52 ` Dominik Brodowski
0 siblings, 1 reply; 5+ messages in thread
From: Serge E. Hallyn @ 2006-06-14 13:01 UTC (permalink / raw)
To: Serge E. Hallyn; +Cc: linux-pcmcia, lkml
Quoting Serge E. Hallyn (serue@us.ibm.com):
> Quoting Dominik Brodowski (linux@dominikbrodowski.net):
> > On Wed, Jun 14, 2006 at 07:06:37AM -0500, Serge E. Hallyn wrote:
> > > Convert pcmcia_cs to use kthread instead of the deprecated
> > > kernel_thread.
> >
> > Nack.
> >
> > See
> > http://lists.infradead.org/pipermail/linux-pcmcia/2006-February/003259.html
> > or http://lkml.org/lkml/2006/2/14/395 for details.
>
> Ok - so if we keep the thread_done completion in front of the main
> loop in pccardd to check for that error, will that be sufficient?
I.e., like so:
Subject: [PATCH] kthread: convert pcmcia_cs from kernel_thread
Convert pcmcia_cs to use kthread instead of the deprecated
kernel_thread.
Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
---
drivers/pcmcia/cs.c | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 deletions(-)
b84aa23a2efeeeef0a53220f93fa36a9f35708f8
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 3162998..06e2cda 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -28,6 +28,7 @@ #include <linux/delay.h>
#include <linux/pm.h>
#include <linux/pci.h>
#include <linux/device.h>
+#include <linux/kthread.h>
#include <asm/system.h>
#include <asm/irq.h>
@@ -176,6 +177,7 @@ static int pccardd(void *__skt);
*/
int pcmcia_register_socket(struct pcmcia_socket *socket)
{
+ struct task_struct *tsk;
int ret;
if (!socket || !socket->ops || !socket->dev.dev || !socket->resource_ops)
@@ -239,15 +241,18 @@ #endif
mutex_init(&socket->skt_mutex);
spin_lock_init(&socket->thread_lock);
- ret = kernel_thread(pccardd, socket, CLONE_KERNEL);
- if (ret < 0)
+ tsk = kthread_run(pccardd, socket, "pccardd");
+ if (IS_ERR(tsk)) {
+ ret = PTR_ERR(tsk);
goto err;
+ }
wait_for_completion(&socket->thread_done);
- if(!socket->thread) {
+ if (!socket->thread) {
printk(KERN_WARNING "PCMCIA: warning: socket thread for socket %p did not start\n", socket);
return -EIO;
}
+
pcmcia_parse_events(socket, SS_DETECT);
return 0;
@@ -272,10 +277,8 @@ void pcmcia_unregister_socket(struct pcm
cs_dbg(socket, 0, "pcmcia_unregister_socket(0x%p)\n", socket->ops);
if (socket->thread) {
- init_completion(&socket->thread_done);
- socket->thread = NULL;
wake_up(&socket->thread_wait);
- wait_for_completion(&socket->thread_done);
+ kthread_stop(socket->thread);
}
release_cis_mem(socket);
@@ -630,8 +633,6 @@ static int pccardd(void *__skt)
DECLARE_WAITQUEUE(wait, current);
int ret;
- daemonize("pccardd");
-
skt->thread = current;
skt->socket = dead_socket;
skt->ops->init(skt);
@@ -643,7 +644,8 @@ static int pccardd(void *__skt)
printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n",
skt);
skt->thread = NULL;
- complete_and_exit(&skt->thread_done, 0);
+ complete(&skt->thread_done);
+ return 0;
}
add_wait_queue(&skt->thread_wait, &wait);
@@ -674,7 +676,7 @@ static int pccardd(void *__skt)
continue;
}
- if (!skt->thread)
+ if (kthread_should_stop())
break;
schedule();
@@ -688,7 +690,7 @@ static int pccardd(void *__skt)
/* remove from the device core */
class_device_unregister(&skt->dev);
- complete_and_exit(&skt->thread_done, 0);
+ return 0;
}
/*
--
1.3.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kthread: convert pcmcia_cs from kernel_thread
2006-06-14 13:01 ` Serge E. Hallyn
@ 2006-06-30 18:52 ` Dominik Brodowski
0 siblings, 0 replies; 5+ messages in thread
From: Dominik Brodowski @ 2006-06-30 18:52 UTC (permalink / raw)
To: Serge E. Hallyn; +Cc: linux-pcmcia, lkml
Hi,
On Wed, Jun 14, 2006 at 08:01:26AM -0500, Serge E. Hallyn wrote:
> I.e., like so:
>
> Subject: [PATCH] kthread: convert pcmcia_cs from kernel_thread
Applied.
Thanks,
Dominik
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-06-30 19:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-14 12:06 [PATCH] kthread: convert pcmcia_cs from kernel_thread Serge E. Hallyn
2006-06-14 12:45 ` Dominik Brodowski
2006-06-14 12:50 ` Serge E. Hallyn
2006-06-14 13:01 ` Serge E. Hallyn
2006-06-30 18:52 ` Dominik Brodowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®