2015-08-24 16:01:33

by João Paulo Rechi Vita

[permalink] [raw]
Subject: [PATCH] rfkill: Copy "all" global state to other types

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 <[email protected]>
---
net/rfkill/core.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

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;
--
2.1.4



2015-08-25 12:56:52

by João Paulo Rechi Vita

[permalink] [raw]
Subject: [PATCH] rfkill: Copy "all" global state to other types

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 <[email protected]>
---
net/rfkill/core.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index f12149a..2c1284a 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) {
+ int 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;
--
2.1.4


2015-08-25 16:13:12

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] rfkill: Copy "all" global state to other types

Hi Joao Paulo,

> 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 <[email protected]>
> ---
> net/rfkill/core.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)

Acked-by: Marcel Holtmann <[email protected]>

Regards

Marcel


2015-08-25 00:44:52

by João Paulo Rechi Vita

[permalink] [raw]
Subject: Re: [PATCH] rfkill: Copy "all" global state to other types

Hello Joe, thanks for your review.

On 24 August 2015 at 20:28, Joe Perches <[email protected]> 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

2015-08-25 00:28:35

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] rfkill: Copy "all" global state to other types

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



2015-09-04 12:28:17

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] rfkill: Copy "all" global state to other types

On Tue, 2015-08-25 at 08:56 -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.
>
Applied.

johannes

2015-09-02 18:36:14

by João Paulo Rechi Vita

[permalink] [raw]
Subject: Re: [PATCH] rfkill: Copy "all" global state to other types

On 2 September 2015 at 14:28, Johannes Berg <[email protected]> wrote:
> On Wed, 2015-09-02 at 10:42 -0700, Marcel Holtmann wrote:
>>
>> > Any feedback or any plans to pick this for mac80211-next (which I
>> > understand is where it should go to be sent upstream)?
>>
>> I can take this through bluetooth-next tree if there are no
>> objections.
>>
>
> I'm going to to take it, but we're in the middle of release/merge
> -window time, so there was no point in doing that just yet.
>

All right, thanks for the feedback!

--
João Paulo Rechi Vita
http://about.me/jprvita

2015-09-02 17:42:11

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] rfkill: Copy "all" global state to other types

Hi Joao,

>>> 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 <[email protected]>
>>> ---
>>> net/rfkill/core.c | 9 ++++++++-
>>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> Acked-by: Marcel Holtmann <[email protected]>
>>
>
> Any feedback or any plans to pick this for mac80211-next (which I
> understand is where it should go to be sent upstream)?

I can take this through bluetooth-next tree if there are no objections.

Regards

Marcel


2015-09-02 18:28:09

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] rfkill: Copy "all" global state to other types

On Wed, 2015-09-02 at 10:42 -0700, Marcel Holtmann wrote:
>
> > Any feedback or any plans to pick this for mac80211-next (which I
> > understand is where it should go to be sent upstream)?
>
> I can take this through bluetooth-next tree if there are no
> objections.
>

I'm going to to take it, but we're in the middle of release/merge
-window time, so there was no point in doing that just yet.

johannes

2015-09-01 20:26:12

by João Paulo Rechi Vita

[permalink] [raw]
Subject: Re: [PATCH] rfkill: Copy "all" global state to other types

Hello Johannes,

On 25 August 2015 at 12:13, Marcel Holtmann <[email protected]> wrote:
> Hi Joao Paulo,
>
>> 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 <[email protected]>
>> ---
>> net/rfkill/core.c | 9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> Acked-by: Marcel Holtmann <[email protected]>
>

Any feedback or any plans to pick this for mac80211-next (which I
understand is where it should go to be sent upstream)?

Thanks,

--
João Paulo Rechi Vita
http://about.me/jprvita