mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] i2c-mux-pca954x: use OF match table
@ 2023-12-22  2:12 Alvin Šipraga
  2023-12-22 12:37 ` Ahmad Fatoum
  0 siblings, 1 reply; 3+ messages in thread
From: Alvin Šipraga @ 2023-12-22  2:12 UTC (permalink / raw)
  To: Sascha Hauer, BAREBOX; +Cc: Alvin Šipraga

From: Alvin Šipraga <alsi@bang-olufsen.dk>

Allow the mux driver to match against device tree compatible strings.

Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
---
 drivers/i2c/muxes/i2c-mux-pca954x.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
index 6c21b92860f0..fef95fa57eb7 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -255,9 +255,23 @@ static int pca954x_probe(struct device *dev)
 	return ret;
 }
 
+static const struct of_device_id pca954x_dt_ids[] = {
+	{ .compatible = "nxp,pca9540", .data = (const void *)pca_9540 },
+	{ .compatible = "nxp,pca9542", .data = (const void *)pca_9542 },
+	{ .compatible = "nxp,pca9543", .data = (const void *)pca_9543 },
+	{ .compatible = "nxp,pca9544", .data = (const void *)pca_9544 },
+	{ .compatible = "nxp,pca9545", .data = (const void *)pca_9545 },
+	{ .compatible = "nxp,pca9546", .data = (const void *)pca_9546 },
+	{ .compatible = "nxp,pca9547", .data = (const void *)pca_9547 },
+	{ .compatible = "nxp,pca9548", .data = (const void *)pca_9548 },
+	{}
+};
+MODULE_DEVICE_TABLE(of, pca954x_of_match);
+
 static struct driver pca954x_driver = {
 	.name	= "pca954x",
 	.probe		= pca954x_probe,
+	.of_compatible	= DRV_OF_COMPAT(pca954x_dt_ids),
 	.id_table	= pca954x_id,
 };
 device_i2c_driver(pca954x_driver);

---
base-commit: cd2f24268402207a20467ddc41be9865a73ca4f8
change-id: 20231222-pca954x-of-dd6da5a25622




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

* Re: [PATCH] i2c-mux-pca954x: use OF match table
  2023-12-22  2:12 [PATCH] i2c-mux-pca954x: use OF match table Alvin Šipraga
@ 2023-12-22 12:37 ` Ahmad Fatoum
  2023-12-22 13:23   ` Alvin Šipraga
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2023-12-22 12:37 UTC (permalink / raw)
  To: Alvin Šipraga, Sascha Hauer, BAREBOX; +Cc: Alvin Šipraga

Hello Alvin,

On 22.12.23 03:12, Alvin Šipraga wrote:
> From: Alvin Šipraga <alsi@bang-olufsen.dk>
> 
> Allow the mux driver to match against device tree compatible strings.
> 
> Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
> ---
>  drivers/i2c/muxes/i2c-mux-pca954x.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
> index 6c21b92860f0..fef95fa57eb7 100644
> --- a/drivers/i2c/muxes/i2c-mux-pca954x.c
> +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
> @@ -255,9 +255,23 @@ static int pca954x_probe(struct device *dev)
>  	return ret;
>  }
>  
> +static const struct of_device_id pca954x_dt_ids[] = {
> +	{ .compatible = "nxp,pca9540", .data = (const void *)pca_9540 },
> +	{ .compatible = "nxp,pca9542", .data = (const void *)pca_9542 },
> +	{ .compatible = "nxp,pca9543", .data = (const void *)pca_9543 },
> +	{ .compatible = "nxp,pca9544", .data = (const void *)pca_9544 },
> +	{ .compatible = "nxp,pca9545", .data = (const void *)pca_9545 },
> +	{ .compatible = "nxp,pca9546", .data = (const void *)pca_9546 },
> +	{ .compatible = "nxp,pca9547", .data = (const void *)pca_9547 },
> +	{ .compatible = "nxp,pca9548", .data = (const void *)pca_9548 },

Could you elaborate why this is necessary? Matches on the I2C bus are
found by device_match_of_modalias(), which will take care to remove
the vendor string and then compare pca954x::id_table, which lists the
same devices that are added here.

Cheers,
Ahmad

> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, pca954x_of_match);
> +
>  static struct driver pca954x_driver = {
>  	.name	= "pca954x",
>  	.probe		= pca954x_probe,
> +	.of_compatible	= DRV_OF_COMPAT(pca954x_dt_ids),
>  	.id_table	= pca954x_id,
>  };
>  device_i2c_driver(pca954x_driver);
> 
> ---
> base-commit: cd2f24268402207a20467ddc41be9865a73ca4f8
> change-id: 20231222-pca954x-of-dd6da5a25622
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

* Re: [PATCH] i2c-mux-pca954x: use OF match table
  2023-12-22 12:37 ` Ahmad Fatoum
@ 2023-12-22 13:23   ` Alvin Šipraga
  0 siblings, 0 replies; 3+ messages in thread
From: Alvin Šipraga @ 2023-12-22 13:23 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: BAREBOX, Alvin Šipraga

Hi Ahmad,

On Fri, Dec 22, 2023 at 01:37:49PM +0100, Ahmad Fatoum wrote:
> Hello Alvin,
> 
> On 22.12.23 03:12, Alvin Šipraga wrote:
> > From: Alvin Šipraga <alsi@bang-olufsen.dk>
> > 
> > Allow the mux driver to match against device tree compatible strings.
> > 
> > Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
> > ---
> >  drivers/i2c/muxes/i2c-mux-pca954x.c | 14 ++++++++++++++
> >  1 file changed, 14 insertions(+)
> > 
> > diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
> > index 6c21b92860f0..fef95fa57eb7 100644
> > --- a/drivers/i2c/muxes/i2c-mux-pca954x.c
> > +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
> > @@ -255,9 +255,23 @@ static int pca954x_probe(struct device *dev)
> >  	return ret;
> >  }
> >  
> > +static const struct of_device_id pca954x_dt_ids[] = {
> > +	{ .compatible = "nxp,pca9540", .data = (const void *)pca_9540 },
> > +	{ .compatible = "nxp,pca9542", .data = (const void *)pca_9542 },
> > +	{ .compatible = "nxp,pca9543", .data = (const void *)pca_9543 },
> > +	{ .compatible = "nxp,pca9544", .data = (const void *)pca_9544 },
> > +	{ .compatible = "nxp,pca9545", .data = (const void *)pca_9545 },
> > +	{ .compatible = "nxp,pca9546", .data = (const void *)pca_9546 },
> > +	{ .compatible = "nxp,pca9547", .data = (const void *)pca_9547 },
> > +	{ .compatible = "nxp,pca9548", .data = (const void *)pca_9548 },
> 
> Could you elaborate why this is necessary? Matches on the I2C bus are
> found by device_match_of_modalias(), which will take care to remove
> the vendor string and then compare pca954x::id_table, which lists the
> same devices that are added here.

No, you are right, there is no point to this patch - it can be ignored.
But thank you - I was unaware of the behaviour you are pointing out!

Kind regards,
Alvin

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

end of thread, other threads:[~2023-12-22 13:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-22  2:12 [PATCH] i2c-mux-pca954x: use OF match table Alvin Šipraga
2023-12-22 12:37 ` Ahmad Fatoum
2023-12-22 13:23   ` Alvin Šipraga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox