Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 10718
b: refs/heads/master
c: ba8e931
h: refs/heads/master
v: v3
  • Loading branch information
Roland Dreier committed Oct 18, 2005
1 parent a9c58ac commit 0706612
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d476306f1cc9156ce4b42586aacce70a356ef656
refs/heads/master: ba8e9310244180bbc820e865d2e4378809b4a443
16 changes: 16 additions & 0 deletions trunk/drivers/infiniband/core/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ struct port_table_attribute {
int index;
};

static inline int ibdev_is_alive(const struct ib_device *dev)
{
return dev->reg_state == IB_DEV_REGISTERED;
}

static ssize_t port_attr_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
Expand All @@ -74,6 +79,8 @@ static ssize_t port_attr_show(struct kobject *kobj,

if (!port_attr->show)
return -EIO;
if (!ibdev_is_alive(p->ibdev))
return -ENODEV;

return port_attr->show(p, port_attr, buf);
}
Expand Down Expand Up @@ -581,6 +588,9 @@ static ssize_t show_node_type(struct class_device *cdev, char *buf)
{
struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);

if (!ibdev_is_alive(dev))
return -ENODEV;

switch (dev->node_type) {
case IB_NODE_CA: return sprintf(buf, "%d: CA\n", dev->node_type);
case IB_NODE_SWITCH: return sprintf(buf, "%d: switch\n", dev->node_type);
Expand All @@ -595,6 +605,9 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf)
struct ib_device_attr attr;
ssize_t ret;

if (!ibdev_is_alive(dev))
return -ENODEV;

ret = ib_query_device(dev, &attr);
if (ret)
return ret;
Expand All @@ -612,6 +625,9 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf)
struct ib_device_attr attr;
ssize_t ret;

if (!ibdev_is_alive(dev))
return -ENODEV;

ret = ib_query_device(dev, &attr);
if (ret)
return ret;
Expand Down

0 comments on commit 0706612

Please sign in to comment.