linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	devicetree <devicetree@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH v2 3/3] gpio: Add Spreadtrum PMIC EIC driver support
Date: Mon, 26 Feb 2018 14:02:41 +0200	[thread overview]
Message-ID: <CAHp75VeJiqp74LrsETHTwxd5iaOObRX5bdYXz=rYeHm-4KbgHA@mail.gmail.com> (raw)
In-Reply-To: <CAMz4kuJ+BmWnSFFvE91Ric-Wm6tzxs_a5UWMx82tPj_ZVvC4tw@mail.gmail.com>

On Mon, Feb 26, 2018 at 5:01 AM, Baolin Wang <baolin.wang@linaro.org> wrote:
> On 25 February 2018 at 20:19, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>> On Sat, Feb 24, 2018 at 12:44 PM, Baolin Wang <baolin.wang@linaro.org> wrote:

>>> +static int sprd_pmic_eic_direction_input(struct gpio_chip *chip,
>>> +                                        unsigned int offset)
>>> +{
>>> +       /* EICs are always input, nothing need to do here. */
>>> +       return 0;
>>> +}
>>> +
>>> +static void sprd_pmic_eic_set(struct gpio_chip *chip, unsigned int offset,
>>> +                             int value)
>>> +{
>>> +       /* EICs are always input, nothing need to do here. */
>>> +}
>>
>> Remove both.
>>
>> Look at what GPIO core does.
>
> I've checked the GPIO core, we need the
> sprd_pmic_eic_direction_input() returns 0, since user can set GPIOD_IN
> flag when requesting one GPIO, otherwise it will return errors.

Right. I thought it depends on presence of direction_output().

> We also need one dummy sprd_pmic_eic_set() when setting debounce for
> one GPIO, otherwise it will return errors.

This is pretty much a "feature" of GPIO framework. It shouldn't
require ->set() by logic if there is no output facility.
OK.

>>> +       for (n = 0; n < chip->ngpio; n++) {
>>> +               if (!(BIT(n) & val))
>>
>> for_each_set_bit().
>>
>> At some point you may need just to go across lib/ in the kernel and
>> see what we have there.
>
> I've considered the for_each_set_bit(), it need one 'unsigned long'
> type parameter, but we get the value from regmap is 'u32' type. So we
> need one extra conversion from 'u32' to 'unsigned long' like:
>
> unsigned long reg = val;
>
> for_each_set_bit(n, &reg, chip->ngpio) {
>         .......
> }
>
> If you like this conversion, then I can change to use
> for_each_set_bit(). Thanks.

Wouldn't it work like

unsigned long val;

...regmap_read(..., &val);

?

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2018-02-26 12:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-24 10:44 [PATCH v2 1/3] dt-bindings: gpio: Add Spreadtrum EIC controller documentation Baolin Wang
2018-02-24 10:44 ` [PATCH v2 2/3] gpio: Add Spreadtrum EIC driver support Baolin Wang
2018-03-02  9:53   ` Linus Walleij
2018-03-02 10:48     ` Baolin Wang
2018-03-02 12:40       ` Linus Walleij
2018-02-24 10:44 ` [PATCH v2 3/3] gpio: Add Spreadtrum PMIC " Baolin Wang
2018-02-25 12:19   ` Andy Shevchenko
2018-02-26  3:01     ` Baolin Wang
2018-02-26 12:02       ` Andy Shevchenko [this message]
2018-02-27  2:35         ` Baolin Wang
2018-02-27 15:54           ` Andy Shevchenko
2018-02-28  2:22             ` Baolin Wang
2018-03-02 22:08 ` [PATCH v2 1/3] dt-bindings: gpio: Add Spreadtrum EIC controller documentation Rob Herring

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='CAHp75VeJiqp74LrsETHTwxd5iaOObRX5bdYXz=rYeHm-4KbgHA@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).