aboutsummaryrefslogtreecommitdiffstats
path: root/net/netlabel/netlabel_mgmt.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-02-18 01:33:16 -0500
committerDavid S. Miller <davem@davemloft.net>2008-02-18 01:33:16 -0500
commit227c43c3bca76df704231324405980851dc7f528 (patch)
tree6b6f32246a974382cc6b7d6474a18c225603a856 /net/netlabel/netlabel_mgmt.c
parentf47b7257c7368698eabff6fd7b340071932af640 (diff)
[NETLABEL]: Shrink the genl-ops registration code.
Turning them to array and registration in a loop saves 80 lines of code and ~300 bytes from text section. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Acked-by: Paul Moore <paul.moore@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlabel/netlabel_mgmt.c')
-rw-r--r--net/netlabel/netlabel_mgmt.c79
1 files changed, 24 insertions, 55 deletions
diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index e2258dc3c845..05d98862fbd4 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -517,68 +517,63 @@ version_failure:
517 * NetLabel Generic NETLINK Command Definitions 517 * NetLabel Generic NETLINK Command Definitions
518 */ 518 */
519 519
520static struct genl_ops netlbl_mgmt_genl_c_add = { 520static struct genl_ops netlbl_mgmt_genl_ops[] = {
521 {
521 .cmd = NLBL_MGMT_C_ADD, 522 .cmd = NLBL_MGMT_C_ADD,
522 .flags = GENL_ADMIN_PERM, 523 .flags = GENL_ADMIN_PERM,
523 .policy = netlbl_mgmt_genl_policy, 524 .policy = netlbl_mgmt_genl_policy,
524 .doit = netlbl_mgmt_add, 525 .doit = netlbl_mgmt_add,
525 .dumpit = NULL, 526 .dumpit = NULL,
526}; 527 },
527 528 {
528static struct genl_ops netlbl_mgmt_genl_c_remove = {
529 .cmd = NLBL_MGMT_C_REMOVE, 529 .cmd = NLBL_MGMT_C_REMOVE,
530 .flags = GENL_ADMIN_PERM, 530 .flags = GENL_ADMIN_PERM,
531 .policy = netlbl_mgmt_genl_policy, 531 .policy = netlbl_mgmt_genl_policy,
532 .doit = netlbl_mgmt_remove, 532 .doit = netlbl_mgmt_remove,
533 .dumpit = NULL, 533 .dumpit = NULL,
534}; 534 },
535 535 {
536static struct genl_ops netlbl_mgmt_genl_c_listall = {
537 .cmd = NLBL_MGMT_C_LISTALL, 536 .cmd = NLBL_MGMT_C_LISTALL,
538 .flags = 0, 537 .flags = 0,
539 .policy = netlbl_mgmt_genl_policy, 538 .policy = netlbl_mgmt_genl_policy,
540 .doit = NULL, 539 .doit = NULL,
541 .dumpit = netlbl_mgmt_listall, 540 .dumpit = netlbl_mgmt_listall,
542}; 541 },
543 542 {
544static struct genl_ops netlbl_mgmt_genl_c_adddef = {
545 .cmd = NLBL_MGMT_C_ADDDEF, 543 .cmd = NLBL_MGMT_C_ADDDEF,
546 .flags = GENL_ADMIN_PERM, 544 .flags = GENL_ADMIN_PERM,
547 .policy = netlbl_mgmt_genl_policy, 545 .policy = netlbl_mgmt_genl_policy,
548 .doit = netlbl_mgmt_adddef, 546 .doit = netlbl_mgmt_adddef,
549 .dumpit = NULL, 547 .dumpit = NULL,
550}; 548 },
551 549 {
552static struct genl_ops netlbl_mgmt_genl_c_removedef = {
553 .cmd = NLBL_MGMT_C_REMOVEDEF, 550 .cmd = NLBL_MGMT_C_REMOVEDEF,
554 .flags = GENL_ADMIN_PERM, 551 .flags = GENL_ADMIN_PERM,
555 .policy = netlbl_mgmt_genl_policy, 552 .policy = netlbl_mgmt_genl_policy,
556 .doit = netlbl_mgmt_removedef, 553 .doit = netlbl_mgmt_removedef,
557 .dumpit = NULL, 554 .dumpit = NULL,
558}; 555 },
559 556 {
560static struct genl_ops netlbl_mgmt_genl_c_listdef = {
561 .cmd = NLBL_MGMT_C_LISTDEF, 557 .cmd = NLBL_MGMT_C_LISTDEF,
562 .flags = 0, 558 .flags = 0,
563 .policy = netlbl_mgmt_genl_policy, 559 .policy = netlbl_mgmt_genl_policy,
564 .doit = netlbl_mgmt_listdef, 560 .doit = netlbl_mgmt_listdef,
565 .dumpit = NULL, 561 .dumpit = NULL,
566}; 562 },
567 563 {
568static struct genl_ops netlbl_mgmt_genl_c_protocols = {
569 .cmd = NLBL_MGMT_C_PROTOCOLS, 564 .cmd = NLBL_MGMT_C_PROTOCOLS,
570 .flags = 0, 565 .flags = 0,
571 .policy = netlbl_mgmt_genl_policy, 566 .policy = netlbl_mgmt_genl_policy,
572 .doit = NULL, 567 .doit = NULL,
573 .dumpit = netlbl_mgmt_protocols, 568 .dumpit = netlbl_mgmt_protocols,
574}; 569 },
575 570 {
576static struct genl_ops netlbl_mgmt_genl_c_version = {
577 .cmd = NLBL_MGMT_C_VERSION, 571 .cmd = NLBL_MGMT_C_VERSION,
578 .flags = 0, 572 .flags = 0,
579 .policy = netlbl_mgmt_genl_policy, 573 .policy = netlbl_mgmt_genl_policy,
580 .doit = netlbl_mgmt_version, 574 .doit = netlbl_mgmt_version,
581 .dumpit = NULL, 575 .dumpit = NULL,
576 },
582}; 577};
583 578
584/* 579/*
@@ -595,44 +590,18 @@ static struct genl_ops netlbl_mgmt_genl_c_version = {
595 */ 590 */
596int netlbl_mgmt_genl_init(void) 591int netlbl_mgmt_genl_init(void)
597{ 592{
598 int ret_val; 593 int ret_val, i;
599 594
600 ret_val = genl_register_family(&netlbl_mgmt_gnl_family); 595 ret_val = genl_register_family(&netlbl_mgmt_gnl_family);
601 if (ret_val != 0) 596 if (ret_val != 0)
602 return ret_val; 597 return ret_val;
603 598
604 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family, 599 for (i = 0; i < ARRAY_SIZE(netlbl_mgmt_genl_ops); i++) {
605 &netlbl_mgmt_genl_c_add); 600 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
606 if (ret_val != 0) 601 &netlbl_mgmt_genl_ops[i]);
607 return ret_val; 602 if (ret_val != 0)
608 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family, 603 return ret_val;
609 &netlbl_mgmt_genl_c_remove); 604 }
610 if (ret_val != 0)
611 return ret_val;
612 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
613 &netlbl_mgmt_genl_c_listall);
614 if (ret_val != 0)
615 return ret_val;
616 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
617 &netlbl_mgmt_genl_c_adddef);
618 if (ret_val != 0)
619 return ret_val;
620 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
621 &netlbl_mgmt_genl_c_removedef);
622 if (ret_val != 0)
623 return ret_val;
624 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
625 &netlbl_mgmt_genl_c_listdef);
626 if (ret_val != 0)
627 return ret_val;
628 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
629 &netlbl_mgmt_genl_c_protocols);
630 if (ret_val != 0)
631 return ret_val;
632 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
633 &netlbl_mgmt_genl_c_version);
634 if (ret_val != 0)
635 return ret_val;
636 605
637 return 0; 606 return 0;
638} 607}