From patchwork Tue Sep 30 07:14:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 38125 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 67E8D20549 for ; Tue, 30 Sep 2014 07:14:52 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id q1sf5146602lam.4 for ; Tue, 30 Sep 2014 00:14:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=jALKV56T/7kIGMptgll6uBn7DKRBMXeJ4Hrq9Ly3dZo=; b=YZ76N0PKuxmpOIBzCZ6iKchc7sm+2smrFway8g3rRItdYYC06Di7UiLCZrelJcgCwT ZPL7zRIyQJBPc52YDxsx81sOe6IuTJLbCCM0wl0Ndr+/MTyZ2ARyyEkpOFtwQzD877Sw khJ6+rjkenASrMKzNDCpGyeGnmH/Y5KXSXFH0Pf48N9kWxaZIAt/yM+gCX5RMfDROTEa 2JHHoRv2yIgXa9+y5aBh96N9lKGE11RK4ix3jEMSkly9jxVPDeXw7BXfXCuCXS5DmVZQ ntF9oCsuXvQLsgby7NEdM51SuDGn7RTJNOFzzyp4G1mGwHhRN2Ip5dVhvYfAiV2F08R6 M/vQ== X-Gm-Message-State: ALoCoQkwDBcNdo6/r0G9uueun+vs6h8Klfhv//hHvWKL9H68M2cqBq2rJQDcmRT/yH7m/9H76IqN X-Received: by 10.152.29.130 with SMTP id k2mr5762121lah.3.1412061291197; Tue, 30 Sep 2014 00:14:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.194 with SMTP id a2ls4067lak.41.gmail; Tue, 30 Sep 2014 00:14:50 -0700 (PDT) X-Received: by 10.152.28.8 with SMTP id x8mr42592362lag.80.1412061290891; Tue, 30 Sep 2014 00:14:50 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com [209.85.217.175]) by mx.google.com with ESMTPS id l1si21302062lbj.70.2014.09.30.00.14.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Sep 2014 00:14:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id u10so3874514lbd.34 for ; Tue, 30 Sep 2014 00:14:50 -0700 (PDT) X-Received: by 10.112.130.226 with SMTP id oh2mr8211407lbb.100.1412061290729; Tue, 30 Sep 2014 00:14:50 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp298882lbb; Tue, 30 Sep 2014 00:14:50 -0700 (PDT) X-Received: by 10.66.225.141 with SMTP id rk13mr66975276pac.112.1412061289286; Tue, 30 Sep 2014 00:14:49 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si19012104pde.105.2014.09.30.00.14.48 for ; Tue, 30 Sep 2014 00:14:49 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752965AbaI3HOn (ORCPT + 27 others); Tue, 30 Sep 2014 03:14:43 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:62297 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751488AbaI3HOl (ORCPT ); Tue, 30 Sep 2014 03:14:41 -0400 Received: by mail-wi0-f180.google.com with SMTP id em10so2714808wid.1 for ; Tue, 30 Sep 2014 00:14:40 -0700 (PDT) X-Received: by 10.194.189.233 with SMTP id gl9mr51020665wjc.2.1412061280343; Tue, 30 Sep 2014 00:14:40 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id td9sm14121186wic.15.2014.09.30.00.14.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Sep 2014 00:14:39 -0700 (PDT) From: Linus Walleij To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: linux-gpio@vger.kernel.org, Linus Walleij Subject: [PATCH 3/3] pinctrl: nomadik: refactor DT parser to take two paths Date: Tue, 30 Sep 2014 09:14:35 +0200 Message-Id: <1412061275-20829-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , We refactor the DT parser to look for either a config or a function and then look for further nodes and reserve maps, not the two things mixed up like prior to this patch. Signed-off-by: Linus Walleij --- drivers/pinctrl/nomadik/pinctrl-nomadik.c | 62 ++++++++++++++++--------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c index 6c9667a44b7b..09efb8c1a2eb 100644 --- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c +++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c @@ -1505,51 +1505,55 @@ static int nmk_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev, const char *function = NULL; unsigned long configs = 0; bool has_config = 0; - unsigned reserve = 0; struct property *prop; const char *group, *gpio_name; struct device_node *np_config; ret = of_property_read_string(np, "ste,function", &function); - if (ret >= 0) - reserve = 1; - - has_config = nmk_pinctrl_dt_get_config(np, &configs); - - np_config = of_parse_phandle(np, "ste,config", 0); - if (np_config) - has_config |= nmk_pinctrl_dt_get_config(np_config, &configs); - - ret = of_property_count_strings(np, "ste,pins"); - if (ret < 0) - goto exit; - - if (has_config) - reserve++; - - reserve *= ret; - - ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps, num_maps, reserve); - if (ret < 0) - goto exit; - - of_property_for_each_string(np, "ste,pins", prop, group) { - if (function) { + if (ret >= 0) { + ret = of_property_count_strings(np, "ste,pins"); + if (ret < 0) + goto exit; + + ret = pinctrl_utils_reserve_map(pctldev, map, + reserved_maps, + num_maps, ret); + if (ret < 0) + goto exit; + + of_property_for_each_string(np, "ste,pins", prop, group) { ret = nmk_dt_add_map_mux(map, reserved_maps, num_maps, group, function); if (ret < 0) goto exit; } - if (has_config) { + } + + has_config = nmk_pinctrl_dt_get_config(np, &configs); + np_config = of_parse_phandle(np, "ste,config", 0); + if (np_config) + has_config |= nmk_pinctrl_dt_get_config(np_config, &configs); + if (has_config) { + ret = of_property_count_strings(np, "ste,pins"); + if (ret < 0) + goto exit; + ret = pinctrl_utils_reserve_map(pctldev, map, + reserved_maps, + num_maps, ret); + if (ret < 0) + goto exit; + + of_property_for_each_string(np, "ste,pins", prop, group) { gpio_name = nmk_find_pin_name(pctldev, group); - ret = nmk_dt_add_map_configs(map, reserved_maps, num_maps, - gpio_name, &configs, 1); + ret = nmk_dt_add_map_configs(map, reserved_maps, + num_maps, + gpio_name, &configs, 1); if (ret < 0) goto exit; } - } + exit: return ret; }