summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorn_hibma <n_hibma@FreeBSD.org>2010-11-05 19:12:48 +0000
committern_hibma <n_hibma@FreeBSD.org>2010-11-05 19:12:48 +0000
commit6a88b24ee2d7ca5016b91d9d019359d50e6924df (patch)
tree59ac6a21c775bdb2ae4ada9162ee26328cebdb90
parent971417400f71b1a51b320f7a4dfcd777980d1469 (diff)
downloadFreeBSD-src-6a88b24ee2d7ca5016b91d9d019359d50e6924df.zip
FreeBSD-src-6a88b24ee2d7ca5016b91d9d019359d50e6924df.tar.gz
Implement ucom_set_pnpinfo_usb() providing ttyname and port number
information through devd. My E220 now produces the notification (1 line): +u3g0 at bus=1 hubaddr=1 port=0 devaddr=2 interface=0 \ vendor=0x12d1 product=0x1003 devclass=0x00 devsubclass=0x00 \ sernum="" release=0x0000 intclass=0xff intsubclass=0xff \ ttyname=U0 ttyports=2 on uhub0 Note: serial/ufoma and net/uhso still provide port number and tty name (uhso only) information through sysctls, which should now be removed. Reviewed by: hpselasky
-rw-r--r--sys/dev/usb/net/uhso.c2
-rw-r--r--sys/dev/usb/serial/u3g.c2
-rw-r--r--sys/dev/usb/serial/uark.c2
-rw-r--r--sys/dev/usb/serial/ubsa.c2
-rw-r--r--sys/dev/usb/serial/ubser.c1
-rw-r--r--sys/dev/usb/serial/uchcom.c2
-rw-r--r--sys/dev/usb/serial/ucycom.c4
-rw-r--r--sys/dev/usb/serial/ufoma.c2
-rw-r--r--sys/dev/usb/serial/uftdi.c2
-rw-r--r--sys/dev/usb/serial/ugensa.c2
-rw-r--r--sys/dev/usb/serial/uipaq.c2
-rw-r--r--sys/dev/usb/serial/umct.c2
-rw-r--r--sys/dev/usb/serial/umodem.c2
-rw-r--r--sys/dev/usb/serial/umoscom.c2
-rw-r--r--sys/dev/usb/serial/uplcom.c2
-rw-r--r--sys/dev/usb/serial/usb_serial.c25
-rw-r--r--sys/dev/usb/serial/usb_serial.h1
-rw-r--r--sys/dev/usb/serial/uslcom.c2
-rw-r--r--sys/dev/usb/serial/uvisor.c2
-rw-r--r--sys/dev/usb/serial/uvscom.c2
20 files changed, 60 insertions, 3 deletions
diff --git a/sys/dev/usb/net/uhso.c b/sys/dev/usb/net/uhso.c
index 63c6dcf..06ac416 100644
--- a/sys/dev/usb/net/uhso.c
+++ b/sys/dev/usb/net/uhso.c
@@ -902,6 +902,7 @@ uhso_probe_iface(struct uhso_softc *sc, int index,
device_printf(sc->sc_dev, "ucom_attach failed\n");
return (ENXIO);
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, sc->sc_dev);
mtx_lock(&sc->sc_mtx);
usbd_transfer_start(sc->sc_xfer[UHSO_MUX_ENDPT_INTR]);
@@ -920,6 +921,7 @@ uhso_probe_iface(struct uhso_softc *sc, int index,
device_printf(sc->sc_dev, "ucom_attach failed\n");
return (ENXIO);
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, sc->sc_dev);
}
else {
UHSO_DPRINTF(0, "Unknown type %x\n", type);
diff --git a/sys/dev/usb/serial/u3g.c b/sys/dev/usb/serial/u3g.c
index dbbe844..71776b2 100644
--- a/sys/dev/usb/serial/u3g.c
+++ b/sys/dev/usb/serial/u3g.c
@@ -818,8 +818,10 @@ u3g_attach(device_t dev)
DPRINTF("ucom_attach failed\n");
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
device_printf(dev, "Found %u port%s.\n", sc->sc_numports,
sc->sc_numports > 1 ? "s":"");
+
return (0);
detach:
diff --git a/sys/dev/usb/serial/uark.c b/sys/dev/usb/serial/uark.c
index 39f66b6..de7f057 100644
--- a/sys/dev/usb/serial/uark.c
+++ b/sys/dev/usb/serial/uark.c
@@ -227,6 +227,8 @@ uark_attach(device_t dev)
DPRINTF("ucom_attach failed\n");
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
return (0); /* success */
detach:
diff --git a/sys/dev/usb/serial/ubsa.c b/sys/dev/usb/serial/ubsa.c
index 9d3d97d..8f1abec 100644
--- a/sys/dev/usb/serial/ubsa.c
+++ b/sys/dev/usb/serial/ubsa.c
@@ -331,6 +331,8 @@ ubsa_attach(device_t dev)
DPRINTF("ucom_attach failed\n");
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
return (0);
detach:
diff --git a/sys/dev/usb/serial/ubser.c b/sys/dev/usb/serial/ubser.c
index d0fe723..204be9b 100644
--- a/sys/dev/usb/serial/ubser.c
+++ b/sys/dev/usb/serial/ubser.c
@@ -296,6 +296,7 @@ ubser_attach(device_t dev)
if (error) {
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
mtx_lock(&sc->sc_mtx);
usbd_xfer_set_stall(sc->sc_xfer[UBSER_BULK_DT_WR]);
diff --git a/sys/dev/usb/serial/uchcom.c b/sys/dev/usb/serial/uchcom.c
index 5a9c02d..99c3ce7 100644
--- a/sys/dev/usb/serial/uchcom.c
+++ b/sys/dev/usb/serial/uchcom.c
@@ -354,6 +354,8 @@ uchcom_attach(device_t dev)
if (error) {
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
return (0);
detach:
diff --git a/sys/dev/usb/serial/ucycom.c b/sys/dev/usb/serial/ucycom.c
index be1ca54..6f0db7d 100644
--- a/sys/dev/usb/serial/ucycom.c
+++ b/sys/dev/usb/serial/ucycom.c
@@ -272,13 +272,15 @@ ucycom_attach(device_t dev)
}
error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
&ucycom_callback, &sc->sc_mtx);
-
if (error) {
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
if (urd_ptr) {
free(urd_ptr, M_USBDEV);
}
+
return (0); /* success */
detach:
diff --git a/sys/dev/usb/serial/ufoma.c b/sys/dev/usb/serial/ufoma.c
index 5555ed5..7da904e 100644
--- a/sys/dev/usb/serial/ufoma.c
+++ b/sys/dev/usb/serial/ufoma.c
@@ -450,6 +450,8 @@ ufoma_attach(device_t dev)
DPRINTF("ucom_attach failed\n");
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
/*Sysctls*/
sctx = device_get_sysctl_ctx(dev);
soid = device_get_sysctl_tree(dev);
diff --git a/sys/dev/usb/serial/uftdi.c b/sys/dev/usb/serial/uftdi.c
index 946768f..5dd6d92 100644
--- a/sys/dev/usb/serial/uftdi.c
+++ b/sys/dev/usb/serial/uftdi.c
@@ -332,6 +332,8 @@ uftdi_attach(device_t dev)
if (error) {
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
return (0); /* success */
detach:
diff --git a/sys/dev/usb/serial/ugensa.c b/sys/dev/usb/serial/ugensa.c
index 70e24cb..022e106 100644
--- a/sys/dev/usb/serial/ugensa.c
+++ b/sys/dev/usb/serial/ugensa.c
@@ -247,6 +247,8 @@ ugensa_attach(device_t dev)
DPRINTF("attach failed\n");
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
return (0); /* success */
detach:
diff --git a/sys/dev/usb/serial/uipaq.c b/sys/dev/usb/serial/uipaq.c
index a5516c1..6d43858 100644
--- a/sys/dev/usb/serial/uipaq.c
+++ b/sys/dev/usb/serial/uipaq.c
@@ -1161,6 +1161,8 @@ uipaq_attach(device_t dev)
if (error) {
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
return (0);
detach:
diff --git a/sys/dev/usb/serial/umct.c b/sys/dev/usb/serial/umct.c
index 1f91464..c9f442f 100644
--- a/sys/dev/usb/serial/umct.c
+++ b/sys/dev/usb/serial/umct.c
@@ -297,6 +297,8 @@ umct_attach(device_t dev)
if (error) {
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
return (0); /* success */
detach:
diff --git a/sys/dev/usb/serial/umodem.c b/sys/dev/usb/serial/umodem.c
index 49bb580..73abf65 100644
--- a/sys/dev/usb/serial/umodem.c
+++ b/sys/dev/usb/serial/umodem.c
@@ -389,6 +389,8 @@ umodem_attach(device_t dev)
if (error) {
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
return (0);
detach:
diff --git a/sys/dev/usb/serial/umoscom.c b/sys/dev/usb/serial/umoscom.c
index 8cf6bc1..79807a6 100644
--- a/sys/dev/usb/serial/umoscom.c
+++ b/sys/dev/usb/serial/umoscom.c
@@ -338,6 +338,8 @@ umoscom_attach(device_t dev)
if (error) {
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
return (0);
detach:
diff --git a/sys/dev/usb/serial/uplcom.c b/sys/dev/usb/serial/uplcom.c
index df48ba2..6a4b149 100644
--- a/sys/dev/usb/serial/uplcom.c
+++ b/sys/dev/usb/serial/uplcom.c
@@ -445,6 +445,8 @@ uplcom_attach(device_t dev)
device_printf(dev, "init failed\n");
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
return (0);
detach:
diff --git a/sys/dev/usb/serial/usb_serial.c b/sys/dev/usb/serial/usb_serial.c
index 7ba74d9..9e9900a 100644
--- a/sys/dev/usb/serial/usb_serial.c
+++ b/sys/dev/usb/serial/usb_serial.c
@@ -185,6 +185,8 @@ static uint8_t ucom_bitmap[(UCOM_UNIT_MAX + 7) / 8];
static struct mtx ucom_bitmap_mtx;
MTX_SYSINIT(ucom_bitmap_mtx, &ucom_bitmap_mtx, "ucom bitmap", MTX_DEF);
+#define UCOM_TTY_PREFIX "U"
+
/*
* Mark a unit number (the X in cuaUX) as in use.
*
@@ -320,11 +322,12 @@ ucom_attach_tty(struct ucom_super_softc *ssc, struct ucom_softc *sc)
/* Use default TTY name */
if (ssc->sc_subunits > 1) {
/* multiple modems in one */
- snprintf(buf, sizeof(buf), "U%u.%u",
+ snprintf(buf, sizeof(buf), UCOM_TTY_PREFIX "%u.%u",
ssc->sc_unit, sc->sc_subunit);
} else {
/* single modem */
- snprintf(buf, sizeof(buf), "U%u", ssc->sc_unit);
+ snprintf(buf, sizeof(buf), UCOM_TTY_PREFIX "%u",
+ ssc->sc_unit);
}
}
tty_makedev(tp, NULL, "%s", buf);
@@ -409,6 +412,24 @@ ucom_detach_tty(struct ucom_softc *sc)
cv_destroy(&sc->sc_cv);
}
+void
+ucom_set_pnpinfo_usb(struct ucom_super_softc *ssc, device_t dev)
+{
+ char buf[64];
+ uint8_t iface_index;
+ struct usb_attach_arg *uaa;
+
+ snprintf(buf, sizeof(buf), "ttyname=%s%d ttyports=%d",
+ UCOM_TTY_PREFIX, ssc->sc_unit, ssc->sc_subunits);
+
+ /* Store the PNP info in the first interface for the dev */
+ uaa = device_get_ivars(dev);
+ iface_index = uaa->info.bIfaceIndex;
+
+ if (usbd_set_pnpinfo(uaa->device, iface_index, buf) != 0)
+ device_printf(dev, "Could not set PNP info\n");
+}
+
static void
ucom_queue_command(struct ucom_softc *sc,
usb_proc_callback_t *fn, struct termios *pt,
diff --git a/sys/dev/usb/serial/usb_serial.h b/sys/dev/usb/serial/usb_serial.h
index d1dbc65..5b53b89 100644
--- a/sys/dev/usb/serial/usb_serial.h
+++ b/sys/dev/usb/serial/usb_serial.h
@@ -193,6 +193,7 @@ int ucom_attach(struct ucom_super_softc *,
struct ucom_softc *, uint32_t, void *,
const struct ucom_callback *callback, struct mtx *);
void ucom_detach(struct ucom_super_softc *, struct ucom_softc *);
+void ucom_set_pnpinfo_usb(struct ucom_super_softc *, device_t);
void ucom_status_change(struct ucom_softc *);
uint8_t ucom_get_data(struct ucom_softc *, struct usb_page_cache *,
uint32_t, uint32_t, uint32_t *);
diff --git a/sys/dev/usb/serial/uslcom.c b/sys/dev/usb/serial/uslcom.c
index 116b6fc..327fb3b 100644
--- a/sys/dev/usb/serial/uslcom.c
+++ b/sys/dev/usb/serial/uslcom.c
@@ -324,6 +324,8 @@ uslcom_attach(device_t dev)
if (error) {
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
return (0);
detach:
diff --git a/sys/dev/usb/serial/uvisor.c b/sys/dev/usb/serial/uvisor.c
index 127f364..b4174e6 100644
--- a/sys/dev/usb/serial/uvisor.c
+++ b/sys/dev/usb/serial/uvisor.c
@@ -347,6 +347,8 @@ uvisor_attach(device_t dev)
DPRINTF("ucom_attach failed\n");
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
return (0);
detach:
diff --git a/sys/dev/usb/serial/uvscom.c b/sys/dev/usb/serial/uvscom.c
index 1d1af8d..865947c 100644
--- a/sys/dev/usb/serial/uvscom.c
+++ b/sys/dev/usb/serial/uvscom.c
@@ -321,6 +321,8 @@ uvscom_attach(device_t dev)
if (error) {
goto detach;
}
+ ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
/* start interrupt pipe */
mtx_lock(&sc->sc_mtx);
usbd_transfer_start(sc->sc_xfer[UVSCOM_INTR_DT_RD]);
OpenPOWER on IntegriCloud