]> git.zerfleddert.de Git - usb-driver/commitdiff
add xpcu_close
authorMichael Gernoth <michael@gernoth.net>
Fri, 11 Apr 2008 13:22:59 +0000 (15:22 +0200)
committerMichael Gernoth <michael@gernoth.net>
Fri, 11 Apr 2008 13:22:59 +0000 (15:22 +0200)
usb-driver.c
xpcu.c
xpcu.h

index 53a0309f6b93cc555770288519c74fd7e93dd2c1..566b10b0d8e056c49675198f0a0f0adac1f7bedb 100644 (file)
@@ -633,13 +633,9 @@ int close(int fd) {
        if (fd == windrvrfd && windrvrfd >= 0) {
                DPRINTF("close windrvrfd\n");
 
-               if (xpcu->handle) {
-                       xpcu_claim(xpcu, XPCU_RELEASE);
-                       usb_close(xpcu->handle);
-               }
+               if (xpcu)
+                       xpcu_close(xpcu);
 
-               xpcu->handle = NULL;
-               xpcu->interface = -1;
                xpcu = NULL;
                windrvrfd = -1;
        }
diff --git a/xpcu.c b/xpcu.c
index 28770fe6eba169a0690d52952443a593d29c7b54..17ab7cb7a2f6de6839387ef9106bb8410e220200 100644 (file)
--- a/xpcu.c
+++ b/xpcu.c
@@ -166,7 +166,7 @@ int xpcu_deviceinfo(struct xpcu_s *xpcu, unsigned char *buf) {
        return len;
 }
 
-int xpcu_claim(struct xpcu_s *xpcu, int claim) {
+static int xpcu_claim(struct xpcu_s *xpcu, int claim) {
        int ret = 0;
        static int claimed = 0;
 
@@ -247,3 +247,14 @@ struct xpcu_s *xpcu_open(void) {
 
        return &xpcu;
 }
+
+void xpcu_close(struct xpcu_s *xpcu) {
+       if (xpcu->handle) {
+               xpcu_claim(xpcu, XPCU_RELEASE);
+               usb_close(xpcu->handle);
+       }
+
+       xpcu->handle = NULL;
+       xpcu->interface = -1;
+       xpcu->alternate = -1;
+}
diff --git a/xpcu.h b/xpcu.h
index 9583ed2cb4ce05601abc1d684fdc2fc866867f29..fb8fd554eeddc99ef9089b22cd78c48d22663625 100644 (file)
--- a/xpcu.h
+++ b/xpcu.h
@@ -10,6 +10,6 @@ struct xpcu_s {
 };
 
 int __attribute__ ((visibility ("hidden"))) xpcu_deviceinfo(struct xpcu_s *xpcu, unsigned char *buf);
-int __attribute__ ((visibility ("hidden"))) xpcu_claim(struct xpcu_s *xpcu, int claim);
 int __attribute__ ((visibility ("hidden"))) xpcu_transfer(struct xpcu_s *xpcu, struct usb_transfer *ut);
 struct xpcu_s __attribute__ ((visibility ("hidden"))) *xpcu_open(void);
+void __attribute__ ((visibility ("hidden"))) xpcu_close(struct xpcu_s *xpcu);
Impressum, Datenschutz