extra/usb_gpio/usb_gpio.c: Format with clang-format
BRANCH=none
TEST=none
int error__ = (expression); \
\
if (error__ != 0) { \
- fprintf(stderr, \
- "libusb error: %s:%d %s\n", \
- __FILE__, \
- __LINE__, \
- libusb_error_name(error__)); \
+ fprintf(stderr, "libusb error: %s:%d %s\n", __FILE__, \
+ __LINE__, libusb_error_name(error__)); \
return error__; \
} \
\
#define TRANSFER_TIMEOUT_MS 100
-static int gpio_write(libusb_device_handle *device,
- uint32_t set_mask,
+static int gpio_write(libusb_device_handle *device, uint32_t set_mask,
uint32_t clear_mask)
{
uint8_t command[8];
@@ -46,19 +42,15 @@ static int gpio_write(libusb_device_handle *device,
command[6] = (clear_mask >> 16) & 0xff;
command[7] = (clear_mask >> 24) & 0xff;
- CHECK(libusb_bulk_transfer(device,
- LIBUSB_ENDPOINT_OUT | 2,
- command,
- sizeof(command),
- &transferred,
+ CHECK(libusb_bulk_transfer(device, LIBUSB_ENDPOINT_OUT | 2, command,
+ sizeof(command), &transferred,
TRANSFER_TIMEOUT_MS));
if (transferred != sizeof(command)) {
fprintf(stderr,
"Failed to transfer full command "
"(sent %d of %d bytes)\n",
- transferred,
- (int)sizeof(command));
+ transferred, (int)sizeof(command));
return LIBUSB_ERROR_OTHER;
}
@@ -74,32 +66,23 @@ static int gpio_read(libusb_device_handle *device, uint32_t *mask)
* The first query does triggers the sampling of the GPIO values, the
* second query reads them back.
*/
- CHECK(libusb_bulk_transfer(device,
- LIBUSB_ENDPOINT_IN | 2,
- response,
- sizeof(response),
- &transferred,
+ CHECK(libusb_bulk_transfer(device, LIBUSB_ENDPOINT_IN | 2, response,
+ sizeof(response), &transferred,
TRANSFER_TIMEOUT_MS));
- CHECK(libusb_bulk_transfer(device,
- LIBUSB_ENDPOINT_IN | 2,
- response,
- sizeof(response),
- &transferred,
+ CHECK(libusb_bulk_transfer(device, LIBUSB_ENDPOINT_IN | 2, response,
+ sizeof(response), &transferred,
TRANSFER_TIMEOUT_MS));
if (transferred != sizeof(response)) {
fprintf(stderr,
"Failed to transfer full response "
"(read %d of %d bytes)\n",
- transferred,
- (int)sizeof(response));
+ transferred, (int)sizeof(response));
return LIBUSB_ERROR_OTHER;
}
- *mask = (response[0] << 0 |
- response[1] << 8 |
- response[2] << 16 |
+ *mask = (response[0] << 0 | response[1] << 8 | response[2] << 16 |
response[3] << 24);
return 0;
@@ -122,15 +105,12 @@ int main(int argc, char **argv)
CHECK(libusb_init(&context));
- device = libusb_open_device_with_vid_pid(context,
- vendor_id,
- product_id);
+ device =
+ libusb_open_device_with_vid_pid(context, vendor_id, product_id);
if (device == NULL) {
- fprintf(stderr,
- "Unable to find device 0x%04x:0x%04x\n",
- vendor_id,
- product_id);
+ fprintf(stderr, "Unable to find device 0x%04x:0x%04x\n",
+ vendor_id, product_id);
return 1;
}
