On 3/5/20 7:35 AM, Gabriel Krisman Bertazi wrote:
+static const struct { + int value; + char *name; +} connection_state_names[] = { + {ISCSI_CONN_UP, "up"}, + {ISCSI_CONN_DOWN, "down"}, + {ISCSI_CONN_FAILED, "failed"} +}; + +static const char *connection_state_name(int state) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(connection_state_names); i++) { + if (connection_state_names[i].value == state) + return connection_state_names[i].name; + } + return NULL; +} + +static ssize_t show_conn_state(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev->parent); + + return sprintf(buf, "%s\n", connection_state_name(conn->state)); +} +static ISCSI_CLASS_ATTR(conn, state, S_IRUGO, show_conn_state, + NULL);
What has been changed in v2 compared to v1? Please always include a changelog when posting a new version.
Additionally, it seems like the comment I posted on v1 has not been addressed?
Thanks, Bart.