mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Neil Armstrong <narmstrong@baylibre.com>,
	Alexandre Courbot <gnurou@gmail.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/3] pinctrl / gpio: Introduce .set_config() callback for GPIO chips
Date: Fri, 20 Jan 2017 15:36:27 +0200	[thread overview]
Message-ID: <20170120133627.GK17297@lahna.fi.intel.com> (raw)
In-Reply-To: <CACRpkdbsOvJkpNtjvCXRNWV6dA6onzomn-E+9n=xJabmcRGbEQ@mail.gmail.com>

On Fri, Jan 20, 2017 at 10:13:05AM +0100, Linus Walleij wrote:
> > +static int gpio_set_drive_mode(struct gpio_chip *gc, unsigned offset,
> > +                              enum pin_config_param mode)
> > +{
> > +       unsigned long config = { PIN_CONF_PACKED(mode, 0) };
> > +
> > +       return gc->set_config ? gc->set_config(gc, offset, config) : -ENOTSUPP;
> > +}
> 
> I would name it gpio_set_drive_single_ended() as the open source/open
> drain is all we support here.

OK.

> >         if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
> >                 /* First see if we can enable open drain in hardware */
> > -               if (gc->set_single_ended) {
> > -                       ret = gc->set_single_ended(gc, gpio_chip_hwgpio(desc),
> > -                                                  LINE_MODE_OPEN_DRAIN);
> > -                       if (!ret)
> > -                               goto set_output_value;
> > -               }
> > +               ret = gpio_set_drive_mode(gc, gpio_chip_hwgpio(desc),
> > +                                         PIN_CONFIG_DRIVE_OPEN_DRAIN);
> > +               if (!ret)
> > +                       goto set_output_value;
> 
> Aha I see, so if we fail to set single ended we get to the next step.
> Nice.
> 
> >                 /* Emulate open drain by not actively driving the line high */
> >                 if (val)
> >                         return gpiod_direction_input(desc);
> >         }
> 
> (...)
> 
> > -               if (gc->set_single_ended) {
> > -                       ret = gc->set_single_ended(gc, gpio_chip_hwgpio(desc),
> > -                                                  LINE_MODE_OPEN_SOURCE);
> > -                       if (!ret)
> > -                               goto set_output_value;
> > -               }
> > +               ret = gpio_set_drive_mode(gc, gpio_chip_hwgpio(desc),
> > +                                         PIN_CONFIG_DRIVE_OPEN_SOURCE);
> >                 /* Emulate open source by not actively driving the line low */
> >                 if (!val)
> >                         return gpiod_direction_input(desc);
> 
> But here the handling seems to be wrong? You still need
> the if (!ret) goto set_output_value?

Good point. I'll fix that in the next version.

  parent reply	other threads:[~2017-01-20 13:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-19  9:48 [PATCH 0/3] pinctrl / gpio: Allow GPIO chips to use generic pinconfig Mika Westerberg
2017-01-19  9:48 ` [PATCH 1/3] pinctrl: Widen the generic pinconf argument from 16 to 24 bits Mika Westerberg
2017-01-19 12:04   ` Andy Shevchenko
2017-01-20  8:43   ` Linus Walleij
2017-01-19  9:48 ` [PATCH 2/3] pinctrl: Allow configuration of pins from gpiolib based drivers Mika Westerberg
2017-01-19 12:11   ` Andy Shevchenko
2017-01-20  8:48     ` Linus Walleij
2017-01-19  9:48 ` [PATCH 3/3] pinctrl / gpio: Introduce .set_config() callback for GPIO chips Mika Westerberg
2017-01-19 12:17   ` Andy Shevchenko
2017-01-20  9:13   ` Linus Walleij
2017-01-20  9:24     ` Neil Armstrong
2017-01-20  9:49       ` Linus Walleij
2017-01-20 13:36     ` Mika Westerberg [this message]
2017-01-19 12:17 ` [PATCH 0/3] pinctrl / gpio: Allow GPIO chips to use generic pinconfig Andy Shevchenko

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=20170120133627.GK17297@lahna.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=narmstrong@baylibre.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

Powered by JetHome