All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] i2c: muxes: pca954x: look up width from chip_desc
@ 2017-09-28 21:53 Chris Packham
  2017-09-29 13:36 ` Marek Behún
  2017-09-29 13:42 ` Marek Behún
  0 siblings, 2 replies; 4+ messages in thread
From: Chris Packham @ 2017-09-28 21:53 UTC (permalink / raw)
  To: u-boot

Commit 8e6eda7cda6c ("drivers/i2c/muxes/pca954x: Add pca9547 I2C mux
support") introduced a chip_desc for the pca954x devices but failed to
update pca954x_ofdata_to_platdata() to be aware of it. Make
pca954x_ofdata_to_platdata() lookup the chip_desc to validate the device
width.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
---

 drivers/i2c/muxes/pca954x.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
index 01ca1ff48db9..2b70ff82bdd0 100644
--- a/drivers/i2c/muxes/pca954x.c
+++ b/drivers/i2c/muxes/pca954x.c
@@ -27,6 +27,7 @@ struct chip_desc {
 		pca954x_ismux = 0,
 		pca954x_isswi,
 	} muxtype;
+	u32 width;
 };
 
 struct pca954x_priv {
@@ -39,14 +40,17 @@ static const struct chip_desc chips[] = {
 	[PCA9544] = {
 		.enable = 0x4,
 		.muxtype = pca954x_ismux,
+		.width = 4,
 	},
 	[PCA9547] = {
 		.enable = 0x8,
 		.muxtype = pca954x_ismux,
+		.width = 8,
 	},
 	[PCA9548] = {
 		.enable = 0x8,
 		.muxtype = pca954x_isswi,
+		.width = 8,
 	},
 };
 
@@ -89,13 +93,14 @@ static const struct udevice_id pca954x_ids[] = {
 static int pca954x_ofdata_to_platdata(struct udevice *dev)
 {
 	struct pca954x_priv *priv = dev_get_priv(dev);
+	const struct chip_desc *chip = &chips[dev_get_driver_data(dev)];
 
 	priv->addr = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", 0);
 	if (!priv->addr) {
 		debug("MUX not found\n");
 		return -ENODEV;
 	}
-	priv->width = dev_get_driver_data(dev);
+	priv->width = chip->width;
 
 	if (!priv->width) {
 		debug("No I2C MUX width specified\n");
-- 
2.14.1

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

* [U-Boot] [PATCH] i2c: muxes: pca954x: look up width from chip_desc
  2017-09-28 21:53 [U-Boot] [PATCH] i2c: muxes: pca954x: look up width from chip_desc Chris Packham
@ 2017-09-29 13:36 ` Marek Behún
  2017-09-29 13:42 ` Marek Behún
  1 sibling, 0 replies; 4+ messages in thread
From: Marek Behún @ 2017-09-29 13:36 UTC (permalink / raw)
  To: u-boot

Reviewed-by: Marek Behun <marek.behun@nic.cz>

On Fri, 29 Sep 2017 10:53:36 +1300
Chris Packham <judge.packham@gmail.com> wrote:

> Commit 8e6eda7cda6c ("drivers/i2c/muxes/pca954x: Add pca9547 I2C mux
> support") introduced a chip_desc for the pca954x devices but failed to
> update pca954x_ofdata_to_platdata() to be aware of it. Make
> pca954x_ofdata_to_platdata() lookup the chip_desc to validate the
> device width.
> 
> Signed-off-by: Chris Packham <judge.packham@gmail.com>
> ---
> 
>  drivers/i2c/muxes/pca954x.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
> index 01ca1ff48db9..2b70ff82bdd0 100644
> --- a/drivers/i2c/muxes/pca954x.c
> +++ b/drivers/i2c/muxes/pca954x.c
> @@ -27,6 +27,7 @@ struct chip_desc {
>  		pca954x_ismux = 0,
>  		pca954x_isswi,
>  	} muxtype;
> +	u32 width;
>  };
>  
>  struct pca954x_priv {
> @@ -39,14 +40,17 @@ static const struct chip_desc chips[] = {
>  	[PCA9544] = {
>  		.enable = 0x4,
>  		.muxtype = pca954x_ismux,
> +		.width = 4,
>  	},
>  	[PCA9547] = {
>  		.enable = 0x8,
>  		.muxtype = pca954x_ismux,
> +		.width = 8,
>  	},
>  	[PCA9548] = {
>  		.enable = 0x8,
>  		.muxtype = pca954x_isswi,
> +		.width = 8,
>  	},
>  };
>  
> @@ -89,13 +93,14 @@ static const struct udevice_id pca954x_ids[] = {
>  static int pca954x_ofdata_to_platdata(struct udevice *dev)
>  {
>  	struct pca954x_priv *priv = dev_get_priv(dev);
> +	const struct chip_desc *chip =
> &chips[dev_get_driver_data(dev)]; 
>  	priv->addr = fdtdec_get_int(gd->fdt_blob,
> dev_of_offset(dev), "reg", 0); if (!priv->addr) {
>  		debug("MUX not found\n");
>  		return -ENODEV;
>  	}
> -	priv->width = dev_get_driver_data(dev);
> +	priv->width = chip->width;
>  
>  	if (!priv->width) {
>  		debug("No I2C MUX width specified\n");

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

* [U-Boot] [PATCH] i2c: muxes: pca954x: look up width from chip_desc
  2017-09-28 21:53 [U-Boot] [PATCH] i2c: muxes: pca954x: look up width from chip_desc Chris Packham
  2017-09-29 13:36 ` Marek Behún
@ 2017-09-29 13:42 ` Marek Behún
  2017-09-29 23:27   ` Chris Packham
  1 sibling, 1 reply; 4+ messages in thread
From: Marek Behún @ 2017-09-29 13:42 UTC (permalink / raw)
  To: u-boot

On Fri, 29 Sep 2017 10:53:36 +1300
Chris Packham <judge.packham@gmail.com> wrote:


>  struct pca954x_priv {
> @@ -39,14 +40,17 @@ static const struct chip_desc chips[] = {
>  	[PCA9544] = {
>  		.enable = 0x4,
>  		.muxtype = pca954x_ismux,
> +		.width = 4,
>  	},
>  	[PCA9547] = {
>  		.enable = 0x8,
>  		.muxtype = pca954x_ismux,
> +		.width = 8,
>  	},
>  	[PCA9548] = {
>  		.enable = 0x8,
>  		.muxtype = pca954x_isswi,
> +		.width = 8,
>  	},
>  };

Hmm, looking at this now, isn't one of the enable or width fields
redundant? They both have same values in all entries.

Marek

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

* [U-Boot] [PATCH] i2c: muxes: pca954x: look up width from chip_desc
  2017-09-29 13:42 ` Marek Behún
@ 2017-09-29 23:27   ` Chris Packham
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Packham @ 2017-09-29 23:27 UTC (permalink / raw)
  To: u-boot

On 30/09/2017 2:43 AM, "Marek Behún" <marek.behun@nic.cz> wrote:

On Fri, 29 Sep 2017 10:53:36 +1300
Chris Packham <judge.packham@gmail.com> wrote:


>  struct pca954x_priv {
> @@ -39,14 +40,17 @@ static const struct chip_desc chips[] = {
>       [PCA9544] = {
>               .enable = 0x4,
>               .muxtype = pca954x_ismux,
> +             .width = 4,
>       },
>       [PCA9547] = {
>               .enable = 0x8,
>               .muxtype = pca954x_ismux,
> +             .width = 8,
>       },
>       [PCA9548] = {
>               .enable = 0x8,
>               .muxtype = pca954x_isswi,
> +             .width = 8,
>       },
>  };

Hmm, looking at this now, isn't one of the enable or width fields
redundant? They both have same values in all entries.


They happen to have the same value but they have different meanings. In
fact enable isn't actually used for the isswi code path.

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

end of thread, other threads:[~2017-09-29 23:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-28 21:53 [U-Boot] [PATCH] i2c: muxes: pca954x: look up width from chip_desc Chris Packham
2017-09-29 13:36 ` Marek Behún
2017-09-29 13:42 ` Marek Behún
2017-09-29 23:27   ` Chris Packham

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.