summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaher Sanalla <msanalla@nvidia.com>2025-02-03 15:48:05 +0300
committerLeon Romanovsky <leon@kernel.org>2025-02-06 11:40:57 +0300
commit1fd119c6db838dbed7084ce48f76ad12f5441d59 (patch)
treec3d99f7c8b1cf18823437894338eca79714dc6f5
parent5459f6523c1f1a053cdc6411a810061ee717219c (diff)
downloadlinux-1fd119c6db838dbed7084ce48f76ad12f5441d59.tar.xz
RDMA/core: Use ib_port_state_to_str() for IB state sysfs
Refactor the IB state sysfs implementation to replace the local array used for converting IB state to string with the ib_port_state_to_str() function. Signed-off-by: Maher Sanalla <msanalla@nvidia.com> Link: https://patch.msgid.link/06affabbbf144f990e64b447918af39483c78c3e.1738586601.git.leon@kernel.org Signed-off-by: Leon Romanovsky <leon@kernel.org>
-rw-r--r--drivers/infiniband/core/sysfs.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 9f97bef02149..7491328ca5e6 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -216,24 +216,12 @@ static ssize_t state_show(struct ib_device *ibdev, u32 port_num,
struct ib_port_attr attr;
ssize_t ret;
- static const char *state_name[] = {
- [IB_PORT_NOP] = "NOP",
- [IB_PORT_DOWN] = "DOWN",
- [IB_PORT_INIT] = "INIT",
- [IB_PORT_ARMED] = "ARMED",
- [IB_PORT_ACTIVE] = "ACTIVE",
- [IB_PORT_ACTIVE_DEFER] = "ACTIVE_DEFER"
- };
-
ret = ib_query_port(ibdev, port_num, &attr);
if (ret)
return ret;
return sysfs_emit(buf, "%d: %s\n", attr.state,
- attr.state >= 0 &&
- attr.state < ARRAY_SIZE(state_name) ?
- state_name[attr.state] :
- "UNKNOWN");
+ ib_port_state_to_str(attr.state));
}
static ssize_t lid_show(struct ib_device *ibdev, u32 port_num,