Commit 911bd1b1 authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

mlxsw: core_env: Avoid unnecessary memcpy()s

Simply get a pointer to the data in the register payload instead of
copying it to a temporary buffer.
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e8192476
...@@ -26,8 +26,8 @@ struct mlxsw_env { ...@@ -26,8 +26,8 @@ struct mlxsw_env {
static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id, static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
bool *qsfp, bool *cmis) bool *qsfp, bool *cmis)
{ {
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
char mcia_pl[MLXSW_REG_MCIA_LEN]; char mcia_pl[MLXSW_REG_MCIA_LEN];
char *eeprom_tmp;
u8 ident; u8 ident;
int err; int err;
...@@ -36,7 +36,7 @@ static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id, ...@@ -36,7 +36,7 @@ static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
err = mlxsw_reg_query(core, MLXSW_REG(mcia), mcia_pl); err = mlxsw_reg_query(core, MLXSW_REG(mcia), mcia_pl);
if (err) if (err)
return err; return err;
mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp); eeprom_tmp = mlxsw_reg_mcia_eeprom_data(mcia_pl);
ident = eeprom_tmp[0]; ident = eeprom_tmp[0];
*cmis = false; *cmis = false;
switch (ident) { switch (ident) {
...@@ -64,8 +64,8 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module, ...@@ -64,8 +64,8 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
u16 offset, u16 size, void *data, u16 offset, u16 size, void *data,
bool qsfp, unsigned int *p_read_size) bool qsfp, unsigned int *p_read_size)
{ {
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
char mcia_pl[MLXSW_REG_MCIA_LEN]; char mcia_pl[MLXSW_REG_MCIA_LEN];
char *eeprom_tmp;
u16 i2c_addr; u16 i2c_addr;
u8 page = 0; u8 page = 0;
int status; int status;
...@@ -116,7 +116,7 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module, ...@@ -116,7 +116,7 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
if (status) if (status)
return -EIO; return -EIO;
mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp); eeprom_tmp = mlxsw_reg_mcia_eeprom_data(mcia_pl);
memcpy(data, eeprom_tmp, size); memcpy(data, eeprom_tmp, size);
*p_read_size = size; *p_read_size = size;
...@@ -127,13 +127,13 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, ...@@ -127,13 +127,13 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
int off, int *temp) int off, int *temp)
{ {
unsigned int module_temp, module_crit, module_emerg; unsigned int module_temp, module_crit, module_emerg;
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
union { union {
u8 buf[MLXSW_REG_MCIA_TH_ITEM_SIZE]; u8 buf[MLXSW_REG_MCIA_TH_ITEM_SIZE];
u16 temp; u16 temp;
} temp_thresh; } temp_thresh;
char mcia_pl[MLXSW_REG_MCIA_LEN] = {0}; char mcia_pl[MLXSW_REG_MCIA_LEN] = {0};
char mtmp_pl[MLXSW_REG_MTMP_LEN]; char mtmp_pl[MLXSW_REG_MTMP_LEN];
char *eeprom_tmp;
bool qsfp, cmis; bool qsfp, cmis;
int page; int page;
int err; int err;
...@@ -195,7 +195,7 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, ...@@ -195,7 +195,7 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
if (err) if (err)
return err; return err;
mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp); eeprom_tmp = mlxsw_reg_mcia_eeprom_data(mcia_pl);
memcpy(temp_thresh.buf, eeprom_tmp, MLXSW_REG_MCIA_TH_ITEM_SIZE); memcpy(temp_thresh.buf, eeprom_tmp, MLXSW_REG_MCIA_TH_ITEM_SIZE);
*temp = temp_thresh.temp * 1000; *temp = temp_thresh.temp * 1000;
...@@ -357,8 +357,8 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module, ...@@ -357,8 +357,8 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module,
device_addr = page->offset; device_addr = page->offset;
while (bytes_read < page->length) { while (bytes_read < page->length) {
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
char mcia_pl[MLXSW_REG_MCIA_LEN]; char mcia_pl[MLXSW_REG_MCIA_LEN];
char *eeprom_tmp;
u8 size; u8 size;
int err; int err;
...@@ -380,7 +380,7 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module, ...@@ -380,7 +380,7 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module,
if (err) if (err)
return err; return err;
mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp); eeprom_tmp = mlxsw_reg_mcia_eeprom_data(mcia_pl);
memcpy(page->data + bytes_read, eeprom_tmp, size); memcpy(page->data + bytes_read, eeprom_tmp, size);
bytes_read += size; bytes_read += size;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment