diff mbox series

[3/7] Staging: iio: adt7316: Add of_device_id table

Message ID 20181116225537.24723-1-shreeya.patel23498@gmail.com (mailing list archive)
State New, archived
Headers show
Series Remove platform data and introduce DT bindings | expand

Commit Message

Shreeya Patel Nov. 16, 2018, 10:55 p.m. UTC
When the kernel starts up, it kicks off compiled-in drivers
that match “compatible” entries it finds in the device tree.
At a later stage (when /lib/modules is available), all kernel modules
that match “compatible” entries in the device tree are loaded.
Hence to be able to use device tree for ADT7316, add of_device_id
table which specifies the supported devices through compatible
property.
Note that there is a fall back path in i2c that will result
in i2c_device_id table being used if there is no of_devcie_id table.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
---
 drivers/staging/iio/addac/adt7316-i2c.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Jonathan Cameron Nov. 17, 2018, 5:05 p.m. UTC | #1
On Sat, 17 Nov 2018 04:25:37 +0530
Shreeya Patel <shreeya.patel23498@gmail.com> wrote:

> When the kernel starts up, it kicks off compiled-in drivers
> that match “compatible” entries it finds in the device tree.
> At a later stage (when /lib/modules is available), all kernel modules
> that match “compatible” entries in the device tree are loaded.
> Hence to be able to use device tree for ADT7316, add of_device_id
> table which specifies the supported devices through compatible
> property.
> Note that there is a fall back path in i2c that will result
> in i2c_device_id table being used if there is no of_devcie_id table.
of_device_id

Should also assign of_match_table in the driver structure so that
we will use these to match when probing rather than just
for module autoloading which is what this does.  See for
example drivers/adc/max1363.c

Do not use of_match_ptr, just assign directly to avoid blocking
the random ACPI probing with DT bindings route.

This does make me wonder if the adt7518 is compatible or not
as those are fairly random part numbers!

Thanks,

Jonathan
> 
> Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
> ---
>  drivers/staging/iio/addac/adt7316-i2c.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c
> index 473e5e34ec00..d4b5060c18ee 100644
> --- a/drivers/staging/iio/addac/adt7316-i2c.c
> +++ b/drivers/staging/iio/addac/adt7316-i2c.c
> @@ -126,6 +126,18 @@ static const struct i2c_device_id adt7316_i2c_id[] = {
>  
>  MODULE_DEVICE_TABLE(i2c, adt7316_i2c_id);
>  
> +static const struct of_device_id adt7316_of_match[] = {
> +	{ .compatible = "adi,adt7316" },
> +	{ .compatible = "adi,adt7317" },
> +	{ .compatible = "adi,adt7318" },
> +	{ .compatible = "adi,adt7516" },
> +	{ .compatible = "adi,adt7517" },
> +	{ .compatible = "adi,adt7519" },
> +	{ },
> +};
> +
> +MODULE_DEVICE_TABLE(of, adt7316_of_match);
> +
>  static struct i2c_driver adt7316_driver = {
>  	.driver = {
>  		.name = "adt7316",
diff mbox series

Patch

diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c
index 473e5e34ec00..d4b5060c18ee 100644
--- a/drivers/staging/iio/addac/adt7316-i2c.c
+++ b/drivers/staging/iio/addac/adt7316-i2c.c
@@ -126,6 +126,18 @@  static const struct i2c_device_id adt7316_i2c_id[] = {
 
 MODULE_DEVICE_TABLE(i2c, adt7316_i2c_id);
 
+static const struct of_device_id adt7316_of_match[] = {
+	{ .compatible = "adi,adt7316" },
+	{ .compatible = "adi,adt7317" },
+	{ .compatible = "adi,adt7318" },
+	{ .compatible = "adi,adt7516" },
+	{ .compatible = "adi,adt7517" },
+	{ .compatible = "adi,adt7519" },
+	{ },
+};
+
+MODULE_DEVICE_TABLE(of, adt7316_of_match);
+
 static struct i2c_driver adt7316_driver = {
 	.driver = {
 		.name = "adt7316",