From patchwork Sun Jul 6 17:47:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HIMANGI SARAOGI X-Patchwork-Id: 4490221 Return-Path: X-Original-To: patchwork-alsa-devel@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 DE559BEEAA for ; Sun, 6 Jul 2014 17:48:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14986202EC for ; Sun, 6 Jul 2014 17:48:15 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id D9491200CF for ; Sun, 6 Jul 2014 17:48:12 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id F1F6F265068; Sun, 6 Jul 2014 19:48:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id DD43F265086; Sun, 6 Jul 2014 19:48:06 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4ADA92650A0; Sun, 6 Jul 2014 19:48:05 +0200 (CEST) Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by alsa0.perex.cz (Postfix) with ESMTP id 035FF265068 for ; Sun, 6 Jul 2014 19:47:56 +0200 (CEST) Received: by mail-pd0-f176.google.com with SMTP id ft15so4124695pdb.35 for ; Sun, 06 Jul 2014 10:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=YqkcvE901FDwpOvafRcN8RC44NaRS5D5e6h8axAkV88=; b=vkeWTdF6/D8LyXKmwJ5R42xbzyL/puN/aJrbItYzuWo19xGE8cx8H1mByv/23x/Tr0 sJiQzHMV1yvQeKIrvv2btGMqoLdEPd/YPe8pcSU4l/f16Q5XU2cgY3P4+H+/sMefaj5U B6tGGJtD3KEFRYF0ovziVfbBZf7jDJUSwp/4gtX1h0NX60h5hWtb3+G1CpcYwamgm+r1 YY6i5xT4ADFPoipwcO9Cd4kh1PnTkzIoLlpSEPhhH4id1NS6+GiT8/Erb39NZnuiyG3r xHVsvwltyOZ6mROQTNrEoe7yxtCHyId+SptvhsjSJfvzMsI2mUjX8bHzkqlM3YCNfC1Z Dwog== X-Received: by 10.70.87.206 with SMTP id ba14mr23412348pdb.4.1404668875836; Sun, 06 Jul 2014 10:47:55 -0700 (PDT) Received: from localhost ([122.178.76.19]) by mx.google.com with ESMTPSA id xk3sm50219236pbb.65.2014.07.06.10.47.49 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 06 Jul 2014 10:47:54 -0700 (PDT) Date: Sun, 6 Jul 2014 23:17:46 +0530 From: Himangi Saraogi To: Linus Walleij , Alexandre Courbot , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Randy Dunlap , linux-doc@vger.kernel.org, Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , patches@opensource.wolfsonmicro.com, alsa-devel@alsa-project.org, Eric Miao , Russell King , Haojian Zhuang , linux-arm-kernel@lists.infradead.org, Philipp Zabel , Paul Parsons Message-ID: <1a1752ce7455bac8f2505a9790da891a830699f5.1404665589.git.himangi774@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: julia.lawall@lip6.fr Subject: [alsa-devel] [PATCH 1/5] gpiolib: devres: Introduce the function devm_request_gpio_array X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces the function devm_request_gpio_array that allocates multiple GPIOs in a single call in a managed manner. The function is also included in the documentation and a declaration is added in include/linux/gpio.h. Signed-off-by: Himangi Saraogi --- Documentation/driver-model/devres.txt | 1 + drivers/gpio/devres.c | 21 +++++++++++++++++++++ include/linux/gpio.h | 2 ++ 3 files changed, 24 insertions(+) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 9e2098e..756f6cf 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -337,6 +337,7 @@ GPIO devm_gpiod_put() devm_gpio_request() devm_gpio_request_one() + devm_gpio_request_array() devm_gpio_free() SND diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c index 65978cf..adae7fa 100644 --- a/drivers/gpio/devres.c +++ b/drivers/gpio/devres.c @@ -229,6 +229,27 @@ int devm_gpio_request_one(struct device *dev, unsigned gpio, EXPORT_SYMBOL(devm_gpio_request_one); /** + * devm_gpio_request_array - request multiple GPIOs in a single call + * @dev: device to request for + * @array: array of the 'struct gpio' + * @num: how many GPIOs in the array + */ +int devm_gpio_request_array(struct device *dev, const struct gpio *array, + size_t num) +{ + int i, err; + + for (i = 0; i < num; i++, array++) { + err = devm_gpio_request_one(dev, array->gpio, array->flags, + array->label); + if (err) + return err; + } + return 0; +} +EXPORT_SYMBOL_GPL(devm_gpio_request_array); + +/** * devm_gpio_free - free a GPIO * @dev: device to free GPIO for * @gpio: GPIO to free diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 85aa5d0..c85f243 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -84,6 +84,8 @@ struct device; int devm_gpio_request(struct device *dev, unsigned gpio, const char *label); int devm_gpio_request_one(struct device *dev, unsigned gpio, unsigned long flags, const char *label); +int devm_gpio_request_array(struct device *dev, const struct gpio *array, + size_t num); void devm_gpio_free(struct device *dev, unsigned int gpio); #else /* ! CONFIG_GPIOLIB */