Date: Mon, 16 Jan 2012 08:20:14 GMT From: dfilter@FreeBSD.ORG (dfilter service) To: freebsd-usb@FreeBSD.org Subject: Re: usb/164090: commit references a PR Message-ID: <201201160820.q0G8KECF098488@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR usb/164090; it has been noted by GNATS. From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: usb/164090: commit references a PR Date: Mon, 16 Jan 2012 08:13:39 +0000 (UTC) Author: hselasky Date: Mon Jan 16 08:13:25 2012 New Revision: 230204 URL: http://svn.freebsd.org/changeset/base/230204 Log: 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 Modified: head/sys/dev/usb/serial/usb_serial.c head/sys/dev/usb/serial/usb_serial.h Modified: head/sys/dev/usb/serial/usb_serial.c ============================================================================== --- head/sys/dev/usb/serial/usb_serial.c Mon Jan 16 07:02:59 2012 (r230203) +++ head/sys/dev/usb/serial/usb_serial.c Mon Jan 16 08:13:25 2012 (r230204) @@ -292,6 +292,16 @@ ucom_detach(struct ucom_super_softc *ssc 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; - - 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; + 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 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 Modified: head/sys/dev/usb/serial/usb_serial.h ============================================================================== --- head/sys/dev/usb/serial/usb_serial.h Mon Jan 16 07:02:59 2012 (r230203) +++ head/sys/dev/usb/serial/usb_serial.h Mon Jan 16 08:13:25 2012 (r230204) @@ -70,6 +70,7 @@ #include <sys/tty.h> #include <sys/serial.h> #include <sys/fcntl.h> +#include <sys/sysctl.h> /* Module interface related macros */ #define UCOM_MODVER 1 @@ -132,8 +133,10 @@ struct ucom_param_task { struct ucom_super_softc { struct usb_process sc_tq; - uint32_t sc_unit; - uint32_t sc_subunits; + int sc_unit; + int sc_subunits; + struct sysctl_oid *sc_sysctl_ttyunit; + struct sysctl_oid *sc_sysctl_ttyports; }; struct ucom_softc { _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201160820.q0G8KECF098488>