diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/platform.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 3f940393d6c7..66b710c28812 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -42,10 +42,8 @@ struct resource *platform_get_resource(struct platform_device *dev, | |||
42 | for (i = 0; i < dev->num_resources; i++) { | 42 | for (i = 0; i < dev->num_resources; i++) { |
43 | struct resource *r = &dev->resource[i]; | 43 | struct resource *r = &dev->resource[i]; |
44 | 44 | ||
45 | if ((r->flags & (IORESOURCE_IO|IORESOURCE_MEM| | 45 | if (type == resource_type(r) && num-- == 0) |
46 | IORESOURCE_IRQ|IORESOURCE_DMA)) == type) | 46 | return r; |
47 | if (num-- == 0) | ||
48 | return r; | ||
49 | } | 47 | } |
50 | return NULL; | 48 | return NULL; |
51 | } | 49 | } |
@@ -78,10 +76,8 @@ struct resource *platform_get_resource_byname(struct platform_device *dev, | |||
78 | for (i = 0; i < dev->num_resources; i++) { | 76 | for (i = 0; i < dev->num_resources; i++) { |
79 | struct resource *r = &dev->resource[i]; | 77 | struct resource *r = &dev->resource[i]; |
80 | 78 | ||
81 | if ((r->flags & (IORESOURCE_IO|IORESOURCE_MEM| | 79 | if (type == resource_type(r) && !strcmp(r->name, name)) |
82 | IORESOURCE_IRQ|IORESOURCE_DMA)) == type) | 80 | return r; |
83 | if (!strcmp(r->name, name)) | ||
84 | return r; | ||
85 | } | 81 | } |
86 | return NULL; | 82 | return NULL; |
87 | } | 83 | } |
@@ -259,9 +255,9 @@ int platform_device_add(struct platform_device *pdev) | |||
259 | 255 | ||
260 | p = r->parent; | 256 | p = r->parent; |
261 | if (!p) { | 257 | if (!p) { |
262 | if (r->flags & IORESOURCE_MEM) | 258 | if (resource_type(r) == IORESOURCE_MEM) |
263 | p = &iomem_resource; | 259 | p = &iomem_resource; |
264 | else if (r->flags & IORESOURCE_IO) | 260 | else if (resource_type(r) == IORESOURCE_IO) |
265 | p = &ioport_resource; | 261 | p = &ioport_resource; |
266 | } | 262 | } |
267 | 263 | ||
@@ -282,9 +278,14 @@ int platform_device_add(struct platform_device *pdev) | |||
282 | return ret; | 278 | return ret; |
283 | 279 | ||
284 | failed: | 280 | failed: |
285 | while (--i >= 0) | 281 | while (--i >= 0) { |
286 | if (pdev->resource[i].flags & (IORESOURCE_MEM|IORESOURCE_IO)) | 282 | struct resource *r = &pdev->resource[i]; |
287 | release_resource(&pdev->resource[i]); | 283 | unsigned long type = resource_type(r); |
284 | |||
285 | if (type == IORESOURCE_MEM || type == IORESOURCE_IO) | ||
286 | release_resource(r); | ||
287 | } | ||
288 | |||
288 | return ret; | 289 | return ret; |
289 | } | 290 | } |
290 | EXPORT_SYMBOL_GPL(platform_device_add); | 291 | EXPORT_SYMBOL_GPL(platform_device_add); |
@@ -306,7 +307,9 @@ void platform_device_del(struct platform_device *pdev) | |||
306 | 307 | ||
307 | for (i = 0; i < pdev->num_resources; i++) { | 308 | for (i = 0; i < pdev->num_resources; i++) { |
308 | struct resource *r = &pdev->resource[i]; | 309 | struct resource *r = &pdev->resource[i]; |
309 | if (r->flags & (IORESOURCE_MEM|IORESOURCE_IO)) | 310 | unsigned long type = resource_type(r); |
311 | |||
312 | if (type == IORESOURCE_MEM || type == IORESOURCE_IO) | ||
310 | release_resource(r); | 313 | release_resource(r); |
311 | } | 314 | } |
312 | } | 315 | } |