Skip to content

Commit 6a98699

Browse files
mellanoxbmcdavem330
authored andcommitted
mlxsw: i2c: Extend initialization by querying resources data
Extend initialization flow by query requests for chip resources data in order to obtain chip's specific capabilities, like the number of ports. Signed-off-by: Vadim Pasternak <vadimp@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 95b75cb commit 6a98699

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "cmd.h"
1515
#include "core.h"
1616
#include "i2c.h"
17+
#include "resources.h"
1718

1819
#define MLXSW_I2C_CIR2_BASE 0x72000
1920
#define MLXSW_I2C_CIR_STATUS_OFF 0x18
@@ -499,10 +500,19 @@ mlxsw_i2c_init(void *bus_priv, struct mlxsw_core *mlxsw_core,
499500
struct mlxsw_res *res)
500501
{
501502
struct mlxsw_i2c *mlxsw_i2c = bus_priv;
503+
char *mbox;
504+
int err;
502505

503506
mlxsw_i2c->core = mlxsw_core;
504507

505-
return 0;
508+
mbox = mlxsw_cmd_mbox_alloc();
509+
if (!mbox)
510+
return -ENOMEM;
511+
512+
err = mlxsw_core_resources_query(mlxsw_core, mbox, res);
513+
514+
mlxsw_cmd_mbox_free(mbox);
515+
return err;
506516
}
507517

508518
static void mlxsw_i2c_fini(void *bus_priv)

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,12 @@ static void mlxsw_m_fini(struct mlxsw_core *mlxsw_core)
333333
static const struct mlxsw_config_profile mlxsw_m_config_profile;
334334

335335
static struct mlxsw_driver mlxsw_m_driver = {
336-
.kind = mlxsw_m_driver_name,
337-
.priv_size = sizeof(struct mlxsw_m),
338-
.init = mlxsw_m_init,
339-
.fini = mlxsw_m_fini,
340-
.profile = &mlxsw_m_config_profile,
336+
.kind = mlxsw_m_driver_name,
337+
.priv_size = sizeof(struct mlxsw_m),
338+
.init = mlxsw_m_init,
339+
.fini = mlxsw_m_fini,
340+
.profile = &mlxsw_m_config_profile,
341+
.res_query_enabled = true,
341342
};
342343

343344
static const struct i2c_device_id mlxsw_m_i2c_id[] = {

0 commit comments

Comments
 (0)