Re: [PATCH] cdc-acm: acm_init: Set initial BAUD to B0

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

 



On Mon, 2020-07-13 at 12:08 +0200, Oliver Neukum wrote:
> 
> Am Freitag, den 10.07.2020, 11:35 +0200 schrieb Joakim Tjernlund:
> > 
> 
> 
> Hi,
> 
> > --- a/drivers/usb/class/cdc-acm.c
> > +++ b/drivers/usb/class/cdc-acm.c
> > @@ -1999,19 +1999,19 @@ static int __init acm_init(void)
> >       acm_tty_driver->subtype = SERIAL_TYPE_NORMAL,
> >       acm_tty_driver->flags = TTY_DRIVER_REAL_RAW |
> > TTY_DRIVER_DYNAMIC_DEV;
> >       acm_tty_driver->init_termios = tty_std_termios;
> > -     acm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD |
> > +     acm_tty_driver->init_termios.c_cflag = B0 | CS8 | CREAD |
> >                                                               HUPCL
> > | CLOCAL;
> >       tty_set_operations(acm_tty_driver, &acm_ops);
> > 
> > -     retval = tty_register_driver(acm_tty_driver);
> > +     retval = usb_register(&acm_driver);
> 
> 
> No,
> 
> you cannot do that. This means that probe() is now live.
> Probe() in turn does this:
> 
>         tty_dev = tty_port_register_device(&acm->port,
> acm_tty_driver, minor,
>                         &control_interface->dev);
>         if (IS_ERR(tty_dev)) {
>                 rv = PTR_ERR(tty_dev);
>                 goto alloc_fail6;
>         }
> 
> 
> That is just not a good idea when the tty is not already registered.
> You are opening up a race.
> 

OK, but it is strange that init_termios.c_cflag does not take/do
anything unless I change order. Perhaps termios should move to probe
instead?

Also, the handling of DTR came up. It seems to me that ACM
deassert DTR until open time which is fine/good.
!DTR signals to the other end that ACM is not ready and don't
want input but ACM still accepts input if received.

Would it make sense to actually enforce DTR locally too?
If input is unwanted, don't accept any either.

 Jocke




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

  Powered by Linux