On Tue, Nov 27, 2012 at 3:36 PM, Luciano Coelho <coelho@xxxxxx> wrote: > On Tue, 2012-11-27 at 08:44 +0200, Arik Nemtsov wrote: >> From: Victor Goldenshtein <victorg@xxxxxx> >> >> wlcore allocates two static structs wl1271_band_2ghz & wl1271_band_5ghz >> which are used/modified by Reg-Domain e.g. some channel might be marked >> as passive at some point. Make sure we don't keep stale settings around >> if the HW is unregistered/registered during operation. >> >> [Arik - use Tx-power constant and tweak commit message] >> >> Signed-off-by: Victor Goldenshtein <victorg@xxxxxx> >> Signed-off-by: Arik Nemtsov <arik@xxxxxxxxxx> >> --- > > [...] > >> diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c >> index e68cd3f..3ced59b 100644 >> --- a/drivers/net/wireless/ti/wlcore/main.c >> +++ b/drivers/net/wireless/ti/wlcore/main.c > > [...] > >> @@ -5537,6 +5537,7 @@ wlcore_iface_combinations[] = { >> >> static int wl1271_init_ieee80211(struct wl1271 *wl) >> { >> + int i; >> static const u32 cipher_suites[] = { >> WLAN_CIPHER_SUITE_WEP40, >> WLAN_CIPHER_SUITE_WEP104, >> @@ -5599,6 +5600,22 @@ static int wl1271_init_ieee80211(struct wl1271 *wl) >> ARRAY_SIZE(wl1271_channels_5ghz) > >> WL1271_MAX_CHANNELS); >> /* >> + * clear channel flags from the previous usage >> + * and restore max_power & max_antenna_gain values. >> + */ >> + for (i = 0; i < ARRAY_SIZE(wl1271_channels); i++) { >> + wl1271_band_2ghz.channels[i].flags = 0; >> + wl1271_band_2ghz.channels[i].max_power = WLCORE_MAX_TXPWR; >> + wl1271_band_2ghz.channels[i].max_antenna_gain = 0; >> + } >> + >> + for (i = 0; i < ARRAY_SIZE(wl1271_channels_5ghz); i++) { >> + wl1271_band_5ghz.channels[i].flags = 0; >> + wl1271_band_5ghz.channels[i].max_power = WLCORE_MAX_TXPWR; >> + wl1271_band_5ghz.channels[i].max_antenna_gain = 0; >> + } >> + >> + /* > > This looks a bit hacky, because you must know what values are being > modified by cfg80211. What if in the future there are more values in > the channel structure that are being modified? > > The best would be to have a copy of the struct to pass to cfg80211 when > the hardware is registered and realloc it when we unregister. That > would be safer and more future-proof, but would use a bit more memory > though. Yea a new struct wasn't used because of the memory requirement. I agree a copy is cleaner. Let's start with this one to solve the actual bug and make a TODO for later? I'm also not sure that having cfg80211 change a structure allocated and owned by the driver is the cleanest solution for the regulatory stuff. -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html