From patchwork Fri Nov 28 01:26:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Soren Brinkmann X-Patchwork-Id: 5400681 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@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 42C479F444 for ; Fri, 28 Nov 2014 01:29:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9AE6F2012B for ; Fri, 28 Nov 2014 01:29:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ADED02012D for ; Fri, 28 Nov 2014 01:29:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751067AbaK1B1I (ORCPT ); Thu, 27 Nov 2014 20:27:08 -0500 Received: from mail-oi0-f43.google.com ([209.85.218.43]:60461 "EHLO mail-oi0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751454AbaK1B1G (ORCPT ); Thu, 27 Nov 2014 20:27:06 -0500 Received: by mail-oi0-f43.google.com with SMTP id a3so4101335oib.30 for ; Thu, 27 Nov 2014 17:27:06 -0800 (PST) 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 :mime-version:content-type:content-transfer-encoding; bh=euNUzsA7YW+UV/jKVznmmXWKPp4PpU5sLSElhnZ+XtA=; b=nTOWOXs4Z28Yr/H8t0Nqob1G8nZn+RrGUGaFpMfB/HPBpERg2xLj9vn/TTzQeI/wFx NaNBT2j2687kU5G3K5rGpR1cIlKMZaHgPJn7SxD/Qih1UdyFdh6v7dHxQLYiW5IWFVT2 USdNHpWgxjgUreKUM7O8Z3dfEf6cC63rkgjMgDCyq3mXUrQx8PF9Vn3OklL2TvKP+f/L SFpQevlAxNdxwKdcfNJkNiI/staqPes3zWxsrAR7IGkXUUORFcY4Tcat5n9wlI9T0Z7R /HvwzXYUpn4MJR49JoZOBj1UfF4Ed96ONBXtKzS5k2HaIqzfk8dVXBvCTi44qcbQUaKG d0Sw== X-Received: by 10.202.74.198 with SMTP id x189mr23967239oia.50.1417138025999; Thu, 27 Nov 2014 17:27:05 -0800 (PST) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id x138sm3838522oie.8.2014.11.27.17.27.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Nov 2014 17:27:05 -0800 (PST) From: Soren Brinkmann To: Linus Walleij Cc: =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , Michal Simek , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alessandro Rubini , Heiko Stuebner , Laurent Pinchart , linux-rockchip@lists.infradead.org, linux-sh@vger.kernel.org, "Ivan T. Ivanov" , Bjorn Andersson , Beniamino Galvani Subject: [PATCH v2 1/7] pinctrl: pinconf-generic: Infer map type from DT property Date: Thu, 27 Nov 2014 17:26:27 -0800 Message-Id: <1417137993-8337-2-git-send-email-soren.brinkmann@xilinx.com> X-Mailer: git-send-email 2.1.3.1.ge241007 In-Reply-To: <1417137993-8337-1-git-send-email-soren.brinkmann@xilinx.com> References: <1417137993-8337-1-git-send-email-soren.brinkmann@xilinx.com> MIME-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable 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 Tested-by: Andreas Färber --- Changes since RFC v2: - none --- 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 f78b416d7984..1e782a0d6e48 100644 --- a/drivers/pinctrl/pinconf-generic.c +++ b/drivers/pinctrl/pinconf-generic.c @@ -264,6 +264,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) { @@ -284,10 +285,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; @@ -296,7 +307,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 d578a60eff23..b6dedfbfce69 100644 --- a/include/linux/pinctrl/pinconf-generic.h +++ b/include/linux/pinctrl/pinconf-generic.h @@ -174,6 +174,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 */