* [PATCH 1/2] mmc: core: simplify ida handling
@ 2017-01-28 8:32 Heiner Kallweit
2017-01-30 10:04 ` Ulf Hansson
0 siblings, 1 reply; 2+ messages in thread
From: Heiner Kallweit @ 2017-01-28 8:32 UTC (permalink / raw)
To: Ulf Hansson; +Cc: linux-mmc
ida handling can be simplified by switching to the ida_simple_
functions.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/mmc/core/host.c | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 98f25ffb..0a26c8b6 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -34,14 +34,11 @@
#define cls_dev_to_mmc_host(d) container_of(d, struct mmc_host, class_dev)
static DEFINE_IDA(mmc_host_ida);
-static DEFINE_SPINLOCK(mmc_host_lock);
static void mmc_host_classdev_release(struct device *dev)
{
struct mmc_host *host = cls_dev_to_mmc_host(dev);
- spin_lock(&mmc_host_lock);
- ida_remove(&mmc_host_ida, host->index);
- spin_unlock(&mmc_host_lock);
+ ida_simple_remove(&mmc_host_ida, host->index);
kfree(host);
}
@@ -354,22 +351,13 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
/* scanning will be enabled when we're ready */
host->rescan_disable = 1;
-again:
- if (!ida_pre_get(&mmc_host_ida, GFP_KERNEL)) {
+ err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL);
+ if (err < 0) {
kfree(host);
return NULL;
}
- spin_lock(&mmc_host_lock);
- err = ida_get_new(&mmc_host_ida, &host->index);
- spin_unlock(&mmc_host_lock);
-
- if (err == -EAGAIN) {
- goto again;
- } else if (err) {
- kfree(host);
- return NULL;
- }
+ host->index = err;
dev_set_name(&host->class_dev, "mmc%d", host->index);
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/2] mmc: core: simplify ida handling
2017-01-28 8:32 [PATCH 1/2] mmc: core: simplify ida handling Heiner Kallweit
@ 2017-01-30 10:04 ` Ulf Hansson
0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2017-01-30 10:04 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: linux-mmc
On 28 January 2017 at 09:32, Heiner Kallweit <hkallweit1@gmail.com> wrote:
> ida handling can be simplified by switching to the ida_simple_
> functions.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Thanks, applied for next!
Kind regards
Uffe
> ---
> drivers/mmc/core/host.c | 20 ++++----------------
> 1 file changed, 4 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 98f25ffb..0a26c8b6 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -34,14 +34,11 @@
> #define cls_dev_to_mmc_host(d) container_of(d, struct mmc_host, class_dev)
>
> static DEFINE_IDA(mmc_host_ida);
> -static DEFINE_SPINLOCK(mmc_host_lock);
>
> static void mmc_host_classdev_release(struct device *dev)
> {
> struct mmc_host *host = cls_dev_to_mmc_host(dev);
> - spin_lock(&mmc_host_lock);
> - ida_remove(&mmc_host_ida, host->index);
> - spin_unlock(&mmc_host_lock);
> + ida_simple_remove(&mmc_host_ida, host->index);
> kfree(host);
> }
>
> @@ -354,22 +351,13 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
> /* scanning will be enabled when we're ready */
> host->rescan_disable = 1;
>
> -again:
> - if (!ida_pre_get(&mmc_host_ida, GFP_KERNEL)) {
> + err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL);
> + if (err < 0) {
> kfree(host);
> return NULL;
> }
>
> - spin_lock(&mmc_host_lock);
> - err = ida_get_new(&mmc_host_ida, &host->index);
> - spin_unlock(&mmc_host_lock);
> -
> - if (err == -EAGAIN) {
> - goto again;
> - } else if (err) {
> - kfree(host);
> - return NULL;
> - }
> + host->index = err;
>
> dev_set_name(&host->class_dev, "mmc%d", host->index);
>
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-30 10:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-28 8:32 [PATCH 1/2] mmc: core: simplify ida handling Heiner Kallweit
2017-01-30 10:04 ` Ulf Hansson
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.