From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH v3 3/5] iio: proximity: sx9500: Set IRQ pin to direction-input if necessary
Date: Wed, 08 Nov 2017 18:35:46 +0200 [thread overview]
Message-ID: <1510158946.25007.112.camel@linux.intel.com> (raw)
In-Reply-To: <20171104032059.0000049a@huawei.com>
+Cc: Mika
On Sat, 2017-11-04 at 03:20 +0000, Jonathan Cameron wrote:
> On Fri, 3 Nov 2017 15:03:38 +0200
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
> > With the new more strict ACPI gpio code the DSDT's IoRestriction
> > flags
> > are honored on gpiod_get(), but in some DSDT's it is wrong, so
> > explicitly call gpiod_direction_input() on the IRQ GPIO if
> > necessary.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Again, I really really don't like filling driver code with fixes
> for broken firmware. I appreciate we have to cope with this, but
> it does rather seem like this should be moved into the core code
> for say gpiod_get_irq.
I would love to fix in general, though it looks not so trivial:
- gpiod_get() doesn't know if GPIO is going to be used as IRQ
- gpiod_to_irq() doesn't know if descriptor in question comes from
GpioIo() ACPI resource
>
> Otherwise we get to fix this hundreds of times in different drivers
> as I doubt this is the only driver effected by wrong tables...
>
> Jonathan
>
> > ---
> > drivers/iio/proximity/sx9500.c | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/proximity/sx9500.c
> > b/drivers/iio/proximity/sx9500.c index eb687b3dd442..3cf054155779
> > 100644 --- a/drivers/iio/proximity/sx9500.c
> > +++ b/drivers/iio/proximity/sx9500.c
> > @@ -17,6 +17,7 @@
> > #include <linux/irq.h>
> > #include <linux/acpi.h>
> > #include <linux/gpio/consumer.h>
> > +#include <linux/gpio.h>
> > #include <linux/regmap.h>
> > #include <linux/pm.h>
> > #include <linux/delay.h>
> > @@ -892,8 +893,13 @@ static void sx9500_gpio_probe(struct i2c_client
> > *client, gpiod_int = devm_gpiod_get(dev, "interrupt", GPIOD_IN);
> > if (IS_ERR(gpiod_int))
> > dev_err(dev, "gpio get irq failed\n");
> > - else
> > + else {
> > + if (gpiod_get_direction(gpiod_int) !=
> > GPIOF_DIR_IN) {
> > + dev_warn(dev, FW_BUG "IRQ GPIO not
> > in input mode, fixing\n");
> > + gpiod_direction_input(gpiod_int);
> > + }
> > client->irq = gpiod_to_irq(gpiod_int);
> > + }
> > }
> >
> > data->gpiod_rst = devm_gpiod_get(dev, "reset",
> > GPIOD_OUT_HIGH);
>
>
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
next prev parent reply other threads:[~2017-11-08 16:37 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-03 13:03 [PATCH v3 1/5] iio: proximity: sx9500: Assign interrupt from GpioIo() Andy Shevchenko
2017-11-03 13:03 ` [PATCH v3 2/5] iio: proximity: sx9500: Add GPIO ACPI mapping table Andy Shevchenko
2017-11-04 3:14 ` Jonathan Cameron
2017-11-19 15:29 ` Jonathan Cameron
2017-11-25 14:24 ` Jonathan Cameron
2017-11-27 15:08 ` Andy Shevchenko
2017-12-01 10:04 ` Linus Walleij
2017-12-01 12:36 ` Andy Shevchenko
2017-11-03 13:03 ` [PATCH v3 3/5] iio: proximity: sx9500: Set IRQ pin to direction-input if necessary Andy Shevchenko
2017-11-04 3:20 ` Jonathan Cameron
2017-11-08 16:35 ` Andy Shevchenko [this message]
2017-11-08 17:03 ` Mika Westerberg
2017-11-08 20:45 ` Linus Walleij
2017-11-08 20:52 ` Andy Shevchenko
2017-11-10 18:13 ` Andy Shevchenko
2018-02-26 19:51 ` Andy Shevchenko
2017-11-03 13:03 ` [PATCH v3 4/5] iio: proximity: sx9500: Add another ACPI ID Andy Shevchenko
2017-11-19 15:32 ` Jonathan Cameron
2017-11-03 13:03 ` [PATCH v3 5/5] iio: magnetometer: ak8975: " Andy Shevchenko
2017-11-04 3:11 ` [PATCH v3 1/5] iio: proximity: sx9500: Assign interrupt from GpioIo() Jonathan Cameron
2017-11-04 10:43 ` Linus Walleij
2017-11-06 9:35 ` Mika Westerberg
2017-11-19 15:24 ` Jonathan Cameron
2017-11-20 10:30 ` Mika Westerberg
2017-11-25 14:28 ` Jonathan Cameron
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=1510158946.25007.112.camel@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=pmeerw@pmeerw.net \
/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).