[ewg] [PATCH ofed-1.4.1] Fix backport patch which causes phys_state to show 5: <unknown>

Ralph Campbell ralph.campbell at qlogic.com
Fri Apr 3 12:20:59 PDT 2009


If you cat /sys/class/infiniband/<hca>/ports/1/phys_state,
you will see it returns "5: <unknown>".
This is because the backport patch core_z0010_sysfs_race.patch
changed "return sprintf(...);" to "ret = sprintf(...);"
without adding "break;". Thus, the last sprintf has effect.

Signed-off-by: Ralph Campbell <ralph.campbell at qlogic.com>

diff -up a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
--- a/drivers/infiniband/core/sysfs.c	2009-04-03 12:18:38.000000000 -0700
+++ b/drivers/infiniband/core/sysfs.c	2009-04-03 12:02:31.000000000 -0700
@@ -246,14 +246,29 @@ static ssize_t phys_state_show(struct ib
 		ret = ib_query_port(p->ibdev, p->port_num, &attr);
 		if (!ret) {
 			switch (attr.phys_state) {
-			case 1:  ret = sprintf(buf, "1: Sleep\n");
-			case 2:  ret = sprintf(buf, "2: Polling\n");
-			case 3:  ret = sprintf(buf, "3: Disabled\n");
-			case 4:  ret = sprintf(buf, "4: PortConfigurationTraining\n");
-			case 5:  ret = sprintf(buf, "5: LinkUp\n");
-			case 6:  ret = sprintf(buf, "6: LinkErrorRecovery\n");
-			case 7:  ret = sprintf(buf, "7: Phy Test\n");
-			default: ret = sprintf(buf, "%d: <unknown>\n", attr.phys_state);
+			case 1:
+				ret = sprintf(buf, "1: Sleep\n");
+				break;
+			case 2:
+				ret = sprintf(buf, "2: Polling\n");
+				break;
+			case 3:
+				ret = sprintf(buf, "3: Disabled\n");
+				break;
+			case 4:
+				ret = sprintf(buf, "4: PortConfigurationTraining\n");
+				break;
+			case 5:
+				ret = sprintf(buf, "5: LinkUp\n");
+				break;
+			case 6:
+				ret = sprintf(buf, "6: LinkErrorRecovery\n");
+				break;
+			case 7:
+				ret = sprintf(buf, "7: Phy Test\n");
+				break;
+			default:
+				ret = sprintf(buf, "%d: <unknown>\n", attr.phys_state);
 			}
 		}
 	}





More information about the ewg mailing list