PERFORCE change 147106 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Sun Aug 10 21:09:30 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=147106
Change 147106 by hselasky at hselasky_laptop001 on 2008/08/10 21:08:29
Add support for custom TTY names. Requested by Andrew Thompson.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb2/serial/usb2_serial.c#5 edit
.. //depot/projects/usb/src/sys/dev/usb2/serial/usb2_serial.h#3 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb2/serial/usb2_serial.c#5 (text+ko) ====
@@ -304,6 +304,7 @@
{
struct tty *tp;
int error = 0;
+ char buf[32]; /* temporary TTY device name buffer */
tp = ttyalloc();
@@ -323,11 +324,24 @@
DPRINTF("tp = %p, unit = %d\n", tp, sc->sc_unit);
+ buf[0] = 0; /* set some default value */
+
+ /* Check if the client has a custom TTY name */
+ if (sc->sc_callback->usb2_com_tty_name) {
+ sc->sc_callback->usb2_com_tty_name(sc, buf,
+ sizeof(buf), sc->sc_local_unit);
+ }
+ if (buf[0] == 0) {
+ /* Use default TTY name */
+ if (snprintf(buf, sizeof(buf), "U%u", sc->sc_unit)) {
+ /* ignore */
+ }
+ }
#if !(defined(TS_CALLOUT) || (__FreeBSD_version >= 700022))
#define TS_CALLOUT NULL, sc->sc_unit, MINOR_CALLOUT /* compile fix for
* FreeBSD 6.x */
#endif
- error = ttycreate(tp, TS_CALLOUT, "U%d", sc->sc_unit);
+ error = ttycreate(tp, TS_CALLOUT, "%s", buf);
if (error) {
ttyfree(tp);
goto done;
==== //depot/projects/usb/src/sys/dev/usb2/serial/usb2_serial.h#3 (text+ko) ====
@@ -91,7 +91,7 @@
* while it is open!
*/
struct usb2_com_callback {
- void (*usb2_com_cfg_get_status) (struct usb2_com_softc *, uint8_t *, uint8_t *);
+ void (*usb2_com_cfg_get_status) (struct usb2_com_softc *, uint8_t *plsr, uint8_t *pmsr);
void (*usb2_com_cfg_set_dtr) (struct usb2_com_softc *, uint8_t);
void (*usb2_com_cfg_set_rts) (struct usb2_com_softc *, uint8_t);
void (*usb2_com_cfg_set_break) (struct usb2_com_softc *, uint8_t);
@@ -105,6 +105,7 @@
void (*usb2_com_stop_read) (struct usb2_com_softc *);
void (*usb2_com_start_write) (struct usb2_com_softc *);
void (*usb2_com_stop_write) (struct usb2_com_softc *);
+ void (*usb2_com_tty_name) (struct usb2_com_softc *, char *pbuf, uint16_t buflen, uint16_t local_subunit);
};
/* Line status register */
More information about the p4-projects
mailing list