Commit 7e846d6b authored by Eugene Crosser's avatar Eugene Crosser Committed by David S. Miller

qeth: sysfs: replace strcmp() with sysfs_streq()

Replace combination of strsep() and a temporary char *
followed by a series of "if (!strcmp(...))" with a series
of "if (sysfs_streq(...))".
Signed-off-by: default avatarEugene Crosser <Eugene.Crosser@ru.ibm.com>
Signed-off-by: default avatarUrsula Braun <ursula.braun@de.ibm.com>
Reviewed-by: default avatarThomas-Mich Richter <tmricht@de.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c3521254
...@@ -231,7 +231,6 @@ static ssize_t qeth_dev_prioqing_store(struct device *dev, ...@@ -231,7 +231,6 @@ static ssize_t qeth_dev_prioqing_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
char *tmp;
int rc = 0; int rc = 0;
if (!card) if (!card)
...@@ -253,36 +252,35 @@ static ssize_t qeth_dev_prioqing_store(struct device *dev, ...@@ -253,36 +252,35 @@ static ssize_t qeth_dev_prioqing_store(struct device *dev,
goto out; goto out;
} }
tmp = strsep((char **) &buf, "\n"); if (sysfs_streq(buf, "prio_queueing_prec")) {
if (!strcmp(tmp, "prio_queueing_prec")) {
card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_PREC; card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_PREC;
card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
} else if (!strcmp(tmp, "prio_queueing_skb")) { } else if (sysfs_streq(buf, "prio_queueing_skb")) {
card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_SKB; card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_SKB;
card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
} else if (!strcmp(tmp, "prio_queueing_tos")) { } else if (sysfs_streq(buf, "prio_queueing_tos")) {
card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_TOS; card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_TOS;
card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
} else if (!strcmp(tmp, "prio_queueing_vlan")) { } else if (sysfs_streq(buf, "prio_queueing_vlan")) {
if (!card->options.layer2) { if (!card->options.layer2) {
rc = -ENOTSUPP; rc = -ENOTSUPP;
goto out; goto out;
} }
card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_VLAN; card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_VLAN;
card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
} else if (!strcmp(tmp, "no_prio_queueing:0")) { } else if (sysfs_streq(buf, "no_prio_queueing:0")) {
card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING;
card->qdio.default_out_queue = 0; card->qdio.default_out_queue = 0;
} else if (!strcmp(tmp, "no_prio_queueing:1")) { } else if (sysfs_streq(buf, "no_prio_queueing:1")) {
card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING;
card->qdio.default_out_queue = 1; card->qdio.default_out_queue = 1;
} else if (!strcmp(tmp, "no_prio_queueing:2")) { } else if (sysfs_streq(buf, "no_prio_queueing:2")) {
card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING;
card->qdio.default_out_queue = 2; card->qdio.default_out_queue = 2;
} else if (!strcmp(tmp, "no_prio_queueing:3")) { } else if (sysfs_streq(buf, "no_prio_queueing:3")) {
card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING;
card->qdio.default_out_queue = 3; card->qdio.default_out_queue = 3;
} else if (!strcmp(tmp, "no_prio_queueing")) { } else if (sysfs_streq(buf, "no_prio_queueing")) {
card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING;
card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
} else } else
...@@ -497,8 +495,6 @@ static ssize_t qeth_dev_isolation_store(struct device *dev, ...@@ -497,8 +495,6 @@ static ssize_t qeth_dev_isolation_store(struct device *dev,
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
enum qeth_ipa_isolation_modes isolation; enum qeth_ipa_isolation_modes isolation;
int rc = 0; int rc = 0;
char *tmp, *curtoken;
curtoken = (char *) buf;
if (!card) if (!card)
return -EINVAL; return -EINVAL;
...@@ -515,12 +511,11 @@ static ssize_t qeth_dev_isolation_store(struct device *dev, ...@@ -515,12 +511,11 @@ static ssize_t qeth_dev_isolation_store(struct device *dev,
} }
/* parse input into isolation mode */ /* parse input into isolation mode */
tmp = strsep(&curtoken, "\n"); if (sysfs_streq(buf, ATTR_QETH_ISOLATION_NONE)) {
if (!strcmp(tmp, ATTR_QETH_ISOLATION_NONE)) {
isolation = ISOLATION_MODE_NONE; isolation = ISOLATION_MODE_NONE;
} else if (!strcmp(tmp, ATTR_QETH_ISOLATION_FWD)) { } else if (sysfs_streq(buf, ATTR_QETH_ISOLATION_FWD)) {
isolation = ISOLATION_MODE_FWD; isolation = ISOLATION_MODE_FWD;
} else if (!strcmp(tmp, ATTR_QETH_ISOLATION_DROP)) { } else if (sysfs_streq(buf, ATTR_QETH_ISOLATION_DROP)) {
isolation = ISOLATION_MODE_DROP; isolation = ISOLATION_MODE_DROP;
} else { } else {
rc = -EINVAL; rc = -EINVAL;
...@@ -597,9 +592,7 @@ static ssize_t qeth_hw_trap_store(struct device *dev, ...@@ -597,9 +592,7 @@ static ssize_t qeth_hw_trap_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
int rc = 0; int rc = 0;
char *tmp, *curtoken;
int state = 0; int state = 0;
curtoken = (char *)buf;
if (!card) if (!card)
return -EINVAL; return -EINVAL;
...@@ -607,9 +600,8 @@ static ssize_t qeth_hw_trap_store(struct device *dev, ...@@ -607,9 +600,8 @@ static ssize_t qeth_hw_trap_store(struct device *dev,
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
if (qeth_card_hw_is_reachable(card)) if (qeth_card_hw_is_reachable(card))
state = 1; state = 1;
tmp = strsep(&curtoken, "\n");
if (!strcmp(tmp, "arm") && !card->info.hwtrap) { if (sysfs_streq(buf, "arm") && !card->info.hwtrap) {
if (state) { if (state) {
if (qeth_is_diagass_supported(card, if (qeth_is_diagass_supported(card,
QETH_DIAGS_CMD_TRAP)) { QETH_DIAGS_CMD_TRAP)) {
...@@ -620,14 +612,14 @@ static ssize_t qeth_hw_trap_store(struct device *dev, ...@@ -620,14 +612,14 @@ static ssize_t qeth_hw_trap_store(struct device *dev,
rc = -EINVAL; rc = -EINVAL;
} else } else
card->info.hwtrap = 1; card->info.hwtrap = 1;
} else if (!strcmp(tmp, "disarm") && card->info.hwtrap) { } else if (sysfs_streq(buf, "disarm") && card->info.hwtrap) {
if (state) { if (state) {
rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
if (!rc) if (!rc)
card->info.hwtrap = 0; card->info.hwtrap = 0;
} else } else
card->info.hwtrap = 0; card->info.hwtrap = 0;
} else if (!strcmp(tmp, "trap") && state && card->info.hwtrap) } else if (sysfs_streq(buf, "trap") && state && card->info.hwtrap)
rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_CAPTURE); rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_CAPTURE);
else else
rc = -EINVAL; rc = -EINVAL;
......
...@@ -57,22 +57,20 @@ static ssize_t qeth_l3_dev_route_store(struct qeth_card *card, ...@@ -57,22 +57,20 @@ static ssize_t qeth_l3_dev_route_store(struct qeth_card *card,
const char *buf, size_t count) const char *buf, size_t count)
{ {
enum qeth_routing_types old_route_type = route->type; enum qeth_routing_types old_route_type = route->type;
char *tmp;
int rc = 0; int rc = 0;
tmp = strsep((char **) &buf, "\n");
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
if (!strcmp(tmp, "no_router")) { if (sysfs_streq(buf, "no_router")) {
route->type = NO_ROUTER; route->type = NO_ROUTER;
} else if (!strcmp(tmp, "primary_connector")) { } else if (sysfs_streq(buf, "primary_connector")) {
route->type = PRIMARY_CONNECTOR; route->type = PRIMARY_CONNECTOR;
} else if (!strcmp(tmp, "secondary_connector")) { } else if (sysfs_streq(buf, "secondary_connector")) {
route->type = SECONDARY_CONNECTOR; route->type = SECONDARY_CONNECTOR;
} else if (!strcmp(tmp, "primary_router")) { } else if (sysfs_streq(buf, "primary_router")) {
route->type = PRIMARY_ROUTER; route->type = PRIMARY_ROUTER;
} else if (!strcmp(tmp, "secondary_router")) { } else if (sysfs_streq(buf, "secondary_router")) {
route->type = SECONDARY_ROUTER; route->type = SECONDARY_ROUTER;
} else if (!strcmp(tmp, "multicast_router")) { } else if (sysfs_streq(buf, "multicast_router")) {
route->type = MULTICAST_ROUTER; route->type = MULTICAST_ROUTER;
} else { } else {
rc = -EINVAL; rc = -EINVAL;
...@@ -370,7 +368,6 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev, ...@@ -370,7 +368,6 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
struct qeth_ipaddr *tmpipa, *t; struct qeth_ipaddr *tmpipa, *t;
char *tmp;
int rc = 0; int rc = 0;
if (!card) if (!card)
...@@ -383,10 +380,9 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev, ...@@ -383,10 +380,9 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
goto out; goto out;
} }
tmp = strsep((char **) &buf, "\n"); if (sysfs_streq(buf, "toggle")) {
if (!strcmp(tmp, "toggle")) {
card->ipato.enabled = (card->ipato.enabled)? 0 : 1; card->ipato.enabled = (card->ipato.enabled)? 0 : 1;
} else if (!strcmp(tmp, "1")) { } else if (sysfs_streq(buf, "1")) {
card->ipato.enabled = 1; card->ipato.enabled = 1;
list_for_each_entry_safe(tmpipa, t, card->ip_tbd_list, entry) { list_for_each_entry_safe(tmpipa, t, card->ip_tbd_list, entry) {
if ((tmpipa->type == QETH_IP_TYPE_NORMAL) && if ((tmpipa->type == QETH_IP_TYPE_NORMAL) &&
...@@ -395,7 +391,7 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev, ...@@ -395,7 +391,7 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
QETH_IPA_SETIP_TAKEOVER_FLAG; QETH_IPA_SETIP_TAKEOVER_FLAG;
} }
} else if (!strcmp(tmp, "0")) { } else if (sysfs_streq(buf, "0")) {
card->ipato.enabled = 0; card->ipato.enabled = 0;
list_for_each_entry_safe(tmpipa, t, card->ip_tbd_list, entry) { list_for_each_entry_safe(tmpipa, t, card->ip_tbd_list, entry) {
if (tmpipa->set_flags & if (tmpipa->set_flags &
...@@ -430,21 +426,19 @@ static ssize_t qeth_l3_dev_ipato_invert4_store(struct device *dev, ...@@ -430,21 +426,19 @@ static ssize_t qeth_l3_dev_ipato_invert4_store(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
char *tmp;
int rc = 0; int rc = 0;
if (!card) if (!card)
return -EINVAL; return -EINVAL;
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
tmp = strsep((char **) &buf, "\n"); if (sysfs_streq(buf, "toggle"))
if (!strcmp(tmp, "toggle")) {
card->ipato.invert4 = (card->ipato.invert4)? 0 : 1; card->ipato.invert4 = (card->ipato.invert4)? 0 : 1;
} else if (!strcmp(tmp, "1")) { else if (sysfs_streq(buf, "1"))
card->ipato.invert4 = 1; card->ipato.invert4 = 1;
} else if (!strcmp(tmp, "0")) { else if (sysfs_streq(buf, "0"))
card->ipato.invert4 = 0; card->ipato.invert4 = 0;
} else else
rc = -EINVAL; rc = -EINVAL;
mutex_unlock(&card->conf_mutex); mutex_unlock(&card->conf_mutex);
return rc ? rc : count; return rc ? rc : count;
...@@ -612,21 +606,19 @@ static ssize_t qeth_l3_dev_ipato_invert6_store(struct device *dev, ...@@ -612,21 +606,19 @@ static ssize_t qeth_l3_dev_ipato_invert6_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
char *tmp;
int rc = 0; int rc = 0;
if (!card) if (!card)
return -EINVAL; return -EINVAL;
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
tmp = strsep((char **) &buf, "\n"); if (sysfs_streq(buf, "toggle"))
if (!strcmp(tmp, "toggle")) {
card->ipato.invert6 = (card->ipato.invert6)? 0 : 1; card->ipato.invert6 = (card->ipato.invert6)? 0 : 1;
} else if (!strcmp(tmp, "1")) { else if (sysfs_streq(buf, "1"))
card->ipato.invert6 = 1; card->ipato.invert6 = 1;
} else if (!strcmp(tmp, "0")) { else if (sysfs_streq(buf, "0"))
card->ipato.invert6 = 0; card->ipato.invert6 = 0;
} else else
rc = -EINVAL; rc = -EINVAL;
mutex_unlock(&card->conf_mutex); mutex_unlock(&card->conf_mutex);
return rc ? rc : count; return rc ? rc : count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment