/* Convert a frequency to a channel (negative -> error)  */
int iw_freq_to_channel(double freq, const struct iw_range *range)
/* Convert a frequency to a channel (negative -> error)  */
int iw_freq_to_channel(double freq, const struct iw_range *range)
{
  double	ref_freq;
  int		k;
  if(freq < KILO)
    return(-1);
  for(k = 0; k < range->num_frequency; k++)
    {
      ref_freq = iw_freq2float(&(range->freq[k]));
      if(freq == ref_freq)
	return(range->freq[k].i);
    }
  return(-2);
}