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
This commit is contained in:
parent
63472df74a
commit
6416c259d4
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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]);
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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,
|
||||
|
@ -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 *);
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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]);
|
||||
|
Loading…
Reference in New Issue
Block a user