Search Linux Wireless

Re: [RFC 2/7] cfg80211: express channels with a KHz component

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2020-03-31 at 23:21 -0700, Thomas Pedersen wrote:
> 
> +/**
> + * ieee80211_get_channel_khz - get channel struct from wiphy for specified
> + * frequency

You can't line-break there, but I think I learned a while back that you
can do

/**
 * ieee80211_get_channel_khz -
 * get channel ...

or something like that. Maybe try?

> +/**
> + * ieee80211_chandef_to_khz - convert chandef to frequency in KHz
> + *
> + * @chandef: the chandef to convert
> + *
> + * Returns the center frequency of chandef (1st segment) in KHz.
> + */
> +u32 ieee80211_chandef_to_khz(const struct cfg80211_chan_def *chandef);

Isn't this one trivial, and probably better inlined (mhz*1000 + khz)?

> +u32 ieee80211_channel_to_freq_khz(int chan, enum nl80211_band band)
> +{
> +	return __ieee80211_channel_to_frequency(chan, band);
> +}
> +EXPORT_SYMBOL(ieee80211_channel_to_freq_khz);
> +
> +int ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
> +{
> +	return KHZ_TO_MHZ(__ieee80211_channel_to_frequency(chan, band));
> +}
>  EXPORT_SYMBOL(ieee80211_channel_to_frequency);
>  
> -int ieee80211_frequency_to_channel(int freq)
> +u32 ieee80211_channel_to_khz(const struct ieee80211_channel *chan)
> +{
> +	return MHZ_TO_KHZ(chan->center_freq) + chan->freq_offset;
> +}
> +EXPORT_SYMBOL(ieee80211_channel_to_khz);

Some of these should probably be inlines? Or maybe all of them, and

> +static int __ieee80211_frequency_to_channel(u32 freq)

export the double-underscore helpers like this one instead? That'd still
be less code overall, IMHO.

> +int ieee80211_freq_khz_to_channel(u32 freq)
> +{
> +	return __ieee80211_frequency_to_channel(freq);
> +}
> +EXPORT_SYMBOL(ieee80211_freq_khz_to_channel);
> +
> +int ieee80211_frequency_to_channel(int freq)
> +{
> +	return __ieee80211_frequency_to_channel(MHZ_TO_KHZ(freq));
> +}
>  EXPORT_SYMBOL(ieee80211_frequency_to_channel);

similarly here, I guess.

> +struct ieee80211_channel *ieee80211_get_channel_khz(struct wiphy *wiphy,
> +						    u32 freq)
> +{
> +	return __ieee80211_get_channel(wiphy, freq);
> +}
> +EXPORT_SYMBOL(ieee80211_get_channel_khz);
> +
> +struct ieee80211_channel *ieee80211_get_channel(struct wiphy *wiphy,
> +						int freq)
> +{
> +	return __ieee80211_get_channel(wiphy, MHZ_TO_KHZ(freq));
> +}
>  EXPORT_SYMBOL(ieee80211_get_channel);

And maybe here? In fact, how is __ieee80211_get_channel() even different
from ieee80211_get_channel_khz()?
 
> @@ -1670,6 +1716,12 @@ bool ieee80211_chandef_to_operating_class(struct cfg80211_chan_def *chandef,
>  }
>  EXPORT_SYMBOL(ieee80211_chandef_to_operating_class);
>  
> +u32 ieee80211_chandef_to_khz(const struct cfg80211_chan_def *chandef)
> +{
> +	return MHZ_TO_KHZ(chandef->center_freq1) + chandef->freq1_offset;
> +}
> +EXPORT_SYMBOL(ieee80211_chandef_to_khz);

That's like I thought above.

I think that'd have less code overall, don't you think?

johannes




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux