mirror of
https://github.com/torvalds/linux.git
synced 2024-12-31 23:31:29 +00:00
[PATCH] pcmcia: convert pcmcia_cs to kthread
Convert pcmcia_cs to use kthread instead of the deprecated kernel_thread. Signed-off-by: Serge E. Hallyn <serue@us.ibm.com> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
This commit is contained in:
parent
6600521607
commit
1da9ab7389
@ -28,6 +28,7 @@
|
|||||||
#include <linux/pm.h>
|
#include <linux/pm.h>
|
||||||
#include <linux/pci.h>
|
#include <linux/pci.h>
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
|
#include <linux/kthread.h>
|
||||||
#include <asm/system.h>
|
#include <asm/system.h>
|
||||||
#include <asm/irq.h>
|
#include <asm/irq.h>
|
||||||
|
|
||||||
@ -176,6 +177,7 @@ static int pccardd(void *__skt);
|
|||||||
*/
|
*/
|
||||||
int pcmcia_register_socket(struct pcmcia_socket *socket)
|
int pcmcia_register_socket(struct pcmcia_socket *socket)
|
||||||
{
|
{
|
||||||
|
struct task_struct *tsk;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!socket || !socket->ops || !socket->dev.dev || !socket->resource_ops)
|
if (!socket || !socket->ops || !socket->dev.dev || !socket->resource_ops)
|
||||||
@ -239,15 +241,18 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
|
|||||||
mutex_init(&socket->skt_mutex);
|
mutex_init(&socket->skt_mutex);
|
||||||
spin_lock_init(&socket->thread_lock);
|
spin_lock_init(&socket->thread_lock);
|
||||||
|
|
||||||
ret = kernel_thread(pccardd, socket, CLONE_KERNEL);
|
tsk = kthread_run(pccardd, socket, "pccardd");
|
||||||
if (ret < 0)
|
if (IS_ERR(tsk)) {
|
||||||
|
ret = PTR_ERR(tsk);
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
wait_for_completion(&socket->thread_done);
|
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);
|
printk(KERN_WARNING "PCMCIA: warning: socket thread for socket %p did not start\n", socket);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
pcmcia_parse_events(socket, SS_DETECT);
|
pcmcia_parse_events(socket, SS_DETECT);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -272,10 +277,8 @@ void pcmcia_unregister_socket(struct pcmcia_socket *socket)
|
|||||||
cs_dbg(socket, 0, "pcmcia_unregister_socket(0x%p)\n", socket->ops);
|
cs_dbg(socket, 0, "pcmcia_unregister_socket(0x%p)\n", socket->ops);
|
||||||
|
|
||||||
if (socket->thread) {
|
if (socket->thread) {
|
||||||
init_completion(&socket->thread_done);
|
|
||||||
socket->thread = NULL;
|
|
||||||
wake_up(&socket->thread_wait);
|
wake_up(&socket->thread_wait);
|
||||||
wait_for_completion(&socket->thread_done);
|
kthread_stop(socket->thread);
|
||||||
}
|
}
|
||||||
release_cis_mem(socket);
|
release_cis_mem(socket);
|
||||||
|
|
||||||
@ -630,8 +633,6 @@ static int pccardd(void *__skt)
|
|||||||
DECLARE_WAITQUEUE(wait, current);
|
DECLARE_WAITQUEUE(wait, current);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
daemonize("pccardd");
|
|
||||||
|
|
||||||
skt->thread = current;
|
skt->thread = current;
|
||||||
skt->socket = dead_socket;
|
skt->socket = dead_socket;
|
||||||
skt->ops->init(skt);
|
skt->ops->init(skt);
|
||||||
@ -643,7 +644,8 @@ static int pccardd(void *__skt)
|
|||||||
printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n",
|
printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n",
|
||||||
skt);
|
skt);
|
||||||
skt->thread = NULL;
|
skt->thread = NULL;
|
||||||
complete_and_exit(&skt->thread_done, 0);
|
complete(&skt->thread_done);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_wait_queue(&skt->thread_wait, &wait);
|
add_wait_queue(&skt->thread_wait, &wait);
|
||||||
@ -674,7 +676,7 @@ static int pccardd(void *__skt)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skt->thread)
|
if (kthread_should_stop())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
schedule();
|
schedule();
|
||||||
@ -688,7 +690,7 @@ static int pccardd(void *__skt)
|
|||||||
/* remove from the device core */
|
/* remove from the device core */
|
||||||
class_device_unregister(&skt->dev);
|
class_device_unregister(&skt->dev);
|
||||||
|
|
||||||
complete_and_exit(&skt->thread_done, 0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user