From: Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>
To: Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH] of: Add of_platform_depopulate() helper
Date: Tue, 13 May 2014 17:08:44 +0100 [thread overview]
Message-ID: <1399997324.3657.35.camel@hornet> (raw)
In-Reply-To: <CAL_JsqLj5Jy1-fvtDYm=CH8J5R-okKyKxP4X-htONuzQWreVRQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Tue, 2014-05-13 at 14:19 +0100, Rob Herring wrote:
> On Tue, May 13, 2014 at 6:50 AM, Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org> wrote:
> > Drivers can us of_platform_populate() to create
> > platform devices for children of the device
> > main node (this can particularly happen in case
> > of MFD devices). Unfortunately, there was no
> > standard way of removing such sub-devices when
> > the main one is being removed.
> >
> > This patch adds of_platform_depopulate() as
> > a complementary operation for the _populate()
> > one. It removes all platform and amba devices
> > that have been created from the Device Tree,
> > but leaves all other ones untouched (returning
> > -EBUSY in such case).
> >
> > Signed-off-by: Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>
> > ---
> > drivers/of/platform.c | 52 +++++++++++++++++++++++++++++++++++++++++++++
> > include/linux/of_platform.h | 5 +++++
> > 2 files changed, 57 insertions(+)
> >
> > diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> > index 2d0c8b7..b5c49c3 100644
> > --- a/drivers/of/platform.c
> > +++ b/drivers/of/platform.c
> > @@ -495,4 +495,56 @@ int of_platform_populate(struct device_node *root,
> > return rc;
> > }
> > EXPORT_SYMBOL_GPL(of_platform_populate);
> > +
> > +static int of_platform_device_destroy(struct device *dev, void *data)
> > +{
> > + int *parents_children_left = data;
>
> You are not really tracking how many children are left, so this can
> just be a bool.
That's true.
> > + int my_children_left = 0;
> > +
> > + /* Do not touch devices not populated from the device tree */
> > + if (!dev->of_node || !of_node_check_flag(dev->of_node, OF_POPULATED)) {
> > + (*parents_children_left)++;
> > + return 0;
> > + }
> > +
> > + device_for_each_child(dev, &my_children_left,
> > + of_platform_device_destroy);
>
> Can't you call of_platform_depopulate here?
... and check its result instead of ? I guess I could. Will have a look
how it looks like.
Paweł
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-05-13 16:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-13 11:50 [PATCH] of: Add of_platform_depopulate() helper Pawel Moll
[not found] ` <1399981836-24837-1-git-send-email-pawel.moll-5wv7dgnIgG8@public.gmane.org>
2014-05-13 13:19 ` Rob Herring
[not found] ` <CAL_JsqLj5Jy1-fvtDYm=CH8J5R-okKyKxP4X-htONuzQWreVRQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-13 16:08 ` Pawel Moll [this message]
2014-05-13 16:24 ` [PATCH v2] of/platform: " Pawel Moll
[not found] ` <1399998294-24447-1-git-send-email-pawel.moll-5wv7dgnIgG8@public.gmane.org>
2014-05-14 11:08 ` Grant Likely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1399997324.3657.35.camel@hornet \
--to=pawel.moll-5wv7dgnigg8@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).