lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGRGNgV0fFDnL25SYQv-F8oYqX3THD-PSCVs3puSX6a1vhD+fg@mail.gmail.com>
Date:	Tue, 9 Feb 2016 09:40:49 +1100
From:	Julian Calaby <julian.calaby@...il.com>
To:	João Paulo Rechi Vita <jprvita@...il.com>
Cc:	Johannes Berg <johannes@...solutions.net>,
	"David S. Miller" <davem@...emloft.net>,
	Darren Hart <dvhart@...radead.org>,
	linux-wireless <linux-wireless@...r.kernel.org>,
	netdev <netdev@...r.kernel.org>,
	platform-driver-x86@...r.kernel.org, linux-api@...r.kernel.org,
	linux-doc@...r.kernel.org,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	linux@...lessm.com,
	João Paulo Rechi Vita <jprvita@...lessm.com>
Subject: Re: [PATCH 5/9] rfkill: Factor rfkill_global_states[].cur assignments

Hi João,

On Tue, Feb 9, 2016 at 2:41 AM, João Paulo Rechi Vita <jprvita@...il.com> wrote:
> Factor all assignments to rfkill_global_states[].cur into a single
> function rfkill_update_global_state().
>
> Signed-off-by: João Paulo Rechi Vita <jprvita@...lessm.com>

Looks sane to me.

Reviewed-by: Julian Calaby <julian.calaby@...il.com>

> ---
>  net/rfkill/core.c | 38 +++++++++++++++++---------------------
>  1 file changed, 17 insertions(+), 21 deletions(-)
>
> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> index 56d79cb..8b96869 100644
> --- a/net/rfkill/core.c
> +++ b/net/rfkill/core.c
> @@ -302,6 +302,19 @@ static void rfkill_set_block(struct rfkill *rfkill, bool blocked)
>                 rfkill_event(rfkill);
>  }
>
> +static void rfkill_update_global_state(enum rfkill_type type, bool blocked)
> +{
> +       int i;
> +
> +       if (type != RFKILL_TYPE_ALL) {
> +               rfkill_global_states[type].cur = blocked;
> +               return;
> +       }
> +
> +       for (i = 0; i < NUM_RFKILL_TYPES; i++)
> +               rfkill_global_states[i].cur = blocked;
> +}
> +
>  #ifdef CONFIG_RFKILL_INPUT
>  static atomic_t rfkill_input_disabled = ATOMIC_INIT(0);
>
> @@ -319,15 +332,7 @@ static void __rfkill_switch_all(const enum rfkill_type type, bool blocked)
>  {
>         struct rfkill *rfkill;
>
> -       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;
> -       }
> -
> +       rfkill_update_global_state(type, blocked);
>         list_for_each_entry(rfkill, &rfkill_list, node) {
>                 if (rfkill->type != type && type != RFKILL_TYPE_ALL)
>                         continue;
> @@ -1164,15 +1169,8 @@ static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
>
>         mutex_lock(&rfkill_global_mutex);
>
> -       if (ev.op == RFKILL_OP_CHANGE_ALL) {
> -               if (ev.type == RFKILL_TYPE_ALL) {
> -                       enum rfkill_type i;
> -                       for (i = 0; i < NUM_RFKILL_TYPES; i++)
> -                               rfkill_global_states[i].cur = ev.soft;
> -               } else {
> -                       rfkill_global_states[ev.type].cur = ev.soft;
> -               }
> -       }
> +       if (ev.op == RFKILL_OP_CHANGE_ALL)
> +               rfkill_update_global_state(ev.type, ev.soft);
>
>         list_for_each_entry(rfkill, &rfkill_list, node) {
>                 if (rfkill->idx != ev.idx && ev.op != RFKILL_OP_CHANGE_ALL)
> @@ -1261,10 +1259,8 @@ static struct miscdevice rfkill_miscdev = {
>  static int __init rfkill_init(void)
>  {
>         int error;
> -       int i;
>
> -       for (i = 0; i < NUM_RFKILL_TYPES; i++)
> -               rfkill_global_states[i].cur = !rfkill_default_state;
> +       rfkill_update_global_state(RFKILL_TYPE_ALL, !rfkill_default_state);
>
>         error = class_register(&rfkill_class);
>         if (error)
> --
> 2.5.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Julian Calaby

Email: julian.calaby@...il.com
Profile: http://www.google.com/profiles/julian.calaby/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ