@@ -402,22 +402,44 @@ void wimax_dev_init(struct wimax_dev *wimax_dev)
402402}
403403EXPORT_SYMBOL_GPL (wimax_dev_init );
404404
405- /*
406- * This extern is declared here because it's easier to keep track --
407- * both declarations are a list of the same
408- */
409- extern struct genl_ops
410- wimax_gnl_msg_from_user ,
411- wimax_gnl_reset ,
412- wimax_gnl_rfkill ,
413- wimax_gnl_state_get ;
405+ static const struct nla_policy wimax_gnl_policy [WIMAX_GNL_ATTR_MAX + 1 ] = {
406+ [WIMAX_GNL_RESET_IFIDX ] = { .type = NLA_U32 , },
407+ [WIMAX_GNL_RFKILL_IFIDX ] = { .type = NLA_U32 , },
408+ [WIMAX_GNL_RFKILL_STATE ] = {
409+ .type = NLA_U32 /* enum wimax_rf_state */
410+ },
411+ [WIMAX_GNL_STGET_IFIDX ] = { .type = NLA_U32 , },
412+ [WIMAX_GNL_MSG_IFIDX ] = { .type = NLA_U32 , },
413+ [WIMAX_GNL_MSG_DATA ] = {
414+ .type = NLA_UNSPEC , /* libnl doesn't grok BINARY yet */
415+ },
416+ };
414417
415- static
416- struct genl_ops * wimax_gnl_ops [] = {
417- & wimax_gnl_msg_from_user ,
418- & wimax_gnl_reset ,
419- & wimax_gnl_rfkill ,
420- & wimax_gnl_state_get ,
418+ static struct genl_ops wimax_gnl_ops [] = {
419+ {
420+ .cmd = WIMAX_GNL_OP_MSG_FROM_USER ,
421+ .flags = GENL_ADMIN_PERM ,
422+ .policy = wimax_gnl_policy ,
423+ .doit = wimax_gnl_doit_msg_from_user ,
424+ },
425+ {
426+ .cmd = WIMAX_GNL_OP_RESET ,
427+ .flags = GENL_ADMIN_PERM ,
428+ .policy = wimax_gnl_policy ,
429+ .doit = wimax_gnl_doit_reset ,
430+ },
431+ {
432+ .cmd = WIMAX_GNL_OP_RFKILL ,
433+ .flags = GENL_ADMIN_PERM ,
434+ .policy = wimax_gnl_policy ,
435+ .doit = wimax_gnl_doit_rfkill ,
436+ },
437+ {
438+ .cmd = WIMAX_GNL_OP_STATE_GET ,
439+ .flags = GENL_ADMIN_PERM ,
440+ .policy = wimax_gnl_policy ,
441+ .doit = wimax_gnl_doit_state_get ,
442+ },
421443};
422444
423445
@@ -567,45 +589,29 @@ struct genl_multicast_group wimax_gnl_mcg = {
567589static
568590int __init wimax_subsys_init (void )
569591{
570- int result , cnt ;
592+ int result ;
571593
572594 d_fnstart (4 , NULL , "()\n" );
573595 d_parse_params (D_LEVEL , D_LEVEL_SIZE , wimax_debug_params ,
574596 "wimax.debug" );
575597
576598 snprintf (wimax_gnl_family .name , sizeof (wimax_gnl_family .name ),
577599 "WiMAX" );
578- result = genl_register_family (& wimax_gnl_family );
600+ result = genl_register_family_with_ops (& wimax_gnl_family , wimax_gnl_ops ,
601+ ARRAY_SIZE (wimax_gnl_ops ));
579602 if (unlikely (result < 0 )) {
580603 printk (KERN_ERR "cannot register generic netlink family: %d\n" ,
581604 result );
582605 goto error_register_family ;
583606 }
584607
585- for (cnt = 0 ; cnt < ARRAY_SIZE (wimax_gnl_ops ); cnt ++ ) {
586- result = genl_register_ops (& wimax_gnl_family ,
587- wimax_gnl_ops [cnt ]);
588- d_printf (4 , NULL , "registering generic netlink op code "
589- "%u: %d\n" , wimax_gnl_ops [cnt ]-> cmd , result );
590- if (unlikely (result < 0 )) {
591- printk (KERN_ERR "cannot register generic netlink op "
592- "code %u: %d\n" ,
593- wimax_gnl_ops [cnt ]-> cmd , result );
594- goto error_register_ops ;
595- }
596- }
597-
598608 result = genl_register_mc_group (& wimax_gnl_family , & wimax_gnl_mcg );
599609 if (result < 0 )
600610 goto error_mc_group ;
601611 d_fnend (4 , NULL , "() = 0\n" );
602612 return 0 ;
603613
604614error_mc_group :
605- error_register_ops :
606- for (cnt -- ; cnt >= 0 ; cnt -- )
607- genl_unregister_ops (& wimax_gnl_family ,
608- wimax_gnl_ops [cnt ]);
609615 genl_unregister_family (& wimax_gnl_family );
610616error_register_family :
611617 d_fnend (4 , NULL , "() = %d\n" , result );
@@ -619,12 +625,7 @@ module_init(wimax_subsys_init);
619625static
620626void __exit wimax_subsys_exit (void )
621627{
622- int cnt ;
623628 wimax_id_table_release ();
624- genl_unregister_mc_group (& wimax_gnl_family , & wimax_gnl_mcg );
625- for (cnt = ARRAY_SIZE (wimax_gnl_ops ) - 1 ; cnt >= 0 ; cnt -- )
626- genl_unregister_ops (& wimax_gnl_family ,
627- wimax_gnl_ops [cnt ]);
628629 genl_unregister_family (& wimax_gnl_family );
629630}
630631module_exit (wimax_subsys_exit );
0 commit comments