From patchwork Sat Feb 2 16:29:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 2084381 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 2FD95DFE75 for ; Sat, 2 Feb 2013 16:31:34 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U1fwf-0001oo-0S; Sat, 02 Feb 2013 16:28:01 +0000 Received: from mail-da0-f46.google.com ([209.85.210.46]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U1fwB-0001jQ-Mi for linux-arm-kernel@lists.infradead.org; Sat, 02 Feb 2013 16:27:33 +0000 Received: by mail-da0-f46.google.com with SMTP id p5so2106385dak.33 for ; Sat, 02 Feb 2013 08:27:30 -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=5WI6hRuBkyjyCP2dzwlHsaxMaZ0YwY5z1n8kYVc8MCo=; b=AdwrSDiMC1CqjKMzhQnBgR8z0d5FDimBKrCHhbpjeMPrkC8QzX+zlp4IO53npsJkiM gp1X+47AHk6X0pIJZUTqFeDP+4PLStkArq+ikvGDmyzRuF3obW92LwlRoPZx8UDoApSl cHCTLrDtez7ldbb4oZdbL90mHepARsXlWIUgITZPTu4zAd0xL4R+RFtPg/6YlamN0F6v vBFcXeVeYziPDsIUTXc7ZNEIqZ7yyGFBDcLJh4pcZ7PESofubd/Aag4g3JkWjPKLH8Pv cgF29b+trA1vgds5wz8TNnJXN8GNzx1YTCC0PrKKK/Xh0+6jBK3PIvijUbbeFv7CMj+k G6Ww== X-Received: by 10.66.90.98 with SMTP id bv2mr22189165pab.19.1359822450713; Sat, 02 Feb 2013 08:27:30 -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.28 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 02 Feb 2013 08:27:30 -0800 (PST) From: Alexandre Courbot To: Grant Likely , Linus Walleij , Arnd Bergmann Subject: [PATCH 3/9] gpiolib: use gpio_chips list in gpiochip_find Date: Sun, 3 Feb 2013 01:29:26 +0900 Message-Id: <1359822572-26009-5-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_112731_894036_020FCFC7 X-CRM114-Status: GOOD ( 11.98 ) 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.210.46 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 Using the GPIO chips list is much faster than parsing the entire GPIO number space. Signed-off-by: Alexandre Courbot Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4ceb4a7..92f9ee4 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1194,20 +1194,17 @@ struct gpio_chip *gpiochip_find(void *data, int (*match)(struct gpio_chip *chip, void *data)) { - struct gpio_chip *chip = NULL; + struct gpio_chip *chip; unsigned long flags; - int i; spin_lock_irqsave(&gpio_lock, flags); - for (i = 0; i < ARCH_NR_GPIOS; i++) { - if (!gpio_desc[i].chip) - continue; - - if (match(gpio_desc[i].chip, data)) { - chip = gpio_desc[i].chip; + list_for_each_entry(chip, &gpio_chips, list) + if (match(chip, data)) break; - } - } + + /* No match? */ + if (&chip->list == &gpio_chips) + chip = NULL; spin_unlock_irqrestore(&gpio_lock, flags); return chip;