|
4 | 4 | * Copyright 2006-2007 Jiri Benc <[email protected]>
|
5 | 5 | * Copyright 2013-2014 Intel Mobile Communications GmbH
|
6 | 6 | * Copyright (C) 2015 - 2017 Intel Deutschland GmbH
|
7 |
| - * Copyright (C) 2018-2023 Intel Corporation |
| 7 | + * Copyright (C) 2018-2024 Intel Corporation |
8 | 8 | */
|
9 | 9 |
|
10 | 10 | #include <linux/module.h>
|
@@ -1329,9 +1329,13 @@ static int _sta_info_move_state(struct sta_info *sta,
|
1329 | 1329 | sta->sta.addr, new_state);
|
1330 | 1330 |
|
1331 | 1331 | /* notify the driver before the actual changes so it can
|
1332 |
| - * fail the transition |
| 1332 | + * fail the transition if the state is increasing. |
| 1333 | + * The driver is required not to fail when the transition |
| 1334 | + * is decreasing the state, so first, do all the preparation |
| 1335 | + * work and only then, notify the driver. |
1333 | 1336 | */
|
1334 |
| - if (test_sta_flag(sta, WLAN_STA_INSERTED)) { |
| 1337 | + if (new_state > sta->sta_state && |
| 1338 | + test_sta_flag(sta, WLAN_STA_INSERTED)) { |
1335 | 1339 | int err = drv_sta_state(sta->local, sta->sdata, sta,
|
1336 | 1340 | sta->sta_state, new_state);
|
1337 | 1341 | if (err)
|
@@ -1407,6 +1411,16 @@ static int _sta_info_move_state(struct sta_info *sta,
|
1407 | 1411 | break;
|
1408 | 1412 | }
|
1409 | 1413 |
|
| 1414 | + if (new_state < sta->sta_state && |
| 1415 | + test_sta_flag(sta, WLAN_STA_INSERTED)) { |
| 1416 | + int err = drv_sta_state(sta->local, sta->sdata, sta, |
| 1417 | + sta->sta_state, new_state); |
| 1418 | + |
| 1419 | + WARN_ONCE(err, |
| 1420 | + "Driver is not allowed to fail if the sta_state is transitioning down the list: %d\n", |
| 1421 | + err); |
| 1422 | + } |
| 1423 | + |
1410 | 1424 | sta->sta_state = new_state;
|
1411 | 1425 |
|
1412 | 1426 | return 0;
|
|
0 commit comments