misc,acpi,backlight: Compal Laptop Extras - use bitmask, not hex
Subsystems (2)
PATCH 2/3 misc,acpi,backlight: Compal Laptop Extras - use bitmask, not hex
From: Cezary Jackiewicz <[email protected]>
Clean up code. Use bitmask for operations.
Signed-off-by Cezary Jackiewicz <[email protected]>
---
drivers/misc/compal-laptop.c +16 -12
@@ -1,7 +1,7 @@/*-*-linux-c-*-*/ /* -Copyright (C) 2008 Cezary Jackiewicz <cezary.Jackiewicz (at) gmail.com> +Copyright (C) 2008 Cezary Jackiewicz <cezary.jackiewicz (at) gmail.com> based on MSI driver
@@ -56,13 +56,17 @@#include <linux/platform_device.h> #include <linux/autoconf.h> -#define COMPAL_DRIVER_VERSION "0.2.2" +#define COMPAL_DRIVER_VERSION "0.2.5"#define COMPAL_LCD_LEVEL_MAX 8#define COMPAL_EC_COMMAND_WIRELESS 0xBB#define COMPAL_EC_COMMAND_LCD_LEVEL 0xB9 +#define KILLSWITCH_MASK 0x10 +#define WLAN_MASK 0x01 +#define BT_MASK 0x02 +static int force;module_param (force, bool,0 );MODULE_PARM_DESC (force,"Force driver load, ignore DMI data" );
@@ -94,13 +98,13 @@ec_read (COMPAL_EC_COMMAND_WIRELESS , &result); -if ((result &0x10 ) ==0 ) +if ((result &KILLSWITCH_MASK ) ==0 )return -EINVAL ;else {if (state) - value = (u8) (result |0x01 ); + value = (u8) (result |WLAN_MASK );else - value = (u8) (result &0xFE ); + value = (u8) (result & ~WLAN_MASK );ec_write (COMPAL_EC_COMMAND_WIRELESS , value); }
@@ -113,13 +117,13 @@ec_read (COMPAL_EC_COMMAND_WIRELESS , &result); -if ((result &0x10 ) ==0 ) +if ((result &KILLSWITCH_MASK ) ==0 )return -EINVAL ;else {if (state) - value = (u8) (result |0x02 ); + value = (u8) (result |BT_MASK );else - value = (u8) (result &0xFD ); + value = (u8) (result & ~BT_MASK );ec_write (COMPAL_EC_COMMAND_WIRELESS , value); }
@@ -133,17 +137,17 @@ec_read (COMPAL_EC_COMMAND_WIRELESS , &result);if (wlan) { -if ((result &0x10 ) ==0 ) +if ((result &KILLSWITCH_MASK ) ==0 ) *wlan =0 ;else - *wlan = result &0x01 ; + *wlan = result &WLAN_MASK ; }if (bluetooth) { -if ((result &0x10 ) ==0 ) +if ((result &KILLSWITCH_MASK ) ==0 ) *bluetooth =0 ;else - *bluetooth = (result >>1 ) &0x01 ; + *bluetooth = (result &BT_MASK ) >>1 ; }return 0 ;