From: Marco Chiappero <marco@absence.it>
To: Matthew Garrett <mjg59@srcf.ucam.org>
Cc: platform-driver-x86@vger.kernel.org, Mattia Dongili <malattia@linux.it>
Subject: [PATCH V2 2/14] sony-laptop: use usigned data type when calling ACPI methods
Date: Fri, 09 Sep 2011 18:39:00 +0200 [thread overview]
Message-ID: <1315586340.3613.80.camel@vesuvio> (raw)
In-Reply-To: <1315585214.3613.51.camel@vesuvio>
Data exchanges with the SNC device should use unsigned data types: to
avoid any implicit cast, this patch removes any int usage in favor of
unsigned int or u32.
Signed-off-by: Marco Chiappero <marco@absence.it>
---
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -689,7 +689,8 @@ static struct acpi_device *sony_nc_acpi_
/*
* acpi_evaluate_object wrappers
*/
-static int acpi_callgetfunc(acpi_handle handle, char *name, int
*result)
+static int acpi_callgetfunc(acpi_handle handle, char *name,
+ unsigned int *result)
{
struct acpi_buffer output;
union acpi_object out_obj;
@@ -709,8 +710,8 @@ static int acpi_callgetfunc(acpi_handle
return -1;
}
-static int acpi_callsetfunc(acpi_handle handle, char *name, int value,
- int *result)
+static int acpi_callsetfunc(acpi_handle handle, char *name, u32 value,
+ unsigned int *result)
{
struct acpi_object_list params;
union acpi_object in_obj;
@@ -767,8 +768,7 @@ static ssize_t sony_nc_handles_show(stru
static int sony_nc_handles_setup(struct platform_device *pd)
{
- int i;
- int result;
+ unsigned int i, result;
handles = kzalloc(sizeof(*handles), GFP_KERNEL);
if (!handles)
@@ -830,7 +830,9 @@ static int sony_find_snc_handle(unsigned
return -1;
}
-static int sony_call_snc_handle(unsigned int handle, int argument, int
*result)
+/* call command method SN07, accepts a 32 bit integer, returns a
integer */
+static int sony_call_snc_handle(unsigned int handle, unsigned int
argument,
+ unsigned int *result)
{
int ret = 0;
int offset = sony_find_snc_handle(handle);
@@ -838,6 +840,7 @@ static int sony_call_snc_handle(unsigned
if (offset < 0)
return -1;
+ /* max 32 bit wide argument, for wider input use SN06 */
ret = acpi_callsetfunc(sony_nc_acpi_handle, "SN07", offset | argument,
result);
dprintk("called SN07 with 0x%.4x (result: 0x%.4x)\n", offset |
argument,
@@ -886,7 +889,7 @@ static int boolean_validate(const int di
static ssize_t sony_nc_sysfs_show(struct device *dev, struct
device_attribute *attr,
char *buffer)
{
- int value;
+ unsigned int value;
struct sony_nc_value *item =
container_of(attr, struct sony_nc_value, devattr);
@@ -906,7 +909,7 @@ static ssize_t sony_nc_sysfs_store(struc
struct device_attribute *attr,
const char *buffer, size_t count)
{
- int value;
+ unsigned long value;
struct sony_nc_value *item =
container_of(attr, struct sony_nc_value, devattr);
@@ -951,7 +954,7 @@ static int sony_backlight_update_status(
static int sony_backlight_get_brightness(struct backlight_device *bd)
{
- int value;
+ unsigned int value;
if (acpi_callgetfunc(sony_nc_acpi_handle, "GBRT", &value))
return 0;
@@ -961,7 +964,7 @@ static int sony_backlight_get_brightness
static int sony_nc_get_brightness_ng(struct backlight_device *bd)
{
- int result;
+ unsigned int result;
struct sony_backlight_props *sdev =
(struct sony_backlight_props *)bl_get_data(bd);
@@ -972,7 +975,7 @@ static int sony_nc_get_brightness_ng(str
static int sony_nc_update_status_ng(struct backlight_device *bd)
{
- int value, result;
+ unsigned int value, result;
struct sony_backlight_props *sdev =
(struct sony_backlight_props *)bl_get_data(bd);
@@ -1069,7 +1072,7 @@ static void sony_nc_notify(struct acpi_d
if (ev >= 0x90) {
/* New-style event */
- int result;
+ unsigned int result;
int key_handle = 0;
ev -= 0x90;
@@ -1139,7 +1142,7 @@ static acpi_status sony_walk_callback(ac
*/
static int sony_nc_function_setup(struct acpi_device *device)
{
- int result;
+ unsigned int result;
/* Enable all events */
acpi_callsetfunc(sony_nc_acpi_handle, "SN02", 0xffff, &result);
@@ -1206,8 +1209,8 @@ static void sony_nc_rfkill_cleanup(void)
static int sony_nc_rfkill_set(void *data, bool blocked)
{
- int result;
- int argument = sony_rfkill_address[(long) data] + 0x100;
+ unsigned int result;
+ unsigned int argument = sony_rfkill_address[(long) data] + 0x100;
if (!blocked)
argument |= 0xff0000;
@@ -1226,7 +1229,7 @@ static int sony_nc_setup_rfkill(struct a
struct rfkill *rfk;
enum rfkill_type type;
const char *name;
- int result;
+ unsigned int result;
bool hwblock;
switch (nc_type) {
@@ -1271,14 +1274,14 @@ static int sony_nc_setup_rfkill(struct a
static void sony_nc_rfkill_update(void)
{
enum sony_nc_rfkill i;
- int result;
+ unsigned int result;
bool hwblock;
sony_call_snc_handle(sony_rfkill_handle, 0x200, &result);
hwblock = !(result & 0x1);
for (i = 0; i < N_SONY_RFKILL; i++) {
- int argument = sony_rfkill_address[i];
+ unsigned int argument = sony_rfkill_address[i];
if (!sony_rfkill_devices[i])
continue;
@@ -1390,7 +1393,7 @@ static struct kbd_backlight *kbdbl_handl
static ssize_t __sony_nc_kbd_backlight_mode_set(u8 value)
{
- int result;
+ unsigned int result;
if (value > 1)
return -EINVAL;
@@ -1438,7 +1441,7 @@ static ssize_t sony_nc_kbd_backlight_mod
static int __sony_nc_kbd_backlight_timeout_set(u8 value)
{
- int result;
+ unsigned int result;
if (value > 3)
return -EINVAL;
@@ -1482,7 +1485,7 @@ static ssize_t sony_nc_kbd_backlight_tim
static int sony_nc_kbd_backlight_setup(struct platform_device *pd)
{
- int result;
+ unsigned int result;
if (sony_call_snc_handle(KBDBL_HANDLER, KBDBL_PRESENT, &result))
return 0;
@@ -1527,7 +1530,7 @@ outkzalloc:
static int sony_nc_kbd_backlight_cleanup(struct platform_device *pd)
{
if (kbdbl_handle) {
- int result;
+ unsigned int result;
device_remove_file(&pd->dev, &kbdbl_handle->mode_attr);
device_remove_file(&pd->dev, &kbdbl_handle->timeout_attr);
@@ -1543,7 +1546,7 @@ static int sony_nc_kbd_backlight_cleanup
static void sony_nc_kbd_backlight_resume(void)
{
- int ignore = 0;
+ unsigned int ignore = 0;
if (!kbdbl_handle)
return;
@@ -2659,7 +2662,7 @@ static long sonypi_misc_ioctl(struct fil
void __user *argp = (void __user *)arg;
u8 val8;
u16 val16;
- int value;
+ unsigned int value;
mutex_lock(&spic_dev.lock);
switch (cmd) {
next prev parent reply other threads:[~2011-09-09 16:39 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-09 16:20 [PATCH V2 0/14] miscellaneous code improvements for sony-laptop Marco Chiappero
2011-09-09 16:34 ` [PATCH V2 1/14] sony-laptop: fix potential improper handle usage Marco Chiappero
2011-09-09 16:39 ` Marco Chiappero [this message]
2011-09-09 16:41 ` [PATCH V2 3/14] sony-laptop: replace simple_strtoul with strict_strtoul Marco Chiappero
2011-09-09 16:45 ` [PATCH V2 4/14] sony-laptop: add new ACPI SN06 method helper functions Marco Chiappero
2011-09-09 16:47 ` [PATCH V2 5/14] sony-laptop: new SNC setup and cleanup functions Marco Chiappero
2011-09-09 16:49 ` [PATCH V2 6/14] sony-laptop: new sony_nc_handles_resume function Marco Chiappero
2011-09-09 16:51 ` [PATCH V2 7/14] sony-laptop: sony_nc_function_setup modifications Marco Chiappero
2011-09-09 16:53 ` [PATCH V2 8/14] sony-laptop: sony_nc_notify rewritten and improved Marco Chiappero
2011-09-09 16:54 ` [PATCH V2 9/14] sony-laptop: sony_walk_callback moved for better readability Marco Chiappero
2011-09-09 16:56 ` [PATCH V2 10/14] sony-laptop: code style fixes Marco Chiappero
2011-09-09 16:58 ` [PATCH V2 11/14] sony-laptop: keyboard backlight support extended to newer Vaios Marco Chiappero
2011-09-09 17:01 ` [PATCH V2 12/14] sony-laptop: rfkill improvements Marco Chiappero
2011-09-09 17:02 ` [PATCH V2 13/14] sony-laptop: input core improvements Marco Chiappero
2011-09-09 17:04 ` [PATCH V2 14/14] sony-laptop: Documentation changes Marco Chiappero
2011-09-10 4:03 ` [PATCH V2 0/14] miscellaneous code improvements for sony-laptop Mattia Dongili
2011-09-13 20:58 ` Marco Chiappero
2011-09-13 20:43 ` [PATCH V2 RESEND 1/14] sony-laptop: fix potential improper handle usage Marco Chiappero
2011-09-13 20:45 ` [PATCH V2 RESEND 2/14] sony-laptop: use usigned data type when calling ACPI methods Marco Chiappero
2011-09-13 20:45 ` [PATCH V2 RESEND 3/14] sony-laptop: replace simple_strtoul with strict_strtoul Marco Chiappero
2011-09-13 20:45 ` [PATCH V2 RESEND 4/14] sony-laptop: add new ACPI SN06 method helper functions Marco Chiappero
2011-09-13 20:46 ` [PATCH V2 RESEND 5/14] sony-laptop: new SNC setup and cleanup functions Marco Chiappero
2011-09-13 20:47 ` [PATCH V2 RESEND 6/14] sony-laptop: new sony_nc_handles_resume function Marco Chiappero
2011-09-13 20:47 ` [PATCH V2 RESEND 7/14] sony-laptop: sony_nc_function_setup modifications Marco Chiappero
2011-09-13 20:47 ` [PATCH V2 RESEND 8/14] sony-laptop: sony_nc_notify rewritten and improved Marco Chiappero
2011-09-13 20:47 ` [PATCH V2 RESEND 9/14] sony-laptop: sony_walk_callback moved for better readability Marco Chiappero
2011-09-13 20:47 ` [PATCH V2 RESEND 10/14] sony-laptop: code style fixes Marco Chiappero
2011-09-13 20:53 ` [PATCH V2 RESEND 11/14] sony-laptop: keyboard backlight support extended to newer Vaios Marco Chiappero
2011-09-13 20:53 ` [PATCH V2 RESEND 12/14] sony-laptop: rfkill improvements Marco Chiappero
2011-09-13 20:53 ` [PATCH V2 RESEND 13/14] sony-laptop: input core improvements Marco Chiappero
2011-09-13 20:53 ` [PATCH V2 RESEND 14/14] sony-laptop: documentation changes Marco Chiappero
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=1315586340.3613.80.camel@vesuvio \
--to=marco@absence.it \
--cc=malattia@linux.it \
--cc=mjg59@srcf.ucam.org \
--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