diff options
author | Ricardo Ribalda Delgado | 2015-05-26 09:31:23 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2015-06-01 10:15:17 +0900 |
commit | 36d4b29260753ad78b1ce4363145332c02519adc (patch) | |
tree | cd1e26be2343ba475057caf1b9357bd9f5480958 /drivers/base | |
parent | e0fd9b1d9c44c0966e322046912a0a0bce237d42 (diff) |
base/platform: Only insert MEM and IO resources
platform_device_del only checks the type of the resource in order to
call release_resource.
On the other hand, platform_device_add calls insert_resource for any
resource that has a parent.
Make both code branches balanced.
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/platform.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 063f0ab15259..46a56f694cec 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -341,19 +341,23 @@ int platform_device_add(struct platform_device *pdev) for (i = 0; i < pdev->num_resources; i++) { struct resource *p, *r = &pdev->resource[i]; + unsigned long type = resource_type(r); if (r->name == NULL) r->name = dev_name(&pdev->dev); + if (!(type == IORESOURCE_MEM || type == IORESOURCE_IO)) + continue; + p = r->parent; if (!p) { - if (resource_type(r) == IORESOURCE_MEM) + if (type == IORESOURCE_MEM) p = &iomem_resource; - else if (resource_type(r) == IORESOURCE_IO) + else if (type == IORESOURCE_IO) p = &ioport_resource; } - if (p && insert_resource(p, r)) { + if (insert_resource(p, r)) { dev_err(&pdev->dev, "failed to claim resource %d\n", i); ret = -EBUSY; goto failed; |