[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200704110847.01107.schindele@nentec.de>
Date: Wed, 11 Apr 2007 08:47:01 +0200
From: Juergen Schindele <schindele@...tec.de>
To: Paul Sokolovsky <pmiscml@...il.com>,
linux-arm-kernel@...ts.arm.linux.org.uk,
linux-kernel@...r.kernel.org
Subject: Re: [RFC, PATCH 1/3] gpiodev - API definitions
Am Dienstag, 10. April 2007 23:30 schrieb Paul Sokolovsky:
> 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;
wouldn't it be more sure to verify if xxx function is NOT null
before using it ?? Perhaps something like that
BUG_ON(!ops->get);
> + 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 */
--
--------------------------------------------------------------
Jürgen Schindele
Software-Entwicklung
NENTEC Netzwerktechnologie GmbH
Greschbachstr. 12
76229 Karlsruhe
Deutschland
Telefon: +49/721/94249-51
Telefax: +49/721/94249-10
E-Mail: schindele@...tec.de
WEB: www.nentec.de
Geschäftsführung: Klaus Becker, Roland Knapp
Sitz der Gesellschaft: Karlsruhe
Handelsregister: Amtsgericht Mannheim HRB 107658
Diese E-Mail enthält vertrauliche oder rechtlich geschützte Informationen.
Wenn Sie nicht der vorgesehene Empfänger sind, informieren Sie bitte sofort
den Absender und löschen Sie diese E-Mail. Das unbefugte Kopieren dieser E-Mail
oder die unbefugte Weitergabe der enthaltenen Informationen ist nicht gestattet.
The information contained in this message is confidential or protected by law.
If you are not the intended recipient, please contact the sender and delete this
message. Any unauthorised copying of this message or unauthorised distribution of
the information contained herein is prohibited.
--------------------------------------------------------------
-
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