public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: greybus: replace DEFINE_IDR with DEFINE_XARRAY_ALLOC in uart.c
@ 2026-03-17 21:16 Oskar Ray-Frayssinet
  2026-03-18  7:45 ` Johan Hovold
  2026-03-18 14:20 ` Greg KH
  0 siblings, 2 replies; 5+ messages in thread
From: Oskar Ray-Frayssinet @ 2026-03-17 21:16 UTC (permalink / raw)
  To: dtwlin
  Cc: johan, elder, gregkh, greybus-dev, linux-staging, linux-kernel,
	Oskar Ray-Frayssinet

Replace deprecated DEFINE_IDR and idr_* functions with the modern
DEFINE_XARRAY_ALLOC and xa_* equivalents in the greybus uart driver.

Signed-off-by: Oskar Ray-Frayssinet <rayfraytech@gmail.com>
---
 drivers/staging/greybus/uart.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 7d060b4cd33d..6af0a3b4d2c4 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -67,7 +67,7 @@ struct gb_tty {
 };
 
 static struct tty_driver *gb_tty_driver;
-static DEFINE_IDR(tty_minors);
+static DEFINE_XARRAY_ALLOC(tty_minors);
 static DEFINE_MUTEX(table_lock);
 
 static int gb_uart_receive_data_handler(struct gb_operation *op)
@@ -342,7 +342,7 @@ static struct gb_tty *get_gb_by_minor(unsigned int minor)
 	struct gb_tty *gb_tty;
 
 	mutex_lock(&table_lock);
-	gb_tty = idr_find(&tty_minors, minor);
+	gb_tty = xa_load(&tty_minors, minor);
 	if (gb_tty) {
 		mutex_lock(&gb_tty->mutex);
 		if (gb_tty->disconnected) {
@@ -360,12 +360,15 @@ static struct gb_tty *get_gb_by_minor(unsigned int minor)
 static int alloc_minor(struct gb_tty *gb_tty)
 {
 	int minor;
+	int ret;
 
 	mutex_lock(&table_lock);
-	minor = idr_alloc(&tty_minors, gb_tty, 0, GB_NUM_MINORS, GFP_KERNEL);
+	ret = xa_alloc(&tty_minors, &minor, gb_tty,
+		       XA_LIMIT(0, GB_NUM_MINORS - 1), GFP_KERNEL);
 	mutex_unlock(&table_lock);
-	if (minor >= 0)
-		gb_tty->minor = minor;
+	if (ret)
+		return ret;
+	gb_tty->minor = minor;
 	return minor;
 }
 
@@ -375,7 +378,7 @@ static void release_minor(struct gb_tty *gb_tty)
 
 	gb_tty->minor = 0;	/* Maybe should use an invalid value instead */
 	mutex_lock(&table_lock);
-	idr_remove(&tty_minors, minor);
+	xa_erase(&tty_minors, minor);
 	mutex_unlock(&table_lock);
 }
 
@@ -984,7 +987,7 @@ static void gb_tty_exit(void)
 {
 	tty_unregister_driver(gb_tty_driver);
 	tty_driver_kref_put(gb_tty_driver);
-	idr_destroy(&tty_minors);
+	xa_destroy(&tty_minors);
 }
 
 static const struct gbphy_device_id gb_uart_id_table[] = {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: greybus: replace DEFINE_IDR with DEFINE_XARRAY_ALLOC in uart.c
  2026-03-17 21:16 [PATCH] staging: greybus: replace DEFINE_IDR with DEFINE_XARRAY_ALLOC in uart.c Oskar Ray-Frayssinet
@ 2026-03-18  7:45 ` Johan Hovold
  2026-03-18 14:20 ` Greg KH
  1 sibling, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2026-03-18  7:45 UTC (permalink / raw)
  To: Oskar Ray-Frayssinet
  Cc: dtwlin, elder, gregkh, greybus-dev, linux-staging, linux-kernel

On Tue, Mar 17, 2026 at 10:16:51PM +0100, Oskar Ray-Frayssinet wrote:
> Replace deprecated DEFINE_IDR and idr_* functions with the modern
> DEFINE_XARRAY_ALLOC and xa_* equivalents in the greybus uart driver.
> 
> Signed-off-by: Oskar Ray-Frayssinet <rayfraytech@gmail.com>

The proposed change has already been rejected. For example, see:

	https://lore.kernel.org/all/2026020735-thumping-chemicals-c76e@gregkh/

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: greybus: replace DEFINE_IDR with DEFINE_XARRAY_ALLOC in uart.c
  2026-03-17 21:16 [PATCH] staging: greybus: replace DEFINE_IDR with DEFINE_XARRAY_ALLOC in uart.c Oskar Ray-Frayssinet
  2026-03-18  7:45 ` Johan Hovold
@ 2026-03-18 14:20 ` Greg KH
  2026-03-18 14:36   ` Johan Hovold
  1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2026-03-18 14:20 UTC (permalink / raw)
  To: Oskar Ray-Frayssinet
  Cc: dtwlin, johan, elder, greybus-dev, linux-staging, linux-kernel

On Tue, Mar 17, 2026 at 10:16:51PM +0100, Oskar Ray-Frayssinet wrote:
> Replace deprecated DEFINE_IDR and idr_* functions with the modern
> DEFINE_XARRAY_ALLOC and xa_* equivalents in the greybus uart driver.

What tool is causing people to want to do this change that I keep
rejecting?  Can you please go and fix it?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: greybus: replace DEFINE_IDR with DEFINE_XARRAY_ALLOC in uart.c
  2026-03-18 14:20 ` Greg KH
@ 2026-03-18 14:36   ` Johan Hovold
  2026-03-18 14:51     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Johan Hovold @ 2026-03-18 14:36 UTC (permalink / raw)
  To: Greg KH
  Cc: Oskar Ray-Frayssinet, dtwlin, elder, greybus-dev, linux-staging,
	linux-kernel

On Wed, Mar 18, 2026 at 03:20:20PM +0100, Greg Kroah-Hartman wrote:
> On Tue, Mar 17, 2026 at 10:16:51PM +0100, Oskar Ray-Frayssinet wrote:
> > Replace deprecated DEFINE_IDR and idr_* functions with the modern
> > DEFINE_XARRAY_ALLOC and xa_* equivalents in the greybus uart driver.
> 
> What tool is causing people to want to do this change that I keep
> rejecting?  Can you please go and fix it?

It's checkpatch:

	WARNING: Deprecated use of 'DEFINE_IDR', prefer 'DEFINE_XARRAY' instead
	#70: FILE: drivers/staging/greybus/uart.c:70:
	+static DEFINE_IDR(tty_minors);

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: greybus: replace DEFINE_IDR with DEFINE_XARRAY_ALLOC in uart.c
  2026-03-18 14:36   ` Johan Hovold
@ 2026-03-18 14:51     ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2026-03-18 14:51 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Oskar Ray-Frayssinet, dtwlin, elder, greybus-dev, linux-staging,
	linux-kernel

On Wed, Mar 18, 2026 at 03:36:03PM +0100, Johan Hovold wrote:
> On Wed, Mar 18, 2026 at 03:20:20PM +0100, Greg Kroah-Hartman wrote:
> > On Tue, Mar 17, 2026 at 10:16:51PM +0100, Oskar Ray-Frayssinet wrote:
> > > Replace deprecated DEFINE_IDR and idr_* functions with the modern
> > > DEFINE_XARRAY_ALLOC and xa_* equivalents in the greybus uart driver.
> > 
> > What tool is causing people to want to do this change that I keep
> > rejecting?  Can you please go and fix it?
> 
> It's checkpatch:
> 
> 	WARNING: Deprecated use of 'DEFINE_IDR', prefer 'DEFINE_XARRAY' instead
> 	#70: FILE: drivers/staging/greybus/uart.c:70:
> 	+static DEFINE_IDR(tty_minors);

Ugh, that should be changed to only trigger that warning on a patch, not
on an existing file.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-18 14:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-17 21:16 [PATCH] staging: greybus: replace DEFINE_IDR with DEFINE_XARRAY_ALLOC in uart.c Oskar Ray-Frayssinet
2026-03-18  7:45 ` Johan Hovold
2026-03-18 14:20 ` Greg KH
2026-03-18 14:36   ` Johan Hovold
2026-03-18 14:51     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox