Skip to content

Commit

Permalink
i2c-hid: convert acpi_evaluate_object() to acpi_evaluate_integer()
Browse files Browse the repository at this point in the history
acpi_evaluate_integer() is an ACPI API introduced to evaluate an
ACPI control method that is known to have an integer return value.
This API can simplify the code because the calling function does not need to
use the specified acpi_buffer structure required by acpi_evaluate_object();

Convert acpi_evaluate_object() to acpi_evaluate_integer()
in drivers/hid/i2c-hid/i2c-hid.c in this patch.

Signed-off-by: Zhang Rui <[email protected]>
Acked-by: Jiri Kosina <[email protected]>
Acked-by: Benjamin Tissoires <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
zhang-rui authored and rafaeljw committed Sep 23, 2013
1 parent 6a868e1 commit 74da276
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions drivers/hid/i2c-hid/i2c-hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,10 +854,10 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,
0xF7, 0xF6, 0xDF, 0x3C, 0x67, 0x42, 0x55, 0x45,
0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE,
};
struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object params[4], *obj;
union acpi_object params[4];
struct acpi_object_list input;
struct acpi_device *adev;
unsigned long long value;
acpi_handle handle;

handle = ACPI_HANDLE(&client->dev);
Expand All @@ -878,22 +878,14 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,
params[3].package.count = 0;
params[3].package.elements = NULL;

if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DSM", &input, &buf))) {
if (ACPI_FAILURE(acpi_evaluate_integer(handle, "_DSM", &input,
&value))) {
dev_err(&client->dev, "device _DSM execution failed\n");
return -ENODEV;
}

obj = (union acpi_object *)buf.pointer;
if (obj->type != ACPI_TYPE_INTEGER) {
dev_err(&client->dev, "device _DSM returned invalid type: %d\n",
obj->type);
kfree(buf.pointer);
return -EINVAL;
}

pdata->hid_descriptor_address = obj->integer.value;
pdata->hid_descriptor_address = value;

kfree(buf.pointer);
return 0;
}

Expand Down

0 comments on commit 74da276

Please sign in to comment.