Re: [PATCH 2/2 v5] tty/serial/8250: use mctrl_gpio helpers

From: Andy Shevchenko
Date: Thu Jun 13 2019 - 11:35:50 EST


On Thu, Jun 13, 2019 at 07:32:39AM +0200, Stefan Roese wrote:
> On 12.06.19 11:16, Andy Shevchenko wrote:
> > On Wed, Jun 12, 2019 at 10:13:05AM +0200, Stefan Roese wrote:
> > > On 11.06.19 16:48, Andy Shevchenko wrote:

> > > Do you something like this in mind?
> >
> > More likely
> >
> > static inline int serial8250_MCR_to_TIOCM(int mcr)
>
> MSR_to_TIOCM (see below) ...

Yes. true.

> > {
> > int tiocm = 0;
> >
> > if (mcr & ...)
> > tiocm |= ...;
> > ...
> >
> > return tiocm;
> > }
> >
> > static inline int serial8250_TIOCM_to_MCR(int tiocm)
> > {
> > ... in a similar way ...
> > }
>
> While implementing such wrapper functions I noticed, that get_mctrl() /
> set_mctrl() need TIOCM->MCR and MSR->TIOCM (notice MSR vs MCR here) but
> serial8250_in_MCR() needs MCR->TIOCM. So there is not that much
> overlay here.

It seems not only this driver is using such conversion. It's even possible to
move it to serial level for all.

> Additionally the wrappers would need to handle all bits
> and only some of them are needed in serial8250_in/out_MCR(),
> so I would
> need to add masking here as well.

I don't see this. You will get a value for exclusive bits only. No additional
mask would be needed.

> For my taste its not really worth adding these wrappers as they won't
> make things much clearer (if at all).

Hmm.. For me it would be quite clear if something with proposed name would be
called in the code.

--
With Best Regards,
Andy Shevchenko