public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Srinivas Pandruvada
	<srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [Patch v1 2/2] iio: ak8975: Added ACPI enumeration
Date: Sat, 22 Mar 2014 12:46:17 +0000	[thread overview]
Message-ID: <532D8619.2060409@kernel.org> (raw)
In-Reply-To: <532D8571.4040004-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

On 22/03/14 12:43, Jonathan Cameron wrote:
> On 19/03/14 16:56, Srinivas Pandruvada wrote:
>> Added capability so that this device can be enumerated via ACPI.
>>
> This is simple enough that I'm going to rely on my limited knowledge of ACPI and
> take it as is.
>> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> Applied to the togreg branch of iio.git
Note there was a bit of fuzz in here.  All looks fine, but might be worth
you taking a quick look at the merge.
>
> Thanks,
>
> Jonathan
>> ---
>>   drivers/iio/magnetometer/ak8975.c | 40 ++++++++++++++++++++++++++++++++++++---
>>   1 file changed, 37 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
>> index aa7682d..09ea5c4 100644
>> --- a/drivers/iio/magnetometer/ak8975.c
>> +++ b/drivers/iio/magnetometer/ak8975.c
>> @@ -31,6 +31,7 @@
>>   #include <linux/bitops.h>
>>   #include <linux/gpio.h>
>>   #include <linux/of_gpio.h>
>> +#include <linux/acpi.h>
>>
>>   #include <linux/iio/iio.h>
>>   #include <linux/iio/sysfs.h>
>> @@ -475,6 +476,27 @@ static const struct iio_info ak8975_info = {
>>       .driver_module = THIS_MODULE,
>>   };
>>
>> +static const struct acpi_device_id ak_acpi_match[] = {
>> +    {"AK8975", AK8975},
>> +    {"AK8963", AK8963},
>> +    {"INVN6500", AK8963},
>> +    { },
>> +};
>> +MODULE_DEVICE_TABLE(acpi, ak_acpi_match);
>> +
>> +static char *ak8975_match_acpi_device(struct device *dev,
>> +                enum asahi_compass_chipset *chipset)
>> +{
>> +    const struct acpi_device_id *id;
>> +
>> +    id = acpi_match_device(dev->driver->acpi_match_table, dev);
>> +    if (!id)
>> +        return NULL;
>> +    *chipset = (int)id->driver_data;
>> +
>> +    return (char *)dev_name(dev);
>> +}
>> +
>>   static int ak8975_probe(struct i2c_client *client,
>>               const struct i2c_device_id *id)
>>   {
>> @@ -482,6 +504,7 @@ static int ak8975_probe(struct i2c_client *client,
>>       struct iio_dev *indio_dev;
>>       int eoc_gpio;
>>       int err;
>> +    char *name = NULL;
>>
>>       /* Grab and set up the supplied GPIO. */
>>       if (client->dev.platform_data)
>> @@ -519,8 +542,18 @@ static int ak8975_probe(struct i2c_client *client,
>>       data->eoc_gpio = eoc_gpio;
>>       data->eoc_irq = 0;
>>
>> -    data->chipset = (enum asahi_compass_chipset)(id->driver_data);
>> -    dev_dbg(&client->dev, "Asahi compass chip %s\n", id->name);
>> +    /* id will be NULL when enumerated via ACPI */
>> +    if (id) {
>> +        data->chipset =
>> +            (enum asahi_compass_chipset)(id->driver_data);
>> +        name = (char *) id->name;
>> +    } else if (ACPI_HANDLE(&client->dev))
>> +        name = ak8975_match_acpi_device(&client->dev, &data->chipset);
>> +    else {
>> +        err = -ENOSYS;
>> +        goto exit_free_iio;
>> +    }
>> +    dev_dbg(&client->dev, "Asahi compass chip %s\n", name);
>>
>>       /* Perform some basic start-of-day setup of the device. */
>>       err = ak8975_setup(client);
>> @@ -537,7 +570,7 @@ static int ak8975_probe(struct i2c_client *client,
>>       indio_dev->num_channels = ARRAY_SIZE(ak8975_channels);
>>       indio_dev->info = &ak8975_info;
>>       indio_dev->modes = INDIO_DIRECT_MODE;
>> -
>> +    indio_dev->name = name;
>>       err = iio_device_register(indio_dev);
>>       if (err < 0)
>>           goto exit_free_iio;
>> @@ -592,6 +625,7 @@ static struct i2c_driver ak8975_driver = {
>>       .driver = {
>>           .name    = "ak8975",
>>           .of_match_table = ak8975_of_match,
>> +        .acpi_match_table = ACPI_PTR(ak_acpi_match),
>>       },
>>       .probe        = ak8975_probe,
>>       .remove        = ak8975_remove,
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-03-22 12:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-19 16:56 [Patch v1 1/2] iio: ak8975 : Add AK8963 compatibility mode support Srinivas Pandruvada
     [not found] ` <1395248167-16991-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-03-19 16:56   ` [Patch v1 2/2] iio: ak8975: Added ACPI enumeration Srinivas Pandruvada
     [not found]     ` <1395248167-16991-2-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-03-22 12:43       ` Jonathan Cameron
     [not found]         ` <532D8571.4040004-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2014-03-22 12:46           ` Jonathan Cameron [this message]
2014-03-22 12:42   ` [Patch v1 1/2] iio: ak8975 : Add AK8963 compatibility mode support 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=532D8619.2060409@kernel.org \
    --to=jic23-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    /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