RDMA: Manual changes for sysfs_emit and neatening
[linux-2.6-block.git] / drivers / infiniband / hw / mlx4 / mcg.c
index 5e4ec9786081cf3a42dfe2f51532b3d6f4ee581b..33f525b744f286c8db8b58407bf8efe4e5f3ed16 100644 (file)
@@ -988,53 +988,63 @@ int mlx4_ib_mcg_multiplex_handler(struct ib_device *ibdev, int port,
 }
 
 static ssize_t sysfs_show_group(struct device *dev,
-               struct device_attribute *attr, char *buf)
+                               struct device_attribute *attr, char *buf)
 {
        struct mcast_group *group =
                container_of(attr, struct mcast_group, dentry);
        struct mcast_req *req = NULL;
-       char pending_str[40];
        char state_str[40];
-       ssize_t len = 0;
-       int f;
+       char pending_str[40];
+       int len;
+       int i;
+       u32 hoplimit;
 
        if (group->state == MCAST_IDLE)
-               sprintf(state_str, "%s", get_state_string(group->state));
+               scnprintf(state_str, sizeof(state_str), "%s",
+                         get_state_string(group->state));
        else
-               sprintf(state_str, "%s(TID=0x%llx)",
-                               get_state_string(group->state),
-                               be64_to_cpu(group->last_req_tid));
+               scnprintf(state_str, sizeof(state_str), "%s(TID=0x%llx)",
+                         get_state_string(group->state),
+                         be64_to_cpu(group->last_req_tid));
+
        if (list_empty(&group->pending_list)) {
-               sprintf(pending_str, "No");
+               scnprintf(pending_str, sizeof(pending_str), "No");
        } else {
-               req = list_first_entry(&group->pending_list, struct mcast_req, group_list);
-               sprintf(pending_str, "Yes(TID=0x%llx)",
-                               be64_to_cpu(req->sa_mad.mad_hdr.tid));
+               req = list_first_entry(&group->pending_list, struct mcast_req,
+                                      group_list);
+               scnprintf(pending_str, sizeof(pending_str), "Yes(TID=0x%llx)",
+                         be64_to_cpu(req->sa_mad.mad_hdr.tid));
        }
-       len += sprintf(buf + len, "%1d [%02d,%02d,%02d] %4d %4s %5s     ",
-                       group->rec.scope_join_state & 0xf,
-                       group->members[2], group->members[1], group->members[0],
-                       atomic_read(&group->refcount),
-                       pending_str,
-                       state_str);
-       for (f = 0; f < MAX_VFS; ++f)
-               if (group->func[f].state == MCAST_MEMBER)
-                       len += sprintf(buf + len, "%d[%1x] ",
-                                       f, group->func[f].join_state);
-
-       len += sprintf(buf + len, "\t\t(%4hx %4x %2x %2x %2x %2x %2x "
-               "%4x %4x %2x %2x)\n",
-               be16_to_cpu(group->rec.pkey),
-               be32_to_cpu(group->rec.qkey),
-               (group->rec.mtusel_mtu & 0xc0) >> 6,
-               group->rec.mtusel_mtu & 0x3f,
-               group->rec.tclass,
-               (group->rec.ratesel_rate & 0xc0) >> 6,
-               group->rec.ratesel_rate & 0x3f,
-               (be32_to_cpu(group->rec.sl_flowlabel_hoplimit) & 0xf0000000) >> 28,
-               (be32_to_cpu(group->rec.sl_flowlabel_hoplimit) & 0x0fffff00) >> 8,
-               be32_to_cpu(group->rec.sl_flowlabel_hoplimit) & 0x000000ff,
-               group->rec.proxy_join);
+
+       len = sysfs_emit(buf, "%1d [%02d,%02d,%02d] %4d %4s %5s     ",
+                        group->rec.scope_join_state & 0xf,
+                        group->members[2],
+                        group->members[1],
+                        group->members[0],
+                        atomic_read(&group->refcount),
+                        pending_str,
+                        state_str);
+
+       for (i = 0; i < MAX_VFS; i++) {
+               if (group->func[i].state == MCAST_MEMBER)
+                       len += sysfs_emit_at(buf, len, "%d[%1x] ", i,
+                                            group->func[i].join_state);
+       }
+
+       hoplimit = be32_to_cpu(group->rec.sl_flowlabel_hoplimit);
+       len += sysfs_emit_at(buf, len,
+                            "\t\t(%4hx %4x %2x %2x %2x %2x %2x %4x %4x %2x %2x)\n",
+                            be16_to_cpu(group->rec.pkey),
+                            be32_to_cpu(group->rec.qkey),
+                            (group->rec.mtusel_mtu & 0xc0) >> 6,
+                            (group->rec.mtusel_mtu & 0x3f),
+                            group->rec.tclass,
+                            (group->rec.ratesel_rate & 0xc0) >> 6,
+                            (group->rec.ratesel_rate & 0x3f),
+                            (hoplimit & 0xf0000000) >> 28,
+                            (hoplimit & 0x0fffff00) >> 8,
+                            (hoplimit & 0x000000ff),
+                            group->rec.proxy_join);
 
        return len;
 }