X86 platform drivers
 help / color / mirror / Atom feed
From: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
To: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Cc: platform-driver-x86@vger.kernel.org, Matthew Garrett <mjg@redhat.com>
Subject: Re: [PATCH 2/2] classmate-laptop: little optimization for cmpc_rfkill_block
Date: Tue, 30 Nov 2010 16:54:20 -0200	[thread overview]
Message-ID: <20101130185420.GE3885@barata.holoscopio.com> (raw)
In-Reply-To: <1291141843-8807-2-git-send-email-herton@mandriva.com.br>

[-- Attachment #1: Type: text/plain, Size: 1975 bytes --]

On Tue, Nov 30, 2010 at 04:30:43PM -0200, Herton Ronaldo Krzesinski wrote:
> We don't need to call bios/acpi (cmpc_set_rfkill_wlan) if the blocked
> state is already set to the same value (little optimization). This can
> happen for example if we initialize the module with same initial
> hardware state (rfkill core always call cmpc_rfkill_block on
> initialization here).
> 
> Also GWRI method only accepts 0 or 1 for setting rfkill block, as can be
> seen on AML code from acpidump->DSDT from a classmate sample I have, so
> should be fine setting state only to 0 or 1 directly.
> 
> Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
> Cc: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
> ---
>  drivers/platform/x86/classmate-laptop.c |   16 +++++++++-------
>  1 files changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
> index b714c6a..51ec5f5 100644
> --- a/drivers/platform/x86/classmate-laptop.c
> +++ b/drivers/platform/x86/classmate-laptop.c
> @@ -522,18 +522,20 @@ static int cmpc_rfkill_block(void *data, bool blocked)
>  	acpi_status status;
>  	acpi_handle handle;
>  	unsigned long long state;
> +	bool is_blocked;
>  
>  	handle = data;
>  	status = cmpc_get_rfkill_wlan(handle, &state);
>  	if (ACPI_FAILURE(status))
>  		return -ENODEV;
> -	if (blocked)
> -		state &= ~1;
> -	else
> -		state |= 1;
> -	status = cmpc_set_rfkill_wlan(handle, state);
> -	if (ACPI_FAILURE(status))
> -		return -ENODEV;
> +	/* Check if we really need to call cmpc_set_rfkill_wlan */
> +	is_blocked = state & 1 ? false : true;
> +	if (is_blocked != blocked) {
> +		state = blocked ? 0 : 1;
> +		status = cmpc_set_rfkill_wlan(handle, state);
> +		if (ACPI_FAILURE(status))
> +			return -ENODEV;
> +	}
>  	return 0;
>  }
>  
> -- 
> 1.7.3.2
> 

Acked-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2010-11-30 18:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-30 18:30 [PATCH 1/2] classmate-laptop: add missing input_sync call Herton Ronaldo Krzesinski
2010-11-30 18:30 ` [PATCH 2/2] classmate-laptop: little optimization for cmpc_rfkill_block Herton Ronaldo Krzesinski
2010-11-30 18:54   ` Thadeu Lima de Souza Cascardo [this message]
2010-11-30 18:50 ` [PATCH 1/2] classmate-laptop: add missing input_sync call Thadeu Lima de Souza Cascardo
2010-12-06 22:03 ` Matthew Garrett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101130185420.GE3885@barata.holoscopio.com \
    --to=cascardo@holoscopio.com \
    --cc=herton@mandriva.com.br \
    --cc=mjg@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox