From patchwork Thu Nov 15 08:36:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 1747531 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 02A2C3FC64 for ; Thu, 15 Nov 2012 08:40:02 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TYuxJ-0003p0-SS; Thu, 15 Nov 2012 08:37:50 +0000 Received: from mail-pb0-f49.google.com ([209.85.160.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TYuwh-0003Zc-Dv for linux-arm-kernel@lists.infradead.org; Thu, 15 Nov 2012 08:37:12 +0000 Received: by mail-pb0-f49.google.com with SMTP id un15so937432pbc.36 for ; Thu, 15 Nov 2012 00:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=SmVUzpKRpOyIGmIZloqFZ729GSViUWQEmXL1ngoqqk8=; b=b4pBeNKbo5DuAuKoyMijPOeWKzSh05ZJd0/5P8vObvfJ/+KQ+ymqEwV72fAPkygJ3Q A7m5TMqh8QRu7y/2bncZnYHgHUyAVXzDx625xih3CjtICq5s01fp3FW5+wLdAzOwNWsc VAULWVz/cgOMJh+S8i8fV0aFXppG/4ufr/lxhB0ltARiD0SDTWW147WLnxQRCrGXuySB 2IEco2p62ueQZzLXdjnwLRSDFcsO9xXJI4zm+66Ja4j2IomXRNz9rvIuKgYnHCkimsO5 P6/Ycq2fFdYguzDRl01HubGHRjZgOwdwRIWW86ntkLNWIPKO6P8Eve54ODv1rwLXYUWt rlHg== Received: by 10.68.130.197 with SMTP id og5mr2346096pbb.138.1352968631195; Thu, 15 Nov 2012 00:37:11 -0800 (PST) Received: from localhost.localdomain ([174.139.116.75]) by mx.google.com with ESMTPS id ok8sm9176554pbb.42.2012.11.15.00.37.06 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Nov 2012 00:37:10 -0800 (PST) From: Haojian Zhuang To: linus.walleij@linaro.org, tony@atomide.com, swarren@wwwdotorg.org, linux-arm-kernel@lists.infradead.org, arnd@arndb.de Subject: [PATCH v5 03/10] pinctrl: append method of lookup pinctrl map Date: Thu, 15 Nov 2012 16:36:32 +0800 Message-Id: <1352968600-15345-4-git-send-email-haojian.zhuang@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1352968600-15345-1-git-send-email-haojian.zhuang@gmail.com> References: <1352968600-15345-1-git-send-email-haojian.zhuang@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121115_033711_664239_C3B1D106 X-CRM114-Status: GOOD ( 14.49 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (haojian.zhuang[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Haojian Zhuang X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org pinctrl driver gets pinctrl map if both group and map type is specified. In pinctrl-single driver, each pin group is defined in DT file. The pinconf information is also defined in each pin group. pinctrl-single driver could store those mask/shift/value information into pinctrl map. pinconf_get()/pinconf_set() and pinconf_group_get()/pinconf_group_set() could get those information from pinctrl map. Signed-off-by: Haojian Zhuang --- drivers/pinctrl/core.c | 24 ++++++++++++++++++++++++ include/linux/pinctrl/consumer.h | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 2e39c04..0d36270 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -839,6 +839,30 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) } EXPORT_SYMBOL_GPL(pinctrl_select_state); +const struct pinctrl_map *pinctrl_lookup_map(struct pinctrl *p, + const char *name, unsigned type) +{ + struct pinctrl_maps *maps_node; + struct pinctrl_map const *map; + int i; + + for_each_maps(maps_node, i, map) { + /* Map must be for this device */ + if (strcmp(map->ctrl_dev_name, dev_name(p->dev))) + continue; + if (map->type != type) + continue; + if (map->type == PIN_MAP_TYPE_MUX_GROUP) + if (!strcmp(map->data.mux.group, name)) + return map; + if (map->type == PIN_MAP_TYPE_CONFIGS_GROUP) + if (!strcmp(map->data.configs.group_or_pin, name)) + return map; + } + return NULL; +} +EXPORT_SYMBOL_GPL(pinctrl_lookup_map); + static void devm_pinctrl_release(struct device *dev, void *res) { pinctrl_put(*(struct pinctrl **)res); diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h index 4aad3ce..2687515 100644 --- a/include/linux/pinctrl/consumer.h +++ b/include/linux/pinctrl/consumer.h @@ -36,6 +36,10 @@ extern struct pinctrl_state * __must_check pinctrl_lookup_state( struct pinctrl *p, const char *name); extern int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *s); +extern const struct pinctrl_map * __must_check pinctrl_lookup_map( + struct pinctrl *p, + const char *name, + unsigned type); extern struct pinctrl * __must_check devm_pinctrl_get(struct device *dev); extern void devm_pinctrl_put(struct pinctrl *p);