Skip to contentSkip to conversation

checkpatch: add IDR to the deprecated list

PATCH Applied Carlos López 3 participants 3 messages Oct 31, 2025 – Nov 1, 2025 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: add IDR to the deprecated list

As of commit 85656ec193e9, the IDR interface is marked as deprecated in the documentation, but no checks are made in that regard for new code. Add the existing IDR initialization APIs to the deprecated list in checkpatch, so that if new code is introduced using these APIs, a warning is emitted.

---
 scripts/checkpatch.pl | 4 ++++
 1 file changed, 4 insertions(+)
scripts/checkpatch.pl +4 -0
index 92669904eecc..bc72fa66c0ef 100755
@@ -860,6 +860,10 @@ our %deprecated_apis = (
 	"kunmap"				=> "kunmap_local",
 	"kmap_atomic"				=> "kmap_local_page",
 	"kunmap_atomic"				=> "kunmap_local",
+	#These should be enough to drive away new IDR users
+	"DEFINE_IDR"				=> "DEFINE_XARRAY",
+	"idr_init"				=> "xa_init",
+	"idr_init_base"				=> "xa_init_flags"
 );
 
 #Create a search pattern for all these strings to speed up a loop below
Signature · 1 line
2.51.0
Acked-by on v1 1/1
#1 lore raw
Quoted 17 lines · Carlos López

As of commit 85656ec193e9, the IDR interface is marked as deprecated in the documentation, but no checks are made in that regard for new code. Add the existing IDR initialization APIs to the deprecated list in checkpatch, so that if new code is introduced using these APIs, a warning is emitted.

---
 scripts/checkpatch.pl | 4 ++++
 1 file changed, 4 insertions(+)
scripts/checkpatch.pl +0 -0
index 92669904eecc..bc72fa66c0ef 100755

scripts/checkpatch.pl our %deprecated_apis = ( · line 867

Quoted 8 lines
scripts/checkpatch.pl +4 -0
@@ -860,6 +860,10 @@ our %deprecated_apis = (
 	"kunmap"				=> "kunmap_local",
 	"kmap_atomic"				=> "kmap_local_page",
 	"kunmap_atomic"				=> "kunmap_local",
+	#These should be enough to drive away new IDR users
+	"DEFINE_IDR"				=> "DEFINE_XARRAY",
+	"idr_init"				=> "xa_init",
+	"idr_init_base"				=> "xa_init_flags"
 );

Thanks! Works for me:

WARNING: Deprecated use of 'DEFINE_IDR', prefer 'DEFINE_XARRAY' instead #111: FILE: drivers/virt/coco/tsm-core.c:15:
+static DEFINE_IDR(tsm_idr);

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Carlos López
Quoted 17 lines · Carlos López

As of commit 85656ec193e9, the IDR interface is marked as deprecated in the documentation, but no checks are made in that regard for new code. Add the existing IDR initialization APIs to the deprecated list in checkpatch, so that if new code is introduced using these APIs, a warning is emitted.

---
 scripts/checkpatch.pl | 4 ++++
 1 file changed, 4 insertions(+)
scripts/checkpatch.pl +0 -0
index 92669904eecc..bc72fa66c0ef 100755

scripts/checkpatch.pl our %deprecated_apis = ( · line 869

Quoted 10 lines
scripts/checkpatch.pl +4 -0
@@ -860,6 +860,10 @@ our %deprecated_apis = (
 	"kunmap"				=> "kunmap_local",
 	"kmap_atomic"				=> "kmap_local_page",
 	"kunmap_atomic"				=> "kunmap_local",
+	#These should be enough to drive away new IDR users
+	"DEFINE_IDR"				=> "DEFINE_XARRAY",
+	"idr_init"				=> "xa_init",
+	"idr_init_base"				=> "xa_init_flags"
 );
 
 #Create a search pattern for all these strings to speed up a loop below