From patchwork Tue Sep 30 09:22:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 38131 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ADCB6202DB for ; Tue, 30 Sep 2014 09:23:04 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id n15sf5320302lbi.3 for ; Tue, 30 Sep 2014 02:23:03 -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=/U1CUxg9ZT/DPK9tXoeJj4EXUms/SJDhDEFO+C14vr8=; b=PGRuE8BvA1oJjN5jgx1g+kQjiH9omqAGgrD/+vdzgoYlrHXl8a4L3cW5YAhvmH4SVR guhbPUJZU+Gv75Q7vvQTUEpW+o/ty5NI09ZvSWVBUUOZz3jKH8KrIy8tngogadkVJ4/O yRFLIE9zbuVOjVDUzuK8mX+a1Atdw09h131tsauLR0gRqQyTbJe8eoPd8k8n+fNriUE5 c8iAcUJDZEzWh5rI/0Hb6xTM6uuSaPpOMrZMGgl/gGCVbqUXKeTeYrm5h99giMkPQ4HC L//SiH07zLxcVErWhisxVr729Zq7Q/LZ60vuU8L46dikknv2osfQGrgFyDvnJ8zRW4wy /oQA== X-Gm-Message-State: ALoCoQkJI2Y2I6RwHOaL9DpV8S0JIFVWIPmQ4aPgSX1mgtM8n8dDD7SZcUBLFa6wisKqL35yplYo X-Received: by 10.180.221.236 with SMTP id qh12mr634600wic.4.1412068983429; Tue, 30 Sep 2014 02:23:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.2 with SMTP id p2ls20202lag.10.gmail; Tue, 30 Sep 2014 02:23:03 -0700 (PDT) X-Received: by 10.112.61.225 with SMTP id t1mr2241792lbr.104.1412068983243; Tue, 30 Sep 2014 02:23:03 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx.google.com with ESMTPS id gd7si21776664lbc.83.2014.09.30.02.23.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Sep 2014 02:23:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id z11so7862504lbi.27 for ; Tue, 30 Sep 2014 02:23:03 -0700 (PDT) X-Received: by 10.152.22.137 with SMTP id d9mr46234459laf.29.1412068983010; Tue, 30 Sep 2014 02:23:03 -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 of9csp312987lbb; Tue, 30 Sep 2014 02:23:02 -0700 (PDT) X-Received: by 10.66.156.42 with SMTP id wb10mr2757112pab.155.1412068981494; Tue, 30 Sep 2014 02:23:01 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7si26537972pdj.57.2014.09.30.02.23.00 for ; Tue, 30 Sep 2014 02:23:01 -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 S1755336AbaI3JW4 (ORCPT + 27 others); Tue, 30 Sep 2014 05:22:56 -0400 Received: from mail-we0-f170.google.com ([74.125.82.170]:49445 "EHLO mail-we0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753945AbaI3JWw (ORCPT ); Tue, 30 Sep 2014 05:22:52 -0400 Received: by mail-we0-f170.google.com with SMTP id q58so5119173wes.15 for ; Tue, 30 Sep 2014 02:22:51 -0700 (PDT) X-Received: by 10.194.120.101 with SMTP id lb5mr50347292wjb.84.1412068971691; Tue, 30 Sep 2014 02:22:51 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id hk8sm14482183wib.18.2014.09.30.02.22.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Sep 2014 02:22:50 -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 1/2] pinctrl: abx500: use helpers for map allocation/free Date: Tue, 30 Sep 2014 11:22:47 +0200 Message-Id: <1412068967-24253-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.182 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: , This switches the abx500 driver to use the pin control helper utils for allocating and free:ing maps. Signed-off-by: Linus Walleij --- drivers/pinctrl/nomadik/pinctrl-abx500.c | 43 ++++---------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c index b0289824cf73..be95f5e68c01 100644 --- a/drivers/pinctrl/nomadik/pinctrl-abx500.c +++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c @@ -34,6 +34,7 @@ #include "pinctrl-abx500.h" #include "../core.h" #include "../pinconf.h" +#include "../pinctrl-utils.h" /* * The AB9540 and AB8540 GPIO support are extended versions @@ -827,41 +828,6 @@ static void abx500_pin_dbg_show(struct pinctrl_dev *pctldev, chip->base + offset - 1); } -static void abx500_dt_free_map(struct pinctrl_dev *pctldev, - struct pinctrl_map *map, unsigned num_maps) -{ - int i; - - for (i = 0; i < num_maps; i++) - if (map[i].type == PIN_MAP_TYPE_CONFIGS_PIN) - kfree(map[i].data.configs.configs); - kfree(map); -} - -static int abx500_dt_reserve_map(struct pinctrl_map **map, - unsigned *reserved_maps, - unsigned *num_maps, - unsigned reserve) -{ - unsigned old_num = *reserved_maps; - unsigned new_num = *num_maps + reserve; - struct pinctrl_map *new_map; - - if (old_num >= new_num) - return 0; - - new_map = krealloc(*map, sizeof(*new_map) * new_num, GFP_KERNEL); - if (!new_map) - return -ENOMEM; - - memset(new_map + old_num, 0, (new_num - old_num) * sizeof(*new_map)); - - *map = new_map; - *reserved_maps = new_num; - - return 0; -} - static int abx500_dt_add_map_mux(struct pinctrl_map **map, unsigned *reserved_maps, unsigned *num_maps, const char *group, @@ -958,7 +924,8 @@ static int abx500_dt_subnode_to_map(struct pinctrl_dev *pctldev, reserve *= ret; - ret = abx500_dt_reserve_map(map, reserved_maps, num_maps, reserve); + ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps, + num_maps, reserve); if (ret < 0) goto exit; @@ -999,7 +966,7 @@ static int abx500_dt_node_to_map(struct pinctrl_dev *pctldev, ret = abx500_dt_subnode_to_map(pctldev, np, map, &reserved_maps, num_maps); if (ret < 0) { - abx500_dt_free_map(pctldev, *map, *num_maps); + pinctrl_utils_dt_free_map(pctldev, *map, *num_maps); return ret; } } @@ -1013,7 +980,7 @@ static const struct pinctrl_ops abx500_pinctrl_ops = { .get_group_pins = abx500_get_group_pins, .pin_dbg_show = abx500_pin_dbg_show, .dt_node_to_map = abx500_dt_node_to_map, - .dt_free_map = abx500_dt_free_map, + .dt_free_map = pinctrl_utils_dt_free_map, }; static int abx500_pin_config_get(struct pinctrl_dev *pctldev,