diff --git a/dediprog.c b/dediprog.c index aa3a1cf0c..11e7d6ca7 100644 --- a/dediprog.c +++ b/dediprog.c @@ -26,6 +26,7 @@ #include "chipdrivers.h" #include "programmer.h" #include "spi.h" +#include "usbdev.h" /* LIBUSB_CALL ensures the right calling conventions on libusb callbacks. * However, the macro is not defined everywhere. m( diff --git a/developerbox_spi.c b/developerbox_spi.c index 64b7e8a1b..67d3d687d 100644 --- a/developerbox_spi.c +++ b/developerbox_spi.c @@ -35,6 +35,7 @@ #include #include "programmer.h" #include "spi.h" +#include "usbdev.h" /* Bit positions for each pin. */ #define DEVELOPERBOX_SPI_SCK 0 diff --git a/include/programmer.h b/include/programmer.h index 5ed9c8af6..babb0bcf5 100644 --- a/include/programmer.h +++ b/include/programmer.h @@ -526,13 +526,4 @@ static inline bool spi_chip_4ba(const struct flashctx *const flash) (flash->chip->feature_bits & (FEATURE_4BA_ENTER | FEATURE_4BA_ENTER_WREN | FEATURE_4BA_ENTER_EAR7)); } -/* usbdev.c */ -struct libusb_device_handle; -struct libusb_context; -struct libusb_device_handle *usb_dev_get_by_vid_pid_serial( - struct libusb_context *usb_ctx, uint16_t vid, uint16_t pid, const char *serialno); -struct libusb_device_handle *usb_dev_get_by_vid_pid_number( - struct libusb_context *usb_ctx, uint16_t vid, uint16_t pid, unsigned int num); - - #endif /* !__PROGRAMMER_H__ */ diff --git a/include/usbdev.h b/include/usbdev.h new file mode 100644 index 000000000..3bd64b397 --- /dev/null +++ b/include/usbdev.h @@ -0,0 +1,27 @@ +/* + * This file is part of the flashrom project. + * + * Copyright (C) 2024 Antonio Vázquez Blanco + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __USBDEV_H__ +#define __USBDEV_H__ 1 + +#include + +struct libusb_device_handle *usb_dev_get_by_vid_pid_serial( + struct libusb_context *usb_ctx, uint16_t vid, uint16_t pid, const char *serialno); +struct libusb_device_handle *usb_dev_get_by_vid_pid_number( + struct libusb_context *usb_ctx, uint16_t vid, uint16_t pid, unsigned int num); + +#endif /* __USBDEV_H__ */ diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index 29aa8d3cf..a5c228937 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -26,6 +26,7 @@ #include "flash.h" #include "programmer.h" #include "spi.h" +#include "usbdev.h" #include #include diff --git a/usbdev.c b/usbdev.c index 846ed58be..02627d8d2 100644 --- a/usbdev.c +++ b/usbdev.c @@ -15,11 +15,13 @@ * GNU General Public License for more details. */ + +#include "usbdev.h" + +#include "flash.h" // msg_perr, msg_pdbg... #include #include #include -#include -#include "programmer.h" /* * Check whether we should filter the current device.