From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Ribalda Delgado Subject: [PATCH v3 2/4] base/platform: Only insert MEM and IO resources Date: Wed, 22 Apr 2015 18:14:19 +0200 Message-ID: <1429719261-18024-3-git-send-email-ricardo.ribalda@gmail.com> References: <1429719261-18024-1-git-send-email-ricardo.ribalda@gmail.com> Return-path: In-Reply-To: <1429719261-18024-1-git-send-email-ricardo.ribalda@gmail.com> Sender: linux-kernel-owner@vger.kernel.org To: Greg Kroah-Hartman , Grant Likely , Rob Herring , Andrew Morton , Jakub Sitnicki , Vivek Goyal , Bjorn Helgaas , Jiang Liu , Mike Travis , Thierry Reding , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Ricardo Ribalda Delgado List-Id: devicetree@vger.kernel.org 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 --- drivers/base/platform.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index ebf034b..6028681 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; -- 2.1.4