提交 0de75116 编写于 作者: B Bartosz Golaszewski 提交者: Greg Kroah-Hartman

platform_device: switch to simpler IDA interface

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: NBartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20200909180248.10093-1-brgl@bgdev.plSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 0c7a6b91
...@@ -573,7 +573,7 @@ int platform_device_add(struct platform_device *pdev) ...@@ -573,7 +573,7 @@ int platform_device_add(struct platform_device *pdev)
* that we remember it must be freed, and we append a suffix * that we remember it must be freed, and we append a suffix
* to avoid namespace collision with explicit IDs. * 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) if (ret < 0)
goto err_out; goto err_out;
pdev->id = ret; pdev->id = ret;
...@@ -614,7 +614,7 @@ int platform_device_add(struct platform_device *pdev) ...@@ -614,7 +614,7 @@ int platform_device_add(struct platform_device *pdev)
failed: failed:
if (pdev->id_auto) { if (pdev->id_auto) {
ida_simple_remove(&platform_devid_ida, pdev->id); ida_free(&platform_devid_ida, pdev->id);
pdev->id = PLATFORM_DEVID_AUTO; pdev->id = PLATFORM_DEVID_AUTO;
} }
...@@ -645,7 +645,7 @@ void platform_device_del(struct platform_device *pdev) ...@@ -645,7 +645,7 @@ void platform_device_del(struct platform_device *pdev)
device_del(&pdev->dev); device_del(&pdev->dev);
if (pdev->id_auto) { if (pdev->id_auto) {
ida_simple_remove(&platform_devid_ida, pdev->id); ida_free(&platform_devid_ida, pdev->id);
pdev->id = PLATFORM_DEVID_AUTO; pdev->id = PLATFORM_DEVID_AUTO;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册