linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] iio: proximity: vl53l0x-i2c add i2c_device_id
@ 2020-10-18  3:31 Vaishnav M A
  2020-10-18 11:33 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Vaishnav M A @ 2020-10-18  3:31 UTC (permalink / raw)
  To: songqiang1304521, jic23, knaack.h, lars, pmeerw, linux-iio, linux-kernel
  Cc: jkridner, drew, robertcnelson, rajkovic, vaishnav

add i2c_device_id for the vl53l0x-i2c driver so
that the device can be instantiated using i2c_new_client_device
or from userspace, useful in cases where device tree based description
is not possible now(Eg. a device on a gbphy i2c
adapter created by greybus).

Signed-off-by: Vaishnav M A <vaishnav@beagleboard.org>
---
 v2:
	- fix commit message
 drivers/iio/proximity/vl53l0x-i2c.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c
index 5fbda9475ba9..7c29d4cae24a 100644
--- a/drivers/iio/proximity/vl53l0x-i2c.c
+++ b/drivers/iio/proximity/vl53l0x-i2c.c
@@ -143,6 +143,12 @@ static int vl53l0x_probe(struct i2c_client *client)
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
+static const struct i2c_device_id vl53l0x_id[] = {
+	{ "vl53l0x", 0},
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, vl53l0x_id);
+
 static const struct of_device_id st_vl53l0x_dt_match[] = {
 	{ .compatible = "st,vl53l0x", },
 	{ }
@@ -155,6 +161,7 @@ static struct i2c_driver vl53l0x_driver = {
 		.of_match_table = st_vl53l0x_dt_match,
 	},
 	.probe_new = vl53l0x_probe,
+	.id_table = vl53l0x_id,
 };
 module_i2c_driver(vl53l0x_driver);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] iio: proximity: vl53l0x-i2c add i2c_device_id
  2020-10-18  3:31 [PATCH v2] iio: proximity: vl53l0x-i2c add i2c_device_id Vaishnav M A
@ 2020-10-18 11:33 ` Jonathan Cameron
  2020-10-18 15:23   ` Vaishnav M A
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2020-10-18 11:33 UTC (permalink / raw)
  To: Vaishnav M A
  Cc: songqiang1304521, knaack.h, lars, pmeerw, linux-iio,
	linux-kernel, jkridner, drew, robertcnelson, rajkovic,
	Wolfram Sang

On Sun, 18 Oct 2020 09:01:42 +0530
Vaishnav M A <vaishnav@beagleboard.org> wrote:

> add i2c_device_id for the vl53l0x-i2c driver so
> that the device can be instantiated using i2c_new_client_device
> or from userspace, useful in cases where device tree based description
> is not possible now(Eg. a device on a gbphy i2c
> adapter created by greybus).
> 
> Signed-off-by: Vaishnav M A <vaishnav@beagleboard.org>

Please fix the description as mentioned in other patches.

The code change is fine, but it does raise the question of whether we want to think
about providing a means to register such devices using the of_match_table.
It's somewhat irritating to need to provide both (I'd rather not
just provide the non-dt version rely on the old hack that drops the
vendor ID for matching).

+CC Wolfram.

> ---
>  v2:
> 	- fix commit message
>  drivers/iio/proximity/vl53l0x-i2c.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c
> index 5fbda9475ba9..7c29d4cae24a 100644
> --- a/drivers/iio/proximity/vl53l0x-i2c.c
> +++ b/drivers/iio/proximity/vl53l0x-i2c.c
> @@ -143,6 +143,12 @@ static int vl53l0x_probe(struct i2c_client *client)
>  	return devm_iio_device_register(&client->dev, indio_dev);
>  }
>  
> +static const struct i2c_device_id vl53l0x_id[] = {
> +	{ "vl53l0x", 0},
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(i2c, vl53l0x_id);
> +
>  static const struct of_device_id st_vl53l0x_dt_match[] = {
>  	{ .compatible = "st,vl53l0x", },
>  	{ }
> @@ -155,6 +161,7 @@ static struct i2c_driver vl53l0x_driver = {
>  		.of_match_table = st_vl53l0x_dt_match,
>  	},
>  	.probe_new = vl53l0x_probe,
> +	.id_table = vl53l0x_id,
>  };
>  module_i2c_driver(vl53l0x_driver);
>  


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] iio: proximity: vl53l0x-i2c add i2c_device_id
  2020-10-18 11:33 ` Jonathan Cameron
@ 2020-10-18 15:23   ` Vaishnav M A
  0 siblings, 0 replies; 3+ messages in thread
From: Vaishnav M A @ 2020-10-18 15:23 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: songqiang1304521, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, open list:IIO SUBSYSTEM AND DRIVERS,
	open list, Jason Kridner, Drew Fustini, Robert Nelson,
	Ivan Rajković,
	Wolfram Sang

On Sun, Oct 18, 2020 at 5:03 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Sun, 18 Oct 2020 09:01:42 +0530
> Vaishnav M A <vaishnav@beagleboard.org> wrote:
>
> > add i2c_device_id for the vl53l0x-i2c driver so
> > that the device can be instantiated using i2c_new_client_device
> > or from userspace, useful in cases where device tree based description
> > is not possible now(Eg. a device on a gbphy i2c
> > adapter created by greybus).
> >
> > Signed-off-by: Vaishnav M A <vaishnav@beagleboard.org>
>
> Please fix the description as mentioned in other patches.
>
Thank you Jonathan for your review, I have sent a v3 patch with fixed
description : https://lore.kernel.org/patchwork/patch/1322196/
understand your concern about the redundant device_id(s), it will be nice to see
of_match_table reused in such cases as you suggested.

> The code change is fine, but it does raise the question of whether we want to think
> about providing a means to register such devices using the of_match_table.
> It's somewhat irritating to need to provide both (I'd rather not
> just provide the non-dt version rely on the old hack that drops the
> vendor ID for matching).
>
> +CC Wolfram.
>
> > ---
> >  v2:
> >       - fix commit message
> >  drivers/iio/proximity/vl53l0x-i2c.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c
> > index 5fbda9475ba9..7c29d4cae24a 100644
> > --- a/drivers/iio/proximity/vl53l0x-i2c.c
> > +++ b/drivers/iio/proximity/vl53l0x-i2c.c
> > @@ -143,6 +143,12 @@ static int vl53l0x_probe(struct i2c_client *client)
> >       return devm_iio_device_register(&client->dev, indio_dev);
> >  }
> >
> > +static const struct i2c_device_id vl53l0x_id[] = {
> > +     { "vl53l0x", 0},
> > +     { }
> > +};
> > +MODULE_DEVICE_TABLE(i2c, vl53l0x_id);
> > +
> >  static const struct of_device_id st_vl53l0x_dt_match[] = {
> >       { .compatible = "st,vl53l0x", },
> >       { }
> > @@ -155,6 +161,7 @@ static struct i2c_driver vl53l0x_driver = {
> >               .of_match_table = st_vl53l0x_dt_match,
> >       },
> >       .probe_new = vl53l0x_probe,
> > +     .id_table = vl53l0x_id,
> >  };
> >  module_i2c_driver(vl53l0x_driver);
> >
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-18 15:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-18  3:31 [PATCH v2] iio: proximity: vl53l0x-i2c add i2c_device_id Vaishnav M A
2020-10-18 11:33 ` Jonathan Cameron
2020-10-18 15:23   ` Vaishnav M A

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).