From: Jeffy Chen <jeffy.chen@rock-chips.com>
To: linux-kernel@vger.kernel.org
Cc: Jeffy Chen <jeffy.chen@rock-chips.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>
Subject: [PATCH] regulator: core: Fix device link error when registering regulator
Date: Thu, 11 Oct 2018 19:32:39 +0800 [thread overview]
Message-ID: <20181011113239.2789-1-jeffy.chen@rock-chips.com> (raw)
The sysfs device link can only be created after regulator device
registered.
Fixes: c438b9d017362 ("regulator: core: Move registration of regulator device")
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
drivers/regulator/core.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 2c66b528aedec..36e650b61f7a9 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1405,12 +1405,15 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
if (regulator->supply_name == NULL)
goto overflow_err;
- err = sysfs_create_link_nowarn(&rdev->dev.kobj, &dev->kobj,
- buf);
- if (err) {
- rdev_dbg(rdev, "could not add device link %s err %d\n",
- dev->kobj.name, err);
- /* non-fatal */
+ if (device_is_registered(dev)) {
+ err = sysfs_create_link_nowarn(&rdev->dev.kobj,
+ &dev->kobj, buf);
+ if (err) {
+ rdev_dbg(rdev,
+ "could not add device link %s err %d\n",
+ dev->kobj.name, err);
+ /* non-fatal */
+ }
}
} else {
regulator->supply_name = kstrdup_const(supply_name, GFP_KERNEL);
@@ -4416,6 +4419,18 @@ regulator_register(const struct regulator_desc *regulator_desc,
goto unset_supplies;
}
+ /* Add a link to the device sysfs entry */
+ if (rdev->supply && rdev->supply->dev) {
+ ret = sysfs_create_link_nowarn(&rdev->supply->dev->kobj,
+ &rdev->dev.kobj,
+ rdev->supply->supply_name);
+ if (ret) {
+ rdev_dbg(rdev, "could not add device link %s err %d\n",
+ rdev->dev.kobj.name, ret);
+ /* non-fatal */
+ }
+ }
+
rdev_init_debugfs(rdev);
/* try to resolve regulators supply since a new one was registered */
--
2.11.0
reply other threads:[~2018-10-11 11:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20181011113239.2789-1-jeffy.chen@rock-chips.com \
--to=jeffy.chen@rock-chips.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®