From: Jonathan Cameron <jic23@kernel.org>
To: Javier Martinez Canillas <javier@osg.samsung.com>,
linux-kernel@vger.kernel.org
Cc: linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
Tomas Novotny <tomas@novotny.cz>,
Fengguang Wu <fengguang.wu@intel.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Julia Lawall <julia.lawall@lip6.fr>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Subject: Re: [PATCH v2 04/17] iio: dac: mcp4725: Add OF device ID table
Date: Sun, 19 Mar 2017 10:51:26 +0000 [thread overview]
Message-ID: <ec57507d-07e5-c66c-0550-38adb59aaf42@kernel.org> (raw)
In-Reply-To: <20170315044505.20660-5-javier@osg.samsung.com>
On 15/03/17 04:44, Javier Martinez Canillas wrote:
> The driver doesn't have a struct of_device_id table but supported devices
> are registered via Device Trees. This is working on the assumption that a
> I2C device registered via OF will always match a legacy I2C device ID and
> that the MODALIAS reported will always be of the form i2c:<device>.
>
> But this could change in the future so the correct approach is to have an
> OF device ID table if the devices are registered via OF.
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Applied.
Thanks,
> ---
>
> drivers/iio/dac/mcp4725.c | 24 ++++++++++++++++++++++--
> 1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
> index db109f0cdd8c..6ab1f23e5a79 100644
> --- a/drivers/iio/dac/mcp4725.c
> +++ b/drivers/iio/dac/mcp4725.c
> @@ -19,6 +19,7 @@
> #include <linux/err.h>
> #include <linux/delay.h>
> #include <linux/regulator/consumer.h>
> +#include <linux/of_device.h>
> #include <linux/of.h>
>
> #include <linux/iio/iio.h>
> @@ -199,7 +200,7 @@ static ssize_t mcp4725_write_powerdown(struct iio_dev *indio_dev,
> return len;
> }
>
> -enum {
> +enum chip_id {
> MCP4725,
> MCP4726,
> };
> @@ -406,7 +407,10 @@ static int mcp4725_probe(struct i2c_client *client,
> data = iio_priv(indio_dev);
> i2c_set_clientdata(client, indio_dev);
> data->client = client;
> - data->id = id->driver_data;
> + if (client->dev.of_node)
> + data->id = (enum chip_id)of_device_get_match_data(&client->dev);
> + else
> + data->id = id->driver_data;
> pdata = dev_get_platdata(&client->dev);
>
> if (!pdata) {
> @@ -525,9 +529,25 @@ static const struct i2c_device_id mcp4725_id[] = {
> };
> MODULE_DEVICE_TABLE(i2c, mcp4725_id);
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id mcp4725_of_match[] = {
> + {
> + .compatible = "microchip,mcp4725",
> + .data = (void *)MCP4725
> + },
> + {
> + .compatible = "microchip,mcp4726",
> + .data = (void *)MCP4726
> + },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, mcp4725_of_match);
> +#endif
> +
> static struct i2c_driver mcp4725_driver = {
> .driver = {
> .name = MCP4725_DRV_NAME,
> + .of_match_table = of_match_ptr(mcp4725_of_match),
> .pm = MCP4725_PM_OPS,
> },
> .probe = mcp4725_probe,
>
next prev parent reply other threads:[~2017-03-19 10:51 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 4:44 [PATCH v2 00/17] iio: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
2017-03-15 4:44 ` [PATCH v2 01/17] iio: adc: ina2xx: Add OF device ID table Javier Martinez Canillas
2017-03-19 10:48 ` Jonathan Cameron
2017-03-15 4:44 ` [PATCH v2 02/17] iio: mlx96014: " Javier Martinez Canillas
2017-03-15 10:46 ` Crt Mori
2017-03-19 10:49 ` Jonathan Cameron
2017-03-15 4:44 ` [PATCH v2 03/17] iio: magnetometer: bmc150_magn_i2c: " Javier Martinez Canillas
2017-03-19 10:50 ` Jonathan Cameron
2017-03-15 4:44 ` [PATCH v2 04/17] iio: dac: mcp4725: " Javier Martinez Canillas
2017-03-19 10:51 ` Jonathan Cameron [this message]
2017-03-15 4:44 ` [PATCH v2 05/17] iio: light: us5182d: " Javier Martinez Canillas
2017-03-19 10:52 ` Jonathan Cameron
2017-03-15 4:44 ` [PATCH v2 06/17] iio: light: tsl2563: " Javier Martinez Canillas
2017-03-19 10:53 ` Jonathan Cameron
2017-03-15 4:44 ` [PATCH v2 07/17] iio: pressure: hp03: " Javier Martinez Canillas
2017-03-19 10:53 ` Jonathan Cameron
2017-03-15 4:44 ` [PATCH v2 08/17] iio: imu: inv_mpu6050: " Javier Martinez Canillas
2017-03-19 10:54 ` Jonathan Cameron
2017-03-15 4:44 ` [PATCH v2 09/17] iio: accel: bma180: " Javier Martinez Canillas
2017-03-19 10:55 ` Jonathan Cameron
2017-03-15 4:44 ` [PATCH v2 10/17] iio: light: apds9960: " Javier Martinez Canillas
2017-03-19 10:55 ` Jonathan Cameron
2017-03-15 4:44 ` [PATCH v2 11/17] iio: dac: max5821: Set .of_match_table to " Javier Martinez Canillas
2017-03-19 10:56 ` Jonathan Cameron
2017-03-15 4:45 ` [PATCH v2 12/17] iio: adc: ti-ads1015: Add " Javier Martinez Canillas
2017-03-19 10:57 ` Jonathan Cameron
2017-03-15 4:45 ` [PATCH v2 13/17] iio: magnetometer: mag3110: " Javier Martinez Canillas
2017-03-19 10:57 ` Jonathan Cameron
2017-03-15 4:45 ` [PATCH v2 14/17] iio: accel: mma7455_i2c: " Javier Martinez Canillas
2017-03-19 10:57 ` Jonathan Cameron
2017-03-15 4:45 ` [PATCH v2 15/17] iio: pressure: mpl3115: " Javier Martinez Canillas
2017-03-19 10:58 ` Jonathan Cameron
2017-03-15 4:45 ` [PATCH v2 16/17] iio: accel: mma7660: " Javier Martinez Canillas
2017-03-19 10:58 ` Jonathan Cameron
2017-03-15 4:45 ` [PATCH v2 17/17] iio: gyro: itg3200: " Javier Martinez Canillas
2017-03-19 10:59 ` 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=ec57507d-07e5-c66c-0550-38adb59aaf42@kernel.org \
--to=jic23@kernel.org \
--cc=fengguang.wu@intel.com \
--cc=javier@osg.samsung.com \
--cc=julia.lawall@lip6.fr \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
--cc=tomas@novotny.cz \
/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).