Commit 36d4b292 authored by Ricardo Ribalda Delgado's avatar Ricardo Ribalda Delgado Committed by Greg Kroah-Hartman

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: default avatarRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e0fd9b1d
...@@ -341,19 +341,23 @@ int platform_device_add(struct platform_device *pdev) ...@@ -341,19 +341,23 @@ int platform_device_add(struct platform_device *pdev)
for (i = 0; i < pdev->num_resources; i++) { for (i = 0; i < pdev->num_resources; i++) {
struct resource *p, *r = &pdev->resource[i]; struct resource *p, *r = &pdev->resource[i];
unsigned long type = resource_type(r);
if (r->name == NULL) if (r->name == NULL)
r->name = dev_name(&pdev->dev); r->name = dev_name(&pdev->dev);
if (!(type == IORESOURCE_MEM || type == IORESOURCE_IO))
continue;
p = r->parent; p = r->parent;
if (!p) { if (!p) {
if (resource_type(r) == IORESOURCE_MEM) if (type == IORESOURCE_MEM)
p = &iomem_resource; p = &iomem_resource;
else if (resource_type(r) == IORESOURCE_IO) else if (type == IORESOURCE_IO)
p = &ioport_resource; 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); dev_err(&pdev->dev, "failed to claim resource %d\n", i);
ret = -EBUSY; ret = -EBUSY;
goto failed; goto failed;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment