mmc: remove kernel_thread()
Replace kernel_thread() with kthread_run()/kthread_stop(). Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
This commit is contained in:
committed by
Pierre Ossman
parent
0215ffb08c
commit
87598a2bd4
@@ -10,13 +10,13 @@
|
|||||||
*/
|
*/
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/blkdev.h>
|
#include <linux/blkdev.h>
|
||||||
|
#include <linux/kthread.h>
|
||||||
|
|
||||||
#include <linux/mmc/card.h>
|
#include <linux/mmc/card.h>
|
||||||
#include <linux/mmc/host.h>
|
#include <linux/mmc/host.h>
|
||||||
#include "mmc_queue.h"
|
#include "mmc_queue.h"
|
||||||
|
|
||||||
#define MMC_QUEUE_EXIT (1 << 0)
|
#define MMC_QUEUE_SUSPENDED (1 << 0)
|
||||||
#define MMC_QUEUE_SUSPENDED (1 << 1)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare a MMC request. Essentially, this means passing the
|
* Prepare a MMC request. Essentially, this means passing the
|
||||||
@@ -59,7 +59,6 @@ static int mmc_queue_thread(void *d)
|
|||||||
{
|
{
|
||||||
struct mmc_queue *mq = d;
|
struct mmc_queue *mq = d;
|
||||||
struct request_queue *q = mq->queue;
|
struct request_queue *q = mq->queue;
|
||||||
DECLARE_WAITQUEUE(wait, current);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set iothread to ensure that we aren't put to sleep by
|
* Set iothread to ensure that we aren't put to sleep by
|
||||||
@@ -67,12 +66,7 @@ static int mmc_queue_thread(void *d)
|
|||||||
*/
|
*/
|
||||||
current->flags |= PF_MEMALLOC|PF_NOFREEZE;
|
current->flags |= PF_MEMALLOC|PF_NOFREEZE;
|
||||||
|
|
||||||
daemonize("mmcqd");
|
|
||||||
|
|
||||||
complete(&mq->thread_complete);
|
|
||||||
|
|
||||||
down(&mq->thread_sem);
|
down(&mq->thread_sem);
|
||||||
add_wait_queue(&mq->thread_wq, &wait);
|
|
||||||
do {
|
do {
|
||||||
struct request *req = NULL;
|
struct request *req = NULL;
|
||||||
|
|
||||||
@@ -84,7 +78,7 @@ static int mmc_queue_thread(void *d)
|
|||||||
spin_unlock_irq(q->queue_lock);
|
spin_unlock_irq(q->queue_lock);
|
||||||
|
|
||||||
if (!req) {
|
if (!req) {
|
||||||
if (mq->flags & MMC_QUEUE_EXIT)
|
if (kthread_should_stop())
|
||||||
break;
|
break;
|
||||||
up(&mq->thread_sem);
|
up(&mq->thread_sem);
|
||||||
schedule();
|
schedule();
|
||||||
@@ -95,10 +89,8 @@ static int mmc_queue_thread(void *d)
|
|||||||
|
|
||||||
mq->issue_fn(mq, req);
|
mq->issue_fn(mq, req);
|
||||||
} while (1);
|
} while (1);
|
||||||
remove_wait_queue(&mq->thread_wq, &wait);
|
|
||||||
up(&mq->thread_sem);
|
up(&mq->thread_sem);
|
||||||
|
|
||||||
complete_and_exit(&mq->thread_complete, 0);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +105,7 @@ static void mmc_request(request_queue_t *q)
|
|||||||
struct mmc_queue *mq = q->queuedata;
|
struct mmc_queue *mq = q->queuedata;
|
||||||
|
|
||||||
if (!mq->req)
|
if (!mq->req)
|
||||||
wake_up(&mq->thread_wq);
|
wake_up_process(mq->thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,36 +144,31 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
|
|||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!mq->sg) {
|
if (!mq->sg) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto cleanup;
|
goto cleanup_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
init_completion(&mq->thread_complete);
|
|
||||||
init_waitqueue_head(&mq->thread_wq);
|
|
||||||
init_MUTEX(&mq->thread_sem);
|
init_MUTEX(&mq->thread_sem);
|
||||||
|
|
||||||
ret = kernel_thread(mmc_queue_thread, mq, CLONE_KERNEL);
|
mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd");
|
||||||
if (ret >= 0) {
|
if (IS_ERR(mq->thread)) {
|
||||||
wait_for_completion(&mq->thread_complete);
|
ret = PTR_ERR(mq->thread);
|
||||||
init_completion(&mq->thread_complete);
|
goto free_sg;
|
||||||
ret = 0;
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
return 0;
|
||||||
|
|
||||||
|
free_sg:
|
||||||
kfree(mq->sg);
|
kfree(mq->sg);
|
||||||
mq->sg = NULL;
|
mq->sg = NULL;
|
||||||
|
cleanup_queue:
|
||||||
blk_cleanup_queue(mq->queue);
|
blk_cleanup_queue(mq->queue);
|
||||||
out:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(mmc_init_queue);
|
EXPORT_SYMBOL(mmc_init_queue);
|
||||||
|
|
||||||
void mmc_cleanup_queue(struct mmc_queue *mq)
|
void mmc_cleanup_queue(struct mmc_queue *mq)
|
||||||
{
|
{
|
||||||
mq->flags |= MMC_QUEUE_EXIT;
|
kthread_stop(mq->thread);
|
||||||
wake_up(&mq->thread_wq);
|
|
||||||
wait_for_completion(&mq->thread_complete);
|
|
||||||
|
|
||||||
kfree(mq->sg);
|
kfree(mq->sg);
|
||||||
mq->sg = NULL;
|
mq->sg = NULL;
|
||||||
|
@@ -6,8 +6,7 @@ struct task_struct;
|
|||||||
|
|
||||||
struct mmc_queue {
|
struct mmc_queue {
|
||||||
struct mmc_card *card;
|
struct mmc_card *card;
|
||||||
struct completion thread_complete;
|
struct task_struct *thread;
|
||||||
wait_queue_head_t thread_wq;
|
|
||||||
struct semaphore thread_sem;
|
struct semaphore thread_sem;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
struct request *req;
|
struct request *req;
|
||||||
|
Reference in New Issue
Block a user