diff options
author | Eugene Crosser <Eugene.Crosser@ru.ibm.com> | 2015-01-16 08:05:48 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-17 23:55:00 -0500 |
commit | 7e846d6b91d9775e7b0b64035033909024338344 (patch) | |
tree | 7eddff9bb1088e77e08e93a32e9bef8cd9f6d5a1 /drivers/s390 | |
parent | c3521254b16dbd270e194f81aa2cbdbcd6cc9f18 (diff) |
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: Eugene Crosser <Eugene.Crosser@ru.ibm.com>
Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
Reviewed-by: Thomas-Mich Richter <tmricht@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/s390')
-rw-r--r-- | drivers/s390/net/qeth_core_sys.c | 38 | ||||
-rw-r--r-- | drivers/s390/net/qeth_l3_sys.c | 42 |
2 files changed, 32 insertions, 48 deletions
diff --git a/drivers/s390/net/qeth_core_sys.c b/drivers/s390/net/qeth_core_sys.c index 8c76574e7270..423bec56cffa 100644 --- a/drivers/s390/net/qeth_core_sys.c +++ b/drivers/s390/net/qeth_core_sys.c | |||
@@ -231,7 +231,6 @@ static ssize_t qeth_dev_prioqing_store(struct device *dev, | |||
231 | struct device_attribute *attr, const char *buf, size_t count) | 231 | struct device_attribute *attr, const char *buf, size_t count) |
232 | { | 232 | { |
233 | struct qeth_card *card = dev_get_drvdata(dev); | 233 | struct qeth_card *card = dev_get_drvdata(dev); |
234 | char *tmp; | ||
235 | int rc = 0; | 234 | int rc = 0; |
236 | 235 | ||
237 | if (!card) | 236 | if (!card) |
@@ -253,36 +252,35 @@ static ssize_t qeth_dev_prioqing_store(struct device *dev, | |||
253 | goto out; | 252 | goto out; |
254 | } | 253 | } |
255 | 254 | ||
256 | tmp = strsep((char **) &buf, "\n"); | 255 | if (sysfs_streq(buf, "prio_queueing_prec")) { |
257 | if (!strcmp(tmp, "prio_queueing_prec")) { | ||
258 | card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_PREC; | 256 | card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_PREC; |
259 | card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; | 257 | card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; |
260 | } else if (!strcmp(tmp, "prio_queueing_skb")) { | 258 | } else if (sysfs_streq(buf, "prio_queueing_skb")) { |
261 | card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_SKB; | 259 | card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_SKB; |
262 | card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; | 260 | card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; |
263 | } else if (!strcmp(tmp, "prio_queueing_tos")) { | 261 | } else if (sysfs_streq(buf, "prio_queueing_tos")) { |
264 | card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_TOS; | 262 | card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_TOS; |
265 | card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; | 263 | card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; |
266 | } else if (!strcmp(tmp, "prio_queueing_vlan")) { | 264 | } else if (sysfs_streq(buf, "prio_queueing_vlan")) { |
267 | if (!card->options.layer2) { | 265 | if (!card->options.layer2) { |
268 | rc = -ENOTSUPP; | 266 | rc = -ENOTSUPP; |
269 | goto out; | 267 | goto out; |
270 | } | 268 | } |
271 | card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_VLAN; | 269 | card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_VLAN; |
272 | card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; | 270 | card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; |
273 | } else if (!strcmp(tmp, "no_prio_queueing:0")) { | 271 | } else if (sysfs_streq(buf, "no_prio_queueing:0")) { |
274 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; | 272 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; |
275 | card->qdio.default_out_queue = 0; | 273 | card->qdio.default_out_queue = 0; |
276 | } else if (!strcmp(tmp, "no_prio_queueing:1")) { | 274 | } else if (sysfs_streq(buf, "no_prio_queueing:1")) { |
277 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; | 275 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; |
278 | card->qdio.default_out_queue = 1; | 276 | card->qdio.default_out_queue = 1; |
279 | } else if (!strcmp(tmp, "no_prio_queueing:2")) { | 277 | } else if (sysfs_streq(buf, "no_prio_queueing:2")) { |
280 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; | 278 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; |
281 | card->qdio.default_out_queue = 2; | 279 | card->qdio.default_out_queue = 2; |
282 | } else if (!strcmp(tmp, "no_prio_queueing:3")) { | 280 | } else if (sysfs_streq(buf, "no_prio_queueing:3")) { |
283 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; | 281 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; |
284 | card->qdio.default_out_queue = 3; | 282 | card->qdio.default_out_queue = 3; |
285 | } else if (!strcmp(tmp, "no_prio_queueing")) { | 283 | } else if (sysfs_streq(buf, "no_prio_queueing")) { |
286 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; | 284 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; |
287 | card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; | 285 | card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; |
288 | } else | 286 | } else |
@@ -497,8 +495,6 @@ static ssize_t qeth_dev_isolation_store(struct device *dev, | |||
497 | struct qeth_card *card = dev_get_drvdata(dev); | 495 | struct qeth_card *card = dev_get_drvdata(dev); |
498 | enum qeth_ipa_isolation_modes isolation; | 496 | enum qeth_ipa_isolation_modes isolation; |
499 | int rc = 0; | 497 | int rc = 0; |
500 | char *tmp, *curtoken; | ||
501 | curtoken = (char *) buf; | ||
502 | 498 | ||
503 | if (!card) | 499 | if (!card) |
504 | return -EINVAL; | 500 | return -EINVAL; |
@@ -515,12 +511,11 @@ static ssize_t qeth_dev_isolation_store(struct device *dev, | |||
515 | } | 511 | } |
516 | 512 | ||
517 | /* parse input into isolation mode */ | 513 | /* parse input into isolation mode */ |
518 | tmp = strsep(&curtoken, "\n"); | 514 | if (sysfs_streq(buf, ATTR_QETH_ISOLATION_NONE)) { |
519 | if (!strcmp(tmp, ATTR_QETH_ISOLATION_NONE)) { | ||
520 | isolation = ISOLATION_MODE_NONE; | 515 | isolation = ISOLATION_MODE_NONE; |
521 | } else if (!strcmp(tmp, ATTR_QETH_ISOLATION_FWD)) { | 516 | } else if (sysfs_streq(buf, ATTR_QETH_ISOLATION_FWD)) { |
522 | isolation = ISOLATION_MODE_FWD; | 517 | isolation = ISOLATION_MODE_FWD; |
523 | } else if (!strcmp(tmp, ATTR_QETH_ISOLATION_DROP)) { | 518 | } else if (sysfs_streq(buf, ATTR_QETH_ISOLATION_DROP)) { |
524 | isolation = ISOLATION_MODE_DROP; | 519 | isolation = ISOLATION_MODE_DROP; |
525 | } else { | 520 | } else { |
526 | rc = -EINVAL; | 521 | rc = -EINVAL; |
@@ -597,9 +592,7 @@ static ssize_t qeth_hw_trap_store(struct device *dev, | |||
597 | { | 592 | { |
598 | struct qeth_card *card = dev_get_drvdata(dev); | 593 | struct qeth_card *card = dev_get_drvdata(dev); |
599 | int rc = 0; | 594 | int rc = 0; |
600 | char *tmp, *curtoken; | ||
601 | int state = 0; | 595 | int state = 0; |
602 | curtoken = (char *)buf; | ||
603 | 596 | ||
604 | if (!card) | 597 | if (!card) |
605 | return -EINVAL; | 598 | return -EINVAL; |
@@ -607,9 +600,8 @@ static ssize_t qeth_hw_trap_store(struct device *dev, | |||
607 | mutex_lock(&card->conf_mutex); | 600 | mutex_lock(&card->conf_mutex); |
608 | if (qeth_card_hw_is_reachable(card)) | 601 | if (qeth_card_hw_is_reachable(card)) |
609 | state = 1; | 602 | state = 1; |
610 | tmp = strsep(&curtoken, "\n"); | ||
611 | 603 | ||
612 | if (!strcmp(tmp, "arm") && !card->info.hwtrap) { | 604 | if (sysfs_streq(buf, "arm") && !card->info.hwtrap) { |
613 | if (state) { | 605 | if (state) { |
614 | if (qeth_is_diagass_supported(card, | 606 | if (qeth_is_diagass_supported(card, |
615 | QETH_DIAGS_CMD_TRAP)) { | 607 | QETH_DIAGS_CMD_TRAP)) { |
@@ -620,14 +612,14 @@ static ssize_t qeth_hw_trap_store(struct device *dev, | |||
620 | rc = -EINVAL; | 612 | rc = -EINVAL; |
621 | } else | 613 | } else |
622 | card->info.hwtrap = 1; | 614 | card->info.hwtrap = 1; |
623 | } else if (!strcmp(tmp, "disarm") && card->info.hwtrap) { | 615 | } else if (sysfs_streq(buf, "disarm") && card->info.hwtrap) { |
624 | if (state) { | 616 | if (state) { |
625 | rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); | 617 | rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); |
626 | if (!rc) | 618 | if (!rc) |
627 | card->info.hwtrap = 0; | 619 | card->info.hwtrap = 0; |
628 | } else | 620 | } else |
629 | card->info.hwtrap = 0; | 621 | card->info.hwtrap = 0; |
630 | } else if (!strcmp(tmp, "trap") && state && card->info.hwtrap) | 622 | } else if (sysfs_streq(buf, "trap") && state && card->info.hwtrap) |
631 | rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_CAPTURE); | 623 | rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_CAPTURE); |
632 | else | 624 | else |
633 | rc = -EINVAL; | 625 | rc = -EINVAL; |
diff --git a/drivers/s390/net/qeth_l3_sys.c b/drivers/s390/net/qeth_l3_sys.c index c4dcd667c894..386eb7b89b1e 100644 --- a/drivers/s390/net/qeth_l3_sys.c +++ b/drivers/s390/net/qeth_l3_sys.c | |||
@@ -57,22 +57,20 @@ static ssize_t qeth_l3_dev_route_store(struct qeth_card *card, | |||
57 | const char *buf, size_t count) | 57 | const char *buf, size_t count) |
58 | { | 58 | { |
59 | enum qeth_routing_types old_route_type = route->type; | 59 | enum qeth_routing_types old_route_type = route->type; |
60 | char *tmp; | ||
61 | int rc = 0; | 60 | int rc = 0; |
62 | 61 | ||
63 | tmp = strsep((char **) &buf, "\n"); | ||
64 | mutex_lock(&card->conf_mutex); | 62 | mutex_lock(&card->conf_mutex); |
65 | if (!strcmp(tmp, "no_router")) { | 63 | if (sysfs_streq(buf, "no_router")) { |
66 | route->type = NO_ROUTER; | 64 | route->type = NO_ROUTER; |
67 | } else if (!strcmp(tmp, "primary_connector")) { | 65 | } else if (sysfs_streq(buf, "primary_connector")) { |
68 | route->type = PRIMARY_CONNECTOR; | 66 | route->type = PRIMARY_CONNECTOR; |
69 | } else if (!strcmp(tmp, "secondary_connector")) { | 67 | } else if (sysfs_streq(buf, "secondary_connector")) { |
70 | route->type = SECONDARY_CONNECTOR; | 68 | route->type = SECONDARY_CONNECTOR; |
71 | } else if (!strcmp(tmp, "primary_router")) { | 69 | } else if (sysfs_streq(buf, "primary_router")) { |
72 | route->type = PRIMARY_ROUTER; | 70 | route->type = PRIMARY_ROUTER; |
73 | } else if (!strcmp(tmp, "secondary_router")) { | 71 | } else if (sysfs_streq(buf, "secondary_router")) { |
74 | route->type = SECONDARY_ROUTER; | 72 | route->type = SECONDARY_ROUTER; |
75 | } else if (!strcmp(tmp, "multicast_router")) { | 73 | } else if (sysfs_streq(buf, "multicast_router")) { |
76 | route->type = MULTICAST_ROUTER; | 74 | route->type = MULTICAST_ROUTER; |
77 | } else { | 75 | } else { |
78 | rc = -EINVAL; | 76 | rc = -EINVAL; |
@@ -370,7 +368,6 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev, | |||
370 | { | 368 | { |
371 | struct qeth_card *card = dev_get_drvdata(dev); | 369 | struct qeth_card *card = dev_get_drvdata(dev); |
372 | struct qeth_ipaddr *tmpipa, *t; | 370 | struct qeth_ipaddr *tmpipa, *t; |
373 | char *tmp; | ||
374 | int rc = 0; | 371 | int rc = 0; |
375 | 372 | ||
376 | if (!card) | 373 | if (!card) |
@@ -383,10 +380,9 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev, | |||
383 | goto out; | 380 | goto out; |
384 | } | 381 | } |
385 | 382 | ||
386 | tmp = strsep((char **) &buf, "\n"); | 383 | if (sysfs_streq(buf, "toggle")) { |
387 | if (!strcmp(tmp, "toggle")) { | ||
388 | card->ipato.enabled = (card->ipato.enabled)? 0 : 1; | 384 | card->ipato.enabled = (card->ipato.enabled)? 0 : 1; |
389 | } else if (!strcmp(tmp, "1")) { | 385 | } else if (sysfs_streq(buf, "1")) { |
390 | card->ipato.enabled = 1; | 386 | card->ipato.enabled = 1; |
391 | list_for_each_entry_safe(tmpipa, t, card->ip_tbd_list, entry) { | 387 | list_for_each_entry_safe(tmpipa, t, card->ip_tbd_list, entry) { |
392 | if ((tmpipa->type == QETH_IP_TYPE_NORMAL) && | 388 | if ((tmpipa->type == QETH_IP_TYPE_NORMAL) && |
@@ -395,7 +391,7 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev, | |||
395 | QETH_IPA_SETIP_TAKEOVER_FLAG; | 391 | QETH_IPA_SETIP_TAKEOVER_FLAG; |
396 | } | 392 | } |
397 | 393 | ||
398 | } else if (!strcmp(tmp, "0")) { | 394 | } else if (sysfs_streq(buf, "0")) { |
399 | card->ipato.enabled = 0; | 395 | card->ipato.enabled = 0; |
400 | list_for_each_entry_safe(tmpipa, t, card->ip_tbd_list, entry) { | 396 | list_for_each_entry_safe(tmpipa, t, card->ip_tbd_list, entry) { |
401 | if (tmpipa->set_flags & | 397 | if (tmpipa->set_flags & |
@@ -430,21 +426,19 @@ static ssize_t qeth_l3_dev_ipato_invert4_store(struct device *dev, | |||
430 | const char *buf, size_t count) | 426 | const char *buf, size_t count) |
431 | { | 427 | { |
432 | struct qeth_card *card = dev_get_drvdata(dev); | 428 | struct qeth_card *card = dev_get_drvdata(dev); |
433 | char *tmp; | ||
434 | int rc = 0; | 429 | int rc = 0; |
435 | 430 | ||
436 | if (!card) | 431 | if (!card) |
437 | return -EINVAL; | 432 | return -EINVAL; |
438 | 433 | ||
439 | mutex_lock(&card->conf_mutex); | 434 | mutex_lock(&card->conf_mutex); |
440 | tmp = strsep((char **) &buf, "\n"); | 435 | if (sysfs_streq(buf, "toggle")) |
441 | if (!strcmp(tmp, "toggle")) { | ||
442 | card->ipato.invert4 = (card->ipato.invert4)? 0 : 1; | 436 | card->ipato.invert4 = (card->ipato.invert4)? 0 : 1; |
443 | } else if (!strcmp(tmp, "1")) { | 437 | else if (sysfs_streq(buf, "1")) |
444 | card->ipato.invert4 = 1; | 438 | card->ipato.invert4 = 1; |
445 | } else if (!strcmp(tmp, "0")) { | 439 | else if (sysfs_streq(buf, "0")) |
446 | card->ipato.invert4 = 0; | 440 | card->ipato.invert4 = 0; |
447 | } else | 441 | else |
448 | rc = -EINVAL; | 442 | rc = -EINVAL; |
449 | mutex_unlock(&card->conf_mutex); | 443 | mutex_unlock(&card->conf_mutex); |
450 | return rc ? rc : count; | 444 | return rc ? rc : count; |
@@ -612,21 +606,19 @@ static ssize_t qeth_l3_dev_ipato_invert6_store(struct device *dev, | |||
612 | struct device_attribute *attr, const char *buf, size_t count) | 606 | struct device_attribute *attr, const char *buf, size_t count) |
613 | { | 607 | { |
614 | struct qeth_card *card = dev_get_drvdata(dev); | 608 | struct qeth_card *card = dev_get_drvdata(dev); |
615 | char *tmp; | ||
616 | int rc = 0; | 609 | int rc = 0; |
617 | 610 | ||
618 | if (!card) | 611 | if (!card) |
619 | return -EINVAL; | 612 | return -EINVAL; |
620 | 613 | ||
621 | mutex_lock(&card->conf_mutex); | 614 | mutex_lock(&card->conf_mutex); |
622 | tmp = strsep((char **) &buf, "\n"); | 615 | if (sysfs_streq(buf, "toggle")) |
623 | if (!strcmp(tmp, "toggle")) { | ||
624 | card->ipato.invert6 = (card->ipato.invert6)? 0 : 1; | 616 | card->ipato.invert6 = (card->ipato.invert6)? 0 : 1; |
625 | } else if (!strcmp(tmp, "1")) { | 617 | else if (sysfs_streq(buf, "1")) |
626 | card->ipato.invert6 = 1; | 618 | card->ipato.invert6 = 1; |
627 | } else if (!strcmp(tmp, "0")) { | 619 | else if (sysfs_streq(buf, "0")) |
628 | card->ipato.invert6 = 0; | 620 | card->ipato.invert6 = 0; |
629 | } else | 621 | else |
630 | rc = -EINVAL; | 622 | rc = -EINVAL; |
631 | mutex_unlock(&card->conf_mutex); | 623 | mutex_unlock(&card->conf_mutex); |
632 | return rc ? rc : count; | 624 | return rc ? rc : count; |