Skip to content

Commit

Permalink
eeepc-laptop: fix set_acpi() to return non-zero on failure
Browse files Browse the repository at this point in the history
If the control method does not exist, return -ENODEV for consistency
with get_acpi()

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Alan Jenkins authored and Len Brown committed Dec 9, 2009
1 parent dc56ad9 commit 13f7002
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions drivers/platform/x86/eeepc-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,26 +289,30 @@ static int read_acpi_int(acpi_handle handle, const char *method, int *val)

static int set_acpi(int cm, int value)
{
if (ehotk->cm_supported & (0x1 << cm)) {
const char *method = cm_setv[cm];
if (method == NULL)
return -ENODEV;
if (write_acpi_int(ehotk->handle, method, value, NULL))
pr_warning("Error writing %s\n", method);
}
const char *method = cm_setv[cm];

if (method == NULL)
return -ENODEV;
if ((ehotk->cm_supported & (0x1 << cm)) == 0)
return -ENODEV;

if (write_acpi_int(ehotk->handle, method, value, NULL))
pr_warning("Error writing %s\n", method);
return 0;
}

static int get_acpi(int cm)
{
int value = -ENODEV;
if ((ehotk->cm_supported & (0x1 << cm))) {
const char *method = cm_getv[cm];
if (method == NULL)
return -ENODEV;
if (read_acpi_int(ehotk->handle, method, &value))
pr_warning("Error reading %s\n", method);
}
const char *method = cm_getv[cm];
int value;

if (method == NULL)
return -ENODEV;
if ((ehotk->cm_supported & (0x1 << cm)) == 0)
return -ENODEV;

if (read_acpi_int(ehotk->handle, method, &value))
pr_warning("Error reading %s\n", method);
return value;
}

Expand Down

0 comments on commit 13f7002

Please sign in to comment.