diff options
author | Zhang Rui <rui.zhang@intel.com> | 2013-09-02 20:32:13 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-09-23 19:37:57 -0400 |
commit | c7c878a41d8b087f292015d4afeb2950a5d28830 (patch) | |
tree | ff7e60acc625227c5cf33f3561c6977923275a01 | |
parent | 29c29a9bb4d5abdb92480375e42e48a9190306e8 (diff) |
intel-rst: convert acpi_evaluate_object() to acpi_evaluate_integer()
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/platform/x86/intel-rst.c in this patch.
Plus, this should also fix a memory leak that
the acpi_buffer is not freed in some cases.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/platform/x86/intel-rst.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/drivers/platform/x86/intel-rst.c b/drivers/platform/x86/intel-rst.c index c6346cc933c6..a2083a9e5662 100644 --- a/drivers/platform/x86/intel-rst.c +++ b/drivers/platform/x86/intel-rst.c | |||
@@ -29,24 +29,16 @@ static ssize_t irst_show_wakeup_events(struct device *dev, | |||
29 | char *buf) | 29 | char *buf) |
30 | { | 30 | { |
31 | struct acpi_device *acpi; | 31 | struct acpi_device *acpi; |
32 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; | 32 | unsigned long long value; |
33 | union acpi_object *result; | ||
34 | acpi_status status; | 33 | acpi_status status; |
35 | 34 | ||
36 | acpi = to_acpi_device(dev); | 35 | acpi = to_acpi_device(dev); |
37 | 36 | ||
38 | status = acpi_evaluate_object(acpi->handle, "GFFS", NULL, &output); | 37 | status = acpi_evaluate_integer(acpi->handle, "GFFS", NULL, &value); |
39 | if (!ACPI_SUCCESS(status)) | 38 | if (!ACPI_SUCCESS(status)) |
40 | return -EINVAL; | 39 | return -EINVAL; |
41 | 40 | ||
42 | result = output.pointer; | 41 | return sprintf(buf, "%lld\n", value); |
43 | |||
44 | if (result->type != ACPI_TYPE_INTEGER) { | ||
45 | kfree(result); | ||
46 | return -EINVAL; | ||
47 | } | ||
48 | |||
49 | return sprintf(buf, "%lld\n", result->integer.value); | ||
50 | } | 42 | } |
51 | 43 | ||
52 | static ssize_t irst_store_wakeup_events(struct device *dev, | 44 | static ssize_t irst_store_wakeup_events(struct device *dev, |
@@ -83,24 +75,16 @@ static ssize_t irst_show_wakeup_time(struct device *dev, | |||
83 | struct device_attribute *attr, char *buf) | 75 | struct device_attribute *attr, char *buf) |
84 | { | 76 | { |
85 | struct acpi_device *acpi; | 77 | struct acpi_device *acpi; |
86 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; | 78 | unsigned long long value; |
87 | union acpi_object *result; | ||
88 | acpi_status status; | 79 | acpi_status status; |
89 | 80 | ||
90 | acpi = to_acpi_device(dev); | 81 | acpi = to_acpi_device(dev); |
91 | 82 | ||
92 | status = acpi_evaluate_object(acpi->handle, "GFTV", NULL, &output); | 83 | status = acpi_evaluate_integer(acpi->handle, "GFTV", NULL, &value); |
93 | if (!ACPI_SUCCESS(status)) | 84 | if (!ACPI_SUCCESS(status)) |
94 | return -EINVAL; | 85 | return -EINVAL; |
95 | 86 | ||
96 | result = output.pointer; | 87 | return sprintf(buf, "%lld\n", value); |
97 | |||
98 | if (result->type != ACPI_TYPE_INTEGER) { | ||
99 | kfree(result); | ||
100 | return -EINVAL; | ||
101 | } | ||
102 | |||
103 | return sprintf(buf, "%lld\n", result->integer.value); | ||
104 | } | 88 | } |
105 | 89 | ||
106 | static ssize_t irst_store_wakeup_time(struct device *dev, | 90 | static ssize_t irst_store_wakeup_time(struct device *dev, |