summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-05-29 06:41:23 +0000
committered <ed@FreeBSD.org>2009-05-29 06:41:23 +0000
commit8d73adc757c1e55e55c2f44cc26e036dc046c5cb (patch)
tree8504d18b61b10ae1ba84f3c8d91f1f3572bcce6f
parentfa743d1903e55eeb33e40743baf3fe61efd7f4ad (diff)
downloadFreeBSD-src-8d73adc757c1e55e55c2f44cc26e036dc046c5cb.zip
FreeBSD-src-8d73adc757c1e55e55c2f44cc26e036dc046c5cb.tar.gz
Last minute TTY API change: remove mutex argument from tty_alloc().
I don't want people to override the mutex when allocating a TTY. It has to be there, to keep drivers like syscons happy. So I'm creating a tty_alloc_mutex() which can be used in those cases. tty_alloc_mutex() should eventually be removed. The advantage of this approach, is that we can just remove a function, without breaking the regular API in the future.
-rw-r--r--sys/dev/cfe/cfe_console.c2
-rw-r--r--sys/dev/dcons/dcons_os.c2
-rw-r--r--sys/dev/nmdm/nmdm.c4
-rw-r--r--sys/dev/ofw/ofw_console.c2
-rw-r--r--sys/dev/rp/rp.c2
-rw-r--r--sys/dev/si/si.c2
-rw-r--r--sys/dev/syscons/syscons.c2
-rw-r--r--sys/dev/syscons/sysmouse.c2
-rw-r--r--sys/dev/uart/uart_tty.c2
-rw-r--r--sys/dev/usb/serial/usb_serial.c2
-rw-r--r--sys/dev/xen/console/console.c2
-rw-r--r--sys/ia64/ia64/ssc.c2
-rw-r--r--sys/kern/tty.c9
-rw-r--r--sys/kern/tty_pts.c4
-rw-r--r--sys/sun4v/sun4v/hvcons.c2
-rw-r--r--sys/sys/tty.h3
16 files changed, 26 insertions, 18 deletions
diff --git a/sys/dev/cfe/cfe_console.c b/sys/dev/cfe/cfe_console.c
index b40567d..2c38096 100644
--- a/sys/dev/cfe/cfe_console.c
+++ b/sys/dev/cfe/cfe_console.c
@@ -89,7 +89,7 @@ cn_drvinit(void *unused)
if (cfe_consdev.cn_pri != CN_DEAD &&
cfe_consdev.cn_name[0] != '\0') {
- tp = tty_alloc(&cfe_ttydevsw, NULL, NULL);
+ tp = tty_alloc(&cfe_ttydevsw, NULL);
tty_makedev(tp, NULL, "%s", output);
tty_makealias(tp, "cfecons");
}
diff --git a/sys/dev/dcons/dcons_os.c b/sys/dev/dcons/dcons_os.c
index 49967eb..3b98cdd 100644
--- a/sys/dev/dcons/dcons_os.c
+++ b/sys/dev/dcons/dcons_os.c
@@ -357,7 +357,7 @@ dcons_attach_port(int port, char *name, int flags)
struct tty *tp;
dc = &sc[port];
- tp = tty_alloc(&dcons_ttydevsw, dc, NULL);
+ tp = tty_alloc(&dcons_ttydevsw, dc);
dc->flags = flags;
dc->tty = tp;
tty_init_console(tp, 0);
diff --git a/sys/dev/nmdm/nmdm.c b/sys/dev/nmdm/nmdm.c
index 2c41290..d2fe877 100644
--- a/sys/dev/nmdm/nmdm.c
+++ b/sys/dev/nmdm/nmdm.c
@@ -117,11 +117,11 @@ nmdm_alloc(unsigned long unit)
callout_init(&ns->ns_part2.np_callout, CALLOUT_MPSAFE);
/* Create device nodes. */
- tp = ns->ns_part1.np_tty = tty_alloc(&nmdm_class, &ns->ns_part1,
+ tp = ns->ns_part1.np_tty = tty_alloc_mutex(&nmdm_class, &ns->ns_part1,
&ns->ns_mtx);
tty_makedev(tp, NULL, "nmdm%luA", unit);
- tp = ns->ns_part2.np_tty = tty_alloc(&nmdm_class, &ns->ns_part2,
+ tp = ns->ns_part2.np_tty = tty_alloc_mutex(&nmdm_class, &ns->ns_part2,
&ns->ns_mtx);
tty_makedev(tp, NULL, "nmdm%luB", unit);
diff --git a/sys/dev/ofw/ofw_console.c b/sys/dev/ofw/ofw_console.c
index 493bb78..fd280c9 100644
--- a/sys/dev/ofw/ofw_console.c
+++ b/sys/dev/ofw/ofw_console.c
@@ -95,7 +95,7 @@ cn_drvinit(void *unused)
* XXX: This is a hack and it may result in two /dev/ttya
* XXX: devices on platforms where the sab driver works.
*/
- tp = tty_alloc(&ofw_ttydevsw, NULL, NULL);
+ tp = tty_alloc(&ofw_ttydevsw, NULL);
tty_makedev(tp, NULL, "%s", output);
tty_makealias(tp, "ofwcons");
}
diff --git a/sys/dev/rp/rp.c b/sys/dev/rp/rp.c
index 690e221..520ca80 100644
--- a/sys/dev/rp/rp.c
+++ b/sys/dev/rp/rp.c
@@ -774,7 +774,7 @@ rp_attachcommon(CONTROLLER_T *ctlp, int num_aiops, int num_ports)
for(aiop=0; aiop < num_aiops; aiop++) {
num_chan = sGetAiopNumChan(ctlp, aiop);
for(chan=0; chan < num_chan; chan++, port++, rp++) {
- rp->rp_tty = tp = tty_alloc(&rp_tty_class, rp, NULL);
+ rp->rp_tty = tp = tty_alloc(&rp_tty_class, rp);
rp->rp_port = port;
rp->rp_ctlp = ctlp;
rp->rp_unit = unit;
diff --git a/sys/dev/si/si.c b/sys/dev/si/si.c
index ded079c..416771c 100644
--- a/sys/dev/si/si.c
+++ b/sys/dev/si/si.c
@@ -584,7 +584,7 @@ try_next:
sprintf(pp->sp_name, "si%r%r", unit,
(int)(pp - sc->sc_ports));
#endif
- tp = pp->sp_tty = tty_alloc(&si_tty_class, pp, &Giant);
+ tp = pp->sp_tty = tty_alloc_mutex(&si_tty_class, pp, &Giant);
tty_makedev(tp, NULL, "A%r%r", unit, (int)(pp - sc->sc_ports));
}
try_next2:
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index 0ba7d7d..653ff08 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -334,7 +334,7 @@ sc_alloc_tty(int index, int devnum)
stc = malloc(sizeof(struct sc_ttysoftc), M_DEVBUF, M_WAITOK);
stc->st_index = index;
stc->st_stat = NULL;
- tp = tty_alloc(&sc_ttydevsw, stc, &Giant);
+ tp = tty_alloc_mutex(&sc_ttydevsw, stc, &Giant);
/* Create device node. */
tty_makedev(tp, NULL, "v%r", devnum);
diff --git a/sys/dev/syscons/sysmouse.c b/sys/dev/syscons/sysmouse.c
index 67c5079..4e787ef 100644
--- a/sys/dev/syscons/sysmouse.c
+++ b/sys/dev/syscons/sysmouse.c
@@ -164,7 +164,7 @@ static struct ttydevsw smdev_ttydevsw = {
static void
sm_attach_mouse(void *unused)
{
- sysmouse_tty = tty_alloc(&smdev_ttydevsw, NULL, NULL);
+ sysmouse_tty = tty_alloc(&smdev_ttydevsw, NULL);
tty_makedev(sysmouse_tty, NULL, "sysmouse");
}
diff --git a/sys/dev/uart/uart_tty.c b/sys/dev/uart/uart_tty.c
index 5fcf98e..cb77f65 100644
--- a/sys/dev/uart/uart_tty.c
+++ b/sys/dev/uart/uart_tty.c
@@ -356,7 +356,7 @@ uart_tty_attach(struct uart_softc *sc)
struct tty *tp;
int unit;
- sc->sc_u.u_tty.tp = tp = tty_alloc(&uart_tty_class, sc, NULL);
+ sc->sc_u.u_tty.tp = tp = tty_alloc(&uart_tty_class, sc);
unit = device_get_unit(sc->sc_dev);
diff --git a/sys/dev/usb/serial/usb_serial.c b/sys/dev/usb/serial/usb_serial.c
index b522270..fc9a6fd 100644
--- a/sys/dev/usb/serial/usb_serial.c
+++ b/sys/dev/usb/serial/usb_serial.c
@@ -293,7 +293,7 @@ usb2_com_attach_tty(struct ucom_softc *sc, uint32_t sub_units)
int error = 0;
char buf[32]; /* temporary TTY device name buffer */
- tp = tty_alloc(&usb2_com_class, sc, sc->sc_mtx);
+ tp = tty_alloc_mutex(&usb2_com_class, sc, sc->sc_mtx);
if (tp == NULL) {
error = ENOMEM;
goto done;
diff --git a/sys/dev/xen/console/console.c b/sys/dev/xen/console/console.c
index 9b376b5..68bb0ae 100644
--- a/sys/dev/xen/console/console.c
+++ b/sys/dev/xen/console/console.c
@@ -230,7 +230,7 @@ xc_attach(device_t dev)
xc_consdev.cn_putc = xccnputc_dom0;
}
- xccons = tty_alloc(&xc_ttydevsw, NULL, NULL);
+ xccons = tty_alloc(&xc_ttydevsw, NULL);
tty_makedev(xccons, NULL, "xc%r", 0);
callout_init(&xc_callout, 0);
diff --git a/sys/ia64/ia64/ssc.c b/sys/ia64/ia64/ssc.c
index 04144c5..ff810fc 100644
--- a/sys/ia64/ia64/ssc.c
+++ b/sys/ia64/ia64/ssc.c
@@ -106,7 +106,7 @@ ssc_cnattach(void *arg)
{
struct tty *tp;
- tp = tty_alloc(&ssc_class, NULL, NULL);
+ tp = tty_alloc(&ssc_class, NULL);
tty_makedev(tp, NULL, "ssccons");
}
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 9b3c571..ba7e6ba 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -885,7 +885,14 @@ ttydevsw_deffree(void *softc)
*/
struct tty *
-tty_alloc(struct ttydevsw *tsw, void *sc, struct mtx *mutex)
+tty_alloc(struct ttydevsw *tsw, void *sc)
+{
+
+ return (tty_alloc_mutex(tsw, sc, NULL));
+}
+
+struct tty *
+tty_alloc_mutex(struct ttydevsw *tsw, void *sc, struct mtx *mutex)
{
struct tty *tp;
diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c
index 67704b8..27e481e 100644
--- a/sys/kern/tty_pts.c
+++ b/sys/kern/tty_pts.c
@@ -741,7 +741,7 @@ pts_alloc(int fflags, struct thread *td, struct file *fp)
psc->pts_uidinfo = uid;
uihold(uid);
- tp = tty_alloc(&pts_class, psc, NULL);
+ tp = tty_alloc(&pts_class, psc);
knlist_init(&psc->pts_inpoll.si_note, tp->t_mtx, NULL, NULL, NULL);
knlist_init(&psc->pts_outpoll.si_note, tp->t_mtx, NULL, NULL, NULL);
@@ -781,7 +781,7 @@ pts_alloc_external(int fflags, struct thread *td, struct file *fp,
psc->pts_uidinfo = uid;
uihold(uid);
- tp = tty_alloc(&pts_class, psc, NULL);
+ tp = tty_alloc(&pts_class, psc);
knlist_init(&psc->pts_inpoll.si_note, tp->t_mtx, NULL, NULL, NULL);
knlist_init(&psc->pts_outpoll.si_note, tp->t_mtx, NULL, NULL, NULL);
diff --git a/sys/sun4v/sun4v/hvcons.c b/sys/sun4v/sun4v/hvcons.c
index 314d15c..60f830b 100644
--- a/sys/sun4v/sun4v/hvcons.c
+++ b/sys/sun4v/sun4v/hvcons.c
@@ -327,7 +327,7 @@ hvcn_dev_attach(device_t dev)
hvcn_consdev.cn_name[0] == '\0')
return (ENXIO);
- tp = tty_alloc(&hvcn_class, NULL, NULL);
+ tp = tty_alloc(&hvcn_class, NULL);
tty_makedev(tp, NULL, "v%r", 1);
tty_makealias(tp, "hvcn");
diff --git a/sys/sys/tty.h b/sys/sys/tty.h
index 8935093..8d7daca 100644
--- a/sys/sys/tty.h
+++ b/sys/sys/tty.h
@@ -152,7 +152,8 @@ struct xtty {
#ifdef _KERNEL
/* Allocation and deallocation. */
-struct tty *tty_alloc(struct ttydevsw *tsw, void *softc, struct mtx *mtx);
+struct tty *tty_alloc(struct ttydevsw *tsw, void *softc);
+struct tty *tty_alloc_mutex(struct ttydevsw *tsw, void *softc, struct mtx *mtx);
void tty_rel_pgrp(struct tty *tp, struct pgrp *pgrp);
void tty_rel_sess(struct tty *tp, struct session *sess);
void tty_rel_gone(struct tty *tp);
OpenPOWER on IntegriCloud