From: Paul Sokolovsky <pmiscml@gmail.com>
To: linux-arm-kernel@lists.arm.linux.org.uk, linux-kernel@vger.kernel.org
Cc: David Brownell <david-b@pacbell.net>
Subject: [RFC, PATCH 1/3] gpiodev - API definitions
Date: Wed, 11 Apr 2007 00:30:58 +0300 [thread overview]
Message-ID: <774343545.20070411003058@gmail.com> (raw)
Hello linux-arm-kernel,
GPIODEV API: Core API definitions. Provided are:
1. struct gpiodev_ops which must be included into platform_data structure
of a device which will provide GPIODEV API; driver for a device must
initialize this structure.
2. Structural definition of generalized GPIO identifier (struct gpio).
2. Set of API calls for clients. This fully follow Generic GPIO API
naming and semantics, except that they have "gpiodev" prefix and
accept struct gpio instead of integer gpio identifiers.
Index: include/linux/gpiodev.h
===================================================================
RCS file: include/linux/gpiodev.h
diff -N include/linux/gpiodev.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/linux/gpiodev.h 10 Apr 2007 19:17:12 -0000 1.5
@@ -0,0 +1,43 @@
+#ifndef __GPIODEV_H
+#define __GPIODEV_H
+
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <asm/gpio.h>
+
+/* Interface */
+
+/* This structure must be first member of device platform_data structure
+ of a device which provides gpiodev interface */
+struct gpiodev_ops {
+ int (*get)(struct device *this, int gpio_no);
+ void (*set)(struct device *this, int gpio_no, int val);
+ int (*to_irq)(struct device *this, int gpio_no);
+};
+
+/* Generalized GPIO structure */
+
+struct gpio {
+ struct platform_device *gpio_dev;
+ int gpio_no;
+};
+
+/* API functions */
+
+static inline int gpiodev_get_value(struct gpio *gpio)
+{
+ struct gpiodev_ops *ops = gpio->gpio_dev->dev.platform_data;
+ return ops->get(&gpio->gpio_dev->dev, gpio->gpio_no);
+}
+static inline void gpiodev_set_value(struct gpio *gpio, int val)
+{
+ struct gpiodev_ops *ops = gpio->gpio_dev->dev.platform_data;
+ ops->set(&gpio->gpio_dev->dev, gpio->gpio_no, val);
+}
+static inline int gpiodev_to_irq(struct gpio *gpio)
+{
+ struct gpiodev_ops *ops = gpio->gpio_dev->dev.platform_data;
+ return ops->to_irq(&gpio->gpio_dev->dev, gpio->gpio_no);
+}
+
+#endif /* __GPIODEV_H */
--
Best regards,
Paul mailto:pmiscml@gmail.com
next reply other threads:[~2007-04-10 21:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-10 21:30 Paul Sokolovsky [this message]
2007-04-11 0:30 ` [RFC, PATCH 1/3] gpiodev - API definitions Eric Miao
2007-04-11 2:11 ` Paul Sokolovsky
2007-04-11 6:47 ` Juergen Schindele
2007-04-11 7:42 ` Russell King
2007-04-12 14:31 ` Paul Sokolovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=774343545.20070411003058@gmail.com \
--to=pmiscml@gmail.com \
--cc=david-b@pacbell.net \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox