diff mbox series

[net-next,v3,1/5] mlxsw: minimal: fix mlxsw_m_module_get_drvinfo() to correctly report driver name

Message ID 20221127130919.638324-2-mailhol.vincent@wanadoo.fr (mailing list archive)
State Handled Elsewhere
Headers show
Series [net-next,v3,1/5] mlxsw: minimal: fix mlxsw_m_module_get_drvinfo() to correctly report driver name | expand

Commit Message

Vincent MAILHOL Nov. 27, 2022, 1:09 p.m. UTC
Currently, mlxsw_m_module_get_drvinfo() reports the device_kind. The
device_kind is not necessarily the same as the device_name. For
example, the mlxsw_i2c implementation sets up the device_kind as
ic2_client::name in [1] which indicates the type of the device
(e.g. chip name), not the actual driver name.

Fix it so that it correctly reports the driver name.

[1] mlxsw_i2c_probe() from drivers/net/ethernet/mellanox/mlxsw/i2c.c
Link: https://elixir.bootlin.com/linux/v6.1-rc1/source/drivers/net/ethernet/mellanox/mlxsw/i2c.c#L714

Fixes: 9bbd7efbc055 ("mlxsw: i2c: Extend initialization with querying firmware info")
CC: Shalom Toledo <shalomt@mellanox.com>
CC: Ido Schimmel <idosch@mellanox.com>
CC: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
---
 drivers/net/ethernet/mellanox/mlxsw/minimal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ido Schimmel Nov. 27, 2022, 4:14 p.m. UTC | #1
On Sun, Nov 27, 2022 at 10:09:15PM +0900, Vincent Mailhol wrote:
> Currently, mlxsw_m_module_get_drvinfo() reports the device_kind. The
> device_kind is not necessarily the same as the device_name. For
> example, the mlxsw_i2c implementation sets up the device_kind as
> ic2_client::name in [1] which indicates the type of the device
> (e.g. chip name), not the actual driver name.
> 
> Fix it so that it correctly reports the driver name.
> 
> [1] mlxsw_i2c_probe() from drivers/net/ethernet/mellanox/mlxsw/i2c.c
> Link: https://elixir.bootlin.com/linux/v6.1-rc1/source/drivers/net/ethernet/mellanox/mlxsw/i2c.c#L714

Before the series:

# ethtool -i eth2 | grep driver
driver: mlxsw_minimal

After the series:

# ethtool -i eth2 | grep driver
driver: mlxsw_minimal

See:
https://elixir.bootlin.com/linux/v6.1-rc1/source/drivers/net/ethernet/mellanox/mlxsw/minimal.c#L721

The current code is consistent with the PCI driver:
https://elixir.bootlin.com/linux/v6.1-rc1/source/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c#L17

Which also correctly reports the driver name.

So I prefer to keep the code as-is.

Thanks

> 
> Fixes: 9bbd7efbc055 ("mlxsw: i2c: Extend initialization with querying firmware info")
> CC: Shalom Toledo <shalomt@mellanox.com>
> CC: Ido Schimmel <idosch@mellanox.com>
> CC: Vadim Pasternak <vadimp@mellanox.com>
> Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
> ---
>  drivers/net/ethernet/mellanox/mlxsw/minimal.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
> index 6b56eadd736e..9b37ddbe0cba 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
> @@ -92,7 +92,7 @@ static void mlxsw_m_module_get_drvinfo(struct net_device *dev,
>  	struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev);
>  	struct mlxsw_m *mlxsw_m = mlxsw_m_port->mlxsw_m;
>  
> -	strscpy(drvinfo->driver, mlxsw_m->bus_info->device_kind,
> +	strscpy(drvinfo->driver, dev_driver_string(dev->dev.parent),
>  		sizeof(drvinfo->driver));
>  	snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
>  		 "%d.%d.%d",
> -- 
> 2.37.4
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
index 6b56eadd736e..9b37ddbe0cba 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
@@ -92,7 +92,7 @@  static void mlxsw_m_module_get_drvinfo(struct net_device *dev,
 	struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev);
 	struct mlxsw_m *mlxsw_m = mlxsw_m_port->mlxsw_m;
 
-	strscpy(drvinfo->driver, mlxsw_m->bus_info->device_kind,
+	strscpy(drvinfo->driver, dev_driver_string(dev->dev.parent),
 		sizeof(drvinfo->driver));
 	snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
 		 "%d.%d.%d",