This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/osmocom-sdr@lists.osmocom.org/.
Michal Demin michal.demin at gmail.comHi Peter,
I don't really see the problem.
Ether kernel had the driver loaded, or there is other app. If there is
kernel I detach the kernel driver and the device is claimed.
If other app is using the device then I will only try to claim. (Which
will fail)
I can only see the "racy" when 2 applications are concurrently trying
to claim the device, in which case not even your solution
is perfect :-)
Could you please be more specific with the problem?
Md
On Mon, Apr 23, 2012 at 7:11 PM, Peter Stuge <peter at stuge.se> wrote:
> Michal Demin wrote:
>> Subject: [PATCH 1/2] Detach the device kernel driver when kernel driver loaded.
> ..
>> @@ -689,6 +690,15 @@ int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t index)
>>
>> libusb_free_device_list(list, 0);
>>
>> + if (libusb_kernel_driver_active(dev->devh, 0)) {
>> + // reattach later
>> + dev->reattach = 1;
>> + if (libusb_detach_kernel_driver(dev->devh, 0)) {
>> + fprintf(stderr, "Error detaching kernel driver \n");
>> + goto err;
>> + }
>> + }
>> +
>> r = libusb_claim_interface(dev->devh, 0);
>> if (r < 0) {
>> fprintf(stderr, "usb_claim_interface error %d\n", r);
>
> This is racy. It's better to call libusb_detach_kernel_driver() when
> libusb_claim_interface() returns an error.
>
>
> //Peter
>