From patchwork Wed Oct 19 16:21:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 4740 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 312B723DEF for ; Wed, 19 Oct 2011 16:21:36 +0000 (UTC) Received: from mail-gy0-f180.google.com (mail-gy0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id CD7EBA189EE for ; Wed, 19 Oct 2011 16:21:35 +0000 (UTC) Received: by gyf1 with SMTP id 1so2664900gyf.11 for ; Wed, 19 Oct 2011 09:21:35 -0700 (PDT) Received: by 10.223.77.71 with SMTP id f7mr11938958fak.33.1319041294940; Wed, 19 Oct 2011 09:21:34 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.1.71 with SMTP id 7cs90190lak; Wed, 19 Oct 2011 09:21:34 -0700 (PDT) Received: by 10.213.20.4 with SMTP id d4mr972067ebb.122.1319041290820; Wed, 19 Oct 2011 09:21:30 -0700 (PDT) Received: from eu1sys200aog114.obsmtp.com (eu1sys200aog114.obsmtp.com. [207.126.144.137]) by mx.google.com with SMTP id m12si2019088eeh.113.2011.10.19.09.21.25 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 19 Oct 2011 09:21:30 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.137 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.137; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.137 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob114.postini.com ([207.126.147.11]) with SMTP; Wed, 19 Oct 2011 16:21:30 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C1A8D185; Wed, 19 Oct 2011 16:21:11 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2ED9A25E5; Wed, 19 Oct 2011 16:21:11 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 6531A24C07C; Wed, 19 Oct 2011 18:21:02 +0200 (CEST) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 19 Oct 2011 18:21:10 +0200 From: Linus Walleij To: , Stephen Warren , Barry Song <21cnbao@gmail.com>, Shawn Guo Cc: Linaro Dev , Sascha Hauer , David Brown , Grant Likely , Linus Walleij Subject: [PATCH 1/2] pinctrl: move group lookup to core Date: Wed, 19 Oct 2011 18:21:06 +0200 Message-ID: <1319041266-18690-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.3.2 MIME-Version: 1.0 From: Linus Walleij Now also the core needs to look up pin groups so move the lookup function there and expose it in the internal header. Signed-off-by: Linus Walleij --- drivers/pinctrl/core.c | 31 +++++++++++++++++++++++++++++++ drivers/pinctrl/core.h | 2 ++ drivers/pinctrl/pinmux.c | 35 ++--------------------------------- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index b2eaf8d..478a002 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -284,6 +284,37 @@ void pinctrl_remove_gpio_range(struct pinctrl_dev *pctldev, mutex_unlock(&pctldev->gpio_ranges_lock); } +/** + * pinctrl_get_group_selector() - returns the group selector for a group + * @pctldev: the pin controller handling the group + * @pin_group: the pin group to look up + */ +int pinctrl_get_group_selector(struct pinctrl_dev *pctldev, + const char *pin_group) +{ + const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; + unsigned group_selector = 0; + + while (pctlops->list_groups(pctldev, group_selector) >= 0) { + const char *gname = pctlops->get_group_name(pctldev, + group_selector); + if (!strcmp(gname, pin_group)) { + dev_dbg(&pctldev->dev, + "found group selector %u for %s\n", + group_selector, + pin_group); + return group_selector; + } + + group_selector++; + } + + dev_err(&pctldev->dev, "does not have pin group %s\n", + pin_group); + + return -EINVAL; +} + #ifdef CONFIG_DEBUG_FS static int pinctrl_pins_show(struct seq_file *s, void *what) diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h index 17e0777..318f7a8 100644 --- a/drivers/pinctrl/core.h +++ b/drivers/pinctrl/core.h @@ -70,3 +70,5 @@ struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev, int pin); int pinctrl_get_device_gpio_range(unsigned gpio, struct pinctrl_dev **outdev, struct pinctrl_gpio_range **outrange); +int pinctrl_get_group_selector(struct pinctrl_dev *pctldev, + const char *pin_group); diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index 6544d98..64e1cdf 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -385,37 +385,6 @@ static void release_pins(struct pinctrl_dev *pctldev, } /** - * pinmux_get_group_selector() - returns the group selector for a group - * @pctldev: the pin controller handling the group - * @pin_group: the pin group to look up - */ -static int pinmux_get_group_selector(struct pinctrl_dev *pctldev, - const char *pin_group) -{ - const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; - unsigned group_selector = 0; - - while (pctlops->list_groups(pctldev, group_selector) >= 0) { - const char *gname = pctlops->get_group_name(pctldev, - group_selector); - if (!strcmp(gname, pin_group)) { - dev_dbg(&pctldev->dev, - "found group selector %u for %s\n", - group_selector, - pin_group); - return group_selector; - } - - group_selector++; - } - - dev_err(&pctldev->dev, "does not have pin group %s\n", - pin_group); - - return -EINVAL; -} - -/** * pinmux_check_pin_group() - check function and pin group combo * @pctldev: device to check the pin group vs function for * @func_selector: the function selector to check the pin group for, we have @@ -456,7 +425,7 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev, return ret; if (num_groups < 1) return -EINVAL; - ret = pinmux_get_group_selector(pctldev, groups[0]); + ret = pinctrl_get_group_selector(pctldev, groups[0]); if (ret < 0) { dev_err(&pctldev->dev, "function %s wants group %s but the pin " @@ -481,7 +450,7 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev, "check if we have pin group %s on controller %s\n", pin_group, pinctrl_dev_get_name(pctldev)); - ret = pinmux_get_group_selector(pctldev, pin_group); + ret = pinctrl_get_group_selector(pctldev, pin_group); if (ret < 0) { dev_dbg(&pctldev->dev, "%s does not support pin group %s with function %s\n",