From: Jonathan Cameron <jic23@kernel.org>
To: Daniel Baluta <daniel.baluta@intel.com>,
pmeerw@pmeerw.net, srinivas.pandruvada@linux.intel.com,
knaack.h@gmx.de
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/6] iio: imu: kmx61: Add acpi support
Date: Fri, 12 Dec 2014 13:35:47 +0000 [thread overview]
Message-ID: <548AEF33.4060209@kernel.org> (raw)
In-Reply-To: <1417613513-28285-3-git-send-email-daniel.baluta@intel.com>
On 03/12/14 13:31, Daniel Baluta wrote:
> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Applied to the togreg branch of iio.git
Thanks,
Jonathan
> ---
> drivers/iio/imu/kmx61.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 59 insertions(+)
>
> diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c
> index 5b44371..893f7c8 100644
> --- a/drivers/iio/imu/kmx61.c
> +++ b/drivers/iio/imu/kmx61.c
> @@ -13,10 +13,13 @@
>
> #include <linux/module.h>
> #include <linux/i2c.h>
> +#include <linux/acpi.h>
> +#include <linux/gpio/consumer.h>
> #include <linux/iio/iio.h>
> #include <linux/iio/sysfs.h>
>
> #define KMX61_DRV_NAME "kmx61"
> +#define KMX61_GPIO_NAME "kmx61_int"
>
> #define KMX61_REG_WHO_AM_I 0x00
>
> @@ -573,6 +576,44 @@ static const struct iio_info kmx61_mag_info = {
> .attrs = &kmx61_mag_attribute_group,
> };
>
> +static const char *kmx61_match_acpi_device(struct device *dev)
> +{
> + const struct acpi_device_id *id;
> +
> + id = acpi_match_device(dev->driver->acpi_match_table, dev);
> + if (!id)
> + return NULL;
> + return dev_name(dev);
> +}
> +
> +static int kmx61_gpio_probe(struct i2c_client *client, struct kmx61_data *data)
> +{
> + struct device *dev;
> + struct gpio_desc *gpio;
> + int ret;
> +
> + if (!client)
> + return -EINVAL;
> +
> + dev = &client->dev;
> +
> + /* data ready gpio interrupt pin */
> + gpio = devm_gpiod_get_index(dev, KMX61_GPIO_NAME, 0);
> + if (IS_ERR(gpio)) {
> + dev_err(dev, "acpi gpio get index failed\n");
> + return PTR_ERR(gpio);
> + }
> +
> + ret = gpiod_direction_input(gpio);
> + if (ret)
> + return ret;
> +
> + ret = gpiod_to_irq(gpio);
> +
> + dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
> + return ret;
> +}
> +
> static struct iio_dev *kmx61_indiodev_setup(struct kmx61_data *data,
> const struct iio_info *info,
> const struct iio_chan_spec *chan,
> @@ -613,6 +654,13 @@ static int kmx61_probe(struct i2c_client *client,
>
> mutex_init(&data->lock);
>
> + if (id)
> + name = id->name;
> + else if (ACPI_HANDLE(&client->dev))
> + name = kmx61_match_acpi_device(&client->dev);
> + else
> + return -ENODEV;
> +
> data->acc_indio_dev =
> kmx61_indiodev_setup(data, &kmx61_acc_info,
> kmx61_acc_channels,
> @@ -633,6 +681,9 @@ static int kmx61_probe(struct i2c_client *client,
> if (ret < 0)
> return ret;
>
> + if (client->irq < 0)
> + client->irq = kmx61_gpio_probe(client, data);
> +
> ret = iio_device_register(data->acc_indio_dev);
> if (ret < 0) {
> dev_err(&client->dev, "Failed to register acc iio device\n");
> @@ -668,6 +719,13 @@ static int kmx61_remove(struct i2c_client *client)
> return 0;
> }
>
> +static const struct acpi_device_id kmx61_acpi_match[] = {
> + {"KMX61021", 0},
> + {}
> +};
> +
> +MODULE_DEVICE_TABLE(acpi, kmx61_acpi_match);
> +
> static const struct i2c_device_id kmx61_id[] = {
> {"kmx611021", 0},
> {}
> @@ -678,6 +736,7 @@ MODULE_DEVICE_TABLE(i2c, kmx61_id);
> static struct i2c_driver kmx61_driver = {
> .driver = {
> .name = KMX61_DRV_NAME,
> + .acpi_match_table = ACPI_PTR(kmx61_acpi_match),
> },
> .probe = kmx61_probe,
> .remove = kmx61_remove,
>
next prev parent reply other threads:[~2014-12-12 13:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-03 13:31 [PATCH v4 0/6] Add support for KMX61 sensor Daniel Baluta
2014-12-03 13:31 ` [PATCH v4 1/6] iio: imu: Add support for Kionix " Daniel Baluta
2014-12-12 13:32 ` Jonathan Cameron
2014-12-14 22:43 ` Hartmut Knaack
2014-12-15 10:50 ` Daniel Baluta
2014-12-03 13:31 ` [PATCH v4 2/6] iio: imu: kmx61: Add acpi support Daniel Baluta
2014-12-12 13:35 ` Jonathan Cameron [this message]
2014-12-03 13:31 ` [PATCH v4 3/6] iio: imu: kmx61: Add PM runtime support Daniel Baluta
2014-12-12 13:37 ` Jonathan Cameron
2014-12-14 22:55 ` Hartmut Knaack
2014-12-15 16:11 ` Daniel Baluta
2014-12-03 13:31 ` [PATCH v4 4/6] iio: imu: kmx61: Add PM sleep support Daniel Baluta
2014-12-12 13:45 ` Jonathan Cameron
2014-12-03 13:31 ` [PATCH v4 5/6] iio: imu: kmx61: Add support for data ready triggers Daniel Baluta
2014-12-12 13:49 ` Jonathan Cameron
2014-12-14 23:04 ` Hartmut Knaack
2014-12-03 13:31 ` [PATCH v4 6/6] iio: imu: kmx61: Add support for any motion trigger Daniel Baluta
2014-12-12 13:54 ` Jonathan Cameron
2014-12-15 23:19 ` Hartmut Knaack
2014-12-16 11:08 ` Daniel Baluta
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=548AEF33.4060209@kernel.org \
--to=jic23@kernel.org \
--cc=daniel.baluta@intel.com \
--cc=knaack.h@gmx.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
--cc=srinivas.pandruvada@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.