+static inline int rate_supported(struct sta_info *sta,
+ enum ieee80211_band band,
+ int index)
+{
+ return (sta == NULL || sta->supp_rates[band] & BIT(index));
+}
+
+static inline int
+rate_lowest_index(struct ieee80211_local *local,
+ struct ieee80211_supported_band *sband,
+ struct sta_info *sta)
+{
+ int i;
+
+ for (i = 0; i < sband->n_bitrates; i++)
+ if (rate_supported(sta, sband->band, i))
+ return i;
+
+ /* warn when we cannot find a rate. */
+ WARN_ON(1);
+
+ return 0;
+}
+
+static inline struct ieee80211_rate *
+rate_lowest(struct ieee80211_local *local,
+ struct ieee80211_supported_band *sband,
+ struct sta_info *sta)
+{
+ return &sband->bitrates[rate_lowest_index(local, sband, sta)];
+}
+