From patchwork Tue Sep 30 07:14:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 394791 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 507391400D5 for ; Tue, 30 Sep 2014 17:15:29 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751109AbaI3HOY (ORCPT ); Tue, 30 Sep 2014 03:14:24 -0400 Received: from mail-wg0-f48.google.com ([74.125.82.48]:47505 "EHLO mail-wg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750945AbaI3HOX (ORCPT ); Tue, 30 Sep 2014 03:14:23 -0400 Received: by mail-wg0-f48.google.com with SMTP id l18so1880256wgh.19 for ; Tue, 30 Sep 2014 00:14:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Abig64K3X9ms2OzzNR9AQu0M+emCuoKYPC5V1VfVYTs=; b=lhcfGvA/Ab9k8cXgmrp9d1/fsa0qhrjM0y7UySfWdtiuyNwP46B/3uotrrXcm0OTXn bIIlAZK56al1M4U5SPrfriRF9Fa7sFm1bAZKcNAcmzUPcFcrlbie7nPCRxrnA3Fnvwu2 HisKD/2qztYEiVI4gnMVMSV3C31hU5SgFmFu4YdGGeCCZINfMrt3CnyLCKXD4mBwt+9N NtM3zQ3XDlcbfQ27HrPZZQpAyHoCULnRpvjStHsJoSt5romG2qUhS4bhJtW30eG7EFqb QA9AHhTLVZzYCWH4MEYY5gvp0TkEmxR1eGDvqKmrv+LiLOMALe02pu2y1pUEdPuGdqqT BJWg== X-Gm-Message-State: ALoCoQlrmf2EhE5ZYBdstabWg8BkbL/n9ywx+phao73Bzph11VEALa+ExmO5NBJnxYqM+BK2Rmf6 X-Received: by 10.180.101.129 with SMTP id fg1mr3455418wib.20.1412061262330; Tue, 30 Sep 2014 00:14:22 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id q5sm18143923wja.49.2014.09.30.00.14.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Sep 2014 00:14:21 -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/3] pinctrl: nomadik: use util function to reserve maps Date: Tue, 30 Sep 2014 09:14:18 +0200 Message-Id: <1412061258-20750-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Stop brewing our own pin map reservation function and use the generic code. Signed-off-by: Linus Walleij --- drivers/pinctrl/nomadik/pinctrl-nomadik.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c index c093d75a022a..9fe31daf9230 100644 --- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c +++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c @@ -32,6 +32,7 @@ #include #include "pinctrl-nomadik.h" #include "../core.h" +#include "../pinctrl-utils.h" /* * The GPIO module in the Nomadik family of Systems-on-Chip is an @@ -1349,28 +1350,6 @@ static void nmk_pinctrl_dt_free_map(struct pinctrl_dev *pctldev, kfree(map); } -static int nmk_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 nmk_dt_add_map_mux(struct pinctrl_map **map, unsigned *reserved_maps, unsigned *num_maps, const char *group, const char *function) @@ -1561,7 +1540,7 @@ static int nmk_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev, reserve *= ret; - ret = nmk_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;