summaryrefslogtreecommitdiff
path: root/gusb
Commit message (Collapse)AuthorAgeFilesLines
* Export g_usb_device_has_tag()Richard Hughes2022-10-265-6/+23
|
* Do not call the hotplug callback with the mutex heldRichard Hughes2022-10-171-6/+22
| | | | | This fixes a regression introduced in 0ff5cca6 which causes a rare deadlock in fwupd.
* Revert "Use GRecMutex to avoid a single-threaded lockup"Richard Hughes2022-10-171-14/+5
| | | | | | This reverts commit cfb40102b0985d52cbd5d9348dedd1a4cc06b10c -- it's the wrong fix as the hotplug callback is being called by two different threads; even a recursive mutex isn't going to save us there.
* Use GRecMutex to avoid a single-threaded lockupRichard Hughes2022-10-121-5/+14
| | | | | | | | | If we call libusb_get_bos_descriptor() in the hotplug device-add handler then we eventually call libusb_handle_events_completed() which can run handle_events -- which might emit devices. Using a mutex that's safe for recursing prevents the deadlock. This fixes half the problem when getting descriptors on deeply nested USB hubs.
* Allow loading and saving only devices with specific tagsRichard Hughes2022-09-133-0/+60
| | | | | This would allow us, for example, to only load devices in bootloader or runtime phases.
* trivial: Don't return -1 for failure for a gbooleanRichard Hughes2022-09-131-1/+1
|
* trivial: Fix up clang-format issueRichard Hughes2022-09-131-1/+1
|
* Allow adding tags to the JSON device eventRichard Hughes2022-09-134-0/+76
| | | | This allows us to see which phase of the emulation should be used.
* Include the created time in the JSON eventRichard Hughes2022-09-131-0/+10
|
* trivial: Remove existing devices when loading a contextRichard Hughes2022-09-131-0/+4
|
* Include removed devices in the JSON dumpRichard Hughes2022-09-131-0/+13
| | | | This is needed to emulate devices with bootloader modes.
* trivial: Fix some docs warnings when compiling the tarballRichard Hughes2022-09-123-4/+5
|
* Allow emulating failed eventsRichard Hughes2022-09-125-0/+80
| | | | | This is required to emulate devices that just reset (without completing the current transfer) when asked to reset.
* Do not copy event data when not-requiredRichard Hughes2022-09-101-3/+48
| | | | | This will prevent crashes if the caller is casting from a const buffer to a mutable buffer.
* trivial: Be more careful with buffers in case the usb.ids file format changesRichard Hughes2022-09-091-1/+4
|
* Ignore usb.ids classes, subclasses and protocolsRichard Hughes2022-09-091-0/+4
|
* Fix loading events using _g_usb_device_event_load()Richard Hughes2022-09-091-1/+1
|
* trivial: Fix two -Wunused-variable warningsRichard Hughes2022-09-091-0/+4
|
* trivial: Fix the ColorMunki self testsRichard Hughes2022-09-091-4/+3
| | | | PVS: Converting type 'gssize' to type 'gboolean' can lead to a loss of high-order bits.
* Save device events when requiredRichard Hughes2022-09-089-6/+804
| | | | | | This allows us to simulate an entire context of devices, simulating responses as if the hardware is connected. This allows building rich device-specific unit tests in programs like fwupd, without having to have the hardware attached.
* trivial: Update the ColorHug test to reflect realityRichard Hughes2022-09-061-1/+1
|
* trivial: Ignore more requests when emulating a deviceRichard Hughes2022-09-061-0/+20
|
* trivial: Use a unique JSON key name for the IDRichard Hughes2022-09-061-4/+5
|
* trivial: Use a boolean flag for cache controlRichard Hughes2022-09-061-2/+10
| | | | There's no point keep asking the device for BOS descriptors when it has none.
* trivial: Check the handle before getting BOS descriptorsRichard Hughes2022-09-061-0/+4
|
* trivial: Fix up some docgen headersRichard Hughes2022-09-062-25/+1
|
* Skip some functionality when emulatingRichard Hughes2022-09-051-0/+12
|
* Include the platform ID in the JSON fileRichard Hughes2022-09-051-0/+10
|
* Serialize the GUsbDevice to and from JSON formatRichard Hughes2022-09-0514-11/+640
| | | | This allows us to write tests that mock up entire devices.
* Cache the list of interfaces and descriptorsRichard Hughes2022-09-053-94/+104
| | | | | This can speed up device enumeration, and also allows us to emulate the interfaces or descriptors in the future.
* trivial: Use @self for instance dataRichard Hughes2022-09-0510-482/+471
|
* Use G_DECLARE_DERIVABLE_TYPE to reduce boilerplateRichard Hughes2022-09-0510-217/+190
|
* trivial: Use @self for instance dataRichard Hughes2022-09-044-115/+114
|
* Reformat the code using clang-formatRichard Hughes2022-09-0427-1990/+1923
| | | | | This frees up mental energy when reviewing patches and is something I should have done a long time ago.
* Add support for getting BOS descriptorsRichard Hughes2022-09-048-0/+275
|
* Use g_autoptr() in a lot more placesRichard Hughes2022-09-043-174/+96
| | | | We started using this several months ago and nobody even noticed.
* trivial: Fix a docs warning when buildingRichard Hughes2022-06-161-1/+1
|
* trivial: Fix case of single-line commentsRichard Hughes2022-06-161-12/+12
|
* trivial: Use SPDX-License-Identifier in one more placeRichard Hughes2022-06-161-12/+1
|
* trivial: Remove some duplicate header includesRichard Hughes2022-06-1611-20/+0
|
* Only include the start year in the copyright headerRichard Hughes2022-06-1610-10/+10
| | | | | The end year is legally and functionally redundant, and more importantly causes cherry-pick conflicts when trying to maintain old branches.
* gusb: Add some umockdev based testsBenjamin Berg2022-06-152-0/+224
| | | | The primary purpose for this is to test the hotplug codepaths.
* Never dispatch idle events after the context has been destroyedRichard Hughes2022-06-151-12/+37
| | | | | Also, reduce the number of idle sources by batching them up as much as possible.
* trivial: Remove the '1:1 already exists' debug lines on rescanRichard Hughes2022-01-061-3/+1
|
* Add API to change the hotplug poll intervalRichard Hughes2022-01-063-3/+79
|
* Fix hotplug after threaded device removalRichard Hughes2021-12-071-1/+1
| | | | Somehow this worked when we unref'd the context but did not ref it.
* Fix version script check for GNU BFD linker on FreeBSDTing-Wei Lan2021-10-102-2/+10
| | | | | | | | | | | | | | | | | | On FreeBSD, symbols 'environ' and ' __progname' are defined in crt1.o and referenced by libc.so. This makes it different from platforms which define 'environ' in libc.so. GNU BFD linker fails to link an executable if these two symbols are not put into the global section of the version script because a shared library should not reference a local symbol defined in a different object file. GNU gold and LLVM LLD don't have the problem. This means the current check for --version-script fails on FreeBSD when GNU BFD linker is used. The failure can be avoided by linking a shared library instead of an executable, but meson doesn't support passing additional arguments to the compiler in its 'has_link_argument' method. Instead of adding these two unused symbols to the real version script, use a smaller version script specifically made for the test.
* Don't hard-code the list of OS supporting --version-scriptTing-Wei Lan2021-10-101-2/+3
| | | | | Instead of keeping a list of OS in the build file, it should be better to run a check to determine if it is supported by the linker.
* context: Fix hotplug handling and signal emission during enumerateBenjamin Berg2021-10-051-50/+56
| | | | | | | | | | | | | | | | | | | | | | Initial device enumeration may happen in a random order. This causes issues if someone calls g_usb_device_get_parent from the "device-added" signal handler. The problem is. that this will cause an infinite recursion as GUsb tries to enumerate again, which results in the device to be added. Also, the order of devices is random and resolving the parent requires the full list of devices. As such, we should delay emission until the internal array has been filled. To fix this, emit the signals from g_usb_context_enumerate. Also, while changing this, it became obvious that libusb hotplug callback is updating priv->devices from the libusb thread, only pushing it to an idle handler when the signal is emitted. Doing this is unsafe if hotplug events arrive during enumeration. Push libusb event into the mainloop immediately in order to process it. Doing means that any libusb hotplug events arriving during g_usb_context_enumerate will be handled after the function has returned. Making all possible corner cases behave correctly.
* Add g_usb_device_get_string_descriptor_bytes_fullmasterRicardo CaƱuelo2021-09-303-15/+57
| | | | | | | Some devices won't answer to a request with a 128-byte data buffer, this allows the user to specify the size of the request data buffer. g_usb_device_get_string_descriptor_bytes still uses the default buffer size (128 bytes).