pinctrl: core: handle pinctrl_get failure
diff mbox

Message ID 1441892286-18989-1-git-send-email-van.freenix@gmail.com
State New
Headers show

Commit Message

Peng Fan Sept. 10, 2015, 1:38 p.m. UTC
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(-)

Comments

Linus Walleij Sept. 25, 2015, 5:23 p.m. UTC | #1
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
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

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;