From: Thierry Reding <thierry.reding@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] pinctrl: Add device link between pin controller and GPIO
Date: Fri, 21 Jun 2019 17:24:13 +0200 [thread overview]
Message-ID: <20190621152413.21361-1-thierry.reding@gmail.com> (raw)
From: Thierry Reding <treding@nvidia.com>
When a GPIO controller registers a pin range with a pin controller,
establish a device link between them in order to keep track of the
dependency, which will help keep the right suspend/resume ordering.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/pinctrl/core.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index b70df27874d1..5079e8a5de61 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -404,6 +404,17 @@ void pinctrl_add_gpio_range(struct pinctrl_dev *pctldev,
mutex_lock(&pctldev->mutex);
list_add_tail(&range->node, &pctldev->gpio_ranges);
mutex_unlock(&pctldev->mutex);
+
+ if (range->gc) {
+ struct device_link *link;
+
+ link = device_link_add(range->gc->parent, pctldev->dev,
+ DL_FLAG_AUTOREMOVE_CONSUMER);
+ if (!link)
+ dev_err(pctldev->dev,
+ "failed to add device link to %s\n",
+ dev_name(range->gc->parent));
+ }
}
EXPORT_SYMBOL_GPL(pinctrl_add_gpio_range);
@@ -2136,8 +2147,12 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev)
pinctrl_free_pindescs(pctldev, pctldev->desc->pins,
pctldev->desc->npins);
/* remove gpio ranges map */
- list_for_each_entry_safe(range, n, &pctldev->gpio_ranges, node)
+ list_for_each_entry_safe(range, n, &pctldev->gpio_ranges, node) {
+ if (range->gc)
+ device_link_remove(range->gc->parent, pctldev->dev);
+
list_del(&range->node);
+ }
mutex_unlock(&pctldev->mutex);
mutex_destroy(&pctldev->mutex);
--
2.21.0
next reply other threads:[~2019-06-21 15:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-21 15:24 Thierry Reding [this message]
2019-06-24 22:36 ` [PATCH] pinctrl: Add device link between pin controller and GPIO Linus Walleij
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=20190621152413.21361-1-thierry.reding@gmail.com \
--to=thierry.reding@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).