mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pinctrl: core: handle pinctrl_get failure
@ 2015-09-10 13:38 Peng Fan
  2015-09-25 17:23 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Peng Fan @ 2015-09-10 13:38 UTC (permalink / raw)
  To: linus.walleij, linux-kernel; +Cc: linux-gpio, van.freenix

Need to do error handling path when pinctrl_get fails. Also when
pinctrl_get success, insert 'pctldev->node' to pinctrldev_list.

Signed-off-by: Peng Fan <van.freenix@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/pinctrl/core.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 69723e0..ae6f9b6 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1753,10 +1753,6 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
 		goto out_err;
 	}
 
-	mutex_lock(&pinctrldev_list_mutex);
-	list_add_tail(&pctldev->node, &pinctrldev_list);
-	mutex_unlock(&pinctrldev_list_mutex);
-
 	pctldev->p = pinctrl_get(pctldev->dev);
 
 	if (!IS_ERR(pctldev->p)) {
@@ -1776,8 +1772,14 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
 						    PINCTRL_STATE_SLEEP);
 		if (IS_ERR(pctldev->hog_sleep))
 			dev_dbg(dev, "failed to lookup the sleep state\n");
+	} else {
+		goto out_err;
 	}
 
+	mutex_lock(&pinctrldev_list_mutex);
+	list_add_tail(&pctldev->node, &pinctrldev_list);
+	mutex_unlock(&pinctrldev_list_mutex);
+
 	pinctrl_init_device_debugfs(pctldev);
 
 	return pctldev;
-- 
1.8.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] pinctrl: core: handle pinctrl_get failure
  2015-09-10 13:38 [PATCH] pinctrl: core: handle pinctrl_get failure Peng Fan
@ 2015-09-25 17:23 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2015-09-25 17:23 UTC (permalink / raw)
  To: Peng Fan; +Cc: linux-kernel, linux-gpio

On Thu, Sep 10, 2015 at 6:38 AM, Peng Fan <van.freenix@gmail.com> wrote:

> Need to do error handling path when pinctrl_get fails. Also when
> pinctrl_get success, insert 'pctldev->node' to pinctrldev_list.
>
> Signed-off-by: Peng Fan <van.freenix@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>

I think this patch is totally wrong and you have probably not tested
it using pinctrl hogs.

pinctr_get() from self will *not work* unless the device is added to
the list *first*.

Dropping this.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-25 17:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-10 13:38 [PATCH] pinctrl: core: handle pinctrl_get failure Peng Fan
2015-09-25 17:23 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome