From: Johan Hovold <johan@kernel.org>
To: Octavian Purdila <octavian.purdila@intel.com>
Cc: gregkh@linuxfoundation.org, linus.walleij@linaro.org,
gnurou@gmail.com, wsa@the-dreams.de, sameo@linux.intel.com,
lee.jones@linaro.org, arnd@arndb.de, johan@kernel.org,
daniel.baluta@intel.com, laurentiu.palcu@intel.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org
Subject: Re: [PATCH v5 4/4] gpio: add support for the Diolan DLN-2 USB GPIO driver
Date: Wed, 24 Sep 2014 14:39:05 +0200 [thread overview]
Message-ID: <20140924123905.GB16198@localhost> (raw)
In-Reply-To: <1411158165-25794-5-git-send-email-octavian.purdila@intel.com>
On Fri, Sep 19, 2014 at 11:22:45PM +0300, Octavian Purdila wrote:
> +struct dln2_gpio {
> + struct platform_device *pdev;
> + struct gpio_chip gpio;
> +
> + /*
> + * Cache pin direction to save us one transfer, since the
> + * hardware has separate commands to read the in and out
> + * values. Bit set for out, bit clear for in.
> + */
> + DECLARE_BITMAP(pin_dir, DLN2_GPIO_MAX_PINS);
Using the more common name output_enabled might be preferred? Then you
can even get rid of (part of) the comment.
> +
> + DECLARE_BITMAP(irqs_masked, DLN2_GPIO_MAX_PINS);
> + DECLARE_BITMAP(irqs_enabled, DLN2_GPIO_MAX_PINS);
> + DECLARE_BITMAP(irqs_pending, DLN2_GPIO_MAX_PINS);
> + struct dln2_irq_work *irq_work;
> +};
[...]
> +#define DLN2_GPIO_DIRECTION_IN 0
> +#define DLN2_GPIO_DIRECTION_OUT 1
> +
> +static int dln2_gpio_request(struct gpio_chip *chip, unsigned offset)
> +{
> + struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio);
> + struct dln2_gpio_pin req = {
> + .pin = cpu_to_le16(offset),
> + };
> + struct dln2_gpio_pin_val rsp;
> + int len = sizeof(rsp);
> + int ret;
> +
> + ret = dln2_gpio_pin_cmd(dln2, DLN2_GPIO_PIN_ENABLE, offset);
> + if (ret < 0)
> + return ret;
> +
> + /* cache the pin direction */
> + ret = dln2_transfer(dln2->pdev, DLN2_GPIO_PIN_GET_DIRECTION,
> + &req, sizeof(req), &rsp, &len);
> + if (ret < 0)
> + return ret;
> + if (len < sizeof(rsp) || req.pin != rsp.pin)
> + return -EPROTO;
Disable the pin?
> +
> + switch (rsp.value) {
> + case DLN2_GPIO_DIRECTION_IN:
> + clear_bit(offset, dln2->pin_dir);
> + return 0;
> + case DLN2_GPIO_DIRECTION_OUT:
> + set_bit(offset, dln2->pin_dir);
> + return 0;
> + default:
> + return -EPROTO;
Disable the pin?
> + }
> +}
[...]
> +static struct platform_driver dln2_gpio_driver = {
> + .driver.name = "dln2-gpio",
> + .driver.owner = THIS_MODULE,
No need to set the owner field when using the module_platform_driver
macro.
> + .probe = dln2_gpio_probe,
> + .remove = dln2_gpio_remove,
> +};
> +
> +module_platform_driver(dln2_gpio_driver);
> +
> +MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com");
> +MODULE_DESCRIPTION("Driver for the Diolan DLN2 GPIO interface");
> +MODULE_LICENSE("GPL v2");
> +MODULE_ALIAS("platform:dln2-gpio");
Johan
next prev parent reply other threads:[~2014-09-24 12:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-19 20:22 [PATCH v5 0/4] mfd: add support for Diolan DLN-2 Octavian Purdila
[not found] ` <1411158165-25794-1-git-send-email-octavian.purdila-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-09-19 20:22 ` [PATCH v5 1/4] mfd: add support for Diolan DLN-2 devices Octavian Purdila
[not found] ` <1411158165-25794-2-git-send-email-octavian.purdila-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-09-24 10:48 ` Johan Hovold
2014-09-24 13:36 ` Octavian Purdila
2014-09-24 13:54 ` Johan Hovold
2014-09-24 14:54 ` Octavian Purdila
2014-09-24 15:07 ` Johan Hovold
2014-09-24 15:22 ` Octavian Purdila
2014-09-25 10:25 ` Octavian Purdila
2014-09-25 10:30 ` Johan Hovold
2014-09-25 10:41 ` Octavian Purdila
2014-09-25 10:43 ` Johan Hovold
2014-09-19 20:22 ` [PATCH v5 4/4] gpio: add support for the Diolan DLN-2 USB GPIO driver Octavian Purdila
2014-09-20 2:48 ` Arnd Bergmann
[not found] ` <201409200448.48180.arnd-r2nGTMty4D4@public.gmane.org>
2014-09-20 6:32 ` Octavian Purdila
2014-09-24 12:39 ` Johan Hovold [this message]
2014-09-19 20:22 ` [PATCH v5 2/4] i2c: add support for Diolan DLN-2 USB-I2C adapter Octavian Purdila
2014-09-24 10:58 ` Johan Hovold
2014-09-19 20:22 ` [PATCH v5 3/4] gpiolib: add irq_not_threaded flag to gpio_chip Octavian Purdila
2014-09-24 8:54 ` Linus Walleij
2014-09-24 11:01 ` Johan Hovold
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=20140924123905.GB16198@localhost \
--to=johan@kernel.org \
--cc=arnd@arndb.de \
--cc=daniel.baluta@intel.com \
--cc=gnurou@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=laurentiu.palcu@intel.com \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=octavian.purdila@intel.com \
--cc=sameo@linux.intel.com \
--cc=wsa@the-dreams.de \
/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;
as well as URLs for NNTP newsgroup(s).