aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-08-26 22:35:14 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-09-14 19:47:33 -0400
commitbd8191cc8a74018e255eb3efff5e02dc305a5ed1 (patch)
tree35d5c9fec87888ad496c19f6827eae2ea3f9e0dd
parent6ff33f3902c3b1c5d0db6b1e2c70b6d76fba357f (diff)
ACPI / property: Add routine for extraction of _DSD properties
Move the extraction of _DSD properties from acpi_init_properties() to a separate routine called acpi_extract_properties() to make the subsequent changes more straightforward. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
-rw-r--r--drivers/acpi/property.c69
1 files changed, 37 insertions, 32 deletions
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 6d99450549c5..8163b4bd7a61 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -100,34 +100,13 @@ static void acpi_init_of_compatible(struct acpi_device *adev)
100 adev->flags.of_compatible_ok = 1; 100 adev->flags.of_compatible_ok = 1;
101} 101}
102 102
103void acpi_init_properties(struct acpi_device *adev) 103static bool acpi_extract_properties(const union acpi_object *desc,
104 struct acpi_device_data *data)
104{ 105{
105 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
106 bool acpi_of = false;
107 struct acpi_hardware_id *hwid;
108 const union acpi_object *desc;
109 acpi_status status;
110 int i; 106 int i;
111 107
112 /*
113 * Check if ACPI_DT_NAMESPACE_HID is present and inthat case we fill in
114 * Device Tree compatible properties for this device.
115 */
116 list_for_each_entry(hwid, &adev->pnp.ids, list) {
117 if (!strcmp(hwid->id, ACPI_DT_NAMESPACE_HID)) {
118 acpi_of = true;
119 break;
120 }
121 }
122
123 status = acpi_evaluate_object_typed(adev->handle, "_DSD", NULL, &buf,
124 ACPI_TYPE_PACKAGE);
125 if (ACPI_FAILURE(status))
126 goto out;
127
128 desc = buf.pointer;
129 if (desc->package.count % 2) 108 if (desc->package.count % 2)
130 goto fail; 109 return false;
131 110
132 /* Look for the device properties UUID. */ 111 /* Look for the device properties UUID. */
133 for (i = 0; i < desc->package.count; i += 2) { 112 for (i = 0; i < desc->package.count; i += 2) {
@@ -154,18 +133,44 @@ void acpi_init_properties(struct acpi_device *adev)
154 if (!acpi_properties_format_valid(properties)) 133 if (!acpi_properties_format_valid(properties))
155 break; 134 break;
156 135
157 adev->data.pointer = buf.pointer; 136 data->properties = properties;
158 adev->data.properties = properties; 137 return true;
138 }
159 139
160 if (acpi_of) 140 return false;
161 acpi_init_of_compatible(adev); 141}
162 142
163 goto out; 143void acpi_init_properties(struct acpi_device *adev)
144{
145 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
146 struct acpi_hardware_id *hwid;
147 acpi_status status;
148 bool acpi_of = false;
149
150 /*
151 * Check if ACPI_DT_NAMESPACE_HID is present and inthat case we fill in
152 * Device Tree compatible properties for this device.
153 */
154 list_for_each_entry(hwid, &adev->pnp.ids, list) {
155 if (!strcmp(hwid->id, ACPI_DT_NAMESPACE_HID)) {
156 acpi_of = true;
157 break;
158 }
164 } 159 }
165 160
166 fail: 161 status = acpi_evaluate_object_typed(adev->handle, "_DSD", NULL, &buf,
167 dev_dbg(&adev->dev, "Returned _DSD data is not valid, skipping\n"); 162 ACPI_TYPE_PACKAGE);
168 ACPI_FREE(buf.pointer); 163 if (ACPI_FAILURE(status))
164 goto out;
165
166 if (acpi_extract_properties(buf.pointer, &adev->data)) {
167 adev->data.pointer = buf.pointer;
168 if (acpi_of)
169 acpi_init_of_compatible(adev);
170 } else {
171 acpi_handle_debug(adev->handle, "Invalid _DSD data, skipping\n");
172 ACPI_FREE(buf.pointer);
173 }
169 174
170 out: 175 out:
171 if (acpi_of && !adev->flags.of_compatible_ok) 176 if (acpi_of && !adev->flags.of_compatible_ok)