From: Linus Walleij <linus.walleij@linaro.org>
To: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Alexandre Courbot <gnurou@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH] GPIO: Add GPIO support for the ACCES 104-IDIO-16
Date: Tue, 6 Oct 2015 09:19:30 +0200 [thread overview]
Message-ID: <CACRpkdaa3XT2gP0NXhz3Mw4SqOSaMmswLk_z8bk9j9Jrqy62kA@mail.gmail.com> (raw)
In-Reply-To: <56130A82.4000105@gmail.com>
On Tue, Oct 6, 2015 at 1:40 AM, William Breathitt Gray
<vilhelm.gray@gmail.com> wrote:
> On 10/05/2015 04:29 AM, Linus Walleij wrote:
>>> +struct a_104_idio_16_gpio {
>>> + struct gpio_chip chip;
>>> + spinlock_t lock;
>>> + unsigned base;
>>
>> Isn't this void __iomem *base?
>
> The 'base' member is used to hold the I/O port base address passed to the
> inb/outb functions for port-mapped I/O operations. Since the addresses are
> not dereferenced, I don't believe an __iomem pointer would be correct.
You're right, sorry I was confused.
>>> +static const unsigned A_104_IDIO_16_EXTENT = 8;
>>
>> Looks like it could be a #define A_104_IDIO_16_EXTENT 8
>
> I used a const variable for the benefit of type-safety; I assumed the
> compiler would optimize it. What is the advantage of a #define constant?
Usually we use #define's for compile-time constants.
>>> +static void __exit a_104_idio_16_exit(void)
>>> +{
>>> + pr_info("104-idio-16: Exiting 104-idio-16 module\n");
>>> +
>>> + gpiochip_remove(&gp.chip);
>>
>> Where is that &gp.chip? Not in this file. Nor should you use any globals.
>
> I agree that using a global data structure isn't good practice, but I'm not
> sure how else to expose the gpio_chip structure in the respective module
> _init and _exit functions since they have void parameter lists. Would it be
> more appropriate to use the platform device API in this situation to avoid
> the global data structure?
It depends where your device is spawn. If there is a natural place to
instantiate the platform device like from a MFD or PCI driver or something
then yes.
>>> +static int a_104_idio_16_gpio_get(struct gpio_chip *chip, unsigned offset)
>>> +{
>>> + struct a_104_idio_16_gpio *a104i16gp = to_a104i16gp(chip);
>>> + const unsigned BIT_MASK = 1U << (offset-16);
>>> +
>>> + if (offset < 16)
>>> + return 0;
>>
>> Always return 0, why? Is that really correct?
>
> GPIO 0-15 are output-only. The kerneldoc for 'struct gpio_chip' states that
> for output signals the get function should return the value actually sensed,
> or zero. Since I cannot sense the output signals, I return zero in these cases.
> Is this behavior correct?
I guess, we recently augmented the gpiolib core so you can actually
return an error code as -ENODEV here. No strong preference though.
Maybe I should have...
Yours,
Linus Walleij
prev parent reply other threads:[~2015-10-06 7:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-01 1:58 [PATCH] GPIO: Add GPIO support for the ACCES 104-IDIO-16 William Breathitt Gray
2015-10-02 11:15 ` kbuild test robot
2015-10-05 8:29 ` Linus Walleij
2015-10-05 22:47 ` Bjorn Helgaas
2015-10-05 23:11 ` William Breathitt Gray
2015-10-06 7:14 ` Linus Walleij
2015-10-05 23:40 ` William Breathitt Gray
2015-10-06 7:19 ` Linus Walleij [this message]
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=CACRpkdaa3XT2gP0NXhz3Mw4SqOSaMmswLk_z8bk9j9Jrqy62kA@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=bhelgaas@google.com \
--cc=gnurou@gmail.com \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vilhelm.gray@gmail.com \
/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).