From patchwork Thu Oct 16 17:11:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soren Brinkmann X-Patchwork-Id: 5092991 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0888B9F30B for ; Thu, 16 Oct 2014 17:17:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 281242010F for ; Thu, 16 Oct 2014 17:17:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 367ED20107 for ; Thu, 16 Oct 2014 17:17:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xeocq-00089h-Qq; Thu, 16 Oct 2014 17:14:08 +0000 Received: from mail-pd0-x231.google.com ([2607:f8b0:400e:c02::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XeobL-0007Iw-FL for linux-arm-kernel@lists.infradead.org; Thu, 16 Oct 2014 17:12:36 +0000 Received: by mail-pd0-f177.google.com with SMTP id v10so3560224pde.22 for ; Thu, 16 Oct 2014 10:12:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=RjRlR3PH4kCRTEnIviJ3tJt6MSKHu5QblaLIhGqbOJA=; b=dNVmNhwfaQ5RVP9G0HLjQ8fgLXXImxxdSMYbtMtEel5xKcdSZpRKD6Ps041jZNWkxI iUcrsiT/N7+nE6k1lECM5x7wqAm5arDqn5R+AMj4A/Vg9mF/ZM46KfOuvsldxZ8d3YXG fLcnAr/RwS9Anq0JQn4JNmusK6iopnb9HLJc2r9FsIHc/ICniK2FH+gDabj5aMa7if2P evWco66dHCfazpDH9Xe0Q6IJWvnh1X3q37ScUCd8QAASO/k7Um8LNF303WzICuXnSyTh 0enud0jIZcLqu3iYk1dcxkxxa8EOaDNKj6mYiIDWhCzumOVNM1H7DFJcUN4+iA5LNcsh meNg== X-Received: by 10.68.216.70 with SMTP id oo6mr2795646pbc.124.1413479534660; Thu, 16 Oct 2014 10:12:14 -0700 (PDT) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id cw5sm20263192pbc.9.2014.10.16.10.12.13 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 16 Oct 2014 10:12:13 -0700 (PDT) From: Soren Brinkmann To: Linus Walleij Subject: [PATCH RFC v2 6/8] pinctrl: pinconf-generic: Infer map type from DT property Date: Thu, 16 Oct 2014 10:11:33 -0700 Message-Id: <1413479495-14206-7-git-send-email-soren.brinkmann@xilinx.com> X-Mailer: git-send-email 2.1.2.1.g5e69ed6 In-Reply-To: <1413479495-14206-1-git-send-email-soren.brinkmann@xilinx.com> References: <1413479495-14206-1-git-send-email-soren.brinkmann@xilinx.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141016_101235_622173_96108A35 X-CRM114-Status: GOOD ( 14.52 ) X-Spam-Score: -0.7 (/) Cc: linux-arm-kernel@lists.infradead.org, Steffen Trumtrar , Michal Simek , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With the new 'groups' property, the DT parser can infer the map type from the fact whether 'pins' or 'groups' is used to specify the pin group to work on. To maintain backwards compatibitliy with current usage of the DT binding, this is only done when an invalid map type is passed to the parsing function. Signed-off-by: Soren Brinkmann --- drivers/pinctrl/pinconf-generic.c | 17 ++++++++++++++--- include/linux/pinctrl/pinconf-generic.h | 7 +++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c index 17ac8f00e16b..38b21e6a36a8 100644 --- a/drivers/pinctrl/pinconf-generic.c +++ b/drivers/pinctrl/pinconf-generic.c @@ -266,6 +266,7 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev, unsigned reserve; struct property *prop; const char *group; + const char *dt_pin_specifier = "pins"; ret = of_property_read_string(np, "function", &function); if (ret < 0) { @@ -286,10 +287,20 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev, reserve++; if (num_configs) reserve++; + ret = of_property_count_strings(np, "pins"); if (ret < 0) { - dev_err(dev, "could not parse property pins\n"); - goto exit; + ret = of_property_count_strings(np, "groups"); + if (ret < 0) { + dev_err(dev, "could not parse property pins/groups\n"); + goto exit; + } + if (type == PIN_MAP_TYPE_INVALID) + type = PIN_MAP_TYPE_CONFIGS_GROUP; + dt_pin_specifier = "groups"; + } else { + if (type == PIN_MAP_TYPE_INVALID) + type = PIN_MAP_TYPE_CONFIGS_PIN; } reserve *= ret; @@ -298,7 +309,7 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev, if (ret < 0) goto exit; - of_property_for_each_string(np, "pins", prop, group) { + of_property_for_each_string(np, dt_pin_specifier, prop, group) { if (function) { ret = pinctrl_utils_add_map_mux(pctldev, map, reserved_maps, num_maps, group, diff --git a/include/linux/pinctrl/pinconf-generic.h b/include/linux/pinctrl/pinconf-generic.h index dd1d3251fb93..5a13bdf9dfc7 100644 --- a/include/linux/pinctrl/pinconf-generic.h +++ b/include/linux/pinctrl/pinconf-generic.h @@ -178,6 +178,13 @@ static inline int pinconf_generic_dt_node_to_map_pin( PIN_MAP_TYPE_CONFIGS_PIN); } +static inline int pinconf_generic_dt_node_to_map_all( + struct pinctrl_dev *pctldev, struct device_node *np_config, + struct pinctrl_map **map, unsigned *num_maps) +{ + return pinconf_generic_dt_node_to_map(pctldev, np_config, map, num_maps, + PIN_MAP_TYPE_INVALID); +} #endif #endif /* CONFIG_GENERIC_PINCONF */