Re: [PATCH v2 5/9] xhci: dbgtty: use IDR to support several dbc instances.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 16, 2022 at 11:51:49AM +0200, Mathias Nyman wrote:
> To support systems with several xhci controllers with active
> dbc on each xhci we need to use IDR to identify and give
> an index to each port.
> 
> Avoid using global struct tty_driver.driver_state for storing
> dbc port pointer as it won't work with several dbc ports
> 
> Signed-off-by: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx>
> ---
>  drivers/usb/host/xhci-dbgcap.h |  1 +
>  drivers/usb/host/xhci-dbgtty.c | 46 ++++++++++++++++++++++++++++------
>  2 files changed, 40 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h
> index 5f3304a06591..ca04192fdab1 100644
> --- a/drivers/usb/host/xhci-dbgcap.h
> +++ b/drivers/usb/host/xhci-dbgcap.h
> @@ -100,6 +100,7 @@ struct dbc_ep {
>  struct dbc_port {
>  	struct tty_port			port;
>  	spinlock_t			port_lock;	/* port access */
> +	int				minor;
>  
>  	struct list_head		read_pool;
>  	struct list_head		read_queue;
> diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
> index 059b58f48e3a..d3acc0829ee5 100644
> --- a/drivers/usb/host/xhci-dbgtty.c
> +++ b/drivers/usb/host/xhci-dbgtty.c
> @@ -10,11 +10,14 @@
>  #include <linux/slab.h>
>  #include <linux/tty.h>
>  #include <linux/tty_flip.h>
> +#include <linux/idr.h>
>  
>  #include "xhci.h"
>  #include "xhci-dbgcap.h"
>  
>  static struct tty_driver *dbc_tty_driver;
> +static struct idr dbc_tty_minors;
> +static DEFINE_MUTEX(dbc_tty_minors_lock);

Why not just use an ida instead?  That way you do not need another lock
and it becomes a tiny bit simpler overall.

I'll take this now, but in the future it might be worth to change this.

thanks,

greg k-h



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux