From: Cezary Jackiewicz <cezary.jackiewicz@gmail.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Len Brown <lenb@kernel.org>, Richard Purdie <rpurdie@rpsys.net>,
Henrique de Moraes Holschuh <hmh@hmh.eng.br>,
linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: [PATCH -mm 2/3] misc,acpi,backlight: Compal Laptop Extras - use bitmask, not hex
Date: Wed, 16 Apr 2008 22:53:04 +0200 [thread overview]
Message-ID: <20080416225304.3dc5b9d2@debian> (raw)
From: Cezary Jackiewicz <cezary.jackiewicz@gmail.com>
Clean up code. Use bitmask for operations.
Signed-off-by: Cezary Jackiewicz <cezary.jackiewicz@gmail.com>
---
diff -Nuar a/drivers/misc/compal-laptop.c b/drivers/misc/compal-laptop.c
--- a/drivers/misc/compal-laptop.c 2008-04-16 19:42:45.000000000 +0200
+++ b/drivers/misc/compal-laptop.c 2008-04-16 20:19:09.000000000 +0200
@@ -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;
reply other threads:[~2008-04-16 20:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20080416225304.3dc5b9d2@debian \
--to=cezary.jackiewicz@gmail.com \
--cc=akpm@osdl.org \
--cc=hmh@hmh.eng.br \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rpurdie@rpsys.net \
/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;
as well as URLs for NNTP newsgroup(s).