1
0

add xpcu_close

This commit is contained in:
Michael Gernoth 2008-04-11 15:22:59 +02:00
parent 6c235d59ca
commit 6234190be3
3 changed files with 15 additions and 8 deletions

View 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;
}

13
xpcu.c
View File

@ -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;
}

2
xpcu.h
View File

@ -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);