* [PATCH] platform_device: switch to simpler IDA interface
@ 2020-09-09 18:02 Bartosz Golaszewski
0 siblings, 0 replies; only message in thread
From: Bartosz Golaszewski @ 2020-09-09 18:02 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J . Wysocki; +Cc: linux-kernel, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
We don't need to specify any ranges when allocating IDs so we can switch
to ida_alloc() and ida_free() instead of the ida_simple_ counterparts.
ida_simple_get(ida, 0, 0, gfp) is equivalent to
ida_alloc_range(ida, 0, UINT_MAX, gfp) which is equivalent to
ida_alloc(ida, gfp). Note: IDR will never actually allocate an ID
larger than INT_MAX.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/base/platform.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index e5d8a0503b4f..194c36e3f37c 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -559,7 +559,7 @@ int platform_device_add(struct platform_device *pdev)
* that we remember it must be freed, and we append a suffix
* to avoid namespace collision with explicit IDs.
*/
- ret = ida_simple_get(&platform_devid_ida, 0, 0, GFP_KERNEL);
+ ret = ida_alloc(&platform_devid_ida, GFP_KERNEL);
if (ret < 0)
goto err_out;
pdev->id = ret;
@@ -600,7 +600,7 @@ int platform_device_add(struct platform_device *pdev)
failed:
if (pdev->id_auto) {
- ida_simple_remove(&platform_devid_ida, pdev->id);
+ ida_free(&platform_devid_ida, pdev->id);
pdev->id = PLATFORM_DEVID_AUTO;
}
@@ -631,7 +631,7 @@ void platform_device_del(struct platform_device *pdev)
device_del(&pdev->dev);
if (pdev->id_auto) {
- ida_simple_remove(&platform_devid_ida, pdev->id);
+ ida_free(&platform_devid_ida, pdev->id);
pdev->id = PLATFORM_DEVID_AUTO;
}
--
2.26.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-09 18:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-09 18:02 [PATCH] platform_device: switch to simpler IDA interface Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox