summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/resource.c
diff options
context:
space:
mode:
authorJiang Liu <jiang.liu@linux.intel.com>2015-02-01 21:42:55 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-02-03 16:27:19 -0500
commit581c19f3a72ae9ff7f24f2a6c2e67f269ed4392a (patch)
treeb6b9f4713b7f5978d2b0dd1c3005c854c5a51041 /drivers/acpi/resource.c
parent8515f9368161730655b64ddaf8b11a3d20049610 (diff)
ACPI: Normalize return value of resource parser functions
Normalize return value of resource parse functions as: 1) return "true" if resource is assigned. 2) return "false" and IORESOURCE_DISABLED setting in res->flags if resource is unassigned. 3) return "false" and zeroing res->flags if it's not an valid or expected resource. Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/resource.c')
-rw-r--r--drivers/acpi/resource.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index 5544c6d26f32..32561290a4a0 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -80,6 +80,11 @@ static void acpi_dev_get_memresource(struct resource *res, u64 start, u64 len,
80 * Check if the given ACPI resource object represents a memory resource and 80 * Check if the given ACPI resource object represents a memory resource and
81 * if that's the case, use the information in it to populate the generic 81 * if that's the case, use the information in it to populate the generic
82 * resource object pointed to by @res. 82 * resource object pointed to by @res.
83 *
84 * Return:
85 * 1) false with res->flags setting to zero: not the expected resource type
86 * 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource
87 * 3) true: valid assigned resource
83 */ 88 */
84bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res) 89bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)
85{ 90{
@@ -107,6 +112,7 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)
107 fixed_memory32->write_protect); 112 fixed_memory32->write_protect);
108 break; 113 break;
109 default: 114 default:
115 res->flags = 0;
110 return false; 116 return false;
111 } 117 }
112 118
@@ -145,6 +151,11 @@ static void acpi_dev_get_ioresource(struct resource *res, u64 start, u64 len,
145 * Check if the given ACPI resource object represents an I/O resource and 151 * Check if the given ACPI resource object represents an I/O resource and
146 * if that's the case, use the information in it to populate the generic 152 * if that's the case, use the information in it to populate the generic
147 * resource object pointed to by @res. 153 * resource object pointed to by @res.
154 *
155 * Return:
156 * 1) false with res->flags setting to zero: not the expected resource type
157 * 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource
158 * 3) true: valid assigned resource
148 */ 159 */
149bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res) 160bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res)
150{ 161{
@@ -165,6 +176,7 @@ bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res)
165 ACPI_DECODE_10); 176 ACPI_DECODE_10);
166 break; 177 break;
167 default: 178 default:
179 res->flags = 0;
168 return false; 180 return false;
169 } 181 }
170 182
@@ -214,12 +226,18 @@ static bool acpi_decode_space(struct resource *res,
214 * Check if the given ACPI resource object represents an address space resource 226 * Check if the given ACPI resource object represents an address space resource
215 * and if that's the case, use the information in it to populate the generic 227 * and if that's the case, use the information in it to populate the generic
216 * resource object pointed to by @res. 228 * resource object pointed to by @res.
229 *
230 * Return:
231 * 1) false with res->flags setting to zero: not the expected resource type
232 * 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource
233 * 3) true: valid assigned resource
217 */ 234 */
218bool acpi_dev_resource_address_space(struct acpi_resource *ares, 235bool acpi_dev_resource_address_space(struct acpi_resource *ares,
219 struct resource *res) 236 struct resource *res)
220{ 237{
221 struct acpi_resource_address64 addr; 238 struct acpi_resource_address64 addr;
222 239
240 res->flags = 0;
223 if (ACPI_FAILURE(acpi_resource_to_address64(ares, &addr))) 241 if (ACPI_FAILURE(acpi_resource_to_address64(ares, &addr)))
224 return false; 242 return false;
225 243
@@ -236,12 +254,18 @@ EXPORT_SYMBOL_GPL(acpi_dev_resource_address_space);
236 * Check if the given ACPI resource object represents an extended address space 254 * Check if the given ACPI resource object represents an extended address space
237 * resource and if that's the case, use the information in it to populate the 255 * resource and if that's the case, use the information in it to populate the
238 * generic resource object pointed to by @res. 256 * generic resource object pointed to by @res.
257 *
258 * Return:
259 * 1) false with res->flags setting to zero: not the expected resource type
260 * 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource
261 * 3) true: valid assigned resource
239 */ 262 */
240bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares, 263bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,
241 struct resource *res) 264 struct resource *res)
242{ 265{
243 struct acpi_resource_extended_address64 *ext_addr; 266 struct acpi_resource_extended_address64 *ext_addr;
244 267
268 res->flags = 0;
245 if (ares->type != ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64) 269 if (ares->type != ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64)
246 return false; 270 return false;
247 271
@@ -339,6 +363,11 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi,
339 * represented by the resource and populate the generic resource object pointed 363 * represented by the resource and populate the generic resource object pointed
340 * to by @res accordingly. If the registration of the GSI is not successful, 364 * to by @res accordingly. If the registration of the GSI is not successful,
341 * IORESOURCE_DISABLED will be set it that object's flags. 365 * IORESOURCE_DISABLED will be set it that object's flags.
366 *
367 * Return:
368 * 1) false with res->flags setting to zero: not the expected resource type
369 * 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource
370 * 3) true: valid assigned resource
342 */ 371 */
343bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, 372bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
344 struct resource *res) 373 struct resource *res)
@@ -372,6 +401,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
372 ext_irq->sharable, false); 401 ext_irq->sharable, false);
373 break; 402 break;
374 default: 403 default:
404 res->flags = 0;
375 return false; 405 return false;
376 } 406 }
377 407