summaryrefslogtreecommitdiffstats
path: root/drivers/nvmem
diff options
context:
space:
mode:
authorBartosz Golaszewski <bgolaszewski@baylibre.com>2020-09-17 15:44:36 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-09-17 18:48:23 +0200
commit1eb51d6a4fce66e7c4428b5761b75b357931422a (patch)
tree6292fbd6068bdf5388404f0e2cf664541bb8542e /drivers/nvmem
parentnvmem: core: Use kobj_to_dev() instead of container_of() (diff)
downloadlinux-1eb51d6a4fce66e7c4428b5761b75b357931422a.tar.xz
linux-1eb51d6a4fce66e7c4428b5761b75b357931422a.zip
nvmem: 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: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20200917134437.16637-4-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/nvmem')
-rw-r--r--drivers/nvmem/core.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 7641e56a17bc..96ac8a632a7a 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -321,7 +321,7 @@ static void nvmem_release(struct device *dev)
{
struct nvmem_device *nvmem = to_nvmem_device(dev);
- ida_simple_remove(&nvmem_ida, nvmem->id);
+ ida_free(&nvmem_ida, nvmem->id);
gpiod_put(nvmem->wp_gpio);
kfree(nvmem);
}
@@ -596,7 +596,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
if (!nvmem)
return ERR_PTR(-ENOMEM);
- rval = ida_simple_get(&nvmem_ida, 0, 0, GFP_KERNEL);
+ rval = ida_alloc(&nvmem_ida, GFP_KERNEL);
if (rval < 0) {
kfree(nvmem);
return ERR_PTR(rval);
@@ -608,7 +608,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp",
GPIOD_OUT_HIGH);
if (IS_ERR(nvmem->wp_gpio)) {
- ida_simple_remove(&nvmem_ida, nvmem->id);
+ ida_free(&nvmem_ida, nvmem->id);
rval = PTR_ERR(nvmem->wp_gpio);
kfree(nvmem);
return ERR_PTR(rval);