int zd_channel_to_freq(struct iw_freq *freq, u8 channel) { if (channel > NUM_CHANNELS) { freq->m = 0; freq->e = 0; return -EINVAL; } if (!channel) { freq->m = 0; freq->e = 0; return -EINVAL; } return compute_freq(freq, channel_frequencies[channel-1], 0); }
void set_freq( ) { #if defined(_AIX) /* pm_cycles() returns cycles per sec --> frequency is cycles per micro-sec */ frequency = ( long long ) pm_cycles( ) / 1000000; #elif defined(__bgp__) _BGP_Personality_t bgp; frequency = ( long long ) BGP_Personality_clockMHz( &bgp ); #elif defined(_WIN32) #elif defined(__APPLE__) int mib[2]; size_t len = sizeof ( frequency ); unsigned long long freq; mib[0] = CTL_HW; mib[1] = HW_CPU_FREQ; if ( 0 > sysctl( mib, 2, &freq, &len, NULL, 0 ) ) frequency = -1; else frequency = freq; #else char maxargs[PAPI_HUGE_STR_LEN], *s; float mhz = 0.0; FILE *f; if ( ( f = fopen( "/proc/cpuinfo", "r" ) ) != NULL ) { rewind( f ); s = search_cpu_info( f, "clock", maxargs ); if ( !s ) { rewind( f ); s = search_cpu_info( f, "cpu MHz", maxargs ); } if ( s ) sscanf( s + 1, "%f", &mhz ); frequency = ( long long ) mhz; fclose( f ); } #endif #ifndef _WIN32 if ( frequency == -1 ) frequency = ( long long ) compute_freq( ); #endif }