Skip to content

Commit

Permalink
sony-laptop: adjust error handling in finding SNC handles
Browse files Browse the repository at this point in the history
All handles must be greater than 0, also return more meaningful error
codes on invalid conditions.

Signed-off-by: Mattia Dongili <malattia@linux.it>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
  • Loading branch information
Mattia Dongili authored and Matthew Garrett committed May 31, 2012
1 parent 49f000a commit bab7084
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/platform/x86/sony-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,8 @@ static int sony_find_snc_handle(int handle)
int i;

/* not initialized yet, return early */
if (!handles)
return -1;
if (!handles || !handle)
return -EINVAL;

for (i = 0; i < 0x10; i++) {
if (handles->cap[i] == handle) {
Expand All @@ -881,7 +881,7 @@ static int sony_find_snc_handle(int handle)
}
}
dprintk("handle 0x%.4x not found\n", handle);
return -1;
return -EINVAL;
}

static int sony_call_snc_handle(int handle, int argument, int *result)
Expand All @@ -890,7 +890,7 @@ static int sony_call_snc_handle(int handle, int argument, int *result)
int offset = sony_find_snc_handle(handle);

if (offset < 0)
return -1;
return offset;

arg = offset | argument;
ret = sony_nc_int_call(sony_nc_acpi_handle, "SN07", &arg, result);
Expand Down

0 comments on commit bab7084

Please sign in to comment.