summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2012-01-16 10:42:43 +0000
committerhselasky <hselasky@FreeBSD.org>2012-01-16 10:42:43 +0000
commite1055fad78ef17896428bae9141458ff90df798b (patch)
tree8e19a2cee6129329b0c96ce16d3b4ade90172c96 /sys/dev/usb
parentba45f0caad51d72e406ef3ef480156f139614f20 (diff)
downloadFreeBSD-src-e1055fad78ef17896428bae9141458ff90df798b.zip
FreeBSD-src-e1055fad78ef17896428bae9141458ff90df798b.tar.gz
Export ttyname instead of ttyunit via the sysctl interface.
Submitted by: Mykhaylo Yehorov PR: usb/164090 MFC after: 1 week
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/serial/usb_serial.c26
-rw-r--r--sys/dev/usb/serial/usb_serial.h3
2 files changed, 18 insertions, 11 deletions
diff --git a/sys/dev/usb/serial/usb_serial.c b/sys/dev/usb/serial/usb_serial.c
index 0f0ecce..08ce2ca 100644
--- a/sys/dev/usb/serial/usb_serial.c
+++ b/sys/dev/usb/serial/usb_serial.c
@@ -248,10 +248,16 @@ ucom_attach(struct ucom_super_softc *ssc, struct ucom_softc *sc,
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,9 +298,9 @@ 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_ttyname != NULL) {
+ sysctl_remove_oid(ssc->sc_sysctl_ttyname, 1, 0);
+ ssc->sc_sysctl_ttyname = NULL;
}
if (ssc->sc_sysctl_ttyports != NULL) {
@@ -434,8 +440,8 @@ ucom_set_pnpinfo_usb(struct ucom_super_softc *ssc, device_t dev)
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=" 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);
@@ -445,14 +451,14 @@ ucom_set_pnpinfo_usb(struct ucom_super_softc *ssc, device_t dev)
device_printf(dev, "Could not set PNP info\n");
/*
- * The following information is also replicated in the pnp-info
+ * 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,
+ if (ssc->sc_sysctl_ttyname == NULL) {
+ ssc->sc_sysctl_ttyname = SYSCTL_ADD_STRING(NULL,
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
- OID_AUTO, "ttyunit", CTLFLAG_RD,
- NULL, ssc->sc_unit, "TTY unit number");
+ 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,
diff --git a/sys/dev/usb/serial/usb_serial.h b/sys/dev/usb/serial/usb_serial.h
index 521612b..ffd2859 100644
--- a/sys/dev/usb/serial/usb_serial.h
+++ b/sys/dev/usb/serial/usb_serial.h
@@ -135,8 +135,9 @@ struct ucom_super_softc {
struct usb_process sc_tq;
int sc_unit;
int sc_subunits;
- struct sysctl_oid *sc_sysctl_ttyunit;
+ struct sysctl_oid *sc_sysctl_ttyname;
struct sysctl_oid *sc_sysctl_ttyports;
+ char sc_ttyname[16];
};
struct ucom_softc {
OpenPOWER on IntegriCloud