* [PATCH] iio: Directly use ida_alloc()/free()
@ 2022-05-27 9:17 keliu
2022-06-03 15:56 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: keliu @ 2022-05-27 9:17 UTC (permalink / raw)
To: jic23, lars, linux-iio, linux-kernel; +Cc: keliu
Use ida_alloc()/ida_free() instead of deprecated
ida_simple_get()/ida_simple_remove() .
Signed-off-by: keliu <liuke94@huawei.com>
---
drivers/iio/industrialio-core.c | 6 +++---
drivers/iio/industrialio-trigger.c | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index e1ed44dec2ab..41daa10cd63d 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1618,7 +1618,7 @@ static void iio_dev_release(struct device *device)
iio_device_detach_buffers(indio_dev);
- ida_simple_remove(&iio_ida, iio_dev_opaque->id);
+ ida_free(&iio_ida, iio_dev_opaque->id);
kfree(iio_dev_opaque);
}
@@ -1660,7 +1660,7 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv)
mutex_init(&iio_dev_opaque->info_exist_lock);
INIT_LIST_HEAD(&iio_dev_opaque->channel_attr_list);
- iio_dev_opaque->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL);
+ iio_dev_opaque->id = ida_alloc(&iio_ida, GFP_KERNEL);
if (iio_dev_opaque->id < 0) {
/* cannot use a dev_err as the name isn't available */
pr_err("failed to get device id\n");
@@ -1669,7 +1669,7 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv)
}
if (dev_set_name(&indio_dev->dev, "iio:device%d", iio_dev_opaque->id)) {
- ida_simple_remove(&iio_ida, iio_dev_opaque->id);
+ ida_free(&iio_ida, iio_dev_opaque->id);
kfree(iio_dev_opaque);
return NULL;
}
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index f504ed351b3e..6eb9b721676e 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -71,7 +71,7 @@ int __iio_trigger_register(struct iio_trigger *trig_info,
trig_info->owner = this_mod;
- trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL);
+ trig_info->id = ida_alloc(&iio_trigger_ida, GFP_KERNEL);
if (trig_info->id < 0)
return trig_info->id;
@@ -98,7 +98,7 @@ int __iio_trigger_register(struct iio_trigger *trig_info,
mutex_unlock(&iio_trigger_list_lock);
device_del(&trig_info->dev);
error_unregister_id:
- ida_simple_remove(&iio_trigger_ida, trig_info->id);
+ ida_free(&iio_trigger_ida, trig_info->id);
return ret;
}
EXPORT_SYMBOL(__iio_trigger_register);
@@ -109,7 +109,7 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
list_del(&trig_info->list);
mutex_unlock(&iio_trigger_list_lock);
- ida_simple_remove(&iio_trigger_ida, trig_info->id);
+ ida_free(&iio_trigger_ida, trig_info->id);
/* Possible issue in here */
device_del(&trig_info->dev);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: Directly use ida_alloc()/free()
2022-05-27 9:17 [PATCH] iio: Directly use ida_alloc()/free() keliu
@ 2022-06-03 15:56 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2022-06-03 15:56 UTC (permalink / raw)
To: keliu; +Cc: lars, linux-iio, linux-kernel
On Fri, 27 May 2022 09:17:39 +0000
keliu <liuke94@huawei.com> wrote:
> Use ida_alloc()/ida_free() instead of deprecated
> ida_simple_get()/ida_simple_remove() .
>
> Signed-off-by: keliu <liuke94@huawei.com>
Looks good to me.
Applied to the togreg branch of iio.git and pushed out initially as testing
to let 0-day see if it can find any problems we missed.
Thanks,
Jonathan
> ---
> drivers/iio/industrialio-core.c | 6 +++---
> drivers/iio/industrialio-trigger.c | 6 +++---
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index e1ed44dec2ab..41daa10cd63d 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1618,7 +1618,7 @@ static void iio_dev_release(struct device *device)
>
> iio_device_detach_buffers(indio_dev);
>
> - ida_simple_remove(&iio_ida, iio_dev_opaque->id);
> + ida_free(&iio_ida, iio_dev_opaque->id);
> kfree(iio_dev_opaque);
> }
>
> @@ -1660,7 +1660,7 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv)
> mutex_init(&iio_dev_opaque->info_exist_lock);
> INIT_LIST_HEAD(&iio_dev_opaque->channel_attr_list);
>
> - iio_dev_opaque->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL);
> + iio_dev_opaque->id = ida_alloc(&iio_ida, GFP_KERNEL);
> if (iio_dev_opaque->id < 0) {
> /* cannot use a dev_err as the name isn't available */
> pr_err("failed to get device id\n");
> @@ -1669,7 +1669,7 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv)
> }
>
> if (dev_set_name(&indio_dev->dev, "iio:device%d", iio_dev_opaque->id)) {
> - ida_simple_remove(&iio_ida, iio_dev_opaque->id);
> + ida_free(&iio_ida, iio_dev_opaque->id);
> kfree(iio_dev_opaque);
> return NULL;
> }
> diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
> index f504ed351b3e..6eb9b721676e 100644
> --- a/drivers/iio/industrialio-trigger.c
> +++ b/drivers/iio/industrialio-trigger.c
> @@ -71,7 +71,7 @@ int __iio_trigger_register(struct iio_trigger *trig_info,
>
> trig_info->owner = this_mod;
>
> - trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL);
> + trig_info->id = ida_alloc(&iio_trigger_ida, GFP_KERNEL);
> if (trig_info->id < 0)
> return trig_info->id;
>
> @@ -98,7 +98,7 @@ int __iio_trigger_register(struct iio_trigger *trig_info,
> mutex_unlock(&iio_trigger_list_lock);
> device_del(&trig_info->dev);
> error_unregister_id:
> - ida_simple_remove(&iio_trigger_ida, trig_info->id);
> + ida_free(&iio_trigger_ida, trig_info->id);
> return ret;
> }
> EXPORT_SYMBOL(__iio_trigger_register);
> @@ -109,7 +109,7 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
> list_del(&trig_info->list);
> mutex_unlock(&iio_trigger_list_lock);
>
> - ida_simple_remove(&iio_trigger_ida, trig_info->id);
> + ida_free(&iio_trigger_ida, trig_info->id);
> /* Possible issue in here */
> device_del(&trig_info->dev);
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-03 15:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-27 9:17 [PATCH] iio: Directly use ida_alloc()/free() keliu
2022-06-03 15:56 ` Jonathan Cameron
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.