summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/serial/usb_serial.c
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2012-01-16 08:13:25 +0000
committerhselasky <hselasky@FreeBSD.org>2012-01-16 08:13:25 +0000
commit9681d0cefcc9de94e08da04552c6b7a59a1012bc (patch)
treedc536d316105d2d8e9afaedf1651828edff86cf4 /sys/dev/usb/serial/usb_serial.c
parent8c9cfa24de66dab31dbbfa02c62ec9e59ca23154 (diff)
downloadFreeBSD-src-9681d0cefcc9de94e08da04552c6b7a59a1012bc.zip
FreeBSD-src-9681d0cefcc9de94e08da04552c6b7a59a1012bc.tar.gz
Export information about USB serial port unit and port numbers
directly via the sysctl interface. Submitted by: Mykhaylo Yehorov PR: usb/164090 MFC after: 1 week
Diffstat (limited to 'sys/dev/usb/serial/usb_serial.c')
-rw-r--r--sys/dev/usb/serial/usb_serial.c47
1 files changed, 37 insertions, 10 deletions
diff --git a/sys/dev/usb/serial/usb_serial.c b/sys/dev/usb/serial/usb_serial.c
index e63a0aa..0f0ecce 100644
--- a/sys/dev/usb/serial/usb_serial.c
+++ b/sys/dev/usb/serial/usb_serial.c
@@ -292,6 +292,16 @@ ucom_detach(struct ucom_super_softc *ssc, struct ucom_softc *sc)
if (ssc->sc_subunits == 0)
return; /* not initialized */
+ if (ssc->sc_sysctl_ttyunit != NULL) {
+ sysctl_remove_oid(ssc->sc_sysctl_ttyunit, 1, 0);
+ ssc->sc_sysctl_ttyunit = NULL;
+ }
+
+ if (ssc->sc_sysctl_ttyports != NULL) {
+ sysctl_remove_oid(ssc->sc_sysctl_ttyports, 1, 0);
+ ssc->sc_sysctl_ttyports = NULL;
+ }
+
usb_proc_drain(&ssc->sc_tq);
for (subunit = 0; subunit < ssc->sc_subunits; subunit++) {
@@ -420,19 +430,36 @@ ucom_detach_tty(struct ucom_softc *sc)
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;
+ 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);
+ 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;
+ /* Store the PNP info in the first interface for the device */
+ 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");
+ if (usbd_set_pnpinfo(uaa->device, iface_index, buf) != 0)
+ device_printf(dev, "Could not set PNP info\n");
+
+ /*
+ * The following information is also replicated in the pnp-info
+ * string which is registered above:
+ */
+ if (ssc->sc_sysctl_ttyunit == NULL) {
+ ssc->sc_sysctl_ttyunit = SYSCTL_ADD_INT(NULL,
+ SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+ OID_AUTO, "ttyunit", CTLFLAG_RD,
+ NULL, ssc->sc_unit, "TTY unit number");
+ }
+ if (ssc->sc_sysctl_ttyports == NULL) {
+ ssc->sc_sysctl_ttyports = SYSCTL_ADD_INT(NULL,
+ SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+ OID_AUTO, "ttyports", CTLFLAG_RD,
+ NULL, ssc->sc_subunits, "Number of ports");
+ }
}
static void
OpenPOWER on IntegriCloud