From patchwork Tue Sep 30 09:22:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 38132 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3376A202DB for ; Tue, 30 Sep 2014 09:23:12 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id b13sf3257413wgh.1 for ; Tue, 30 Sep 2014 02:23:11 -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=dhyPSmB9ynp6FTUYu1JBWGlQ5do3OY28e7Gm4dBVHUw=; b=cq1owuQamjyZsDL6jJepl4cQfpYD1HVQP+gdHXr6naHNs/6BkjGbHLYk8ef1hnLEW6 Ivicg7DPOLM6aFWPAHK5Vz7C8WjL9kVD4RbQCTXkmd649cS93L2dn6Qt5Nwa831frBVc 2E/JO+IbWS28JY2js6/f+OPpY1FsWxzYfjqH3Omqj1BmdqdqvVXqBGR0+hsBtER2nkOj rAmWfgduw5f3SSnlldt6vHiKNtTSh9eesl2yuKI3YF90PQny838hFZHfxi7nBNuZj2yM 3rl8pYOZx41kAf7kNw3l+7Pvi355qmwIDQo4N7XU7ood7UCAVPtqjSZ6bKgNX+UOGaXb Yskg== X-Gm-Message-State: ALoCoQn6eZjy/uw2l9wpwYRztdkFdOArPH0Y2wz3q3Bck39K2eYF8bGkXOOnd6+TowVqtZdCVB3k X-Received: by 10.112.184.197 with SMTP id ew5mr6720295lbc.0.1412068991287; Tue, 30 Sep 2014 02:23:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.193 with SMTP id x1ls18212lae.53.gmail; Tue, 30 Sep 2014 02:23:11 -0700 (PDT) X-Received: by 10.152.23.69 with SMTP id k5mr46398999laf.70.1412068991148; Tue, 30 Sep 2014 02:23:11 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com [209.85.217.179]) by mx.google.com with ESMTPS id rc5si21716410lac.118.2014.09.30.02.23.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Sep 2014 02:23:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id l4so225017lbv.38 for ; Tue, 30 Sep 2014 02:23:11 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr11244320lad.40.1412068991077; Tue, 30 Sep 2014 02:23:11 -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 of9csp312993lbb; Tue, 30 Sep 2014 02:23:10 -0700 (PDT) X-Received: by 10.68.233.68 with SMTP id tu4mr69472124pbc.65.1412068989536; Tue, 30 Sep 2014 02:23:09 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si26451091pdl.112.2014.09.30.02.23.08 for ; Tue, 30 Sep 2014 02:23:09 -0700 (PDT) Received-SPF: none (google.com: linux-gpio-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 S1755356AbaI3JXE (ORCPT ); Tue, 30 Sep 2014 05:23:04 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:45803 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751091AbaI3JXD (ORCPT ); Tue, 30 Sep 2014 05:23:03 -0400 Received: by mail-wi0-f181.google.com with SMTP id n3so3906118wiv.8 for ; Tue, 30 Sep 2014 02:23:01 -0700 (PDT) X-Received: by 10.180.77.193 with SMTP id u1mr4144594wiw.45.1412068981397; Tue, 30 Sep 2014 02:23:01 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id ji10sm14493107wid.7.2014.09.30.02.22.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Sep 2014 02:23:00 -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 2/2] pinctrl: abx500: refactor DT parser to take two paths Date: Tue, 30 Sep 2014 11:22:57 +0200 Message-Id: <1412068977-24296-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-gpio@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.179 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-abx500.c | 54 +++++++++++++++++--------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c index be95f5e68c01..af0d417fe3fb 100644 --- a/drivers/pinctrl/nomadik/pinctrl-abx500.c +++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c @@ -893,19 +893,32 @@ static int abx500_dt_subnode_to_map(struct pinctrl_dev *pctldev, unsigned long *configs; unsigned int nconfigs = 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; + 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 = abx500_dt_add_map_mux(map, reserved_maps, + num_maps, group, function); + if (ret < 0) + goto exit; + } + } ret = pinconf_generic_parse_dt_config(np, &configs, &nconfigs); if (nconfigs) has_config = 1; - np_config = of_parse_phandle(np, "ste,config", 0); if (np_config) { ret = pinconf_generic_parse_dt_config(np_config, &configs, @@ -914,29 +927,18 @@ static int abx500_dt_subnode_to_map(struct pinctrl_dev *pctldev, goto exit; has_config |= nconfigs; } + if (has_config) { + ret = of_property_count_strings(np, "ste,pins"); + if (ret < 0) + goto exit; - 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; + 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) { - if (function) { - ret = abx500_dt_add_map_mux(map, reserved_maps, - num_maps, group, function); - if (ret < 0) - goto exit; - } - if (has_config) { + of_property_for_each_string(np, "ste,pins", prop, group) { gpio_name = abx500_find_pin_name(pctldev, group); ret = abx500_dt_add_map_configs(map, reserved_maps, @@ -944,8 +946,8 @@ static int abx500_dt_subnode_to_map(struct pinctrl_dev *pctldev, if (ret < 0) goto exit; } - } + exit: return ret; }