linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] gpio: mcp23s08: add pinconf support
Date: Mon, 30 Jan 2017 17:40:56 +0100	[thread overview]
Message-ID: <20170130164055.vuae4tesfepiwikd@earth> (raw)
In-Reply-To: <CACRpkdZyUq+v756vBhM=eu1i3ccsOrkMkEJObrt4HttmVXFkYQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2881 bytes --]

Hi Linus,

On Mon, Jan 30, 2017 at 04:08:01PM +0100, Linus Walleij wrote:
> On Fri, Jan 27, 2017 at 3:47 PM, Sebastian Reichel <sre@kernel.org> wrote:
> 
> > mcp23xxx device have configurable 100k pullup resistors. This adds
> > support for enabling them using pinctrl's pinconf interface.
> >
> > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> 
> That's the right approach!
>
> > diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
> 
> Can we move the patch to drivers/pinctrl/* like all other mixed drivers
> doing combined pinctrl and GPIO?

Sure. Two questions:

 * Should the config name change to PINCTRL_MCP23s08 (or PINCTRL_MCP23XXX)?
   This will mean people will have to fix their .config
 * Should there be a "SPI or I2C GPIO expanders" sub-menu for it as in the
   gpio Kconfig?

> Also: no Kconfig changes? Surely you must select the right pinctrl
> things, I guess you're just lucky that some other pin controller on your
> system selects your infrastructure. I think that is why the build robot
> is complaining.

Yes, it should select GENERIC_PINCONF as far as I can see.

> > +static int mcp_update_cache(struct mcp23s08 *mcp)
> > +{
> > +       int ret, reg, i;
> > +
> > +       for (i = 0; i < ARRAY_SIZE(mcp->cache); i++) {
> > +               ret = mcp_read(mcp, i, &reg);
> > +               if (ret < 0)
> > +                       return ret;
> > +               mcp->cache[i] = reg;
> > +       }
> > +
> > +       return 0;
> > +}
> 
> Why do you need a cache of register values when regmap already
> supports this?
>
> Instead I suggest: exploit the .volatile_reg() callback from
> struct regmap_config and use regmap to maintain the cache.

The mcp_update_cache method is just moved in this patch. I do not
need it, but the existing code uses it. Actually I only moved it, so
that it sticks together with the mcp_read and mcp_write functions,
which must be placed a bit earlier to be usable by the pinctrl stuff.

I did not convert the custom caching in the regmap patch, since it
should be done in its own cleanup patch. Introducing basic regmap
was much more straight forward than removing the open-coded caching.

> Apart from this is is nice!

I guess the custom platform data based pullup config could also
be removed. I just checked and there are not many users of the
platform data:

linux/arch $ git grep -l mcp23 | grep -v "/dts/"         
blackfin/mach-bf527/boards/tll6527m.c
blackfin/mach-bf609/boards/ezkit.c

None of them seems to use the pullups variable.

> With the recent changes from Mika Westerberg scheduled for v4.11
> the road is open to expose pullups all the way to userspace from
> GPIOs chardev if we want to (some patches would be needed).

I just added the pinctrl config to DT, but that sounds useful.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-01-30 16:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-27 14:47 [PATCH 0/2] mcp23s08 pinconf support Sebastian Reichel
2017-01-27 14:47 ` [PATCH 1/2] gpio: mcp23s08: use regmap Sebastian Reichel
2017-01-30 14:58   ` Linus Walleij
2017-01-27 14:47 ` [PATCH 2/2] gpio: mcp23s08: add pinconf support Sebastian Reichel
2017-01-27 17:16   ` kbuild test robot
2017-01-27 19:00   ` kbuild test robot
2017-01-30 15:08   ` Linus Walleij
2017-01-30 16:40     ` Sebastian Reichel [this message]
2017-02-01 15:12       ` Linus Walleij

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=20170130164055.vuae4tesfepiwikd@earth \
    --to=sre@kernel.org \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).