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>
This commit is contained in:
parent
29c29a9bb4
commit
c7c878a41d
|
@ -29,24 +29,16 @@ static ssize_t irst_show_wakeup_events(struct device *dev,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct acpi_device *acpi;
|
struct acpi_device *acpi;
|
||||||
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
|
unsigned long long value;
|
||||||
union acpi_object *result;
|
|
||||||
acpi_status status;
|
acpi_status status;
|
||||||
|
|
||||||
acpi = to_acpi_device(dev);
|
acpi = to_acpi_device(dev);
|
||||||
|
|
||||||
status = acpi_evaluate_object(acpi->handle, "GFFS", NULL, &output);
|
status = acpi_evaluate_integer(acpi->handle, "GFFS", NULL, &value);
|
||||||
if (!ACPI_SUCCESS(status))
|
if (!ACPI_SUCCESS(status))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
result = output.pointer;
|
return sprintf(buf, "%lld\n", value);
|
||||||
|
|
||||||
if (result->type != ACPI_TYPE_INTEGER) {
|
|
||||||
kfree(result);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sprintf(buf, "%lld\n", result->integer.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t irst_store_wakeup_events(struct device *dev,
|
static ssize_t irst_store_wakeup_events(struct device *dev,
|
||||||
|
@ -83,24 +75,16 @@ static ssize_t irst_show_wakeup_time(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct acpi_device *acpi;
|
struct acpi_device *acpi;
|
||||||
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
|
unsigned long long value;
|
||||||
union acpi_object *result;
|
|
||||||
acpi_status status;
|
acpi_status status;
|
||||||
|
|
||||||
acpi = to_acpi_device(dev);
|
acpi = to_acpi_device(dev);
|
||||||
|
|
||||||
status = acpi_evaluate_object(acpi->handle, "GFTV", NULL, &output);
|
status = acpi_evaluate_integer(acpi->handle, "GFTV", NULL, &value);
|
||||||
if (!ACPI_SUCCESS(status))
|
if (!ACPI_SUCCESS(status))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
result = output.pointer;
|
return sprintf(buf, "%lld\n", value);
|
||||||
|
|
||||||
if (result->type != ACPI_TYPE_INTEGER) {
|
|
||||||
kfree(result);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sprintf(buf, "%lld\n", result->integer.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t irst_store_wakeup_time(struct device *dev,
|
static ssize_t irst_store_wakeup_time(struct device *dev,
|
||||||
|
|
Loading…
Reference in New Issue