Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Eugene Crosser and committed by
David S. Miller
7e846d6b c3521254

+32 -48
+15 -23
drivers/s390/net/qeth_core_sys.c
··· 231 231 struct device_attribute *attr, const char *buf, size_t count) 232 232 { 233 233 struct qeth_card *card = dev_get_drvdata(dev); 234 - char *tmp; 235 234 int rc = 0; 236 235 237 236 if (!card) ··· 252 253 goto out; 253 254 } 254 255 255 - tmp = strsep((char **) &buf, "\n"); 256 - if (!strcmp(tmp, "prio_queueing_prec")) { 256 + if (sysfs_streq(buf, "prio_queueing_prec")) { 257 257 card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_PREC; 258 258 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; 259 - } else if (!strcmp(tmp, "prio_queueing_skb")) { 259 + } else if (sysfs_streq(buf, "prio_queueing_skb")) { 260 260 card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_SKB; 261 261 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; 262 - } else if (!strcmp(tmp, "prio_queueing_tos")) { 262 + } else if (sysfs_streq(buf, "prio_queueing_tos")) { 263 263 card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_TOS; 264 264 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; 265 - } else if (!strcmp(tmp, "prio_queueing_vlan")) { 265 + } else if (sysfs_streq(buf, "prio_queueing_vlan")) { 266 266 if (!card->options.layer2) { 267 267 rc = -ENOTSUPP; 268 268 goto out; 269 269 } 270 270 card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_VLAN; 271 271 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; 272 - } else if (!strcmp(tmp, "no_prio_queueing:0")) { 272 + } else if (sysfs_streq(buf, "no_prio_queueing:0")) { 273 273 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; 274 274 card->qdio.default_out_queue = 0; 275 - } else if (!strcmp(tmp, "no_prio_queueing:1")) { 275 + } else if (sysfs_streq(buf, "no_prio_queueing:1")) { 276 276 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; 277 277 card->qdio.default_out_queue = 1; 278 - } else if (!strcmp(tmp, "no_prio_queueing:2")) { 278 + } else if (sysfs_streq(buf, "no_prio_queueing:2")) { 279 279 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; 280 280 card->qdio.default_out_queue = 2; 281 - } else if (!strcmp(tmp, "no_prio_queueing:3")) { 281 + } else if (sysfs_streq(buf, "no_prio_queueing:3")) { 282 282 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; 283 283 card->qdio.default_out_queue = 3; 284 - } else if (!strcmp(tmp, "no_prio_queueing")) { 284 + } else if (sysfs_streq(buf, "no_prio_queueing")) { 285 285 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; 286 286 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; 287 287 } else ··· 495 497 struct qeth_card *card = dev_get_drvdata(dev); 496 498 enum qeth_ipa_isolation_modes isolation; 497 499 int rc = 0; 498 - char *tmp, *curtoken; 499 - curtoken = (char *) buf; 500 500 501 501 if (!card) 502 502 return -EINVAL; ··· 511 515 } 512 516 513 517 /* parse input into isolation mode */ 514 - tmp = strsep(&curtoken, "\n"); 515 - if (!strcmp(tmp, ATTR_QETH_ISOLATION_NONE)) { 518 + if (sysfs_streq(buf, ATTR_QETH_ISOLATION_NONE)) { 516 519 isolation = ISOLATION_MODE_NONE; 517 - } else if (!strcmp(tmp, ATTR_QETH_ISOLATION_FWD)) { 520 + } else if (sysfs_streq(buf, ATTR_QETH_ISOLATION_FWD)) { 518 521 isolation = ISOLATION_MODE_FWD; 519 - } else if (!strcmp(tmp, ATTR_QETH_ISOLATION_DROP)) { 522 + } else if (sysfs_streq(buf, ATTR_QETH_ISOLATION_DROP)) { 520 523 isolation = ISOLATION_MODE_DROP; 521 524 } else { 522 525 rc = -EINVAL; ··· 592 597 { 593 598 struct qeth_card *card = dev_get_drvdata(dev); 594 599 int rc = 0; 595 - char *tmp, *curtoken; 596 600 int state = 0; 597 - curtoken = (char *)buf; 598 601 599 602 if (!card) 600 603 return -EINVAL; ··· 600 607 mutex_lock(&card->conf_mutex); 601 608 if (qeth_card_hw_is_reachable(card)) 602 609 state = 1; 603 - tmp = strsep(&curtoken, "\n"); 604 610 605 - if (!strcmp(tmp, "arm") && !card->info.hwtrap) { 611 + if (sysfs_streq(buf, "arm") && !card->info.hwtrap) { 606 612 if (state) { 607 613 if (qeth_is_diagass_supported(card, 608 614 QETH_DIAGS_CMD_TRAP)) { ··· 612 620 rc = -EINVAL; 613 621 } else 614 622 card->info.hwtrap = 1; 615 - } else if (!strcmp(tmp, "disarm") && card->info.hwtrap) { 623 + } else if (sysfs_streq(buf, "disarm") && card->info.hwtrap) { 616 624 if (state) { 617 625 rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); 618 626 if (!rc) 619 627 card->info.hwtrap = 0; 620 628 } else 621 629 card->info.hwtrap = 0; 622 - } else if (!strcmp(tmp, "trap") && state && card->info.hwtrap) 630 + } else if (sysfs_streq(buf, "trap") && state && card->info.hwtrap) 623 631 rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_CAPTURE); 624 632 else 625 633 rc = -EINVAL;
+17 -25
drivers/s390/net/qeth_l3_sys.c
··· 57 57 const char *buf, size_t count) 58 58 { 59 59 enum qeth_routing_types old_route_type = route->type; 60 - char *tmp; 61 60 int rc = 0; 62 61 63 - tmp = strsep((char **) &buf, "\n"); 64 62 mutex_lock(&card->conf_mutex); 65 - if (!strcmp(tmp, "no_router")) { 63 + if (sysfs_streq(buf, "no_router")) { 66 64 route->type = NO_ROUTER; 67 - } else if (!strcmp(tmp, "primary_connector")) { 65 + } else if (sysfs_streq(buf, "primary_connector")) { 68 66 route->type = PRIMARY_CONNECTOR; 69 - } else if (!strcmp(tmp, "secondary_connector")) { 67 + } else if (sysfs_streq(buf, "secondary_connector")) { 70 68 route->type = SECONDARY_CONNECTOR; 71 - } else if (!strcmp(tmp, "primary_router")) { 69 + } else if (sysfs_streq(buf, "primary_router")) { 72 70 route->type = PRIMARY_ROUTER; 73 - } else if (!strcmp(tmp, "secondary_router")) { 71 + } else if (sysfs_streq(buf, "secondary_router")) { 74 72 route->type = SECONDARY_ROUTER; 75 - } else if (!strcmp(tmp, "multicast_router")) { 73 + } else if (sysfs_streq(buf, "multicast_router")) { 76 74 route->type = MULTICAST_ROUTER; 77 75 } else { 78 76 rc = -EINVAL; ··· 368 370 { 369 371 struct qeth_card *card = dev_get_drvdata(dev); 370 372 struct qeth_ipaddr *tmpipa, *t; 371 - char *tmp; 372 373 int rc = 0; 373 374 374 375 if (!card) ··· 380 383 goto out; 381 384 } 382 385 383 - tmp = strsep((char **) &buf, "\n"); 384 - if (!strcmp(tmp, "toggle")) { 386 + if (sysfs_streq(buf, "toggle")) { 385 387 card->ipato.enabled = (card->ipato.enabled)? 0 : 1; 386 - } else if (!strcmp(tmp, "1")) { 388 + } else if (sysfs_streq(buf, "1")) { 387 389 card->ipato.enabled = 1; 388 390 list_for_each_entry_safe(tmpipa, t, card->ip_tbd_list, entry) { 389 391 if ((tmpipa->type == QETH_IP_TYPE_NORMAL) && ··· 391 395 QETH_IPA_SETIP_TAKEOVER_FLAG; 392 396 } 393 397 394 - } else if (!strcmp(tmp, "0")) { 398 + } else if (sysfs_streq(buf, "0")) { 395 399 card->ipato.enabled = 0; 396 400 list_for_each_entry_safe(tmpipa, t, card->ip_tbd_list, entry) { 397 401 if (tmpipa->set_flags & ··· 426 430 const char *buf, size_t count) 427 431 { 428 432 struct qeth_card *card = dev_get_drvdata(dev); 429 - char *tmp; 430 433 int rc = 0; 431 434 432 435 if (!card) 433 436 return -EINVAL; 434 437 435 438 mutex_lock(&card->conf_mutex); 436 - tmp = strsep((char **) &buf, "\n"); 437 - if (!strcmp(tmp, "toggle")) { 439 + if (sysfs_streq(buf, "toggle")) 438 440 card->ipato.invert4 = (card->ipato.invert4)? 0 : 1; 439 - } else if (!strcmp(tmp, "1")) { 441 + else if (sysfs_streq(buf, "1")) 440 442 card->ipato.invert4 = 1; 441 - } else if (!strcmp(tmp, "0")) { 443 + else if (sysfs_streq(buf, "0")) 442 444 card->ipato.invert4 = 0; 443 - } else 445 + else 444 446 rc = -EINVAL; 445 447 mutex_unlock(&card->conf_mutex); 446 448 return rc ? rc : count; ··· 606 612 struct device_attribute *attr, const char *buf, size_t count) 607 613 { 608 614 struct qeth_card *card = dev_get_drvdata(dev); 609 - char *tmp; 610 615 int rc = 0; 611 616 612 617 if (!card) 613 618 return -EINVAL; 614 619 615 620 mutex_lock(&card->conf_mutex); 616 - tmp = strsep((char **) &buf, "\n"); 617 - if (!strcmp(tmp, "toggle")) { 621 + if (sysfs_streq(buf, "toggle")) 618 622 card->ipato.invert6 = (card->ipato.invert6)? 0 : 1; 619 - } else if (!strcmp(tmp, "1")) { 623 + else if (sysfs_streq(buf, "1")) 620 624 card->ipato.invert6 = 1; 621 - } else if (!strcmp(tmp, "0")) { 625 + else if (sysfs_streq(buf, "0")) 622 626 card->ipato.invert6 = 0; 623 - } else 627 + else 624 628 rc = -EINVAL; 625 629 mutex_unlock(&card->conf_mutex); 626 630 return rc ? rc : count;