|
25 | 25 | static char *reg_alpha2; |
26 | 26 | module_param(reg_alpha2, charp, 0); |
27 | 27 |
|
| 28 | +static bool allow_ps_mode; |
| 29 | +module_param(allow_ps_mode, bool, 0444); |
| 30 | +MODULE_PARM_DESC(allow_ps_mode, |
| 31 | + "allow WiFi power management to be enabled. (default: disallowed)"); |
| 32 | + |
28 | 33 | static const struct ieee80211_iface_limit mwifiex_ap_sta_limits[] = { |
29 | 34 | { |
30 | 35 | .max = 3, .types = BIT(NL80211_IFTYPE_STATION) | |
@@ -439,6 +444,27 @@ mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
439 | 444 |
|
440 | 445 | ps_mode = enabled; |
441 | 446 |
|
| 447 | + /* Allow ps_mode to be enabled only when allow_ps_mode is set |
| 448 | + * (but always allow ps_mode to be disabled in case it gets enabled |
| 449 | + * for unknown reason and you want to disable it) */ |
| 450 | + if (ps_mode && !allow_ps_mode) { |
| 451 | + dev_info(priv->adapter->dev, |
| 452 | + "Request to enable ps_mode received but it's disallowed " |
| 453 | + "by module parameter. Rejecting the request.\n"); |
| 454 | + |
| 455 | + /* Return negative value to inform userspace tools that setting |
| 456 | + * power_save to be enabled is not permitted. */ |
| 457 | + return -1; |
| 458 | + } |
| 459 | + |
| 460 | + if (ps_mode) |
| 461 | + dev_warn(priv->adapter->dev, |
| 462 | + "WARN: Request to enable ps_mode received. Enabling it. " |
| 463 | + "Disable it if you encounter connection instability.\n"); |
| 464 | + else |
| 465 | + dev_info(priv->adapter->dev, |
| 466 | + "Request to disable ps_mode received. Disabling it.\n"); |
| 467 | + |
442 | 468 | return mwifiex_drv_set_power(priv, &ps_mode); |
443 | 469 | } |
444 | 470 |
|
|
0 commit comments