aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHerton Ronaldo Krzesinski <herton@mandriva.com.br>2010-11-30 13:30:43 -0500
committerMatthew Garrett <mjg@redhat.com>2011-01-07 17:03:41 -0500
commit698e1641a37f833dd26ee2fde5eed426cd97880b (patch)
treec0b6bc8bb6e39e813cf3711c7a4fd95d899c4a9f /drivers
parent58f6425eb92f54943878b0b3f9c1e51f99c2cb72 (diff)
classmate-laptop: little optimization for cmpc_rfkill_block
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> Signed-off-by: Matthew Garrett <mjg@redhat.com> Acked-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/platform/x86/classmate-laptop.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index d2b7720c0e6f..3dabd00b1d5a 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)
522 acpi_status status; 522 acpi_status status;
523 acpi_handle handle; 523 acpi_handle handle;
524 unsigned long long state; 524 unsigned long long state;
525 bool is_blocked;
525 526
526 handle = data; 527 handle = data;
527 status = cmpc_get_rfkill_wlan(handle, &state); 528 status = cmpc_get_rfkill_wlan(handle, &state);
528 if (ACPI_FAILURE(status)) 529 if (ACPI_FAILURE(status))
529 return -ENODEV; 530 return -ENODEV;
530 if (blocked) 531 /* Check if we really need to call cmpc_set_rfkill_wlan */
531 state &= ~1; 532 is_blocked = state & 1 ? false : true;
532 else 533 if (is_blocked != blocked) {
533 state |= 1; 534 state = blocked ? 0 : 1;
534 status = cmpc_set_rfkill_wlan(handle, state); 535 status = cmpc_set_rfkill_wlan(handle, state);
535 if (ACPI_FAILURE(status)) 536 if (ACPI_FAILURE(status))
536 return -ENODEV; 537 return -ENODEV;
538 }
537 return 0; 539 return 0;
538} 540}
539 541