linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Robert Dolca <robert.dolca@intel.com>,
	linux-iio@vger.kernel.org, Jonathan Cameron <jic23@kernel.org>
Cc: linux-kernel@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
	Peter Meerwald <pmeerw@pmeerw.net>,
	Linus Walleij <linus.walleij@linaro.org>,
	Denis CIOCCA <denis.ciocca@st.com>
Subject: Re: [PATCH] IIO: Adds ACPI support for ST gyroscopes
Date: Tue, 24 Mar 2015 13:17:07 +0100	[thread overview]
Message-ID: <551155C3.2030403@metafoo.de> (raw)
In-Reply-To: <1427118025-4380-1-git-send-email-robert.dolca@intel.com>

[...]
> +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);
> +	if (IS_ERR(gpiod_irq))
> +		return -ENODEV;
> +
> +	/* Configure IRQ GPIO */
> +	ret = gpiod_direction_input(gpiod_irq);
> +	if (ret)
> +		return ret;

How exactly does this whole GPIO IRQ thing work with ACPI. Does the ACPI 
description just specify the GPIOs and the driver needs to know which GPIO 
is the is used for the IRQ or does the description indicate that a certain 
GPIO should be used as a IRQ. The reason why I'm asking is that same code 
pops up in pretty much every ACPI I2C sensor driver now. Which suggests that 
this should be factored out into common infrastructure.

And especially the requesting and the setting of the direction of the GPIO 
should not be necessary if the GPIO controller implements interrupt handling 
correctly as this is something that is, as far as I understand, taken care 
of by the GPIO framework when the IRQ is requested.

> +
> +	/* 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)));

Both client->irq and client->name should not be modified by the driver, 
these are only supposed to be set by the I2C framework. Modifying them in 
the driver can result in undefined behavior.

- Lars

  parent reply	other threads:[~2015-03-24 12:17 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
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 [this message]
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=551155C3.2030403@metafoo.de \
    --to=lars@metafoo.de \
    --cc=denis.ciocca@st.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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).