Re: [PATCH] usb: xhci: dbc: get rid of global pointer

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

 



Hi,

Johan Hovold <johan@xxxxxxxxxx> writes:
> On Tue, Jun 11, 2019 at 08:24:16PM +0300, Felipe Balbi wrote:
>> If we happen to have two XHCI controllers with DbC capability, then
>> there's no hope this will ever work as the global pointer will be
>> overwritten by the controller that probes last.
>> 
>> Avoid this problem by keeping the tty_driver struct pointer inside
>> struct xhci_dbc.
>
> How did you test this patch?

by running it on a machine that actually has two DbCs

>> @@ -279,52 +279,52 @@ static const struct tty_operations dbc_tty_ops = {
>>  	.unthrottle		= dbc_tty_unthrottle,
>>  };
>>  
>> -static struct tty_driver *dbc_tty_driver;
>> -
>>  int xhci_dbc_tty_register_driver(struct xhci_hcd *xhci)
>>  {
>>  	int			status;
>>  	struct xhci_dbc		*dbc = xhci->dbc;
>>  
>> -	dbc_tty_driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW |
>> +	dbc->tty_driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW |
>>  					  TTY_DRIVER_DYNAMIC_DEV);
>> -	if (IS_ERR(dbc_tty_driver)) {
>> -		status = PTR_ERR(dbc_tty_driver);
>> -		dbc_tty_driver = NULL;
>> +	if (IS_ERR(dbc->tty_driver)) {
>> +		status = PTR_ERR(dbc->tty_driver);
>> +		dbc->tty_driver = NULL;
>>  		return status;
>>  	}
>>  
>> -	dbc_tty_driver->driver_name = "dbc_serial";
>> -	dbc_tty_driver->name = "ttyDBC";
>> +	dbc->tty_driver->driver_name = "dbc_serial";
>> +	dbc->tty_driver->name = "ttyDBC";
>
> You're now registering multiple drivers for the same thing (and wasting
> a major number for each) and specifically using the same name, which
> should lead to name clashes when registering the second port.

No warnings were printed while running this, actually. Odd

-- 
balbi

Attachment: signature.asc
Description: PGP signature


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

  Powered by Linux