Re: remove double call of ttyopen()

2020-12-28 Thread Jan Klemkow
On Mon, Dec 28, 2020 at 07:59:23PM +0100, Klemens Nanni wrote:
> On Mon, Dec 28, 2020 at 03:49:35PM +0100, Jan Klemkow wrote:
> > The following diff removes useless double calls of ttyopen.  l_open is
> > a pointer to ttyopen().  All other serial drivers also just use l_open,
> > as it is the general API for this.
> I'm not familiar with the subsystem/API, but one thing looks off to me.
> 
> > Index: dev/pci/cz.c
> > ===
> > RCS file: /cvs/src/sys/dev/pci/cz.c,v
> > retrieving revision 1.24
> > diff -u -p -r1.24 cz.c
> > --- dev/pci/cz.c21 May 2020 09:31:59 -  1.24
> > +++ dev/pci/cz.c28 Dec 2020 14:41:30 -
> > @@ -1034,10 +1034,6 @@ czttyopen(dev_t dev, int flags, int mode
> >  
> > splx(s);
> >  
> > -   error = ttyopen(CZTTY_DIALOUT(dev), tp, p);
> > -   if (error)
> > -   goto bad;
> > -
> > error = (*linesw[tp->t_line].l_open)(dev, tp, p);
> 
> Is `CZTTY_DIALOUT(dev)' the same as `dev'?

No, is not the same in all cases.  The macro converts cuaXX to
corresponding ttyXX.  But, it doesn't matter, would be overwritten by
l_open anyway:
...
tp->t_dev = device;
...

> Either way, the `CZTTY_DIALOUT' macro becomes unused with this diff.

The updated diff below also removes the dead CZTTY_DIALOUT macro.

OK?

Thanks,
Jan

Index: arch/luna88k/dev/siotty.c
===
RCS file: /cvs/src/sys/arch/luna88k/dev/siotty.c,v
retrieving revision 1.23
diff -u -p -r1.23 siotty.c
--- arch/luna88k/dev/siotty.c   25 Feb 2019 11:29:30 -  1.23
+++ arch/luna88k/dev/siotty.c   28 Dec 2020 14:40:29 -
@@ -503,9 +503,6 @@ sioopen(dev_t dev, int flag, int mode, s
splx(s);
}
 
-   error = ttyopen(dev, tp, p);
-   if (error > 0)
-   return error;
return (*linesw[tp->t_line].l_open)(dev, tp, p);
 }
  
Index: arch/sh/dev/scif.c
===
RCS file: /cvs/src/sys/arch/sh/dev/scif.c,v
retrieving revision 1.19
diff -u -p -r1.19 scif.c
--- arch/sh/dev/scif.c  19 Feb 2018 08:59:52 -  1.19
+++ arch/sh/dev/scif.c  28 Dec 2020 14:41:05 -
@@ -756,10 +756,6 @@ scifopen(dev_t dev, int flag, int mode, 
 
splx(s);
 
-   error = ttyopen(dev, tp, p);
-   if (error)
-   goto bad;
-
error = (*linesw[tp->t_line].l_open)(dev, tp, p);
if (error)
goto bad;
Index: dev/pci/cz.c
===
RCS file: /cvs/src/sys/dev/pci/cz.c,v
retrieving revision 1.24
diff -u -p -r1.24 cz.c
--- dev/pci/cz.c21 May 2020 09:31:59 -  1.24
+++ dev/pci/cz.c29 Dec 2020 00:48:52 -
@@ -835,7 +835,6 @@ cz_wait_pci_doorbell(struct cz_softc *cz
 
 #define CZTTYDIALOUT_MASK  0x80
 
-#defineCZTTY_DIALOUT(dev)  (minor((dev)) & CZTTYDIALOUT_MASK)
 #defineCZTTY_CZ(sc)((sc)->sc_parent)
 
 #defineCZTTY_SOFTC(dev)cztty_getttysoftc(dev)
@@ -1033,10 +1032,6 @@ czttyopen(dev_t dev, int flags, int mode
}
 
splx(s);
-
-   error = ttyopen(CZTTY_DIALOUT(dev), tp, p);
-   if (error)
-   goto bad;
 
error = (*linesw[tp->t_line].l_open)(dev, tp, p);
if (error)



Re: remove double call of ttyopen()

2020-12-28 Thread Klemens Nanni
On Mon, Dec 28, 2020 at 03:49:35PM +0100, Jan Klemkow wrote:
> The following diff removes useless double calls of ttyopen.  l_open is
> a pointer to ttyopen().  All other serial drivers also just use l_open,
> as it is the general API for this.
I'm not familiar with the subsystem/API, but one thing looks off to me.

> Index: dev/pci/cz.c
> ===
> RCS file: /cvs/src/sys/dev/pci/cz.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 cz.c
> --- dev/pci/cz.c  21 May 2020 09:31:59 -  1.24
> +++ dev/pci/cz.c  28 Dec 2020 14:41:30 -
> @@ -1034,10 +1034,6 @@ czttyopen(dev_t dev, int flags, int mode
>  
>   splx(s);
>  
> - error = ttyopen(CZTTY_DIALOUT(dev), tp, p);
> - if (error)
> - goto bad;
> -
>   error = (*linesw[tp->t_line].l_open)(dev, tp, p);

Is `CZTTY_DIALOUT(dev)' the same as `dev'?

Either way, the `CZTTY_DIALOUT' macro becomes unused with this diff.

>   if (error)
>   goto bad;
> 



remove double call of ttyopen()

2020-12-28 Thread Jan Klemkow
Hi,

The following diff removes useless double calls of ttyopen.  l_open is
a pointer to ttyopen().  All other serial drivers also just use l_open,
as it is the general API for this.

OK?

Bye,
Jan

Index: arch/luna88k/dev/siotty.c
===
RCS file: /cvs/src/sys/arch/luna88k/dev/siotty.c,v
retrieving revision 1.23
diff -u -p -r1.23 siotty.c
--- arch/luna88k/dev/siotty.c   25 Feb 2019 11:29:30 -  1.23
+++ arch/luna88k/dev/siotty.c   28 Dec 2020 14:40:29 -
@@ -503,9 +503,6 @@ sioopen(dev_t dev, int flag, int mode, s
splx(s);
}
 
-   error = ttyopen(dev, tp, p);
-   if (error > 0)
-   return error;
return (*linesw[tp->t_line].l_open)(dev, tp, p);
 }
  
Index: arch/sh/dev/scif.c
===
RCS file: /cvs/src/sys/arch/sh/dev/scif.c,v
retrieving revision 1.19
diff -u -p -r1.19 scif.c
--- arch/sh/dev/scif.c  19 Feb 2018 08:59:52 -  1.19
+++ arch/sh/dev/scif.c  28 Dec 2020 14:41:05 -
@@ -756,10 +756,6 @@ scifopen(dev_t dev, int flag, int mode, 
 
splx(s);
 
-   error = ttyopen(dev, tp, p);
-   if (error)
-   goto bad;
-
error = (*linesw[tp->t_line].l_open)(dev, tp, p);
if (error)
goto bad;
Index: dev/pci/cz.c
===
RCS file: /cvs/src/sys/dev/pci/cz.c,v
retrieving revision 1.24
diff -u -p -r1.24 cz.c
--- dev/pci/cz.c21 May 2020 09:31:59 -  1.24
+++ dev/pci/cz.c28 Dec 2020 14:41:30 -
@@ -1034,10 +1034,6 @@ czttyopen(dev_t dev, int flags, int mode
 
splx(s);
 
-   error = ttyopen(CZTTY_DIALOUT(dev), tp, p);
-   if (error)
-   goto bad;
-
error = (*linesw[tp->t_line].l_open)(dev, tp, p);
if (error)
goto bad;