summaryrefslogtreecommitdiffstats
path: root/stlinkv3_spi.c
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2021-06-07 13:29:13 +0200
committerNico Huber <nico.h@gmx.de>2021-06-09 16:07:45 +0000
commitf41d24823c1703e328fc27588bbcf3c96eecdbc9 (patch)
tree3bd19f60db955c7206fa72a1ccdb7a2607e7001d /stlinkv3_spi.c
parent3bd47524c044168b01e54e772d23c7fa723dc0d5 (diff)
downloadflashrom-f41d24823c1703e328fc27588bbcf3c96eecdbc9.tar.gz
flashrom-f41d24823c1703e328fc27588bbcf3c96eecdbc9.tar.bz2
flashrom-f41d24823c1703e328fc27588bbcf3c96eecdbc9.zip
treewide: Drop unnecessary uses of memset/memcpy
Simply provide an initialiser or use a direct assignment instead. Change-Id: I07385375cd8eec8a95874001b402b2c17ec09e09 Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/55267 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
Diffstat (limited to 'stlinkv3_spi.c')
-rw-r--r--stlinkv3_spi.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c
index 24531628a..8b62740ce 100644
--- a/stlinkv3_spi.c
+++ b/stlinkv3_spi.c
@@ -156,14 +156,12 @@ static int stlinkv3_command(uint8_t *command, size_t command_length,
*/
static int stlinkv3_get_clk(uint32_t *bridge_input_clk, libusb_device_handle *stlinkv3_handle)
{
- uint8_t command[16];
+ uint8_t command[16] = { 0 };
uint8_t answer[12];
if (bridge_input_clk == NULL)
return -1;
- memset(command, 0, sizeof(command));
-
command[0] = STLINK_BRIDGE_COMMAND;
command[1] = STLINK_BRIDGE_GET_CLOCK;
command[2] = STLINK_SPI_COM;
@@ -234,9 +232,7 @@ static int stlinkv3_spi_calc_prescaler(uint16_t reqested_freq_in_kHz,
static int stlinkv3_check_version(enum fw_version_check_result *result, libusb_device_handle *stlinkv3_handle)
{
uint8_t answer[12];
- uint8_t command[16];
-
- memset(command, 0, sizeof(command));
+ uint8_t command[16] = { 0 };
command[0] = ST_GETVERSION_EXT;
command[1] = 0x80;
@@ -256,7 +252,7 @@ static int stlinkv3_check_version(enum fw_version_check_result *result, libusb_d
static int stlinkv3_spi_open(uint16_t reqested_freq_in_kHz, libusb_device_handle *stlinkv3_handle)
{
- uint8_t command[16];
+ uint8_t command[16] = { 0 };
uint8_t answer[2];
uint16_t SCK_freq_in_kHz;
enum spi_prescaler prescaler;
@@ -284,8 +280,6 @@ static int stlinkv3_spi_open(uint16_t reqested_freq_in_kHz, libusb_device_handle
}
msg_pinfo("SCK frequency set to %d kHz\n", SCK_freq_in_kHz);
- memset(command, 0, sizeof(command));
-
command[0] = STLINK_BRIDGE_COMMAND;
command[1] = STLINK_BRIDGE_INIT_SPI;
command[2] = SPI_DIRECTION_2LINES_FULLDUPLEX;
@@ -305,11 +299,9 @@ static int stlinkv3_spi_open(uint16_t reqested_freq_in_kHz, libusb_device_handle
static int stlinkv3_get_last_readwrite_status(uint32_t *status, libusb_device_handle *stlinkv3_handle)
{
- uint8_t command[16];
+ uint8_t command[16] = { 0 };
uint16_t answer[4];
- memset(command, 0, sizeof(command));
-
command[0] = STLINK_BRIDGE_COMMAND;
command[1] = STLINK_BRIDGE_GET_RWCMD_STATUS;
@@ -325,11 +317,9 @@ static int stlinkv3_get_last_readwrite_status(uint32_t *status, libusb_device_ha
static int stlinkv3_spi_set_SPI_NSS(enum spi_nss_level nss_level, libusb_device_handle *stlinkv3_handle)
{
- uint8_t command[16];
+ uint8_t command[16] = { 0 };
uint8_t answer[2];
- memset(command, 0, sizeof(command));
-
command[0] = STLINK_BRIDGE_COMMAND;
command[1] = STLINK_BRIDGE_CS_SPI;
command[2] = (uint8_t) (nss_level);
@@ -350,7 +340,7 @@ static int stlinkv3_spi_transmit(const struct flashctx *flash,
{
struct stlinkv3_spi_data *stlinkv3_data = flash->mst->spi.data;
libusb_device_handle *stlinkv3_handle = stlinkv3_data->handle;
- uint8_t command[16];
+ uint8_t command[16] = { 0 };
int rc = 0;
int actual_length = 0;
uint32_t rw_status = 0;
@@ -361,8 +351,6 @@ static int stlinkv3_spi_transmit(const struct flashctx *flash,
return -1;
}
- memset(command, 0, sizeof(command));
-
command[0] = STLINK_BRIDGE_COMMAND;
command[1] = STLINK_BRIDGE_WRITE_SPI;
command[2] = (uint8_t)write_cnt;
@@ -452,11 +440,9 @@ transmit_err:
static int stlinkv3_spi_shutdown(void *data)
{
struct stlinkv3_spi_data *stlinkv3_data = data;
- uint8_t command[16];
+ uint8_t command[16] = { 0 };
uint8_t answer[2];
- memset(command, 0, sizeof(command));
-
command[0] = STLINK_BRIDGE_COMMAND;
command[1] = STLINK_BRIDGE_CLOSE;
command[2] = STLINK_SPI_COM;