Skip to contentSkip to conversation

Remove usage of the deprecated ida_simple_xx() API

PATCH RESEND Applied Christophe JAILLET 2 participants 5 messages Jun 8, 2024 – Jun 12, 2024

Subsystems (5)

v1 of 3 Applied 3/3 Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Remove usage of the deprecated ida_simple_xx() API

The small serie removes the *last* usages of the deprecated ida_simple_xx() API.

The 3 patches have received either a R-b or A-b tag but never reached -next in the last 2 months.

So, I've added the tags and I'm now adding Andrew Morton in To:, in order to help in the merge process.

2 other patches related to this API are still pending somewhere and are not reposted here.

[1] is related to tools/testing/ and will be re-sent as part of the final removal, as suggested by Matthew.
It is A-b, but the name of the function used in the test should be updated as well (s/ida_simple_get_remove_test/ida_alloc_remove_test)

[2] is a tiny clean-up of a comment. I'll resend it to the corresponding maintainer (Srinivas Kandagatla) later, but won't fight for it.

Obviously, you can also pick up one or both of these patches as well :)

CJ

[1]: https://lore.kernel.org/all/81f44a41b7ccceb26a802af473f931799445821a.1705683269.git.christophe.jaillet@wanadoo.fr/
[2]: https://lore.kernel.org/all/032b8035bd1f2dcc13ffc781c8348d9fbdf9e3b2.1713606957.git.christophe.jaillet@wanadoo.fr/

Christophe JAILLET (3):
fsi: occ: Remove usage of the deprecated ida_simple_xx() API
most: Remove usage of the deprecated ida_simple_xx() API
proc: Remove usage of the deprecated ida_simple_xx() API

 drivers/fsi/fsi-occ.c    | 17 ++++++++---------
 drivers/most/core.c      | 10 +++++-----
 drivers/most/most_cdev.c |  6 +++---
 fs/proc/generic.c        |  6 +++---
 4 files changed, 19 insertions(+), 20 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH RESEND 1/3 fsi: occ: 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_range() is inclusive. So, this upper limit, INT_MAX, should have been changed to INT_MAX-1.

But, it is likely that the INT_MAX 'idx' is valid that the max value passed to ida_simple_get() should have been 0.

So, allow this INT_MAX 'idx' value now.

---
The change related to the INT_MAX value is speculative. Review with care. (or I can re-submit with INT_MAX-1, to be safe :))

This patch has been sent about 5 months ago [1].
A gentle reminder has been sent 3 months later and an R-by has been given [2].

However, it has still not reached -next in the last 2 months.

So, I've added the R-b tag and I'm adding Andrew Morton in To:, in order to help in the merge process.

Thanks
CJ

[1]: https://lore.kernel.org/all/6e17f2145ce2bbc12af6700c8bd56a8a7bdb103d.1705738045.git.christophe.jaillet@wanadoo.fr/
[2]: https://lore.kernel.org/all/[email protected]/

---
 drivers/fsi/fsi-occ.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/fsi/fsi-occ.c +8 -9
index da35ca9e84a6..f7157c1d77d8 100644
@@ -656,17 +656,16 @@ static int occ_probe(struct platform_device *pdev)
 		rc = of_property_read_u32(dev->of_node, "reg", &reg);
 		if (!rc) {
 			/* make sure we don't have a duplicate from dts */
-			occ->idx = ida_simple_get(&occ_ida, reg, reg + 1,
-						  GFP_KERNEL);
+			occ->idx = ida_alloc_range(&occ_ida, reg, reg,
+						   GFP_KERNEL);
 			if (occ->idx < 0)
-				occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX,
-							  GFP_KERNEL);
+				occ->idx = ida_alloc_min(&occ_ida, 1,
+							 GFP_KERNEL);
 		} else {
-			occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX,
-						  GFP_KERNEL);
+			occ->idx = ida_alloc_min(&occ_ida, 1, GFP_KERNEL);
 		}
 	} else {
-		occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, GFP_KERNEL);
+		occ->idx = ida_alloc_min(&occ_ida, 1, GFP_KERNEL);
 	}
 
 	platform_set_drvdata(pdev, occ);
@@ -680,7 +679,7 @@ static int occ_probe(struct platform_device *pdev)
 	rc = misc_register(&occ->mdev);
 	if (rc) {
 		dev_err(dev, "failed to register miscdevice: %d\n", rc);
-		ida_simple_remove(&occ_ida, occ->idx);
+		ida_free(&occ_ida, occ->idx);
 		kvfree(occ->buffer);
 		return rc;
 	}
@@ -719,7 +718,7 @@ static int occ_remove(struct platform_device *pdev)
 	else
 		device_for_each_child(&pdev->dev, NULL, occ_unregister_of_child);
 
-	ida_simple_remove(&occ_ida, occ->idx);
+	ida_free(&occ_ida, occ->idx);
 
 	return 0;
 }
Signature · 1 line
2.45.2
#2 lore raw

PATCH RESEND 2/3 most: Remove usage of the deprecated ida_simple_xx() API

In reply to Christophe JAILLET

ida_alloc() and ida_free() should be preferred to the deprecated ida_simple_get() and ida_simple_remove().

This is less verbose.

---
This patch has been sent about 6 months ago [1].
A gentle reminder has been sent 2 months later and an A-by has been given [2].

Another gentle reminder has been sent another 2 months later [3].

However, it has still not reached -next since then in the last 2 months.

So, I've added the A-b tag and I'm adding Andrew Morton in To:, in order to help in the merge process.

Thanks
CJ

[1]: https://lore.kernel.org/all/988c218ef3d91bffaf4c3db9b6fba0d369cbb2b2.1702326601.git.christophe.jaillet@wanadoo.fr/
[2]: https://lore.kernel.org/all/[email protected]/
[3]: https://lore.kernel.org/all/[email protected]/

---
 drivers/most/core.c      | 10 +++++-----
 drivers/most/most_cdev.c |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/most/core.c +5 -5
index f13d0e14a48b..10342e8801bf 100644
@@ -1286,7 +1286,7 @@ int most_register_interface(struct most_interface *iface)
 	    !iface->poison_channel || (iface->num_channels > MAX_CHANNELS))
 		return -EINVAL;
 
-	id = ida_simple_get(&mdev_id, 0, 0, GFP_KERNEL);
+	id = ida_alloc(&mdev_id, GFP_KERNEL);
 	if (id < 0) {
 		dev_err(iface->dev, "Failed to allocate device ID\n");
 		return id;
@@ -1294,7 +1294,7 @@ int most_register_interface(struct most_interface *iface)
 
 	iface->p = kzalloc(sizeof(*iface->p), GFP_KERNEL);
 	if (!iface->p) {
-		ida_simple_remove(&mdev_id, id);
+		ida_free(&mdev_id, id);
 		return -ENOMEM;
 	}
 
@@ -1308,7 +1308,7 @@ int most_register_interface(struct most_interface *iface)
 		dev_err(iface->dev, "Failed to register interface device\n");
 		kfree(iface->p);
 		put_device(iface->dev);
-		ida_simple_remove(&mdev_id, id);
+		ida_free(&mdev_id, id);
 		return -ENOMEM;
 	}
 
@@ -1366,7 +1366,7 @@ int most_register_interface(struct most_interface *iface)
 	}
 	kfree(iface->p);
 	device_unregister(iface->dev);
-	ida_simple_remove(&mdev_id, id);
+	ida_free(&mdev_id, id);
 	return -ENOMEM;
 }
 EXPORT_SYMBOL_GPL(most_register_interface);
@@ -1397,7 +1397,7 @@ void most_deregister_interface(struct most_interface *iface)
 		device_unregister(&c->dev);
 	}
 
-	ida_simple_remove(&mdev_id, iface->p->dev_id);
+	ida_free(&mdev_id, iface->p->dev_id);
 	kfree(iface->p);
 	device_unregister(iface->dev);
 }
drivers/most/most_cdev.c +3 -3
index 3ed8f461e01e..b9423f82373d 100644
@@ -100,7 +100,7 @@ static void destroy_cdev(struct comp_channel *c)
 
 static void destroy_channel(struct comp_channel *c)
 {
-	ida_simple_remove(&comp.minor_id, MINOR(c->devno));
+	ida_free(&comp.minor_id, MINOR(c->devno));
 	kfifo_free(&c->fifo);
 	kfree(c);
 }
@@ -425,7 +425,7 @@ static int comp_probe(struct most_interface *iface, int channel_id,
 	if (c)
 		return -EEXIST;
 
-	current_minor = ida_simple_get(&comp.minor_id, 0, 0, GFP_KERNEL);
+	current_minor = ida_alloc(&comp.minor_id, GFP_KERNEL);
 	if (current_minor < 0)
 		return current_minor;
 
@@ -472,7 +472,7 @@ static int comp_probe(struct most_interface *iface, int channel_id,
 err_free_c:
 	kfree(c);
 err_remove_ida:
-	ida_simple_remove(&comp.minor_id, current_minor);
+	ida_free(&comp.minor_id, current_minor);
 	return retval;
 }
 
Signature · 1 line
2.45.2
#3 lore raw

PATCH RESEND 3/3 proc: Remove usage of the deprecated ida_simple_xx() API

In reply to Christophe JAILLET

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.

---
This patch has been sent about 5 months ago [1] and has been A-by just a few minutes after.

A gentle reminder has been sent 3 months later [2].

However, it has still not reached -next since then in the last 2 months.

So, I've added the R-b tag and I'm adding Andrew Morton in To:, in order to help in the merge process.

Thanks
CJ

[1]: https://lore.kernel.org/all/f235bd25763bd530ff5508084989f63e020c3606.1705341186.git.christophe.jaillet@wanadoo.fr/
[2]: https://lore.kernel.org/all/[email protected]/

---
 fs/proc/generic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/proc/generic.c +3 -3
index 775ce0bcf08c..c02f1e63f82d 100644
@@ -202,8 +202,8 @@ int proc_alloc_inum(unsigned int *inum)
 {
 	int i;
 
-	i = ida_simple_get(&proc_inum_ida, 0, UINT_MAX - PROC_DYNAMIC_FIRST + 1,
-			   GFP_KERNEL);
+	i = ida_alloc_max(&proc_inum_ida, UINT_MAX - PROC_DYNAMIC_FIRST,
+			  GFP_KERNEL);
 	if (i < 0)
 		return i;
 
@@ -213,7 +213,7 @@ int proc_alloc_inum(unsigned int *inum)
 
 void proc_free_inum(unsigned int inum)
 {
-	ida_simple_remove(&proc_inum_ida, inum - PROC_DYNAMIC_FIRST);
+	ida_free(&proc_inum_ida, inum - PROC_DYNAMIC_FIRST);
 }
 
 static int proc_misc_d_revalidate(struct dentry *dentry, unsigned int flags)
Signature · 1 line
2.45.2
maintainer Applied
#4 lore raw

Re: (subset) [PATCH RESEND 3/3] proc: Remove usage of the deprecated ida_simple_xx() API

Quoted 8 lines · Christophe JAILLET

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.

[...]

Applied to the vfs.misc branch of the vfs/vfs.git tree. Patches in the vfs.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.misc

[3/3] proc: Remove usage of the deprecated ida_simple_xx() API

      https://git.kernel.org/vfs/vfs/c/08ce6f724ce9