From owner-svn-src-stable@FreeBSD.ORG Thu Feb 23 07:34:54 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 04681106566B; Thu, 23 Feb 2012 07:34:54 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E29CE8FC12; Thu, 23 Feb 2012 07:34:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q1N7YrpT090043; Thu, 23 Feb 2012 07:34:53 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1N7Yr9E090040; Thu, 23 Feb 2012 07:34:53 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201202230734.q1N7Yr9E090040@svn.freebsd.org> From: Hans Petter Selasky Date: Thu, 23 Feb 2012 07:34:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232038 - stable/9/sys/dev/usb/serial X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2012 07:34:54 -0000 Author: hselasky Date: Thu Feb 23 07:34:53 2012 New Revision: 232038 URL: http://svn.freebsd.org/changeset/base/232038 Log: MFC r230204 and r230209: Export information about USB serial port unit and port numbers directly via the sysctl interface. PR: usb/164090 Modified: stable/9/sys/dev/usb/serial/usb_serial.c stable/9/sys/dev/usb/serial/usb_serial.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/dev/usb/serial/usb_serial.c ============================================================================== --- stable/9/sys/dev/usb/serial/usb_serial.c Thu Feb 23 07:27:20 2012 (r232037) +++ stable/9/sys/dev/usb/serial/usb_serial.c Thu Feb 23 07:34:53 2012 (r232038) @@ -248,10 +248,16 @@ ucom_attach(struct ucom_super_softc *ssc return (EINVAL); } + /* allocate a uniq unit number */ ssc->sc_unit = ucom_unit_alloc(); if (ssc->sc_unit == -1) return (ENOMEM); + /* generate TTY name string */ + snprintf(ssc->sc_ttyname, sizeof(ssc->sc_ttyname), + UCOM_TTY_PREFIX "%d", ssc->sc_unit); + + /* create USB request handling process */ error = usb_proc_create(&ssc->sc_tq, mtx, "ucom", USB_PRI_MED); if (error) { ucom_unit_free(ssc->sc_unit); @@ -292,6 +298,16 @@ ucom_detach(struct ucom_super_softc *ssc if (ssc->sc_subunits == 0) return; /* not initialized */ + if (ssc->sc_sysctl_ttyname != NULL) { + sysctl_remove_oid(ssc->sc_sysctl_ttyname, 1, 0); + ssc->sc_sysctl_ttyname = 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 +436,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=" UCOM_TTY_PREFIX + "%d ttyports=%d", 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_ttyname == NULL) { + ssc->sc_sysctl_ttyname = SYSCTL_ADD_STRING(NULL, + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "ttyname", CTLFLAG_RD, ssc->sc_ttyname, 0, + "TTY device basename"); + } + 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: stable/9/sys/dev/usb/serial/usb_serial.h ============================================================================== --- stable/9/sys/dev/usb/serial/usb_serial.h Thu Feb 23 07:27:20 2012 (r232037) +++ stable/9/sys/dev/usb/serial/usb_serial.h Thu Feb 23 07:34:53 2012 (r232038) @@ -70,6 +70,7 @@ #include #include #include +#include /* Module interface related macros */ #define UCOM_MODVER 1 @@ -132,8 +133,11 @@ 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_ttyname; + struct sysctl_oid *sc_sysctl_ttyports; + char sc_ttyname[16]; }; struct ucom_softc {