/* Convert a channel to a frequency (negative -> error) Return the channel on success  */
int iw_channel_to_freq(int channel, double *pfreq, const struct iw_range *range)
/* Convert a channel to a frequency (negative -> error) Return the channel on success  */
int iw_channel_to_freq(int channel, double *pfreq, const struct iw_range *range)
{
  int		has_freq = 0;
  int		k;
  for(k = 0; k < range->num_frequency; k++)
    {
      if((range->freq[k].e != 0) || (range->freq[k].m > (int) KILO))
	has_freq = 1;
    }
  if(!has_freq)
    return(-1);
  for(k = 0; k < range->num_frequency; k++)
    {
      if(range->freq[k].i == channel)
	{
	  *pfreq = iw_freq2float(&(range->freq[k]));
	  return(channel);
	}
    }
  return(-2);
}