--- zzzz-none-000/linux-3.10.107/drivers/net/wireless/hostap/hostap_ioctl.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/net/wireless/hostap/hostap_ioctl.c 2021-02-04 17:41:59.000000000 +0000 @@ -655,7 +655,7 @@ if (!local->last_scan_results) break; entry = &local->last_scan_results[i]; - if (memcmp(local->preferred_ap, entry->bssid, ETH_ALEN) == 0) { + if (ether_addr_equal(local->preferred_ap, entry->bssid)) { req.channel = entry->chid; break; } @@ -1479,23 +1479,20 @@ val = 255; tmp = val; - tmp >>= 2; - return -12 - tmp; + return tmp; } static u16 prism2_txpower_dBm_to_hfa386x(int val) { signed char tmp; - if (val > 20) - return 128; - else if (val < -43) + if (val > 127) return 127; + else if (val < -128) + return 128; tmp = val; - tmp = -12 - tmp; - tmp <<= 2; return (unsigned char) tmp; } @@ -1978,7 +1975,7 @@ list_for_each(ptr, &local->bss_list) { struct hostap_bss_info *bss; bss = list_entry(ptr, struct hostap_bss_info, list); - if (memcmp(bss->bssid, scan->bssid, ETH_ALEN) == 0) { + if (ether_addr_equal(bss->bssid, scan->bssid)) { bss->included = 1; current_ev = __prism2_translate_scan( local, info, scan, bss, current_ev, @@ -2567,7 +2564,7 @@ local->passive_scan_interval = value; if (timer_pending(&local->passive_scan_timer)) del_timer(&local->passive_scan_timer); - if (value > 0) { + if (value > 0 && value < INT_MAX / HZ) { local->passive_scan_timer.expires = jiffies + local->passive_scan_interval * HZ; add_timer(&local->passive_scan_timer); @@ -4052,3 +4049,35 @@ return ret; } + +/* BUG FIX: Restore power setting value when lost due to F/W bug */ + +int hostap_restore_power(struct net_device *dev) +{ + struct hostap_interface *iface = netdev_priv(dev); + local_info_t *local = iface->local; + + u16 val; + int ret = 0; + + if (local->txpower_type == PRISM2_TXPOWER_OFF) { + val = 0xff; /* use all standby and sleep modes */ + ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF, + HFA386X_CR_A_D_TEST_MODES2, + &val, NULL); + } + +#ifdef RAW_TXPOWER_SETTING + if (local->txpower_type == PRISM2_TXPOWER_FIXED) { + val = HFA384X_TEST_CFG_BIT_ALC; + local->func->cmd(dev, HFA384X_CMDCODE_TEST | + (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL); + val = prism2_txpower_dBm_to_hfa386x(local->txpower); + ret = (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF, + HFA386X_CR_MANUAL_TX_POWER, &val, NULL)); + } +#endif /* RAW_TXPOWER_SETTING */ + return (ret ? -EOPNOTSUPP : 0); +} + +EXPORT_SYMBOL(hostap_restore_power);