From: Johannes Berg <johannes@sipsolutions.net>
To: Thomas Pedersen <thomas@adapt-ip.com>
Cc: linux-wireless <linux-wireless@vger.kernel.org>
Subject: Re: [RFC 2/7] cfg80211: express channels with a KHz component
Date: Wed, 01 Apr 2020 08:54:30 +0200 [thread overview]
Message-ID: <52850c8eb3131ca742eea30a21a7e685a3a3045b.camel@sipsolutions.net> (raw)
In-Reply-To: <20200401062150.3324-3-thomas@adapt-ip.com>
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
next prev parent reply other threads:[~2020-04-01 6:54 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-01 6:21 [RFC 0/7] add a KHz component to wireless channels Thomas Pedersen
2020-04-01 6:21 ` [RFC 1/7] ieee80211: share 802.11 unit conversion helpers Thomas Pedersen
2020-04-01 6:21 ` [RFC 2/7] cfg80211: express channels with a KHz component Thomas Pedersen
2020-04-01 6:54 ` Johannes Berg [this message]
2020-04-01 17:30 ` Thomas Pedersen
2020-04-01 17:53 ` Johannes Berg
2020-04-01 21:32 ` Thomas Pedersen
2020-04-01 6:21 ` [RFC 3/7] mac80211: handle channel frequency offset Thomas Pedersen
2020-04-01 6:59 ` Johannes Berg
2020-04-01 17:39 ` Thomas Pedersen
2020-04-01 17:53 ` Johannes Berg
2020-04-01 6:21 ` [RFC 4/7] mac80211: add freq_offset to RX status Thomas Pedersen
2020-04-01 7:08 ` Johannes Berg
2020-04-01 17:58 ` Thomas Pedersen
2020-04-01 6:21 ` [RFC 5/7] cfg80211: report frequency in KHz for management RX Thomas Pedersen
2020-04-01 6:21 ` [RFC 6/7] nl80211: add KHz frequency offset for most wifi commands Thomas Pedersen
2020-04-01 7:10 ` Johannes Berg
2020-04-01 18:15 ` Thomas Pedersen
2020-04-01 7:12 ` Johannes Berg
2020-04-01 6:21 ` [RFC 7/7] nl80211: accept scan frequencies in KHz Thomas Pedersen
2020-04-01 7:15 ` [RFC 0/7] add a KHz component to wireless channels Johannes Berg
2020-04-01 18:26 ` Thomas Pedersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52850c8eb3131ca742eea30a21a7e685a3a3045b.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=thomas@adapt-ip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).