提交 0559d8dc 编写于 作者: R Roland Dreier

IB/core: Don't return EINVAL from sysfs rate attribute for invalid speeds

Commit e9319b0c ("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: NRoland Dreier <roland@purestorage.com>
上级 d2ef4068
......@@ -179,7 +179,7 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
{
struct ib_port_attr attr;
char *speed = "";
int rate = -1; /* in deci-Gb/sec */
int rate; /* in deci-Gb/sec */
ssize_t ret;
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,
return ret;
switch (attr.active_speed) {
case IB_SPEED_SDR:
rate = 25;
break;
case IB_SPEED_DDR:
speed = " DDR";
rate = 50;
......@@ -210,6 +207,10 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
speed = " EDR";
rate = 250;
break;
case IB_SPEED_SDR:
default: /* default to SDR for invalid rates */
rate = 25;
break;
}
rate *= ib_width_enum_to_int(attr.active_width);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册