mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 14:11:15 +02:00
tree: Remove forward-declarations for spi masters
Reorder functions to avoid forward-declarations. It looks like for most of the spi masters this has already been done before, I covered remaining small ones in one patch. BUG=b:140394053 TEST=builds Change-Id: I23ff6b79d794876f73b327f18784ca7c04c32c84 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/50711 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Sam McNally <sammc@google.com> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:

committed by
Edward O'Callaghan

parent
d784d484c9
commit
f1391c756f
84
ni845x_spi.c
84
ni845x_spi.c
@ -50,10 +50,6 @@ static NiHandle configuration_handle;
|
||||
static uint16_t io_voltage_in_mV;
|
||||
static bool ignore_io_voltage_limits;
|
||||
|
||||
static int ni845x_spi_shutdown(void *data);
|
||||
static int32 ni845x_spi_open_resource(char *resource_handle, uInt32 *opened_handle);
|
||||
static void ni845x_spi_print_available_devices(void);
|
||||
|
||||
// USB-8452 supported voltages, keep this array in ascending order!
|
||||
static const uint8_t usb8452_io_voltages_in_100mV[5] = {
|
||||
kNi845x12Volts,
|
||||
@ -128,6 +124,28 @@ static void ni845x_report_warning(const char *const func, const int32 err)
|
||||
msg_pwarn("%s failed with: %s (%d)\n", func, buf, (int)err);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ni845x_spi_open_resource
|
||||
* @param resource_handle the resource handle returned by the ni845xFindDevice or ni845xFindDeviceNext
|
||||
* @param opened_handle the opened handle from the ni845xOpen
|
||||
* @return the 0 on successful competition, negative error code on failure positive code on warning
|
||||
*/
|
||||
static int32 ni845x_spi_open_resource(char *resource_handle, uInt32 *opened_handle)
|
||||
{
|
||||
// NI-845x driver loads the FPGA bitfile at the first time
|
||||
// which can take couple seconds
|
||||
if (device_pid == USB8452)
|
||||
msg_pwarn("Opening NI-8452, this might take a while for the first time\n");
|
||||
|
||||
int32 tmp = ni845xOpen(resource_handle, opened_handle);
|
||||
|
||||
if (tmp < 0)
|
||||
ni845x_report_error("ni845xOpen", tmp);
|
||||
else if (tmp > 0)
|
||||
ni845x_report_warning("ni845xOpen", tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param serial a null terminated string containing the serial number of the specific device or NULL
|
||||
* @return the 0 on successful completition, negative error code on failure
|
||||
@ -193,28 +211,6 @@ _close_ret:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ni845x_spi_open_resource
|
||||
* @param resource_handle the resource handle returned by the ni845xFindDevice or ni845xFindDeviceNext
|
||||
* @param opened_handle the opened handle from the ni845xOpen
|
||||
* @return the 0 on successful competition, negative error code on failure positive code on warning
|
||||
*/
|
||||
static int32 ni845x_spi_open_resource(char *resource_handle, uInt32 *opened_handle)
|
||||
{
|
||||
// NI-845x driver loads the FPGA bitfile at the first time
|
||||
// which can take couple seconds
|
||||
if (device_pid == USB8452)
|
||||
msg_pwarn("Opening NI-8452, this might take a while for the first time\n");
|
||||
|
||||
int32 tmp = ni845xOpen(resource_handle, opened_handle);
|
||||
|
||||
if (tmp < 0)
|
||||
ni845x_report_error("ni845xOpen", tmp);
|
||||
else if (tmp > 0)
|
||||
ni845x_report_warning("ni845xOpen", tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usb8452_spi_set_io_voltage sets the IO voltage for the USB-8452 devices
|
||||
* @param requested_io_voltage_mV the desired IO voltage in mVolts
|
||||
@ -389,6 +385,24 @@ static void ni845x_spi_print_available_devices(void)
|
||||
ni845x_report_error("ni845xCloseFindDeviceHandle", tmp);
|
||||
}
|
||||
|
||||
static int ni845x_spi_shutdown(void *data)
|
||||
{
|
||||
int32 ret = 0;
|
||||
|
||||
if (configuration_handle != 0) {
|
||||
ret = ni845xSpiConfigurationClose(configuration_handle);
|
||||
if (ret)
|
||||
ni845x_report_error("ni845xSpiConfigurationClose", ret);
|
||||
}
|
||||
|
||||
if (device_handle != 0) {
|
||||
ret = ni845xClose(device_handle);
|
||||
if (ret)
|
||||
ni845x_report_error("ni845xClose", ret);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ni845x_spi_init(void)
|
||||
{
|
||||
char *speed_str = NULL;
|
||||
@ -486,24 +500,6 @@ int ni845x_spi_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ni845x_spi_shutdown(void *data)
|
||||
{
|
||||
int32 ret = 0;
|
||||
|
||||
if (configuration_handle != 0) {
|
||||
ret = ni845xSpiConfigurationClose(configuration_handle);
|
||||
if (ret)
|
||||
ni845x_report_error("ni845xSpiConfigurationClose", ret);
|
||||
}
|
||||
|
||||
if (device_handle != 0) {
|
||||
ret = ni845xClose(device_handle);
|
||||
if (ret)
|
||||
ni845x_report_error("ni845xClose", ret);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ni845x_warn_over_max_voltage(const struct flashctx *flash)
|
||||
{
|
||||
if (device_pid == USB8451) {
|
||||
|
Reference in New Issue
Block a user