From patchwork Sat Feb 2 16:29:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 2084401 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 8FBCE40148 for ; Sat, 2 Feb 2013 16:31:35 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U1fxK-00027b-DW; Sat, 02 Feb 2013 16:28:42 +0000 Received: from mail-pb0-f50.google.com ([209.85.160.50]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U1fwO-0001ln-5t for linux-arm-kernel@lists.infradead.org; Sat, 02 Feb 2013 16:27:47 +0000 Received: by mail-pb0-f50.google.com with SMTP id ro8so2584278pbb.23 for ; Sat, 02 Feb 2013 08:27:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=dbqknQsWFBu3PXDUhpzW+gKBdGltgnVDL2R7tcicDQA=; b=pJPU+C20I7uemvtPMjGnWUOqpyHkQVupFAG1F7dVx7Xl9/Qh96RfONJqMrXyqfbGwz J8107qU67LH+Gni4L3mjF2Vl3mf9zDzZKjlrp+Ip0YuCFBUmM1fgXnUndunTNyWUUtEB wVX9F6cw0MaoTs2Uo5DHzR0IaN/OctHhA+03gzXLGaEs/Uw+dgJQwMvSlkhu+QG6WrBH 15cgGDRAPuCbFb1CtttWqXASQXHYL/owil3JaNpEn8Vdr+bsHLQEskJTRV239ZWim/YW +pXPwdeIFwzBed8zDNZC/cTAu8u4ccwj0ArhPyBzL0IEYfbepxMAiHi71/GxgS4m9E3e YOeQ== X-Received: by 10.66.86.101 with SMTP id o5mr39117836paz.15.1359822463366; Sat, 02 Feb 2013 08:27:43 -0800 (PST) Received: from localhost.localdomain (softbank126010191003.bbtec.net. [126.10.191.3]) by mx.google.com with ESMTPS id vn2sm12100769pbc.31.2013.02.02.08.27.41 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 02 Feb 2013 08:27:42 -0800 (PST) From: Alexandre Courbot To: Grant Likely , Linus Walleij , Arnd Bergmann Subject: [PATCH 9/9] gpiolib: dynamically allocate descriptors array Date: Sun, 3 Feb 2013 01:29:32 +0900 Message-Id: <1359822572-26009-11-git-send-email-acourbot@nvidia.com> X-Mailer: git-send-email 1.8.1.1 In-Reply-To: <1359822572-26009-1-git-send-email-acourbot@nvidia.com> References: <1359822572-26009-1-git-send-email-acourbot@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130202_112744_330172_522AA419 X-CRM114-Status: GOOD ( 12.72 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.50 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (gnurou[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: linux-arch@vger.kernel.org, gnurou@gmail.com, Alexandre Courbot , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Allocate the GPIO descriptor's memory dynamically when GPIO chips are added instead of using the static gpio_desc[] array. gpio_desc[] is now totally unused and therefore removed. Signed-off-by: Alexandre Courbot Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 0247c48..893cf94 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -41,7 +41,7 @@ #define extra_checks 0 #endif -/* gpio_lock prevents conflicts during gpio_desc[] table updates. +/* gpio_lock prevents conflicts during gpio descriptors updates. * While any GPIO is requested, its gpio_chip is not removable; * each GPIO's "requested" flag serves as a lock and refcount. */ @@ -70,7 +70,6 @@ struct gpio_desc { const char *label; #endif }; -static struct gpio_desc gpio_desc[ARCH_NR_GPIOS]; #define GPIO_OFFSET_VALID(chip, offset) (offset >= 0 && offset < chip->ngpio) @@ -1163,6 +1162,13 @@ int gpiochip_add(struct gpio_chip *chip) goto fail; } + chip->desc = kzalloc(sizeof(struct gpio_desc) * chip->ngpio, + GFP_KERNEL); + if (!chip->desc) { + status = -ENOMEM; + goto fail; + } + spin_lock_irqsave(&gpio_lock, flags); if (base < 0) { @@ -1177,8 +1183,6 @@ int gpiochip_add(struct gpio_chip *chip) status = gpiochip_add_to_list(chip); if (status == 0) { - chip->desc = &gpio_desc[chip->base]; - for (id = 0; id < chip->ngpio; id++) { struct gpio_desc *desc = &chip->desc[id]; desc->chip = chip; @@ -1218,6 +1222,8 @@ unlock: return 0; fail: + kfree(chip->desc); + /* failures here can mean systems won't boot... */ pr_err("gpiochip_add: gpios %d..%d (%s) failed to register\n", chip->base, chip->base + chip->ngpio - 1, @@ -1261,6 +1267,8 @@ int gpiochip_remove(struct gpio_chip *chip) if (status == 0) gpiochip_unexport(chip); + kfree(chip->desc); + return status; } EXPORT_SYMBOL_GPL(gpiochip_remove);