lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1437486658-28365-10-git-send-email-tomeu.vizoso@collabora.com>
Date:	Tue, 21 Jul 2015 15:50:51 +0200
From:	Tomeu Vizoso <tomeu.vizoso@...labora.com>
To:	linux-kernel@...r.kernel.org
Cc:	Stephen Warren <swarren@...dotorg.org>,
	"Rafael J. Wysocki" <rjw@...ysocki.net>,
	linux-arm-kernel@...ts.infradead.org,
	Arnd Bergmann <arnd@...db.de>, Mark Brown <broonie@...nel.org>,
	Tomeu Vizoso <tomeu.vizoso@...labora.com>
Subject: [RFC PATCH 09/16] Add DEVM_GPIO_NAMED()

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@...labora.com>
---

 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 <linux/kernel.h>
 
 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)
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ