1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 14:42:36 +02:00

Extract usbdev declarations to a separate header.

This is a simple refactor that aims to simplify maintenance and to
clarify file dependency inside the project.
Currently, most of the declarations reside in programmer.h making it
difficult to really understand file dependency.

Change-Id: I9d819ea1c5bd51289d02189c1dff367ce6d25617
Signed-off-by: Antonio Vázquez Blanco <antoniovazquezblanco@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84982
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Miklós Márton <martonmiklosqdev@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
Antonio Vázquez Blanco 2024-11-03 18:18:43 +01:00 committed by Anastasia Klimchuk
parent 3a1c0d0e85
commit 69a03a3ab1
6 changed files with 34 additions and 11 deletions

View File

@ -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(

View File

@ -35,6 +35,7 @@
#include <libusb.h>
#include "programmer.h"
#include "spi.h"
#include "usbdev.h"
/* Bit positions for each pin. */
#define DEVELOPERBOX_SPI_SCK 0

View File

@ -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__ */

27
include/usbdev.h Normal file
View File

@ -0,0 +1,27 @@
/*
* This file is part of the flashrom project.
*
* Copyright (C) 2024 Antonio Vázquez Blanco <antoniovazquezblanco@gmail.com>
*
* 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 <libusb.h>
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__ */

View File

@ -26,6 +26,7 @@
#include "flash.h"
#include "programmer.h"
#include "spi.h"
#include "usbdev.h"
#include <libusb.h>
#include <limits.h>

View File

@ -15,11 +15,13 @@
* GNU General Public License for more details.
*/
#include "usbdev.h"
#include "flash.h" // msg_perr, msg_pdbg...
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
#include <libusb.h>
#include "programmer.h"
/*
* Check whether we should filter the current device.