Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb add uplcom_{open,close}



details:   https://anonhg.NetBSD.org/src/rev/53e76ec2ba3f
branches:  trunk
changeset: 503061:53e76ec2ba3f
user:      ichiro <ichiro%NetBSD.org@localhost>
date:      Tue Jan 30 13:17:43 2001 +0000

description:
add uplcom_{open,close}
it only reset routine yet.

diffstat:

 sys/dev/usb/uplcom.c |  57 ++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 49 insertions(+), 8 deletions(-)

diffs (110 lines):

diff -r 1c61ee38801d -r 53e76ec2ba3f sys/dev/usb/uplcom.c
--- a/sys/dev/usb/uplcom.c      Tue Jan 30 12:48:34 2001 +0000
+++ b/sys/dev/usb/uplcom.c      Tue Jan 30 13:17:43 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uplcom.c,v 1.10 2001/01/28 03:44:46 ichiro Exp $       */
+/*     $NetBSD: uplcom.c,v 1.11 2001/01/30 13:17:43 ichiro Exp $       */
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -103,7 +103,7 @@
 #define UPLCOMIBUFSIZE 256
 #define UPLCOMOBUFSIZE 256
 
-Static usbd_status uplcom_init(struct uplcom_softc *);
+Static usbd_status uplcom_reset(struct uplcom_softc *);
 Static usbd_status uplcom_set_line_coding(struct uplcom_softc *sc,
                                           usb_cdc_line_state_t *state);
 
@@ -113,14 +113,16 @@
 Static void    uplcom_break(struct uplcom_softc *, int);
 Static void    uplcom_set_line_state(struct uplcom_softc *);
 Static int     uplcom_param(void *, int, struct termios *);
+Static int     uplcom_open(void *, int);
+Static void    uplcom_close(void *, int);
 
 struct ucom_methods uplcom_methods = {
        NULL,
        uplcom_set,
        uplcom_param,
        NULL,
-       NULL,
-       NULL,
+       uplcom_open,
+       uplcom_close,
        NULL,
        NULL,
 };
@@ -271,9 +273,10 @@
        uca.arg = sc;
        uca.info = NULL;
 
-       err = uplcom_init(sc);
+       err = uplcom_reset(sc);
+
        if (err) {
-               printf("%s: init failed, %s\n", USBDEVNAME(sc->sc_dev),
+               printf("%s: reset failed, %s\n", USBDEVNAME(sc->sc_dev),
                        usbd_errstr(err));
                USB_ATTACH_ERROR_RETURN;
        }
@@ -327,7 +330,7 @@
 
 
 usbd_status
-uplcom_init(struct uplcom_softc *sc)
+uplcom_reset(struct uplcom_softc *sc)
 {
         usb_device_request_t req;
        usbd_status err;
@@ -387,7 +390,7 @@
 uplcom_dtr(struct uplcom_softc *sc, int onoff)
 {
 
-       DPRINTF(("uplcom: onoff=%d\n", onoff));
+       DPRINTF(("uplcom_dtr: onoff=%d\n", onoff));
 
        if (sc->sc_dtr == onoff)
                return;
@@ -500,3 +503,41 @@
        }
        return (0);
 }
+
+int
+uplcom_open(void *addr, int portno)
+{
+       struct uplcom_softc *sc = addr;
+       usbd_status err;
+       
+       if (sc->sc_dying)
+               return (EIO);
+
+       err = uplcom_reset(sc);
+        if (err) {
+                printf("%s: reset failed, %s\n", USBDEVNAME(sc->sc_dev),
+                        usbd_errstr(err));
+        }
+
+       DPRINTF(("uplcom_open: open\n"));
+
+       return (0);
+}
+
+void
+uplcom_close(void *addr, int portno) 
+{
+       struct uplcom_softc *sc = addr;
+       usbd_status err;
+
+       if (sc->sc_dying)
+               return;
+
+       err = uplcom_reset(sc);
+       if (err) {
+               printf("%s: reset failed, %s\n", USBDEVNAME(sc->sc_dev),
+                       usbd_errstr(err));
+       }
+
+       DPRINTF(("uplcom_close: close\n"));
+}



Home | Main Index | Thread Index | Old Index