@@ -647,6 +647,31 @@ wl_iw_get_macaddr(
647
647
return error ;
648
648
}
649
649
650
+ static int
651
+ wl_iw_set_country_code (struct net_device * dev , char * ccode )
652
+ {
653
+ char country_code [WLC_CNTRY_BUF_SZ ];
654
+ int ret = -1 ;
655
+
656
+ WL_TRACE (("%s\n" , __FUNCTION__ ));
657
+ if (!ccode )
658
+ ccode = dhd_bus_country_get (dev );
659
+ strncpy (country_code , ccode , sizeof (country_code ));
660
+ if (ccode && (country_code [0 ] != 0 )) {
661
+ #ifdef CONFIG_US_NON_DFS_CHANNELS_ONLY
662
+ if (use_non_dfs_channels && !strncmp (country_code , "US" , 2 ))
663
+ strncpy (country_code , "Q2" , WLC_CNTRY_BUF_SZ );
664
+ if (!use_non_dfs_channels && !strncmp (country_code , "Q2" , 2 ))
665
+ strncpy (country_code , "US" , WLC_CNTRY_BUF_SZ );
666
+ #endif
667
+ ret = dev_wlc_ioctl (dev , WLC_SET_COUNTRY , & country_code , sizeof (country_code ));
668
+ if (ret >= 0 ) {
669
+ WL_TRACE (("%s: set country %s OK\n" , __FUNCTION__ , country_code ));
670
+ dhd_bus_country_set (dev , & country_code [0 ]);
671
+ }
672
+ }
673
+ return ret ;
674
+ }
650
675
651
676
static int
652
677
wl_iw_set_country (
@@ -661,38 +686,25 @@ wl_iw_set_country(
661
686
char * p = extra ;
662
687
int country_offset ;
663
688
int country_code_size ;
664
- wl_country_t cspec = {{0 }, 0 , {0 }};
665
- char smbuf [WLC_IOCTL_SMLEN ];
666
689
667
- cspec . rev = -1 ;
690
+ WL_TRACE (( "%s\n" , __FUNCTION__ )) ;
668
691
memset (country_code , 0 , sizeof (country_code ));
669
- memset (smbuf , 0 , sizeof (smbuf ));
670
692
671
693
country_offset = strcspn (extra , " " );
672
694
country_code_size = strlen (extra ) - country_offset ;
673
695
674
696
if (country_offset != 0 ) {
675
697
strncpy (country_code , extra + country_offset + 1 ,
676
698
MIN (country_code_size , sizeof (country_code )));
677
-
678
-
679
- memcpy (cspec .country_abbrev , country_code , WLC_CNTRY_BUF_SZ );
680
- memcpy (cspec .ccode , country_code , WLC_CNTRY_BUF_SZ );
681
-
682
- get_customized_country_code ((char * )& cspec .country_abbrev , & cspec );
683
-
684
- if ((error = dev_iw_iovar_setbuf (dev , "country" , & cspec , \
685
- sizeof (cspec ), smbuf , sizeof (smbuf ))) >= 0 ) {
699
+ error = wl_iw_set_country_code (dev , country_code );
700
+ if (error >= 0 ) {
686
701
p += snprintf (p , MAX_WX_STRING , "OK" );
687
- WL_ERROR (("%s: set country for %s as %s rev %d is OK\n" , \
688
- __FUNCTION__ , country_code , cspec .ccode , cspec .rev ));
689
- dhd_bus_country_set (dev , & cspec );
702
+ WL_TRACE (("%s: set country %s OK\n" , __FUNCTION__ , country_code ));
690
703
goto exit ;
691
704
}
692
705
}
693
706
694
- WL_ERROR (("%s: set country for %s as %s rev %d failed\n" , \
695
- __FUNCTION__ , country_code , cspec .ccode , cspec .rev ));
707
+ WL_ERROR (("%s: set country %s failed code %d\n" , __FUNCTION__ , country_code , error ));
696
708
697
709
p += snprintf (p , MAX_WX_STRING , "FAIL" );
698
710
@@ -6413,8 +6425,16 @@ static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
6413
6425
}
6414
6426
6415
6427
if (strlen (ap -> country_code )) {
6416
- WL_ERROR (("%s: Igonored: Country MUST be specified \
6417
- COUNTRY command with \n" , __FUNCTION__ ));
6428
+ int error = 0 ;
6429
+ if ((error = dev_wlc_ioctl (dev , WLC_SET_COUNTRY ,
6430
+ ap -> country_code , sizeof (ap -> country_code ))) >= 0 ) {
6431
+ WL_SOFTAP (("%s: set country %s OK\n" ,
6432
+ __FUNCTION__ , ap -> country_code ));
6433
+ dhd_bus_country_set (dev , & ap -> country_code [0 ]);
6434
+ } else {
6435
+ WL_ERROR (("%s: ERROR:%d setting country %s\n" ,
6436
+ __FUNCTION__ , error , ap -> country_code ));
6437
+ }
6418
6438
} else {
6419
6439
WL_SOFTAP (("%s: Country code is not specified,"
6420
6440
" will use Radio's default\n" ,
0 commit comments