diff mbox series

[v3,2/5] iio: light: vcnl4000 add devicetree hooks

Message ID 20190321154047.23236-3-angus@akkea.ca (mailing list archive)
State New, archived
Headers show
Series Add a VCNL4040 light and proximity driver | expand

Commit Message

Angus Ainslie March 21, 2019, 3:40 p.m. UTC
Add an of_match table for devicetree probing.

Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
---
 drivers/iio/light/vcnl4000.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Jonathan Cameron March 24, 2019, 5:19 p.m. UTC | #1
On Thu, 21 Mar 2019 08:40:44 -0700
"Angus Ainslie (Purism)" <angus@akkea.ca> wrote:

> Add an of_match table for devicetree probing.
> 
> Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>

I made a small tweak (see inline) for an issue I'd missed
previously (which is pretty obscure!)

Jonathan
> ---
>  drivers/iio/light/vcnl4000.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> index 5e0a8eb83ebc..308cb2d2b641 100644
> --- a/drivers/iio/light/vcnl4000.c
> +++ b/drivers/iio/light/vcnl4000.c
> @@ -363,9 +363,31 @@ static int vcnl4000_probe(struct i2c_client *client,
>  	return devm_iio_device_register(&client->dev, indio_dev);
>  }
>  
> +static const struct of_device_id vcnl_4000_of_match[] = {
> +	{
> +		.compatible = "vishay,vcnl4000",
> +		.data = "VCNL4000",
> +	},
> +	{
> +		.compatible = "vishay,vcnl4010",
> +		.data = "VCNL4010",
> +	},
> +	{
> +		.compatible = "vishay,vcnl4010",
> +		.data = "VCNL4020",
> +	},
> +	{
> +		.compatible = "vishay,vcnl4200",
> +		.data = "VCNL4200",
> +	},
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, vcnl4000_of_match);
> +
>  static struct i2c_driver vcnl4000_driver = {
>  	.driver = {
>  		.name   = VCNL4000_DRV_NAME,
> +		.of_match_table = of_match_ptr(vcnl_4000_of_match),
Ah. I'd missed this previously.  Don't use the of_match_ptr
magic anymore. It prevents ACPI probing via the weird
DSDT entry that basically says "here be devicetree".
>  	},
>  	.probe  = vcnl4000_probe,
>  	.id_table = vcnl4000_id,
Jonathan Cameron March 24, 2019, 5:22 p.m. UTC | #2
On Sun, 24 Mar 2019 17:19:30 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Thu, 21 Mar 2019 08:40:44 -0700
> "Angus Ainslie (Purism)" <angus@akkea.ca> wrote:
> 
> > Add an of_match table for devicetree probing.
> > 
> > Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>  
> 
> I made a small tweak (see inline) for an issue I'd missed
> previously (which is pretty obscure!)
> 
> Jonathan
> > ---
> >  drivers/iio/light/vcnl4000.c | 22 ++++++++++++++++++++++
> >  1 file changed, 22 insertions(+)
> > 
> > diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> > index 5e0a8eb83ebc..308cb2d2b641 100644
> > --- a/drivers/iio/light/vcnl4000.c
> > +++ b/drivers/iio/light/vcnl4000.c
> > @@ -363,9 +363,31 @@ static int vcnl4000_probe(struct i2c_client *client,
> >  	return devm_iio_device_register(&client->dev, indio_dev);
> >  }
> >  
> > +static const struct of_device_id vcnl_4000_of_match[] = {
> > +	{
> > +		.compatible = "vishay,vcnl4000",
> > +		.data = "VCNL4000",
> > +	},
> > +	{
> > +		.compatible = "vishay,vcnl4010",
> > +		.data = "VCNL4010",
> > +	},
> > +	{
> > +		.compatible = "vishay,vcnl4010",
> > +		.data = "VCNL4020",
> > +	},
> > +	{
> > +		.compatible = "vishay,vcnl4200",
> > +		.data = "VCNL4200",
> > +	},
> > +	{},
> > +};
> > +MODULE_DEVICE_TABLE(of, vcnl4000_of_match);
vcnl_4000_of_match.

Fixed up.
> > +
> >  static struct i2c_driver vcnl4000_driver = {
> >  	.driver = {
> >  		.name   = VCNL4000_DRV_NAME,
> > +		.of_match_table = of_match_ptr(vcnl_4000_of_match),  
> Ah. I'd missed this previously.  Don't use the of_match_ptr
> magic anymore. It prevents ACPI probing via the weird
> DSDT entry that basically says "here be devicetree".
> >  	},
> >  	.probe  = vcnl4000_probe,
> >  	.id_table = vcnl4000_id,  
>
diff mbox series

Patch

diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 5e0a8eb83ebc..308cb2d2b641 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -363,9 +363,31 @@  static int vcnl4000_probe(struct i2c_client *client,
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
+static const struct of_device_id vcnl_4000_of_match[] = {
+	{
+		.compatible = "vishay,vcnl4000",
+		.data = "VCNL4000",
+	},
+	{
+		.compatible = "vishay,vcnl4010",
+		.data = "VCNL4010",
+	},
+	{
+		.compatible = "vishay,vcnl4010",
+		.data = "VCNL4020",
+	},
+	{
+		.compatible = "vishay,vcnl4200",
+		.data = "VCNL4200",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, vcnl4000_of_match);
+
 static struct i2c_driver vcnl4000_driver = {
 	.driver = {
 		.name   = VCNL4000_DRV_NAME,
+		.of_match_table = of_match_ptr(vcnl_4000_of_match),
 	},
 	.probe  = vcnl4000_probe,
 	.id_table = vcnl4000_id,