From patchwork Sun Feb 23 14:20:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 3703951 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6E3B1BF13A for ; Sun, 23 Feb 2014 14:23:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 860B5201BF for ; Sun, 23 Feb 2014 14:23:20 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A19B201BC for ; Sun, 23 Feb 2014 14:23:19 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WHZww-0002yB-QU; Sun, 23 Feb 2014 14:22:35 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WHZwq-0001on-Eu; Sun, 23 Feb 2014 14:22:28 +0000 Received: from mail-ea0-x233.google.com ([2a00:1450:4013:c01::233]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WHZwA-0001hW-H7 for linux-arm-kernel@lists.infradead.org; Sun, 23 Feb 2014 14:21:49 +0000 Received: by mail-ea0-f179.google.com with SMTP id q10so2563053ead.24 for ; Sun, 23 Feb 2014 06:21:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0KbpbuV3XqTFRy7VZivbtu/VzcEK++LxIzYLHwxaL8U=; b=TJnkldSB8MJklMIGRJJsj+yHW8p+EA+HMeOtRCMR42fD2HmZHK0iIfgHHr2uAYSz8w VJltbg/hZiuPFCiH5eu60loCiiJp2HLNlEbj1ifbVRRypb/KZ4bBF8PHYvmBI/VpRXtm owlx1DEzdth6Vl1SlbgRUHcOrtxr5GHHj60sVqVHj2ecmLpTSp+AlY8mKzwq8ikouvvE wGRNHSBo+2yCiDSVUCOhdMYHINEGekPYiHpHE82eNo6xkSc9MeyvNNRqMj0DBmLaWU2y /gTv0LGXRZcM9AiqotLDk6bDHHiwMYw2KD7YikAERBD3o0wMOTdVZozltlSAbZp4wDZx gf9g== X-Received: by 10.15.111.130 with SMTP id cj2mr19410272eeb.102.1393165284365; Sun, 23 Feb 2014 06:21:24 -0800 (PST) Received: from topkick.lan (dslc-082-083-251-183.pools.arcor-ip.net. [82.83.251.183]) by mx.google.com with ESMTPSA id j41sm51636687eeg.10.2014.02.23.06.21.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Feb 2014 06:21:23 -0800 (PST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH v4 01/16] pinctrl: mvebu: count unnamed controls and allocate name buffer Date: Sun, 23 Feb 2014 15:20:59 +0100 Message-Id: <1393165274-32492-2-git-send-email-sebastian.hesselbarth@gmail.com> In-Reply-To: <1393165274-32492-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1392220776-30851-1-git-send-email-sebastian.hesselbarth@gmail.com> <1393165274-32492-1-git-send-email-sebastian.hesselbarth@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140223_092146_818984_2E4D570B X-CRM114-Status: GOOD ( 12.41 ) X-Spam-Score: -2.0 (--) Cc: Thomas Petazzoni , Andrew Lunn , Jason Cooper , Linus Walleij , linux-kernel@vger.kernel.org, Ezequiel Garcia , Gregory Clement , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 pinctrl-mvebu allows SoCs to pass unnamed controls that will get an auto-generated name of "mpp". Currently, we are allocating name buffers on a per-control basis while looping over passed controls. This counts the total number of unnamed controls and allocates a global name buffer instead. The new buffer is then used while assigning controls to pinctrl groups later. Signed-off-by: Sebastian Hesselbarth Tested-by: Andrew Lunn Tested-by: Thomas Petazzoni --- Cc: Linus Walleij Cc: Jason Cooper Cc: Andrew Lunn Cc: Gregory Clement Cc: Thomas Petazzoni Cc: Ezequiel Garcia Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/pinctrl/mvebu/pinctrl-mvebu.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c index 0fd1ad31fbf9..d47650fc5119 100644 --- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c +++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c @@ -598,6 +598,9 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) void __iomem *base; struct pinctrl_pin_desc *pdesc; unsigned gid, n, k; + unsigned size, noname = 0; + char *noname_buf; + void *p; int ret; if (!soc || !soc->controls || !soc->modes) { @@ -660,6 +663,7 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) sprintf(names + 8*k, "mpp%d", ctrl->pid+k); ctrl->name = names; pctl->num_groups += ctrl->npins; + noname += ctrl->npins; } pdesc = devm_kzalloc(&pdev->dev, pctl->desc.npins * @@ -673,12 +677,17 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) pdesc[n].number = n; pctl->desc.pins = pdesc; - pctl->groups = devm_kzalloc(&pdev->dev, pctl->num_groups * - sizeof(struct mvebu_pinctrl_group), GFP_KERNEL); - if (!pctl->groups) { - dev_err(&pdev->dev, "failed to alloc pinctrl groups\n"); + /* + * allocate groups and name buffers for unnamed groups. + */ + size = pctl->num_groups * sizeof(*pctl->groups) + noname * 8; + p = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); + if (!p) { + dev_err(&pdev->dev, "failed to alloc group data\n"); return -ENOMEM; } + pctl->groups = p; + noname_buf = p + pctl->num_groups * sizeof(*pctl->groups); /* assign mpp controls to groups */ gid = 0; @@ -692,15 +701,20 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) /* generic mvebu register control maps to a number of groups */ if (!ctrl->mpp_get && !ctrl->mpp_set) { + pctl->groups[gid].name = noname_buf; pctl->groups[gid].npins = 1; + sprintf(noname_buf, "mpp%d", ctrl->pid+0); + noname_buf += 8; for (k = 1; k < ctrl->npins; k++) { gid++; pctl->groups[gid].gid = gid; pctl->groups[gid].ctrl = ctrl; - pctl->groups[gid].name = &ctrl->name[8*k]; + pctl->groups[gid].name = noname_buf; pctl->groups[gid].pins = &ctrl->pins[k]; pctl->groups[gid].npins = 1; + sprintf(noname_buf, "mpp%d", ctrl->pid+k); + noname_buf += 8; } } gid++;