linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Baluta <daniel.baluta@intel.com>
To: Mika Westerberg <mika.westerberg@linux.intel.com>,
	Denis CIOCCA <denis.ciocca@st.com>
Cc: Robert Dolca <robert.dolca@intel.com>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	Jonathan Cameron <jic23@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald <pmeerw@pmeerw.net>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH] IIO: Adds ACPI support for ST gyroscopes
Date: Tue, 24 Mar 2015 13:51:08 +0200	[thread overview]
Message-ID: <CAEnQRZCkb4o3VrmXHa+W6em+uggxEraOWtWP0yfO7CQ8Q0+KHw@mail.gmail.com> (raw)
In-Reply-To: <20150323151841.GA1878@lahna.fi.intel.com>

On Mon, Mar 23, 2015 at 5:18 PM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
> On Mon, Mar 23, 2015 at 03:40:24PM +0200, Robert Dolca wrote:
>> Signed-off-by: Robert Dolca <robert.dolca@intel.com>
>> ---
>>  drivers/iio/common/st_sensors/st_sensors_i2c.c | 35 ++++++++++++++++++++++++++
>>  drivers/iio/gyro/st_gyro_i2c.c                 | 29 ++++++++++++++++++++-
>>  include/linux/iio/common/st_sensors_i2c.h      |  3 +++
>>  3 files changed, 66 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c
>> index 98cfee29..2f612ec 100644
>> --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c
>> +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c
>> @@ -13,6 +13,8 @@
>>  #include <linux/slab.h>
>>  #include <linux/iio/iio.h>
>>  #include <linux/of_device.h>
>> +#include <linux/acpi.h>
>> +#include <linux/gpio/consumer.h>
>>
>>  #include <linux/iio/common/st_sensors_i2c.h>
>>
>> @@ -107,6 +109,39 @@ void st_sensors_of_i2c_probe(struct i2c_client *client,
>>  EXPORT_SYMBOL(st_sensors_of_i2c_probe);
>>  #endif
>>
>> +int st_sensors_acpi_i2c_probe(struct i2c_client *client,
>> +                            const struct acpi_device_id *match)
>> +{
>> +     const struct acpi_device_id *id;
>> +     struct gpio_desc *gpiod_irq;
>> +     int ret;
>> +
>> +     id = acpi_match_device(match, &client->dev);
>> +     if (!id)
>> +             return -ENODEV;
>> +
>> +     /* Get IRQ GPIO */
>> +     gpiod_irq = devm_gpiod_get_index(&client->dev, 0, 0);
>
> Please use plain devm_gpiod_get(&client->dev, NULL). That should work
> with DT and ACPI _DSD as well.
>
>> +     if (IS_ERR(gpiod_irq))
>> +             return -ENODEV;
>
> Why not return the original error here? Now you lose things like
> -EPROBE_DEFER.
>
>> +     /* Configure IRQ GPIO */
>> +     ret = gpiod_direction_input(gpiod_irq);
>> +     if (ret)
>> +             return ret;
>> +
>> +     /* Map the pin to an IRQ */
>> +     client->irq = gpiod_to_irq(gpiod_irq);
>> +
>> +     /* The name from the ACPI match takes precedence if present */
>> +     memset(client->name, 0, sizeof(client->name));
>> +     strncpy(client->name, (char *) id->driver_data,
>> +             min(sizeof(client->name), strlen((char *) id->driver_data)));
>
> Hmm, the above should not be required at all. If the device has an ACPI
> companion the I2C core will match first with that.
>
> Also you now modify the original i2c_client structure. Should you at
> least restore the original values when the driver is unbound?

Hi Mika,

This is similar with device tree  aproach. Looking at st_sensors_of_i2c_probe,
we have:

»       /* The name from the OF match takes precedence if present */
»       strncpy(client->name, of_id->data, sizeof(client->name));
»       client->name[sizeof(client->name) - 1] = '\0';

We want to keep the compatibility with the device tree implementation. Not
sure if the custom name is really required.

Denis, perhaps you can offer more info on this.

Daniel.

  reply	other threads:[~2015-03-24 11:51 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-23 13:40 [PATCH] IIO: Adds ACPI support for ST gyroscopes Robert Dolca
2015-03-23 13:40 ` [PATCH] IIO: Add support for L3GD20H gyroscope Robert Dolca
2015-03-24 10:29   ` Linus Walleij
2015-03-28 11:14     ` Jonathan Cameron
2015-03-23 15:18 ` [PATCH] IIO: Adds ACPI support for ST gyroscopes Mika Westerberg
2015-03-24 11:51   ` Daniel Baluta [this message]
2015-03-24 10:22 ` Linus Walleij
2015-03-24 10:37 ` Linus Walleij
2015-03-24 10:44 ` Linus Walleij
2015-03-24 12:17 ` Lars-Peter Clausen
2015-03-24 13:26   ` Robert Dolca
2015-03-24 13:38     ` Lars-Peter Clausen
2015-03-24 13:57       ` Linus Walleij
2015-03-24 15:06         ` Mika Westerberg
2015-03-24 15:22           ` Lars-Peter Clausen
2015-03-24 15:28             ` Daniel Baluta
2015-03-24 15:55             ` Mika Westerberg
2015-03-24 16:43               ` Lars-Peter Clausen
2015-03-24 16:55                 ` Mika Westerberg
2015-03-25  8:44           ` Linus Walleij
2015-03-25  9:43             ` Mika Westerberg
2015-03-25 12:25               ` Mika Westerberg
2015-03-25 13:21                 ` Mika Westerberg
2015-03-25 13:42                   ` Robert Dolca
2015-03-25 18:05                   ` sathyanarayanan kuppuswamy
2015-03-25 18:08                     ` Lars-Peter Clausen
2015-03-25 21:12                   ` Octavian Purdila
2015-03-26 10:06                     ` Robert Dolca
2015-03-26 10:36                       ` Mika Westerberg
2015-03-26 10:16                     ` Mika Westerberg
2015-03-26 12:04                       ` Octavian Purdila
2015-03-26 14:04                         ` Mika Westerberg
2015-03-26 14:37                           ` Octavian Purdila
2015-03-26 14:47                             ` Mika Westerberg
2015-03-26 15:00                               ` Octavian Purdila
2015-03-26 16:28                                 ` Octavian Purdila
2015-03-27 10:06                                   ` Mika Westerberg
2015-03-27 10:36                                     ` Linus Walleij
2015-03-30  9:52                                       ` Mika Westerberg
2015-03-30 12:55                                         ` Octavian Purdila
2015-03-30 13:33                                           ` Mika Westerberg
2015-03-30 13:52                                             ` Octavian Purdila
2015-03-30 14:18                                               ` Mika Westerberg
2015-04-07  9:35                                               ` Linus Walleij
2015-04-07  9:39                                                 ` Lars-Peter Clausen
2015-03-26 18:32                                 ` 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=CAEnQRZCkb4o3VrmXHa+W6em+uggxEraOWtWP0yfO7CQ8Q0+KHw@mail.gmail.com \
    --to=daniel.baluta@intel.com \
    --cc=denis.ciocca@st.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=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=pmeerw@pmeerw.net \
    --cc=robert.dolca@intel.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).