347-0001-cfg80211-move-function-checking-range-fit-to-util.c.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  2. Date: Wed, 4 Jan 2017 18:58:30 +0100
  3. Subject: [PATCH] cfg80211: move function checking range fit to util.c
  4. MIME-Version: 1.0
  5. Content-Type: text/plain; charset=UTF-8
  6. Content-Transfer-Encoding: 8bit
  7. It is needed for another cfg80211 helper that will be out of reg.c so
  8. move it to common util.c file and make it non-static.
  9. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  10. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  11. ---
  12. --- a/net/wireless/core.h
  13. +++ b/net/wireless/core.h
  14. @@ -429,6 +429,9 @@ int cfg80211_change_iface(struct cfg8021
  15. void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev);
  16. void cfg80211_process_wdev_events(struct wireless_dev *wdev);
  17. +bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range,
  18. + u32 center_freq_khz, u32 bw_khz);
  19. +
  20. /**
  21. * cfg80211_chandef_dfs_usable - checks if chandef is DFS usable
  22. * @wiphy: the wiphy to validate against
  23. --- a/net/wireless/reg.c
  24. +++ b/net/wireless/reg.c
  25. @@ -748,21 +748,6 @@ static bool is_valid_rd(const struct iee
  26. return true;
  27. }
  28. -static bool reg_does_bw_fit(const struct ieee80211_freq_range *freq_range,
  29. - u32 center_freq_khz, u32 bw_khz)
  30. -{
  31. - u32 start_freq_khz, end_freq_khz;
  32. -
  33. - start_freq_khz = center_freq_khz - (bw_khz/2);
  34. - end_freq_khz = center_freq_khz + (bw_khz/2);
  35. -
  36. - if (start_freq_khz >= freq_range->start_freq_khz &&
  37. - end_freq_khz <= freq_range->end_freq_khz)
  38. - return true;
  39. -
  40. - return false;
  41. -}
  42. -
  43. /**
  44. * freq_in_rule_band - tells us if a frequency is in a frequency band
  45. * @freq_range: frequency rule we want to query
  46. @@ -1070,7 +1055,7 @@ freq_reg_info_regd(u32 center_freq,
  47. if (!band_rule_found)
  48. band_rule_found = freq_in_rule_band(fr, center_freq);
  49. - bw_fits = reg_does_bw_fit(fr, center_freq, bw);
  50. + bw_fits = cfg80211_does_bw_fit_range(fr, center_freq, bw);
  51. if (band_rule_found && bw_fits)
  52. return rr;
  53. @@ -1138,11 +1123,13 @@ static uint32_t reg_rule_to_chan_bw_flag
  54. max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule);
  55. /* If we get a reg_rule we can assume that at least 5Mhz fit */
  56. - if (!reg_does_bw_fit(freq_range, MHZ_TO_KHZ(chan->center_freq),
  57. - MHZ_TO_KHZ(10)))
  58. + if (!cfg80211_does_bw_fit_range(freq_range,
  59. + MHZ_TO_KHZ(chan->center_freq),
  60. + MHZ_TO_KHZ(10)))
  61. bw_flags |= IEEE80211_CHAN_NO_10MHZ;
  62. - if (!reg_does_bw_fit(freq_range, MHZ_TO_KHZ(chan->center_freq),
  63. - MHZ_TO_KHZ(20)))
  64. + if (!cfg80211_does_bw_fit_range(freq_range,
  65. + MHZ_TO_KHZ(chan->center_freq),
  66. + MHZ_TO_KHZ(20)))
  67. bw_flags |= IEEE80211_CHAN_NO_20MHZ;
  68. if (max_bandwidth_khz < MHZ_TO_KHZ(10))
  69. --- a/net/wireless/util.c
  70. +++ b/net/wireless/util.c
  71. @@ -1788,6 +1788,21 @@ void cfg80211_free_nan_func(struct cfg80
  72. }
  73. EXPORT_SYMBOL(cfg80211_free_nan_func);
  74. +bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range,
  75. + u32 center_freq_khz, u32 bw_khz)
  76. +{
  77. + u32 start_freq_khz, end_freq_khz;
  78. +
  79. + start_freq_khz = center_freq_khz - (bw_khz / 2);
  80. + end_freq_khz = center_freq_khz + (bw_khz / 2);
  81. +
  82. + if (start_freq_khz >= freq_range->start_freq_khz &&
  83. + end_freq_khz <= freq_range->end_freq_khz)
  84. + return true;
  85. +
  86. + return false;
  87. +}
  88. +
  89. /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
  90. /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
  91. const unsigned char rfc1042_header[] __aligned(2) =