- local->scan.mode_idx++;
- if (local->scan.mode_idx >= local->hw.num_modes)
- local->scan.mode_idx = 0;
- *mode = &local->hw.modes[local->scan.mode_idx];
+ next = (*mode)->list.next;
+ if (next == &local->modes_list)
+ next = next->next;
+ *mode = list_entry(next,
+ struct ieee80211_hw_mode,
+ list);
+ local->scan.mode = *mode;