diff mbox series

iio: accel: adxl372: Add OF device ID table

Message ID 20200720134931.71537-1-alexandru.ardelean@analog.com (mailing list archive)
State New, archived
Headers show
Series iio: accel: adxl372: Add OF device ID table | expand

Commit Message

Alexandru Ardelean July 20, 2020, 1:49 p.m. UTC
From: Stefan Popa <stefan.popa@analog.com>

The driver does not have a struct of_device_id table, but supported
devices are registered via Device Trees. This patch adds OF device ID
table.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/iio/accel/adxl372_i2c.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Andy Shevchenko July 21, 2020, 6:37 p.m. UTC | #1
On Mon, Jul 20, 2020 at 4:48 PM Alexandru Ardelean
<alexandru.ardelean@analog.com> wrote:
>
> From: Stefan Popa <stefan.popa@analog.com>
>
> The driver does not have a struct of_device_id table, but supported
> devices are registered via Device Trees. This patch adds OF device ID
> table.
>
> Signed-off-by: Stefan Popa <stefan.popa@analog.com>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> ---
>  drivers/iio/accel/adxl372_i2c.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/iio/accel/adxl372_i2c.c b/drivers/iio/accel/adxl372_i2c.c
> index e1affe480c77..5197d1eb6803 100644
> --- a/drivers/iio/accel/adxl372_i2c.c
> +++ b/drivers/iio/accel/adxl372_i2c.c
> @@ -8,6 +8,8 @@
>  #include <linux/i2c.h>
>  #include <linux/module.h>
>  #include <linux/regmap.h>


> +#include <linux/of.h>
> +#include <linux/of_device.h>

With the huge patch series from Jonathan I think you may learn that
proper header here is

mod_devicetable.h.


>
>  #include "adxl372.h"
>
> @@ -46,9 +48,16 @@ static const struct i2c_device_id adxl372_i2c_id[] = {
>  };
>  MODULE_DEVICE_TABLE(i2c, adxl372_i2c_id);
>
> +static const struct of_device_id adxl372_of_match[] = {
> +       { .compatible = "adi,adxl372" },

> +       { },

No comma, please!

> +};
> +MODULE_DEVICE_TABLE(of, adxl372_of_match);
> +
>  static struct i2c_driver adxl372_i2c_driver = {
>         .driver = {
>                 .name = "adxl372_i2c",
> +               .of_match_table = adxl372_of_match,
>         },
>         .probe = adxl372_i2c_probe,
>         .id_table = adxl372_i2c_id,
> --
> 2.17.1
>
Alexandru Ardelean July 22, 2020, 7:08 a.m. UTC | #2
On Tue, Jul 21, 2020 at 9:39 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Mon, Jul 20, 2020 at 4:48 PM Alexandru Ardelean
> <alexandru.ardelean@analog.com> wrote:
> >
> > From: Stefan Popa <stefan.popa@analog.com>
> >
> > The driver does not have a struct of_device_id table, but supported
> > devices are registered via Device Trees. This patch adds OF device ID
> > table.
> >
> > Signed-off-by: Stefan Popa <stefan.popa@analog.com>
> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> > ---
> >  drivers/iio/accel/adxl372_i2c.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/drivers/iio/accel/adxl372_i2c.c b/drivers/iio/accel/adxl372_i2c.c
> > index e1affe480c77..5197d1eb6803 100644
> > --- a/drivers/iio/accel/adxl372_i2c.c
> > +++ b/drivers/iio/accel/adxl372_i2c.c
> > @@ -8,6 +8,8 @@
> >  #include <linux/i2c.h>
> >  #include <linux/module.h>
> >  #include <linux/regmap.h>
>
>
> > +#include <linux/of.h>
> > +#include <linux/of_device.h>
>
> With the huge patch series from Jonathan I think you may learn that
> proper header here is
>
> mod_devicetable.h.

yep;
thanks for pointing that out;

>
>
> >
> >  #include "adxl372.h"
> >
> > @@ -46,9 +48,16 @@ static const struct i2c_device_id adxl372_i2c_id[] = {
> >  };
> >  MODULE_DEVICE_TABLE(i2c, adxl372_i2c_id);
> >
> > +static const struct of_device_id adxl372_of_match[] = {
> > +       { .compatible = "adi,adxl372" },
>
> > +       { },
>
> No comma, please!
>
> > +};
> > +MODULE_DEVICE_TABLE(of, adxl372_of_match);
> > +
> >  static struct i2c_driver adxl372_i2c_driver = {
> >         .driver = {
> >                 .name = "adxl372_i2c",
> > +               .of_match_table = adxl372_of_match,
> >         },
> >         .probe = adxl372_i2c_probe,
> >         .id_table = adxl372_i2c_id,
> > --
> > 2.17.1
> >
>
>
> --
> With Best Regards,
> Andy Shevchenko
diff mbox series

Patch

diff --git a/drivers/iio/accel/adxl372_i2c.c b/drivers/iio/accel/adxl372_i2c.c
index e1affe480c77..5197d1eb6803 100644
--- a/drivers/iio/accel/adxl372_i2c.c
+++ b/drivers/iio/accel/adxl372_i2c.c
@@ -8,6 +8,8 @@ 
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #include "adxl372.h"
 
@@ -46,9 +48,16 @@  static const struct i2c_device_id adxl372_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, adxl372_i2c_id);
 
+static const struct of_device_id adxl372_of_match[] = {
+	{ .compatible = "adi,adxl372" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, adxl372_of_match);
+
 static struct i2c_driver adxl372_i2c_driver = {
 	.driver = {
 		.name = "adxl372_i2c",
+		.of_match_table = adxl372_of_match,
 	},
 	.probe = adxl372_i2c_probe,
 	.id_table = adxl372_i2c_id,