From patchwork Tue Jul 21 13:50:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6836351 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6EBC9C05AC for ; Tue, 21 Jul 2015 13:56:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C57A2069A for ; Tue, 21 Jul 2015 13:56:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C1AD220670 for ; Tue, 21 Jul 2015 13:56:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHXzt-0005sq-Nc; Tue, 21 Jul 2015 13:54:17 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHXy6-0004nN-Dj for linux-arm-kernel@bombadil.infradead.org; Tue, 21 Jul 2015 13:52:26 +0000 Received: from mail-wi0-x232.google.com ([2a00:1450:400c:c05::232]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHXy3-00074A-SZ for linux-arm-kernel@lists.infradead.org; Tue, 21 Jul 2015 13:52:24 +0000 Received: by wicmv11 with SMTP id mv11so42322118wic.0 for ; Tue, 21 Jul 2015 06:52:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=YeeYMLk6tUXWAN6aVB+IZ/ZdS7T7FOGW8e8708lyGuc=; b=HueczMgv4jL9VefjtQuJTHqhYcFstYV/Z6piUaF80GyG9ExDZAFX5pCijKvdX/KHBm wF/4QW+zeHpmPxWR4E9BpJVNJ7KJbYRzFPXgQXDWLc/jsCYEkzZ3XKaUIXVIHVFfzPFh E4KxRoMv6jmDClFfAlYme67jlSVsf12+l2L39MUKv1Z+dAb0VL/ONz3WaKpcumzoUnYr JVDQEZT6Zgvt0JRS3rOIjvUXPw9kR2dbPBNlEn6/dV9BglxFWsw/4tHsSMsjS3lLE0vI 53Eze1ZIs5y/7hsmUqnvUfV57a375p2Ln1jzdXB5VvBHRc8of3m9s8dfjyk+8stjyJsy iJEQ== X-Received: by 10.180.182.40 with SMTP id eb8mr31000979wic.47.1437486721708; Tue, 21 Jul 2015 06:52:01 -0700 (PDT) Received: from cizrna.lan ([109.72.12.178]) by smtp.gmail.com with ESMTPSA id pf4sm37172056wjb.23.2015.07.21.06.52.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jul 2015 06:52:00 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [RFC PATCH 09/16] Add DEVM_GPIO_NAMED() Date: Tue, 21 Jul 2015 15:50:51 +0200 Message-Id: <1437486658-28365-10-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1437486658-28365-1-git-send-email-tomeu.vizoso@collabora.com> References: <1437486658-28365-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150721_145223_959106_D034ADE8 X-CRM114-Status: GOOD ( 13.65 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Tomeu Vizoso , Stephen Warren , "Rafael J. Wysocki" , Mark Brown , linux-arm-kernel@lists.infradead.org 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=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 Signed-off-by: Tomeu Vizoso --- drivers/gpio/devres.c | 16 ++++++++++++++++ include/linux/gpio/consumer.h | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c index 07ba82317ece..b1e7a51ff72d 100644 --- a/drivers/gpio/devres.c +++ b/drivers/gpio/devres.c @@ -390,3 +390,19 @@ void devm_gpio_free(struct device *dev, unsigned int gpio) &gpio)); } EXPORT_SYMBOL(devm_gpio_free); + +int devm_acquire_gpio_named(struct device *dev, + const struct devm_resource *resource) +{ + struct gpio_desc *desc, **descp; + + desc = devm_get_gpiod_from_child(dev, resource->name, dev->fwnode); + if (IS_ERR(desc)) + return PTR_ERR(desc); + + descp = dev_get_drvdata(dev) + resource->offset; + *descp = desc; + + return 0; +} +EXPORT_SYMBOL(devm_acquire_gpio_named); diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index adac255aee86..df868f7c4dc7 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -6,6 +6,7 @@ #include struct device; +struct devm_resource; /** * Opaque descriptor for a GPIO. These are obtained using gpiod_get() and are @@ -139,6 +140,16 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, struct gpio_desc *devm_get_gpiod_from_child(struct device *dev, const char *con_id, struct fwnode_handle *child); + +int devm_acquire_gpio_named(struct device *dev, + const struct devm_resource *resource); + +#define DEVM_GPIO_NAMED(_struct, _member, _name) { \ + .initfunc = devm_acquire_gpio_named, \ + .offset = offsetof_t(struct _struct, _member, struct gpio_desc *),\ + .name = _name, \ +} + #else /* CONFIG_GPIOLIB */ static inline int gpiod_count(struct device *dev, const char *con_id)