summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTroy Kisky <troy.kisky@boundarydevices.com>2014-04-28 17:25:15 -0700
committerTroy Kisky <troy.kisky@boundarydevices.com>2014-04-28 17:27:12 -0700
commitef09ea124482bd34b06897433ea66dea9cfbd16c (patch)
tree1951096c0ddf443cd20ee1a6e44627bcc0bd5820
parent11028f5276fa78bf3eb96bae7974d30ac0f64003 (diff)
mmc: each mmc_host has its own workqueue
-rw-r--r--drivers/mmc/core/core.c36
-rw-r--r--drivers/mmc/core/host.c4
-rw-r--r--include/linux/mmc/host.h1
3 files changed, 10 insertions, 31 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index c40396f23202..acc69ecc23f8 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -51,7 +51,6 @@
*/
#define MMC_BKOPS_MAX_TIMEOUT (4 * 60 * 1000) /* max time to wait in ms */
-static struct workqueue_struct *workqueue;
static const unsigned freqs[] = { 400000, 300000, 200000, 100000 };
/*
@@ -79,23 +78,6 @@ MODULE_PARM_DESC(
removable,
"MMC/SD cards are removable and may be removed during suspend");
-/*
- * Internal function. Schedule delayed work in the MMC work queue.
- */
-static int mmc_schedule_delayed_work(struct delayed_work *work,
- unsigned long delay)
-{
- return queue_delayed_work(workqueue, work, delay);
-}
-
-/*
- * Internal function. Flush all scheduled work from the MMC work queue.
- */
-static void mmc_flush_scheduled_work(void)
-{
- flush_workqueue(workqueue);
-}
-
#ifdef CONFIG_FAIL_MMC_REQUEST
/*
@@ -1656,7 +1638,7 @@ void mmc_detect_change(struct mmc_host *host, unsigned long delay)
spin_unlock_irqrestore(&host->lock, flags);
#endif
host->detect_change = 1;
- mmc_schedule_delayed_work(&host->detect, delay);
+ queue_delayed_work(host->workqueue, &host->detect, delay);
}
EXPORT_SYMBOL(mmc_detect_change);
@@ -2409,7 +2391,7 @@ void mmc_rescan(struct work_struct *work)
out:
if (host->caps & MMC_CAP_NEEDS_POLL)
- mmc_schedule_delayed_work(&host->detect, HZ);
+ queue_delayed_work(host->workqueue, &host->detect, HZ);
}
void mmc_start_host(struct mmc_host *host)
@@ -2434,7 +2416,7 @@ void mmc_stop_host(struct mmc_host *host)
host->rescan_disable = 1;
cancel_delayed_work_sync(&host->detect);
- mmc_flush_scheduled_work();
+ flush_workqueue(host->workqueue);
/* clear pm flags now and let card drivers set them as needed */
host->pm_flags = 0;
@@ -2629,7 +2611,7 @@ int mmc_suspend_host(struct mmc_host *host)
int err = 0;
cancel_delayed_work(&host->detect);
- mmc_flush_scheduled_work();
+ flush_workqueue(host->workqueue);
mmc_bus_get(host);
if (host->bus_ops && !host->bus_dead) {
@@ -2793,13 +2775,9 @@ static int __init mmc_init(void)
{
int ret;
- workqueue = alloc_ordered_workqueue("kmmcd", 0);
- if (!workqueue)
- return -ENOMEM;
-
ret = mmc_register_bus();
if (ret)
- goto destroy_workqueue;
+ return ret;
ret = mmc_register_host_class();
if (ret)
@@ -2815,9 +2793,6 @@ unregister_host_class:
mmc_unregister_host_class();
unregister_bus:
mmc_unregister_bus();
-destroy_workqueue:
- destroy_workqueue(workqueue);
-
return ret;
}
@@ -2826,7 +2801,6 @@ static void __exit mmc_exit(void)
sdio_unregister_bus();
mmc_unregister_host_class();
mmc_unregister_bus();
- destroy_workqueue(workqueue);
}
subsys_initcall(mmc_init);
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 2a3593d9f87d..6ac9c3af023e 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -36,6 +36,7 @@ static void mmc_host_classdev_release(struct device *dev)
{
struct mmc_host *host = cls_dev_to_mmc_host(dev);
mutex_destroy(&host->slot.lock);
+ destroy_workqueue(host->workqueue);
kfree(host);
}
@@ -446,6 +447,9 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
goto free;
dev_set_name(&host->class_dev, "mmc%d", host->index);
+ host->workqueue = alloc_ordered_workqueue("kmmcd%d", 0, host->index);
+ if (!host->workqueue)
+ goto free;
host->parent = dev;
host->class_dev.parent = dev;
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index e326ae2882a0..bc45257f76c6 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -328,6 +328,7 @@ struct mmc_host {
struct task_struct *claimer; /* task that has host claimed */
int claim_cnt; /* "claim" nesting count */
+ struct workqueue_struct *workqueue;
struct delayed_work detect;
int detect_change; /* card detect flag */
struct mmc_slot slot;