aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/sysfs.c
diff options
context:
space:
mode:
authorRoland Dreier <roland@purestorage.com>2012-04-02 13:57:31 -0400
committerRoland Dreier <roland@purestorage.com>2012-04-02 13:57:31 -0400
commit0559d8dc13a1cd68b5e64c0b61659f36c7b5c89f (patch)
tree680c2516ac8f6a6114ca35ade2a2ab341449c686 /drivers/infiniband/core/sysfs.c
parentd2ef406866620f0450ad0b4c7fb5c2796c7bf245 (diff)
IB/core: Don't return EINVAL from sysfs rate attribute for invalid speeds
Commit e9319b0cb00d ("IB/core: Fix SDR rates in sysfs") changed our sysfs rate attribute to return EINVAL to userspace if the underlying device driver returns an invalid rate. Apparently some drivers do this when the link is down and some userspace pukes if it gets an error when reading this attribute, so avoid a regression by not return an error to match the old code. Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/core/sysfs.c')
-rw-r--r--drivers/infiniband/core/sysfs.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 83b720ef6c34..246fdc151652 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -179,7 +179,7 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
179{ 179{
180 struct ib_port_attr attr; 180 struct ib_port_attr attr;
181 char *speed = ""; 181 char *speed = "";
182 int rate = -1; /* in deci-Gb/sec */ 182 int rate; /* in deci-Gb/sec */
183 ssize_t ret; 183 ssize_t ret;
184 184
185 ret = ib_query_port(p->ibdev, p->port_num, &attr); 185 ret = ib_query_port(p->ibdev, p->port_num, &attr);
@@ -187,9 +187,6 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
187 return ret; 187 return ret;
188 188
189 switch (attr.active_speed) { 189 switch (attr.active_speed) {
190 case IB_SPEED_SDR:
191 rate = 25;
192 break;
193 case IB_SPEED_DDR: 190 case IB_SPEED_DDR:
194 speed = " DDR"; 191 speed = " DDR";
195 rate = 50; 192 rate = 50;
@@ -210,6 +207,10 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
210 speed = " EDR"; 207 speed = " EDR";
211 rate = 250; 208 rate = 250;
212 break; 209 break;
210 case IB_SPEED_SDR:
211 default: /* default to SDR for invalid rates */
212 rate = 25;
213 break;
213 } 214 }
214 215
215 rate *= ib_width_enum_to_int(attr.active_width); 216 rate *= ib_width_enum_to_int(attr.active_width);