Message ID | 1440432084-20928-1-git-send-email-jprvita@endlessm.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Johannes Berg |
Headers | show |
On Mon, 2015-08-24 at 12:01 -0400, João Paulo Rechi Vita wrote: > When switching the state of all RFKill switches of type all we need to > replicate the RFKILL_TYPE_ALL global state to all the other types global > state, so it is used to initialize persistent RFKill switches on > register. [] > diff --git a/net/rfkill/core.c b/net/rfkill/core.c [] > @@ -341,7 +341,14 @@ static void __rfkill_switch_all(const enum rfkill_type type, bool blocked) > { > struct rfkill *rfkill; > > - rfkill_global_states[type].cur = blocked; > + if (type == RFKILL_TYPE_ALL) { > + enum rfkill_type i; Does it really make sense to use an enum here? > + for (i = 0; i < NUM_RFKILL_TYPES; i++) > + rfkill_global_states[i].cur = blocked; increment it and then use it as an index? Most every other loop use of NUM_RFKILL_TYPES is int -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello Joe, thanks for your review. On 24 August 2015 at 20:28, Joe Perches <joe@perches.com> wrote: > On Mon, 2015-08-24 at 12:01 -0400, João Paulo Rechi Vita wrote: >> When switching the state of all RFKill switches of type all we need to >> replicate the RFKILL_TYPE_ALL global state to all the other types global >> state, so it is used to initialize persistent RFKill switches on >> register. > [] >> diff --git a/net/rfkill/core.c b/net/rfkill/core.c > [] >> @@ -341,7 +341,14 @@ static void __rfkill_switch_all(const enum rfkill_type type, bool blocked) >> { >> struct rfkill *rfkill; >> >> - rfkill_global_states[type].cur = blocked; >> + if (type == RFKILL_TYPE_ALL) { >> + enum rfkill_type i; > > Does it really make sense to use an enum here? > >> + for (i = 0; i < NUM_RFKILL_TYPES; i++) >> + rfkill_global_states[i].cur = blocked; > > increment it and then use it as an index? > > Most every other loop use of NUM_RFKILL_TYPES is int > I don't have a preference whether to the iterator here is an integer or an enum, I've simply followed what is done in rfkill_fop_write(). I can send an updated version. -- João Paulo Rechi Vita http://about.me/jprvita -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/rfkill/core.c b/net/rfkill/core.c index f12149a..1626e26 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c @@ -341,7 +341,14 @@ static void __rfkill_switch_all(const enum rfkill_type type, bool blocked) { struct rfkill *rfkill; - rfkill_global_states[type].cur = blocked; + if (type == RFKILL_TYPE_ALL) { + enum rfkill_type i; + for (i = 0; i < NUM_RFKILL_TYPES; i++) + rfkill_global_states[i].cur = blocked; + } else { + rfkill_global_states[type].cur = blocked; + } + list_for_each_entry(rfkill, &rfkill_list, node) { if (rfkill->type != type && type != RFKILL_TYPE_ALL) continue;
When switching the state of all RFKill switches of type all we need to replicate the RFKILL_TYPE_ALL global state to all the other types global state, so it is used to initialize persistent RFKill switches on register. Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com> --- net/rfkill/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)