summaryrefslogtreecommitdiffstats
path: root/ni845x_spi.c
diff options
context:
space:
mode:
authorAnastasia Klimchuk <aklm@chromium.org>2021-02-15 15:04:20 +1100
committerEdward O'Callaghan <quasisec@chromium.org>2021-02-16 23:36:15 +0000
commitf1391c756f315af7acc2494f9524b78f14d62bef (patch)
tree1ce2020c6e2d35423b27c0d33bd50d3ba4637dd9 /ni845x_spi.c
parentd784d484c92f31ea46fd1fa649812ecc1c6a36d8 (diff)
downloadflashrom-f1391c756f315af7acc2494f9524b78f14d62bef.tar.gz
flashrom-f1391c756f315af7acc2494f9524b78f14d62bef.tar.bz2
flashrom-f1391c756f315af7acc2494f9524b78f14d62bef.zip
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>
Diffstat (limited to 'ni845x_spi.c')
-rw-r--r--ni845x_spi.c84
1 files changed, 40 insertions, 44 deletions
diff --git a/ni845x_spi.c b/ni845x_spi.c
index 7b2bea3e2..153e03ed8 100644
--- a/ni845x_spi.c
+++ b/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,
@@ -129,6 +125,28 @@ static void ni845x_report_warning(const char *const func, const int32 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
*/
@@ -194,28 +212,6 @@ _close_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
* @param set_io_voltage_mV the IO voltage which was set 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) {