[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20150607142616.B21B3C4244B@trevor.secretlab.ca>
Date: Sun, 07 Jun 2015 15:26:16 +0100
From: Grant Likely <grant.likely@...aro.org>
To: Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Rob Herring <robh+dt@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Jakub Sitnicki <jsitnicki@...il.com>,
Vivek Goyal <vgoyal@...hat.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Jiang Liu <jiang.liu@...ux.intel.com>,
Mike Travis <travis@....com>,
Thierry Reding <treding@...dia.com>,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org
Cc: Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
Subject: Re: [PATCH v4 1/4] base/platform: Only insert MEM and IO resources
On Thu, 23 Apr 2015 15:58:11 +0200
, Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
wrote:
> 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@...il.com>
> ---
> 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;
This patch is correct in that it makes things balanced, but I don't
think it is the right behaviour. I've just posted a patch that does it
the other way around, based on a patch that Pantelis posted doing the
same thing, but without refactoring at the same time.
Instead of filtering out the non-MEM/IO resources, the new code checks
the parent pointer on removal, because that is the safe test of if a
resource has been registered in the first place.
g.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists