diff mbox series

[net-next,v3,2/5] mlxsw: core: fix mlxsw_devlink_info_get() to correctly report driver name

Message ID 20221127130919.638324-3-mailhol.vincent@wanadoo.fr (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: devlink: return the driver name in devlink_nl_info_fill | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Vincent Mailhol Nov. 27, 2022, 1:09 p.m. UTC
Currently, mlxsw_devlink_info_get() 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).

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: a9c8336f6544 ("mlxsw: core: Add support for devlink info command")
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/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ido Schimmel Nov. 27, 2022, 4:17 p.m. UTC | #1
On Sun, Nov 27, 2022 at 10:09:16PM +0900, Vincent Mailhol wrote:
> Currently, mlxsw_devlink_info_get() 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

s/ic2/i2c/

> (e.g. chip 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

Same comment as before.

Before the series:

# devlink dev info i2c/2-0048 | grep driver
  driver mlxsw_minimal

After the series:

# devlink dev info i2c/2-0048 | grep driver
  driver mlxsw_minimal

> 
> Fixes: a9c8336f6544 ("mlxsw: core: Add support for devlink info command")
> 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/core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
> index a83f6bc30072..d8b1bb03cdb0 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/core.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
> @@ -1453,6 +1453,7 @@ mlxsw_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
>  		       struct netlink_ext_ack *extack)
>  {
>  	struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
> +	struct device *dev = mlxsw_core->bus_info->dev;
>  	char fw_info_psid[MLXSW_REG_MGIR_FW_INFO_PSID_SIZE];
>  	u32 hw_rev, fw_major, fw_minor, fw_sub_minor;
>  	char mgir_pl[MLXSW_REG_MGIR_LEN];
> @@ -1460,7 +1461,7 @@ mlxsw_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
>  	int err;
>  
>  	err = devlink_info_driver_name_put(req,
> -					   mlxsw_core->bus_info->device_kind);
> +					   dev_driver_string(dev->parent));
>  	if (err)
>  		return err;
>  
> -- 
> 2.37.4
>
Vincent Mailhol Nov. 28, 2022, 1:42 a.m. UTC | #2
On Mon. 28 Nov. 2022 at 01:17, Ido Schimmel <idosch@nvidia.com> wrote:
> On Sun, Nov 27, 2022 at 10:09:16PM +0900, Vincent Mailhol wrote:
> > Currently, mlxsw_devlink_info_get() 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
>
> s/ic2/i2c/
>
> > (e.g. chip 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
>
> Same comment as before.
>
> Before the series:
>
> # devlink dev info i2c/2-0048 | grep driver
>   driver mlxsw_minimal
>
> After the series:
>
> # devlink dev info i2c/2-0048 | grep driver
>   driver mlxsw_minimal

ACK. I was overall confused by the device_kind. Thank you for your
confirmation. I will drop the first two patches from this series.


Yours sincerely,
Vincent Mailhol
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index a83f6bc30072..d8b1bb03cdb0 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -1453,6 +1453,7 @@  mlxsw_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
 		       struct netlink_ext_ack *extack)
 {
 	struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
+	struct device *dev = mlxsw_core->bus_info->dev;
 	char fw_info_psid[MLXSW_REG_MGIR_FW_INFO_PSID_SIZE];
 	u32 hw_rev, fw_major, fw_minor, fw_sub_minor;
 	char mgir_pl[MLXSW_REG_MGIR_LEN];
@@ -1460,7 +1461,7 @@  mlxsw_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
 	int err;
 
 	err = devlink_info_driver_name_put(req,
-					   mlxsw_core->bus_info->device_kind);
+					   dev_driver_string(dev->parent));
 	if (err)
 		return err;