* [PATCH] pinctrl: Add device link between pin controller and GPIO
@ 2019-06-21 15:24 Thierry Reding
2019-06-24 22:36 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Thierry Reding @ 2019-06-21 15:24 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio, linux-kernel
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] pinctrl: Add device link between pin controller and GPIO
2019-06-21 15:24 [PATCH] pinctrl: Add device link between pin controller and GPIO Thierry Reding
@ 2019-06-24 22:36 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2019-06-24 22:36 UTC (permalink / raw)
To: Thierry Reding; +Cc: open list:GPIO SUBSYSTEM, linux-kernel@vger.kernel.org
On Fri, Jun 21, 2019 at 5:24 PM Thierry Reding <thierry.reding@gmail.com> wrote:
> 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>
This make sense.
> + link = device_link_add(range->gc->parent, pctldev->dev,
> + DL_FLAG_AUTOREMOVE_CONSUMER);
What about parentless GPIO chips now again?
The parent field is optional, sad to say (yes I wish I could just
fix it all).
> + device_link_remove(range->gc->parent, pctldev->dev);
And here again.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-24 22:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-21 15:24 [PATCH] pinctrl: Add device link between pin controller and GPIO Thierry Reding
2019-06-24 22:36 ` Linus Walleij
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).