All of lore.kernel.org
 help / color / mirror / Atom feed
* [4/4] usb/serial: Convert serial_minors to XArray
@ 2019-03-19 12:11 Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2019-03-19 12:11 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: Matthew Wilcox, linux-usb

On Tue, Mar 19, 2019 at 12:36:21PM +0100, Oliver Neukum wrote:
> On Di, 2019-03-19 at 04:35 -0700, Matthew Wilcox wrote:
> > On Tue, Mar 19, 2019 at 07:14:09AM +0100, Greg KH wrote:
> > > On Mon, Mar 18, 2019 at 02:17:13PM -0700, Matthew Wilcox wrote:
> > > > Signed-off-by: Matthew Wilcox <willy@infradead.org>
> > > > ---
> > > >  drivers/usb/serial/usb-serial.c | 21 ++++++++++-----------
> > > >  1 file changed, 10 insertions(+), 11 deletions(-)
> > > 
> > > I really do not like taking patches without any changelog text at all :(
> > 
> > I'm really not sure what to say.  Something extolling the superiority
> > of the new API?
> 
> Yes. Something like
> 
> XARRAy is a replacement for radix trees. Convert this subsystem.
> Part of a project for the whole kernel.

Yes, that's perfect.  Matthew, just add it to a script and away you go
:)

thanks,

greg k-h

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

* [4/4] usb/serial: Convert serial_minors to XArray
@ 2019-03-19 11:36 Oliver Neukum
  0 siblings, 0 replies; 5+ messages in thread
From: Oliver Neukum @ 2019-03-19 11:36 UTC (permalink / raw)
  To: Matthew Wilcox, Greg KH; +Cc: linux-usb

On Di, 2019-03-19 at 04:35 -0700, Matthew Wilcox wrote:
> On Tue, Mar 19, 2019 at 07:14:09AM +0100, Greg KH wrote:
> > On Mon, Mar 18, 2019 at 02:17:13PM -0700, Matthew Wilcox wrote:
> > > Signed-off-by: Matthew Wilcox <willy@infradead.org>
> > > ---
> > >  drivers/usb/serial/usb-serial.c | 21 ++++++++++-----------
> > >  1 file changed, 10 insertions(+), 11 deletions(-)
> > 
> > I really do not like taking patches without any changelog text at all :(
> 
> I'm really not sure what to say.  Something extolling the superiority
> of the new API?

Yes. Something like

XARRAy is a replacement for radix trees. Convert this subsystem.
Part of a project for the whole kernel.

	Regards
		Oliver

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

* [4/4] usb/serial: Convert serial_minors to XArray
@ 2019-03-19 11:35 Matthew Wilcox
  0 siblings, 0 replies; 5+ messages in thread
From: Matthew Wilcox @ 2019-03-19 11:35 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-usb

On Tue, Mar 19, 2019 at 07:14:09AM +0100, Greg KH wrote:
> On Mon, Mar 18, 2019 at 02:17:13PM -0700, Matthew Wilcox wrote:
> > Signed-off-by: Matthew Wilcox <willy@infradead.org>
> > ---
> >  drivers/usb/serial/usb-serial.c | 21 ++++++++++-----------
> >  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> I really do not like taking patches without any changelog text at all :(

I'm really not sure what to say.  Something extolling the superiority
of the new API?  I've got 279 patches here and some of them are really
just 1:1 replacements like this one.

What would you want to read if you came across this patch in git log
in five years time?

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

* [4/4] usb/serial: Convert serial_minors to XArray
@ 2019-03-19  6:14 Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2019-03-19  6:14 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-usb

On Mon, Mar 18, 2019 at 02:17:13PM -0700, Matthew Wilcox wrote:
> Signed-off-by: Matthew Wilcox <willy@infradead.org>
> ---
>  drivers/usb/serial/usb-serial.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)

I really do not like taking patches without any changelog text at all :(

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

* [4/4] usb/serial: Convert serial_minors to XArray
@ 2019-03-18 21:17 Matthew Wilcox
  0 siblings, 0 replies; 5+ messages in thread
From: Matthew Wilcox @ 2019-03-18 21:17 UTC (permalink / raw)
  To: linux-usb; +Cc: Matthew Wilcox

Signed-off-by: Matthew Wilcox <willy@infradead.org>
---
 drivers/usb/serial/usb-serial.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 7e89efbf2c28..ad8b9cb17ca5 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -49,7 +49,7 @@
    drivers depend on it.
 */
 
-static DEFINE_IDR(serial_minors);
+static DEFINE_XARRAY_ALLOC(serial_minors);
 static DEFINE_MUTEX(table_lock);
 static LIST_HEAD(usb_serial_driver_list);
 
@@ -64,7 +64,7 @@ struct usb_serial_port *usb_serial_port_get_by_minor(unsigned minor)
 	struct usb_serial_port *port;
 
 	mutex_lock(&table_lock);
-	port = idr_find(&serial_minors, minor);
+	port = xa_load(&serial_minors, minor);
 	if (!port)
 		goto exit;
 
@@ -85,18 +85,18 @@ static int allocate_minors(struct usb_serial *serial, int num_ports)
 {
 	struct usb_serial_port *port;
 	unsigned int i, j;
-	int minor;
+	int err;
 
 	dev_dbg(&serial->interface->dev, "%s %d\n", __func__, num_ports);
 
 	mutex_lock(&table_lock);
 	for (i = 0; i < num_ports; ++i) {
 		port = serial->port[i];
-		minor = idr_alloc(&serial_minors, port, 0,
-					USB_SERIAL_TTY_MINORS, GFP_KERNEL);
-		if (minor < 0)
+		err = xa_alloc(&serial_minors, &port->minor, port,
+				XA_LIMIT(0, USB_SERIAL_TTY_MINORS - 1),
+				GFP_KERNEL);
+		if (err < 0)
 			goto error;
-		port->minor = minor;
 		port->port_number = i;
 	}
 	serial->minors_reserved = 1;
@@ -105,9 +105,9 @@ static int allocate_minors(struct usb_serial *serial, int num_ports)
 error:
 	/* unwind the already allocated minors */
 	for (j = 0; j < i; ++j)
-		idr_remove(&serial_minors, serial->port[j]->minor);
+		xa_erase(&serial_minors, serial->port[j]->minor);
 	mutex_unlock(&table_lock);
-	return minor;
+	return err;
 }
 
 static void release_minors(struct usb_serial *serial)
@@ -116,7 +116,7 @@ static void release_minors(struct usb_serial *serial)
 
 	mutex_lock(&table_lock);
 	for (i = 0; i < serial->num_ports; ++i)
-		idr_remove(&serial_minors, serial->port[i]->minor);
+		xa_erase(&serial_minors, serial->port[i]->minor);
 	mutex_unlock(&table_lock);
 	serial->minors_reserved = 0;
 }
@@ -1271,7 +1271,6 @@ static void __exit usb_serial_exit(void)
 	tty_unregister_driver(usb_serial_tty_driver);
 	put_tty_driver(usb_serial_tty_driver);
 	bus_unregister(&usb_serial_bus_type);
-	idr_destroy(&serial_minors);
 }
 
 

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

end of thread, other threads:[~2019-03-19 12:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19 12:11 [4/4] usb/serial: Convert serial_minors to XArray Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2019-03-19 11:36 Oliver Neukum
2019-03-19 11:35 Matthew Wilcox
2019-03-19  6:14 Greg KH
2019-03-18 21:17 Matthew Wilcox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.