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

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

 



On Fri, 2020-07-10 at 11:54 +0200, Johan Hovold wrote:
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> 
> 
> On Fri, Jul 10, 2020 at 11:35:18AM +0200, Joakim Tjernlund wrote:
> > BO will disable USB input until the device opens. This will
> > avoid garbage chars waiting flood the TTY. This mimics a real UART
> > device better.
> > For initial termios to reach USB core, USB driver has to be
> > registered before TTY driver.
> > 
> > Signed-off-by: Joakim Tjernlund <joakim.tjernlund@xxxxxxxxxxxx>
> > Cc: stable@xxxxxxxxxxxxxxx
> > ---
> > 
> >  I hope this change makes sense to you, if so I belive
> >  ttyUSB could do the same.
> 
> No, this doesn't make sense. B0 is used to hang up an already open tty.

This is at module init so there is no tty yet.
acm_probe() will later set:
        acm->line.dwDTERate = cpu_to_le32(9600);
	acm->line.bDataBits = 8;
	acm_set_line(acm, &acm->line);

> 
> Furthermore, this change only affects the initial terminal settings and
> won't have any effect the next time you open the same port.

hmm, it is not ideal but acm_probe() will later set:
        acm->line.dwDTERate = cpu_to_le32(9600);
	acm->line.bDataBits = 8;
	acm_set_line(acm, &acm->line);

But, would it not make sense to not accept input until TTY is opened ?
That would be more inline with a real RS232, would it not?
> 
> Why not fix your firmware so that it doesn't transmit before DTR is
> asserted during open()?

I would but it is not my firmware, it is a ready made USB to UART chip. will talk
to the manufacturer though.


> >  drivers/usb/class/cdc-acm.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
> > index 751f00285ee6..5680f71200e5 100644
> > --- 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);
> >       if (retval) {
> >               put_tty_driver(acm_tty_driver);
> >               return retval;
> >       }
> > 
> > -     retval = usb_register(&acm_driver);
> > +     retval = tty_register_driver(acm_tty_driver);
> >       if (retval) {
> > -             tty_unregister_driver(acm_tty_driver);
> > +             usb_deregister(&acm_driver);
> >               put_tty_driver(acm_tty_driver);
> >               return retval;
> >       }
> 
> Johan





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

  Powered by Linux