Skip to content

Commit 911bd1b

Browse files
idoschdavem330
authored andcommitted
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: Ido Schimmel <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e819247 commit 911bd1b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/net/ethernet/mellanox/mlxsw/core_env.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ struct mlxsw_env {
2626
static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
2727
bool *qsfp, bool *cmis)
2828
{
29-
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
3029
char mcia_pl[MLXSW_REG_MCIA_LEN];
30+
char *eeprom_tmp;
3131
u8 ident;
3232
int err;
3333

@@ -36,7 +36,7 @@ static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
3636
err = mlxsw_reg_query(core, MLXSW_REG(mcia), mcia_pl);
3737
if (err)
3838
return err;
39-
mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp);
39+
eeprom_tmp = mlxsw_reg_mcia_eeprom_data(mcia_pl);
4040
ident = eeprom_tmp[0];
4141
*cmis = false;
4242
switch (ident) {
@@ -64,8 +64,8 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
6464
u16 offset, u16 size, void *data,
6565
bool qsfp, unsigned int *p_read_size)
6666
{
67-
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
6867
char mcia_pl[MLXSW_REG_MCIA_LEN];
68+
char *eeprom_tmp;
6969
u16 i2c_addr;
7070
u8 page = 0;
7171
int status;
@@ -116,7 +116,7 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
116116
if (status)
117117
return -EIO;
118118

119-
mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp);
119+
eeprom_tmp = mlxsw_reg_mcia_eeprom_data(mcia_pl);
120120
memcpy(data, eeprom_tmp, size);
121121
*p_read_size = size;
122122

@@ -127,13 +127,13 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
127127
int off, int *temp)
128128
{
129129
unsigned int module_temp, module_crit, module_emerg;
130-
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
131130
union {
132131
u8 buf[MLXSW_REG_MCIA_TH_ITEM_SIZE];
133132
u16 temp;
134133
} temp_thresh;
135134
char mcia_pl[MLXSW_REG_MCIA_LEN] = {0};
136135
char mtmp_pl[MLXSW_REG_MTMP_LEN];
136+
char *eeprom_tmp;
137137
bool qsfp, cmis;
138138
int page;
139139
int err;
@@ -195,7 +195,7 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
195195
if (err)
196196
return err;
197197

198-
mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp);
198+
eeprom_tmp = mlxsw_reg_mcia_eeprom_data(mcia_pl);
199199
memcpy(temp_thresh.buf, eeprom_tmp, MLXSW_REG_MCIA_TH_ITEM_SIZE);
200200
*temp = temp_thresh.temp * 1000;
201201

@@ -357,8 +357,8 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module,
357357
device_addr = page->offset;
358358

359359
while (bytes_read < page->length) {
360-
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
361360
char mcia_pl[MLXSW_REG_MCIA_LEN];
361+
char *eeprom_tmp;
362362
u8 size;
363363
int err;
364364

@@ -380,7 +380,7 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module,
380380
if (err)
381381
return err;
382382

383-
mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp);
383+
eeprom_tmp = mlxsw_reg_mcia_eeprom_data(mcia_pl);
384384
memcpy(page->data + bytes_read, eeprom_tmp, size);
385385
bytes_read += size;
386386
}

0 commit comments

Comments
 (0)