/* Returns a frequency, or a negative error code, or 0 for auto.  */
int cfg80211_wext_freq(struct wiphy *wiphy, struct iw_freq *freq)
/* Returns a frequency, or a negative error code, or 0 for auto.  */
int cfg80211_wext_freq(struct wiphy *wiphy, struct iw_freq *freq)
{
	if (freq->e == 0) {
		if (freq->m < 0)
			return 0;
		return ieee80211_channel_to_frequency(freq->m);
	} else {
		int i, div = 1000000;
		for (i = 0; i < freq->e; i++)
			div /= 10;
		if (div <= 0)
			return -EINVAL;
		return freq->m / div;
	}
}