[PATCH 2/2] classmate-laptop: little optimization for cmpc_rfkill_block

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
Cc: Thadeu Lima de Souza Cascardo <cascardo@xxxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux