Commit acc48fee authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Mathieu Poirier

rpmsg: Remove usage of the deprecated ida_simple_xx() API

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: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/c09ee5b66d451bf97d14c167048549aa0824ee06.1705225049.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
parent 6613476e
...@@ -399,8 +399,8 @@ static void rpmsg_eptdev_release_device(struct device *dev) ...@@ -399,8 +399,8 @@ static void rpmsg_eptdev_release_device(struct device *dev)
{ {
struct rpmsg_eptdev *eptdev = dev_to_eptdev(dev); struct rpmsg_eptdev *eptdev = dev_to_eptdev(dev);
ida_simple_remove(&rpmsg_ept_ida, dev->id); ida_free(&rpmsg_ept_ida, dev->id);
ida_simple_remove(&rpmsg_minor_ida, MINOR(eptdev->dev.devt)); ida_free(&rpmsg_minor_ida, MINOR(eptdev->dev.devt));
kfree(eptdev); kfree(eptdev);
} }
...@@ -441,12 +441,12 @@ static int rpmsg_chrdev_eptdev_add(struct rpmsg_eptdev *eptdev, struct rpmsg_cha ...@@ -441,12 +441,12 @@ static int rpmsg_chrdev_eptdev_add(struct rpmsg_eptdev *eptdev, struct rpmsg_cha
eptdev->chinfo = chinfo; eptdev->chinfo = chinfo;
ret = ida_simple_get(&rpmsg_minor_ida, 0, RPMSG_DEV_MAX, GFP_KERNEL); ret = ida_alloc_max(&rpmsg_minor_ida, RPMSG_DEV_MAX - 1, GFP_KERNEL);
if (ret < 0) if (ret < 0)
goto free_eptdev; goto free_eptdev;
dev->devt = MKDEV(MAJOR(rpmsg_major), ret); dev->devt = MKDEV(MAJOR(rpmsg_major), ret);
ret = ida_simple_get(&rpmsg_ept_ida, 0, 0, GFP_KERNEL); ret = ida_alloc(&rpmsg_ept_ida, GFP_KERNEL);
if (ret < 0) if (ret < 0)
goto free_minor_ida; goto free_minor_ida;
dev->id = ret; dev->id = ret;
...@@ -462,9 +462,9 @@ static int rpmsg_chrdev_eptdev_add(struct rpmsg_eptdev *eptdev, struct rpmsg_cha ...@@ -462,9 +462,9 @@ static int rpmsg_chrdev_eptdev_add(struct rpmsg_eptdev *eptdev, struct rpmsg_cha
return ret; return ret;
free_ept_ida: free_ept_ida:
ida_simple_remove(&rpmsg_ept_ida, dev->id); ida_free(&rpmsg_ept_ida, dev->id);
free_minor_ida: free_minor_ida:
ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); ida_free(&rpmsg_minor_ida, MINOR(dev->devt));
free_eptdev: free_eptdev:
put_device(dev); put_device(dev);
kfree(eptdev); kfree(eptdev);
......
...@@ -130,8 +130,8 @@ static void rpmsg_ctrldev_release_device(struct device *dev) ...@@ -130,8 +130,8 @@ static void rpmsg_ctrldev_release_device(struct device *dev)
{ {
struct rpmsg_ctrldev *ctrldev = dev_to_ctrldev(dev); struct rpmsg_ctrldev *ctrldev = dev_to_ctrldev(dev);
ida_simple_remove(&rpmsg_ctrl_ida, dev->id); ida_free(&rpmsg_ctrl_ida, dev->id);
ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); ida_free(&rpmsg_minor_ida, MINOR(dev->devt));
kfree(ctrldev); kfree(ctrldev);
} }
...@@ -156,12 +156,12 @@ static int rpmsg_ctrldev_probe(struct rpmsg_device *rpdev) ...@@ -156,12 +156,12 @@ static int rpmsg_ctrldev_probe(struct rpmsg_device *rpdev)
cdev_init(&ctrldev->cdev, &rpmsg_ctrldev_fops); cdev_init(&ctrldev->cdev, &rpmsg_ctrldev_fops);
ctrldev->cdev.owner = THIS_MODULE; ctrldev->cdev.owner = THIS_MODULE;
ret = ida_simple_get(&rpmsg_minor_ida, 0, RPMSG_DEV_MAX, GFP_KERNEL); ret = ida_alloc_max(&rpmsg_minor_ida, RPMSG_DEV_MAX - 1, GFP_KERNEL);
if (ret < 0) if (ret < 0)
goto free_ctrldev; goto free_ctrldev;
dev->devt = MKDEV(MAJOR(rpmsg_major), ret); dev->devt = MKDEV(MAJOR(rpmsg_major), ret);
ret = ida_simple_get(&rpmsg_ctrl_ida, 0, 0, GFP_KERNEL); ret = ida_alloc(&rpmsg_ctrl_ida, GFP_KERNEL);
if (ret < 0) if (ret < 0)
goto free_minor_ida; goto free_minor_ida;
dev->id = ret; dev->id = ret;
...@@ -179,9 +179,9 @@ static int rpmsg_ctrldev_probe(struct rpmsg_device *rpdev) ...@@ -179,9 +179,9 @@ static int rpmsg_ctrldev_probe(struct rpmsg_device *rpdev)
return ret; return ret;
free_ctrl_ida: free_ctrl_ida:
ida_simple_remove(&rpmsg_ctrl_ida, dev->id); ida_free(&rpmsg_ctrl_ida, dev->id);
free_minor_ida: free_minor_ida:
ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); ida_free(&rpmsg_minor_ida, MINOR(dev->devt));
free_ctrldev: free_ctrldev:
put_device(dev); put_device(dev);
kfree(ctrldev); kfree(ctrldev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment