On Mon, Jun 03, 2013 at 10:59:08PM -0400, Dave Jones wrote:
> On Mon, Jun 03, 2013 at 07:49:59PM -0700, Greg Kroah-Hartman wrote:
>  > On Mon, May 27, 2013 at 02:28:51PM +0200, Bjørn Mork wrote:
>  > > But, IMHO, a nicer approach would be to make the allocation completely
>  > > dynamic, using e.g. the idr subsystem. Static tables are always feel
>  > > like straight jackets to me, no matter how big they are :)
>  > 
>  > You are right, I didn't change the code to use idr (it predates idr by
>  > about a decade or so), because I thought we needed the "rage" logic that
>  > the usb-serial minor reservation does.
> 
> Rage logic sounds like my kinda code.

Late nite typo :)

>  > +static int get_free_port(struct usb_serial_port *port)
>  >  {
>  > -  unsigned int i, j;
>  > -  int good_spot;
>  > -
>  > -  dev_dbg(&serial->interface->dev, "%s %d\n", __func__, num_ports);
>  > +  int i;
>  >  
>  > -  *minor = 0;
>  >    mutex_lock(&table_lock);
>  > -  for (i = 0; i < SERIAL_TTY_MINORS; ++i) {
>  > -          if (serial_table[i])
>  > -                  continue;
>  > +  i = idr_alloc(&serial_minors, port, 0, 0, GFP_KERNEL);
>  > +  if (i < 0)
>  > +          return -EEXIST;
>  > +  port->number = i;
>  > +  mutex_unlock(&table_lock);
>  > +  return i;
>  > +}
> 
> -EEXIST case misses the mutex unlock.

Thanks, now fixed.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to