staging: fieldbus: Remove usage of the deprecated ida_simple_xx() API
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 14 Jan 2024 10:10:15 +0000 (11:10 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jan 2024 18:19:47 +0000 (10:19 -0800)
ida_alloc() and ida_free() should be preferred to the deprecated
ida_simple_get() and ida_simple_remove().

Note that the upper limit of ida_simple_get() is exclusive, but the one of
ida_alloc_max() is inclusive. So a -1 has been added when needed.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/d305b97b1064ba7e026232fb8c2a0783ba1b1098.1705227001.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/fieldbus/anybuss/arcx-anybus.c
drivers/staging/fieldbus/dev_core.c

index 34d18b09beddcb951bf86047b6e6d9a2e9238f90..fcd3e3722ae017f7714e7bac786e48b48eb2b33c 100644 (file)
@@ -285,7 +285,7 @@ static int controller_probe(struct platform_device *pdev)
                }
        }
 
-       id = ida_simple_get(&controller_index_ida, 0, 0, GFP_KERNEL);
+       id = ida_alloc(&controller_index_ida, GFP_KERNEL);
        if (id < 0) {
                err = id;
                goto out_reset;
@@ -318,7 +318,7 @@ static int controller_probe(struct platform_device *pdev)
 out_dev:
        put_device(cd->class_dev);
 out_ida:
-       ida_simple_remove(&controller_index_ida, id);
+       ida_free(&controller_index_ida, id);
 out_reset:
        gpiod_set_value_cansleep(cd->reset_gpiod, 1);
        return err;
@@ -330,7 +330,7 @@ static void controller_remove(struct platform_device *pdev)
        int id = cd->class_dev->id;
 
        device_unregister(cd->class_dev);
-       ida_simple_remove(&controller_index_ida, id);
+       ida_free(&controller_index_ida, id);
        gpiod_set_value_cansleep(cd->reset_gpiod, 1);
 }
 
index bf1812d8924fa5c5a5b885373da569fd9bc92412..370a229443a18e9d1cc0e8a0982c6b070ec85c74 100644 (file)
@@ -247,7 +247,7 @@ static void __fieldbus_dev_unregister(struct fieldbus_dev *fb)
                return;
        device_destroy(&fieldbus_class, fb->cdev.dev);
        cdev_del(&fb->cdev);
-       ida_simple_remove(&fieldbus_ida, fb->id);
+       ida_free(&fieldbus_ida, fb->id);
 }
 
 void fieldbus_dev_unregister(struct fieldbus_dev *fb)
@@ -267,7 +267,7 @@ static int __fieldbus_dev_register(struct fieldbus_dev *fb)
                return -EINVAL;
        if (!fb->read_area || !fb->write_area || !fb->fieldbus_id_get)
                return -EINVAL;
-       fb->id = ida_simple_get(&fieldbus_ida, 0, MAX_FIELDBUSES, GFP_KERNEL);
+       fb->id = ida_alloc_max(&fieldbus_ida, MAX_FIELDBUSES - 1, GFP_KERNEL);
        if (fb->id < 0)
                return fb->id;
        devno = MKDEV(MAJOR(fieldbus_devt), fb->id);
@@ -290,7 +290,7 @@ static int __fieldbus_dev_register(struct fieldbus_dev *fb)
 err_dev_create:
        cdev_del(&fb->cdev);
 err_cdev:
-       ida_simple_remove(&fieldbus_ida, fb->id);
+       ida_free(&fieldbus_ida, fb->id);
        return err;
 }