>>>>> "Matthias" == Matthias Janke <matthias.janke@xxxxxxxxxxxxxxxxxxxxxxx>
>>>>> writes:
Matthias> Well, that solution should work (not tested yet) but is rather
Matthias> invasive. I was thinking of something which plays with the
Matthias> refcount mechanism of libusb changing: (*curdev)->dev = dev;
Matthias> to (*curdev)->dev = libusb_ref_device(dev); but I didn't find
Matthias> any docs on the behaviour of this mechanism, yet. so I'm not
Matthias> sure if it would work.
Appended patch instead of
"1.0: Add the list retrieved by libusb_get_device_list to the ftdi_context
and only release it on exit"
seems to work to and is much less intrusive, as Matthias pointed out.
Bye
--
Uwe Bonnes bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
>From 55c1e53898bb983a90fc7ede6ee5d3e4e34a4831 Mon Sep 17 00:00:00 2001
From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 28 Jun 2011 16:04:14 +0200
Subject: Increment the refcount on devices we return from ftdi_usb_find_all()
---
src/ftdi.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/ftdi.c b/src/ftdi.c
index e3862a8..57730d9 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -299,7 +299,7 @@ int ftdi_usb_find_all(struct ftdi_context *ftdi, struct
ftdi_device_list **devli
(*curdev)->next = NULL;
(*curdev)->dev = dev;
-
+ libusb_ref_device(dev);
curdev = &(*curdev)->next;
count++;
}
@@ -320,6 +320,7 @@ void ftdi_list_free(struct ftdi_device_list **devlist)
for (curdev = *devlist; curdev != NULL;)
{
next = curdev->next;
+ libusb_unref_device(curdev->dev);
free(curdev);
curdev = next;
}
--
1.7.3.4
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|