From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
To: Rob Herring <robh@kernel.org>, Frank Rowand <frowand.list@gmail.com>
Cc: Pawel Moll <pawel.moll@arm.com>,
Grant Likely <grant.likely@secretlab.ca>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] of/platform: depopulate devices in the reverse order of creation
Date: Mon, 12 Dec 2016 11:39:05 -0700 [thread overview]
Message-ID: <20161212183905.GA30702@obsidianresearch.com> (raw)
If the DT has inter-dependencies, then the devices need to be removed
in the right order to avoid removal problems.
Assuming the DT is constructed so that EPROBE_DEFER doesn't happen
during creating then a good way to avoid removal problems is reversing
the order during depopulation.
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
drivers/of/platform.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
In my specific case I have a gpio driver, followed by a i2c bitbang
using that driver. So gpiolib prints an error if it the gpio driver is
removed before the gpio client..
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index cd72c0156db2ba..5720fe44f991e9 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -568,7 +568,8 @@ static int of_platform_device_destroy(struct device *dev, void *data)
void of_platform_depopulate(struct device *parent)
{
if (parent->of_node && of_node_check_flag(parent->of_node, OF_POPULATED_BUS)) {
- device_for_each_child(parent, NULL, of_platform_device_destroy);
+ device_for_each_child_reverse(parent, NULL,
+ of_platform_device_destroy);
of_node_clear_flag(parent->of_node, OF_POPULATED_BUS);
}
}
--
2.7.4
next reply other threads:[~2016-12-12 18:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-12 18:39 Jason Gunthorpe [this message]
2016-12-14 20:54 ` [PATCH] of/platform: depopulate devices in the reverse order of creation Rob Herring
2016-12-14 21:40 ` Jason Gunthorpe
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=20161212183905.GA30702@obsidianresearch.com \
--to=jgunthorpe@obsidianresearch.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=grant.likely@secretlab.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=pawel.moll@arm.com \
--cc=robh@kernel.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